I've looked at the function affect_total() in handler.c for a while now, and I am baffled why it's needed.
It looks to me like it:
1) Removes the current affect bits and affect attribute modifiers
2) Resets attributes to default attributes
3) Adds the current affect bits and affect attribute modifiers
So remove everything, then put it all back. Why?
As a test, I commented out the contents of the function and reran my mud. Then I casted spells, did Imm "set" commands, removed items with attribute affects, waited for spells to fall off, etc. and it seems to be working fine.
I must be missing something, can someone help me?
Here is the function:
Code:
/* This updates a character by subtracting everything he is affected by
* restoring original abilities, and then affecting all again. */
void affect_total(struct char_data *ch)
{
struct affected_type *af;
int i, j;
for (i = 0; i < NUM_WEARS; i++) {
if (GET_EQ(ch, i))
for (j = 0; j < MAX_OBJ_AFFECT; j++)
affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location,
GET_EQ(ch, i)->affected[j].modifier,
GET_OBJ_AFFECT(GET_EQ(ch, i)), FALSE);
}
for (af = ch->affected; af; af = af->next)
affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE);
ch->aff_abils = ch->real_abils;
for (i = 0; i < NUM_WEARS; i++) {
if (GET_EQ(ch, i))
for (j = 0; j < MAX_OBJ_AFFECT; j++)
affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location,
GET_EQ(ch, i)->affected[j].modifier,
GET_OBJ_AFFECT(GET_EQ(ch, i)), TRUE);
}
for (af = ch->affected; af; af = af->next)
affect_modify_ar(ch, af->location, af->modifier, af->bitvector, TRUE);
/* Make certain values are between 0..25, not < 0 and not > 25! */
i = (IS_NPC(ch) || GET_LEVEL(ch) >= LVL_GRGOD) ? 25 : 18;
GET_DEX(ch) = MAX(0, MIN(GET_DEX(ch), i));
GET_INT(ch) = MAX(0, MIN(GET_INT(ch), i));
GET_WIS(ch) = MAX(0, MIN(GET_WIS(ch), i));
GET_CON(ch) = MAX(0, MIN(GET_CON(ch), i));
GET_CHA(ch) = MAX(0, MIN(GET_CHA(ch), i));
GET_STR(ch) = MAX(0, GET_STR(ch));
if (IS_NPC(ch) || GET_LEVEL(ch) >= LVL_GRGOD) {
GET_STR(ch) = MIN(GET_STR(ch), i);
} else {
if (GET_STR(ch) > 18) {
i = GET_ADD(ch) + ((GET_STR(ch) - 18) * 10);
GET_ADD(ch) = MIN(i, 100);
GET_STR(ch) = 18;
}
}
}