I'm having trouble getting the affects from equipment displayed. I looked
over my loops and my if checks and can't seem to get it to work properly. I
included my whole do_affects if anyone can give me some insite i'd
appriciate it.
void do_affects(CHAR_DATA *ch, char *argument )
{
AFFECT_DATA *paf, *paf_last = NULL;
OBJ_DATA *obj;
char buf[MAX_STRING_LENGTH];
char word[MAX_INPUT_LENGTH];
char *curaff;
char *racestring;
int space, length, i, iWear;
buf[0] = '\0';
racestring = "[ Race ] ";
send_to_char("-==--==-\n\r", ch);
send_to_char("|AFFECTS|\n\r", ch);
send_to_char("-==--==-\n\r", ch);
if ( race_table[ch->race].aff != 0 && IS_AFFECTED ( ch,
race_table[ch->race].aff ) )
{
curaff = flag_string ( affect_flags, race_table[ch->race].aff );
for (; ;)
{
curaff = one_argument( curaff, word );
if ( word[0] == '\0' )
{
break;
}
word[0] = UPPER(word[0]);
strcat( buf, racestring);
strcat( buf, word );
length = strlen(word);
space = 15 - length;
for (i = 0; i < space; i++)
{
strcat(buf, " ");
}
strcat(buf, ": Racial Affect ");
strcat( buf, "\n\r" );
}
send_to_char( buf, ch );
}
buf[0] = '\0';
if ( race_table[ch->race].aff2 != 0 && IS_AFFECTED2 ( ch,
race_table[ch->race].aff2 ) )
{
curaff = flag_string ( affect_flags, race_table[ch->race].aff2 );
for (; ;)
{
curaff = one_argument( curaff, word );
if ( word[0] == '\0' )
{
break;
}
word[0] = UPPER(word[0]);
strcat( buf, racestring);
strcat( buf, word );
length = strlen(word);
space = 15 - length;
for (i = 0; i < space; i++)
{
strcat(buf, " ");
}
strcat(buf, ": Racial Affect");
strcat( buf, "\n\r" );
}
send_to_char( buf, ch );
}
buf[0] = '\0';
if ( race_table[ch->race].imm != 0 && IS_FLAGGED_IMMUNE ( ch,
race_table[ch->race].imm ) )
{
curaff = flag_string ( imm_flags, race_table[ch->race].imm );
for (; ;)
{
curaff = one_argument( curaff, word );
if ( word[0] == '\0' )
{
break;
}
word[0] = UPPER(word[0]);
strcat( buf, racestring);
strcat( buf, word );
length = strlen(word);
space = 15 - length;
for (i = 0; i < space; i++)
{
strcat(buf, " ");
}
strcat(buf, ": Racial Immunity ");
strcat( buf, "\n\r" );
}
send_to_char( buf, ch );
}
buf[0] = '\0';
if ( race_table[ch->race].res != 0 && IS_FLAGGED_RESISTANT ( ch,
race_table[ch->race].res ) )
{
curaff = flag_string ( res_flags, race_table[ch->race].res );
for (; ;)
{
curaff = one_argument( curaff, word );
if ( word[0] == '\0' )
{
break;
}
word[0] = UPPER(word[0]);
strcat( buf, racestring);
strcat( buf, word );
length = strlen(word);
space = 15 - length;
for (i = 0; i < space; i++)
{
strcat(buf, " ");
}
strcat(buf, ": Racial Resistance ");
strcat( buf, "\n\r" );
}
send_to_char( buf, ch );
}
buf[0] = '\0';
if ( race_table[ch->race].vuln != 0 && IS_FLAGGED_VULNERABLE ( ch,
race_table[ch->race].vuln ) )
{
curaff = flag_string ( imm_flags, race_table[ch->race].vuln );
for (; ;)
{
curaff = one_argument( curaff, word );
if ( word[0] == '\0' )
{
break;
}
word[0] = UPPER(word[0]);
strcat( buf, racestring);
strcat( buf, word );
length = strlen(word);
space = 15 - length;
for (i = 0; i < space; i++)
{
strcat(buf, " ");
}
strcat(buf, ": Racial Vulnerability ");
strcat( buf, "\n\r" );
}
send_to_char( buf, ch );
}
buf[0] = '\0';
/* Problem code is in below */
for ( iWear = 0; iWear < MAX_WEAR; iWear++ )
{
if((obj = get_eq_char(ch,iWear)) != NULL)
{
for ( paf = obj->affected; paf != NULL; paf = paf->next )
{
switch(paf->where)
{
case TO_AFFECTS:
sprintf(buf,"Adds %s affect.\n",
affect_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_AFFECTS2:
sprintf(buf, "Also adds %s affect.\n",
affect2_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_WEAPON:
sprintf(buf,"Adds %s weapon flags.\n",
weapon_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_OBJECT:
sprintf(buf,"Adds %s object flag.\n",
extra_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_IMMUNE:
sprintf(buf,"Adds immunity to %s.\n",
imm_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_RESIST:
sprintf(buf,"Adds resistance to %s.\n\r",
imm_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
case TO_VULN:
sprintf(buf,"Adds vulnerability to %s.\n\r",
imm_bit_name(paf->bitvector));
send_to_char(buf,ch);
break;
default:
sprintf(buf,"Unknown bit %d: %d\n\r",
paf->where,paf->bitvector);
send_to_char(buf,ch);
break;
}
send_to_char(buf,ch);
}
}
}
/* Problem code ends here */
for ( paf = ch->affected; paf != NULL; paf = paf->next )
{
if (paf_last != NULL && paf->type == paf_last->type)
sprintf( buf, " ");
else
sprintf( buf, "[ Spell ] %-15s", skill_table[paf->type].name );
send_to_char( buf, ch );
sprintf( buf, ": modifies %s by %d and ",
affect_loc_name( paf->location ), paf->modifier);
send_to_char( buf, ch );
if ( paf->duration == -1 )
sprintf( buf, "permanently" );
else
sprintf( buf, "lasts for %d hours", paf->duration );
send_to_char( buf, ch );
send_to_char( "\n\r", ch );
paf_last = paf;
}
return;
}