03 Sep, 2010, jurdendurden wrote in the 1st comment:
Votes: 0
I'm trying to add a simple ifcheck in my mobprog code to compare a character's god to the specified god. This is for a sort of interactive temple we are building. Anyhow it doesn't seem to be checking it properly. I've also tested the ifchecks for class and race, class doesn't work, race does. I'm confused to why this is occuring. Especially since I'm using pretty much the exact same code for the god_lookup that is in stock for race_lookup. Here is the code:

case CHK_RACE:
return( lval_char != NULL && lval_char->race == race_lookup( buf ) );
case CHK_CLASS:
return( lval_char != NULL && lval_char->class == class_lookup( buf ) );
case CHK_OBJTYPE:
return( lval_obj != NULL && lval_obj->item_type == item_lookup( buf ) );
case CHK_GOD:
return( lval_obj != NULL && lval_char->god == god_lookup( buf ) );


And the lookups:
int god_lookup (const char *name)
{
int god;

for ( god = 0; god_table[god].name != NULL; god++)
{
if (LOWER(name[0]) == LOWER(god_table[god].name[0])
&& !str_cmp( name,god_table[god].name))
return god;
}

return 0;
}


int race_lookup (const char *name)
{
int race;

for (race = 0; race_table[race].name != NULL; race++)
{
if (LOWER (name[0]) == LOWER (race_table[race].name[0])
&& !str_prefix (name, race_table[race].name))
return race;
}

return 0;
}


So yeah, it's not evaluating at all the pc's god. Any ideas?


Note: After digging through while writing this, I noticed that the copy of mob_prog.c that I have does not even have a check for CHK_CLASS, even though it's defined…. Anyone know which mob_prog.c out there is the most up to date for Rom 2.4/Quickmud?
03 Sep, 2010, Rudha wrote in the 2nd comment:
Votes: 0
Try looking up what parameters the functions are returning; its possible they may not be returning what you think they are; this is often the problem for my builders with NPC triggers and code. Moreover, it may be worth testing for "error cases" from the returns within your conditional branch, if they exist.

Maya/Rudha
03 Sep, 2010, Tyche wrote in the 3rd comment:
Votes: 0
case CHK_GOD:
return( lval_obj != NULL && lval_char->god == god_lookup( buf ) );

Just a typo. You probably mean lval_char there.
03 Sep, 2010, Rudha wrote in the 4th comment:
Votes: 0
Huh, I didn't even catch that. Sharp eyes. I was suspecting that conditional was failing somewheres, though.

Maya/Rudha
03 Sep, 2010, jurdendurden wrote in the 5th comment:
Votes: 0
Yup sure enough. Stupid typo. Cost me 3 hours of my day :/ Figured out though that the OLC in the Quickmud release in the repository is NOT 1.81 which seems to be the newest version (and has the CHK_CLASS check in it). Anyhow, thanks guys!
Random Picks
0.0/5