Obj Enchantment

From: Jon Barrett (jon@thebarretts.com)
Date: 12/15/98

   I was tinkering with the enchant_weapon() spell and found one particular
problem: The enchanted object is reset when someone oedits the same obj.
Now I had a few ideas to fix this, but I thought I'd see what people here
thought about them.  I think the obj enchantment needs a little bit of work
for stock, because that is the kind of things players like. :)
   So I was thinking, first, make an ITEM_ENCHANTED flag, and then update
oedit to copy the appropriate variables back from the swap.  In the instance
of obj->affects, given an object with no applies, and was enchanted with +n
to hit/dam:  If the builder later upgrades that object to also apply to
strength, the enchanted obj will not get the new str apply, while all the
others will.  The player could just go enchant a new obj, but why punish the
player for using their spells?
  So on to my other idea.  I could get complicated and add an 'enchanted'
variable to the obj struct and make it a bitvector.  The bitvector will
store what was enchanted, so if changes were made, everything will change,
but not the enchanted affect.  As you add skills or spells that enchant
various values or applies, you can add them to the enchanted bitvector.
When you oedit the obj, only the changes in the enchanted bitvector are
copied and all the new ones are added.
  I know there are probably many other options, so I'd like to hear em... :P

Oh, I made a nifty little obj apply adding function which will, given an
apply and modifier:
1)  Search for the specified apply and increment/decrement it
2)  Add a new one if the specified apply was not found
It makes the enchant_weapon() spell really short, and makes any other
enchantment spells really easy.

//* This function will search the object for a specified APPLY_XX and adjust
it according
//* to modifier.  If it does not find a similar apply, it will look for an
empty one.
bool enchant_obj(struct obj_data *obj, int apply, int mod)
        int pos = 0;
        bool add = false;

        while (pos < MAX_OBJ_AFFECT) {
                //**** If add is true: add a new apply. If found specified apply:
increment the mod **
                if ((add && (obj->affected[pos].location == APPLY_NONE)) ||
                            (obj->affected[pos].location == apply)) {
                        obj->affected[pos].location = apply;
                        obj->affected[pos].modifier += mod;
                        return true;
                } else if ((++pos == MAX_OBJ_AFFECT) && !add) {
                        add = true;             //** Didnt'd find a similar apply, add a new one.
                        pos = 0;                //** Start back at 0 and add the new apply.

        return false;

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |

This archive was generated by hypermail 2b30 : 12/15/00 PST