#define BITV_TYPE(loc) (loc==APPLY_AFFECT \ || loc==APPLY_NONE \ || loc==APPLY_RESISTANT \ || loc==APPLY_IMMUNE \ || loc==APPLY_SUSCEPTIBLE) void affect_summary( CHAR_DATA *ch, OBJ_DATA *obj ) { int x, y, values[MAX_APPLY_TYPE]; // An array of values with a slot for every possible type. AFFECT_DATA *paf; for ( paf = obj->pIndexData->first_affect; paf; paf = paf->next ) { if (BITV_TYPE(paf->location)) values[paf->location] |= paf->modifier; // Sets these bits in modifier else values[paf->location] += paf->modifier; } for ( paf = obj->first_affect; paf; paf = paf->next ) { if (BITV_TYPE(paf->location)) values[paf->location] |= paf->modifier; // Sets these bits in modifier else values[paf->location] += paf->modifier; } // At this point the array has the sum of every affect type in it. Now we dispatch them to the character: for ( x = 0; x < MAX_APPLY_TYPE; x++ ) if ( values[x] != 0 ) // Remember it could be positive or negative, but lets not show effects that have cancelled each other out. { switch( x ) { default: ch_printf( ch, "&BAffects &W%s &wby &W%d.\n\r", affect_loc_name( x ), values[x] ); break; case APPLY_SAVING_POISON: case APPLY_SAVING_ROD: case APPLY_SAVING_PARA: case APPLY_SAVING_BREATH: case APPLY_SAVING_SPELL: case APPLY_SAVING_PSI: case APPLY_SAVING_SUMMON: case APPLY_SAVING_SONG: case APPLY_SAVING_RUNE: ch_printf( ch, "&BAffects &W%s &wby &W%s%d%%.\n\r", affect_loc_name(x), values[x] > 0 ? "+" : "", values[x] ); break; case APPLY_AFFECT: for ( y = 0; y < 32 ; y++ ) if ( IS_SET( values[x], 1 << y ) ) ch_printf( ch, "&BAffects &W%s &wby&W %s\n\r.", affect_loc_name( x ), a_flags[y] ); break; case APPLY_WEAPONSPELL: ch_printf( ch, "&BCasts spell '&C%s&B' when used in combat.\n\r", IS_VALID_SN(x) ? skill_table[values[x]]->name : "unknown" ); break; case APPLY_WEARSPELL: ch_printf( ch, "&BCasts spell '&C%s&B' when worn.\n\r", IS_VALID_SN(x) ? skill_table[values[x]]->name : "unknown" ); break; case APPLY_REMOVESPELL: ch_printf( ch, "&BCasts spell '&C%s&B' when removed.\n\r", IS_VALID_SN(x) ? skill_table[values[x]]->name : "unknown" ); break; case APPLY_RESISTANT: case APPLY_IMMUNE: case APPLY_SUSCEPTIBLE: for ( y = 0; y < 32 ; y++ ) if ( IS_SET( values[x], 1 << y ) ) ch_printf( ch, "&BAffects &W%s &wby&W %s\n\r.", affect_loc_name( x ), ris_flags[y] ); break; } } }