I am no master at mobprogs (actually quite the opposite), but I think I have
an idea to your problem.
First off, the elseif in this basically:
if something
{
code
}
else
{
if something
code
}
And if you will notice, that takes you in one nested level.
Also, the else part of your elseif is depenant on the last if-check being
FALSE, so you need to use cond in there somewhere.
> else if( !str_cmp( control, "elseif" ) )
> {
> int qbool;
>
> if ( !level || state[level-1] != BEGIN_BLOCK )
> {
> prog_error( mob, obj, room, "elseif without if",
> mvnum, ovnum, rvnum, pvnum );
call_level--;
> return;
> }
>
> state[level] = BEGIN_BLOCK;
>
> if ( ++level >= MAX_NESTED_LEVEL )
> {
> prog_error( mob, obj, room, "Max nested level exceeded",
> mvnum, ovnum, rvnum, pvnum );
call_level--;
> return;
> }
>
> line = one_argument( line, control );
>
> if ( mob && ( check = keyword_lookup( fn_keyword,
> control ) ) >=
> 0 )
> {
> qbool = cmd_eval_mob( pvnum, line, check, mob, ch,
> arg1, arg2,
> rc$
> }
> else if ( obj && ( check = keyword_lookup( fn_keyword,
> control ) ) >$
> {
> qbool = cmd_eval_obj( pvnum, line, check, obj, ch,
> arg1, arg2,
> rc$
> }
> else if ( room && ( check = keyword_lookup( fn_keyword,
> control ) ) $
> {
> qbool = cmd_eval_room( pvnum, line, check, room, ch, arg1,
> arg2, $
> }
> else
> {
> prog_error( mob, obj, room, "invalid if_check (elseif)",
> mvnum, ovnum, rvnum, pvnum );
> return;
> }
> state[level] = END_BLOCK;
> cond[level] = (cond[level-1] == TRUE) ? FALSE : qbool > 0 ;
cond[level] = (qbool > 0) ? TRUE : FALSE;
> }
> }
>
> GRALL 100
>
> if isnpc $n
> say hi npc!
> elseif ispc $n
> say hi pc!
> else
> say who the **** are you?
> endif
>
You could just do
if isnpc $n
say hi npc!
else
if ispc $n
say hi pc!
else
say who the **** are you?
endif
endif
But oh well. Try the fixes above and see if that gets you any closer. Try
stepping through your program_flow using GDB while running the script and
see if that helps you any.
I have not tried the fixes myself, so they are not guarenteed to work.
Ammaross Danan