if( obj->enchanted == FALSE ) {
obj->enchanted = TRUE;
// Copy affects from the prototype to the real object
// This is sloppy – the copied affects will be in reverse order if that kind of thing bothers you
for( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next ) {
naf = clone_affect( paf );
naf->next = obj->affected;
obj->affected = naf;
}
}
// Find and modify the fireresist affect.
for( paf = obj->affected; paf != NULL; paf = paf->next ) {
if( paf->location == APPLY_FIRERESIST ) {
paf->type = 0;
paf->modifier += 1;
paf->level = 1;
break;
}
}
if( paf == NULL ) {
// No fireresist affect exists on this object.
// So create a new APPLY_FIRERESIST type affect here and attach it to the object.
}
APPLY_FIRERESIST already on it, if it does, it sets resistance to true. // this all works
Next, it will check which essence you are using // This works too
Then it will see if resistance is true, if so it checks to see if location is apply_fireresist
once again, and if it is, it just ADDS to the current # of fire resist on that object.
I have the code commented on what works and doesnt.
for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next )
{
if ( paf->location == APPLY_FIRERESIST )
{
send_to_char("Gets here.!\r\n",ch); // Gets here
resistance = TRUE;
}
}
if (!str_cmp(obj2->name, "poor essence fire"))
{
if (resistance)
{
send_to_char("Gets here too!\r\n",ch); // Gets here
for ( paf = obj->affected; paf != NULL; paf = paf->next)
{
if (paf->location == APPLY_FIRERESIST)
{
send_to_char("Doesn't get here.\r\n",ch); // Doesn't get to here.
paf->type = 0;
paf->modifier += 1;
paf->level = 1;
}
}
}
else
{
// After the else, it adds a new effect because resistance isnt found as TRUE.
// This part also works correctly.