Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Bing, Yahoo!

Members: 0
Guests: 13
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Smaug Snippets » MudProg Variable
Forum Rules | Mark all | Recent Posts

MudProg Variable
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 29, 2009, 9:20 pm
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

So I followed the instructions for both parts, but I have no idea how to make an ifcheck using the variables. Kayle or anyone else want to share that info?
       
Post is unread #2 Sep 29, 2009, 9:24 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Both parts of what? A link to the snippet in question would be helpful. There are several MudProg variable snippets out there.
       
Post is unread #3 Sep 29, 2009, 9:43 pm   Last edited Sep 29, 2009, 9:44 pm by dbna2
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

       
Post is unread #4 Sep 29, 2009, 9:57 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Oh, well, then it should just be something like:

if $n.race == Racename or the like. Not real sure, wrote that snippet a long time ago, and don't currently have it in any of my active projects atm. But if that doesn't work, I'll have a look at the snippet and see what I can decipher for you.
       
Post is unread #5 Sep 29, 2009, 10:00 pm   Last edited Sep 29, 2009, 10:01 pm by dbna2
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

yeah that doesn't work.


>speech_prog 2
if $n.race == Saiyan
say You are a saiyan
else
endif

gets me nothing and I am set to the saiyan race.
       
Post is unread #6 Sep 29, 2009, 10:30 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Not sure, and looking at the code wasn't all that helpfile, I'll install it in one of my existing projects after I get some sleep and see what I can come up with unless someone else answers before then.
       
Post is unread #7 Sep 30, 2009, 8:27 am
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

Kay let me know how it goes.
       
Post is unread #8 Sep 30, 2009, 8:06 pm
Go to the top of the page
Go to the bottom of the page

Sanus Compleo
Magician
GroupMembers
Posts153
JoinedMar 25, 2008

Maybe the way you determine races are different, than what it was native for? Check out how it usually declares the output of your race (Check in Score, or summat), then take a look for when it's looking for races in the Variable code. Does plain ol' say $n.race output "This mob says 'Saiyan'"?
       
Post is unread #9 Oct 1, 2009, 7:14 am
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

it says saiyan
       
Post is unread #10 Oct 1, 2009, 6:24 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Uh, what's wrong with using if race($n) == Saiyan?

Also, try "saiyan" if it's saying it in lowercase.
       
Post is unread #11 Oct 2, 2009, 4:24 pm
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

nope...
       
Post is unread #12 Oct 2, 2009, 5:28 pm
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

I put this into my SWR and it works great. I've also expanded it a bunch. If I remember correctly, the system was designed to use the setvar and say commands within the progs, not the ifcheck system. I think you need to modify mprog_do_ifcheck to support the new syntax because it was designed to use the if check(target) style.

What I did was added the following at the top of that function:
   if( ifcheck[0] == '$' )
   {
      ifcheck = one_argument3( ifcheck, cvar ); // modified version of one_argument2 to handle a '.'
      ifcheck = one_argument( ifcheck, chck );
      ifcheck = one_argument( ifcheck, opr );
      one_argument( ifcheck, rval );
   }
   else
   { --- original syntax checking code here to leave support for the original check() system

After that the following stuff works like a charm.

>act_prog p arrives from the west.
if $n.name == solao
or $n.name == gentti
or $n.name == andril
mpecho A voice intones from around you, "Greetings, Great One".
endif
       
Post is unread #13 Oct 2, 2009, 5:51 pm
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

Two things does the old style of ifchecks work? and if so can you post your one_argument3?
       
Post is unread #14 Oct 2, 2009, 11:40 pm
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

Yes, if isnpc($n) and whatever still works, as long as you leave the old syntax stuff in place, which is why that else block is there after the if( ifcheck[0] == '$' ) block.

Here's my one_argument3 function.
// this is a copy of one_argument2 from interp.c, but checking for a '.' instead of a '-'
char *one_argument3( char *argument, char *arg_first )
{
   char cEnd;
   short count;

   count = 0;

   while( isspace( *argument ) )
      argument++;

   cEnd = ' ';
   if( *argument == '\'' || *argument == '"' )
      cEnd = *argument++;

   while( *argument != '\0' || ++count >= 255 )
   {
      if( *argument == cEnd || *argument == '.' ) // changed from a '-' to a '.'
      {
         argument++;
         break;
      }
      *arg_first = LOWER( *argument );
      arg_first++;
      argument++;
   }
   *arg_first = '\0';

   while( isspace( *argument ) )
      argument++;

   return argument;
}

I thought about possibly combining all three into one_argument but that would cause major problems.
       
Post is unread #15 Oct 3, 2009, 11:36 am
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

how did the or's come in?
       
Post is unread #16 Oct 3, 2009, 11:45 am
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

btw this still does not work, I am going to post the function to show you what I got.

[code]
int mprog_do_ifcheck( char *ifcheck, CHAR_DATA *mob, CHAR_DATA *actor,
OBJ_DATA *obj, void *vo, CHAR_DATA *rndm )
{
char buf[MAX_STRING_LENGTH];
char opr[MAX_INPUT_LENGTH];
char *chck, *cvar;
char *argv[MAX_IF_ARGS];
char *rval = "";
char *q, *p = buf;
int argc = 0;
CHAR_DATA *chkchar = NULL;
OBJ_DATA *chkobj = NULL;
int lhsvl, rhsvl = 0;

if ( !*ifcheck )
{
progbug("Null ifcheck", mob);
return BERR;
}

/*
* New parsing by Thoric to allow for multiple arguments inside the
* brackets, ie: if leveldiff($n, $i) > 10
* It's also smaller, cleaner and probably faster
*/
strcpy(buf, ifcheck); opr[0] = '\0';
while ( isspace(*p) ) ++p;
argv[argc++] = p;
while ( isalnum(*p) ) ++p;
while ( isspace(*p) ) *p++ = '\0';
if ( *p != '(' )
{
progbug("Ifcheck Syntax error (missing left bracket)", mob);
return BERR;
}

*p++ = '\0';
/* Need to check for spaces or if name( $n ) isn't legal --Shaddai */
while ( isspace(*p) ) *p++ = '\0';
for (;;)
{
argv[argc++] = p;
while ( *p == '$' || isalnum(*p) ) ++p;
while ( isspace(*p) ) *p++ = '\0';
switch(*p)
{
case ',':
*p++ = '\0';
while ( isspace(*p) ) *p++ = '\0';
if ( argc >= MAX_IF_ARGS )
{
while ( *p && *p != ')' ) ++p;
if ( *p )
*p++ = '\0';
while ( isspace(*p) ) *p++ = '\0';
goto doneargs;
}
break;
case ')':
*p++ = '\0';
while ( isspace(*p) ) *p++ = '\0';
goto doneargs;
break;
default:
progbug("Ifcheck Syntax warning (missing right bracket)", mob);
goto doneargs;
break;
}
}
doneargs:
q = p;
while ( isoperator(*p) ) ++p;
strncpy(opr, q, p-q);
opr[p-q] = '\0';
while ( isspace(*p) ) *p++ = '\0';
rval = p;
/*
while ( *p && !isspace(*p) ) ++p;
*/
while ( *p ) ++p;
*p = '\0';
rval = parse_var( p, mob, actor, obj, vo, rndm );
chck = argv[0] ? argv[0] : "";
cvar = argv[1] ? argv[1] : "";

/*
* chck contains check, cvar is the variable in the (), opr is the
* operator if there is one, and rval is the value if there was an
* operator.
*/
if ( cvar[0] == '$' )
{
switch(cvar[1])
{
case 'i': chkchar = mob; break;
case 'n': chkchar = actor; break;
case 't': chkchar = (CHAR_DATA *)vo; break;
case 'r': chkchar = rndm; break;
case 'o': chkobj = obj; break;
case 'p': chkobj = (OBJ_DATA *)vo; break;
default:
sprintf(rval, "Bad argument '%c' to '%s'", cvar[0], chck);
progbug(rval, mob);
return BERR;
}
if ( !chkchar && !chkobj )
return BERR;
}
if( ifcheck[0] == '$' )
{
ifcheck = one_argument3( ifcheck, cvar ); // modified version of one_argument2 to handle a '.'
ifcheck = one_argument( ifcheck, chck );
ifcheck = one_argument( ifcheck, opr );
one_argument( ifcheck, rval );
}
else
{
if ( !str_cmp(chck, "rand";) )
{
return (number_percent() <= atoi(cvar));
}
if ( !str_cmp(chck, "economy";) )
{
int idx = atoi(cvar);
ROOM_INDEX_DATA *room;

if ( !idx )
{
if ( !mob->in_room )
{
progbug( "'economy' ifcheck: mob in NULL room with no room vnum "
"argument", mob );
return BERR;
}
room = mob->in_room;
}
else
room = get_room_index(idx);
if ( !room )
{
progbug( "Bad room vnum passed to 'economy'", mob );
return BERR;
}
return mprog_veval( ((room->area->high_economy > 0) ? 1000000000 : 0)
+ room->area->low_economy, opr, atoi(rval), mob );
}
if (!str_cmp(chck, "mobinarea";))
{
int vnum = atoi(cvar);
int lhsvl;
int world_count;
int found_count;
CHAR_DATA *tmob;
MOB_INDEX_DATA *m_index;

if (vnum < 1 || vnum > MAX_VNUMS)
{
progbug("Bad vnum to 'mobinarea'", mob);
return BERR;
}

m_index = get_mob_index(vnum);

if(!m_index)
world_count = 0;
else
world_count = m_index->count;

lhsvl = 0;
found_count = 0;

for(tmob = first_char; tmob && found_count != world_count;
tmob = tmob->next)
{
if(IS_NPC(tmob) && tmob->pIndexData->vnum == vnum)
{
found_count++;

if(tmob->in_room->area == mob->in_room->area)
lhsvl++;
}
}
rhsvl = atoi(rval);

/* Changed below from 1 to 0 */
if(rhsvl < 0)
rhsvl = 0;
if(!*opr)
strcpy(opr, "==";);

return mprog_veval(lhsvl, opr, rhsvl, mob);
}

if ( !str_cmp(chck, "mobinroom";) )
{
int vnum = atoi(cvar);
int lhsvl;
CHAR_DATA *oMob;

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug( "Bad vnum to 'mobinroom'", mob );
return BERR;
}
lhsvl = 0;
for ( oMob = mob->in_room->first_person; oMob;
oMob = oMob->next_in_room )
if ( IS_NPC(oMob) && oMob->pIndexData->vnum == vnum )
lhsvl++;
rhsvl = atoi(rval);
/* Changed below from 1 to 0 */
if ( rhsvl < 0 ) rhsvl = 0;
if ( !*opr )
strcpy( opr, "==" );
return mprog_veval(lhsvl, opr, rhsvl, mob);
}

if(!str_cmp(chck, "mobinworld";))
{
int vnum = atoi(cvar);
int lhsvl;
MOB_INDEX_DATA *m_index;

if(vnum < 1 || vnum > MAX_VNUMS)
{
progbug("Bad vnum to 'mobinworld'", mob);
return BERR;
}

m_index = get_mob_index(vnum);

if(!m_index)
lhsvl = 0;
else
lhsvl = m_index->count;

rhsvl = atoi(rval);
/* Changed below from 1 to 0 */

if(rhsvl < 0)
rhsvl = 0;
if(!*opr)
strcpy(opr, "==";);

return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "timeskilled";) )
{
MOB_INDEX_DATA *pMob;

if ( chkchar )
pMob = chkchar->pIndexData;
else if ( !(pMob = get_mob_index(atoi(cvar))) )
{
progbug("TimesKilled ifcheck: bad vnum", mob);
return BERR;
}
return mprog_veval(pMob->killed, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "ovnumhere";) )
{
OBJ_DATA *pObj;
int vnum = atoi(cvar);

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug("OvnumHere: bad vnum", mob);
return BERR;
}
lhsvl = 0;

for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
for ( pObj = mob->in_room->first_content; pObj; pObj = pObj->next_content )
if ( pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed from 1 to 0 */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "otypehere";) )
{
OBJ_DATA *pObj;
int type;

if ( is_number(cvar) )
type = atoi(cvar);
else
type = get_otype(cvar);
if ( type < 0 || type > MAX_ITEM_TYPE )
{
progbug("OtypeHere: bad type", mob);
return BERR;
}
lhsvl = 0;

for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->item_type == type )
lhsvl+=pObj->count;
for ( pObj = mob->in_room->first_content; pObj;
pObj = pObj->next_content )
if ( pObj->item_type == type )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Change below from 1 to 0 */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "ovnumroom";) )
{
OBJ_DATA *pObj;
int vnum = atoi(cvar);

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug("OvnumRoom: bad vnum", mob);
return BERR;
}
lhsvl = 0;
for ( pObj = mob->in_room->first_content; pObj;
pObj = pObj->next_content )
if ( pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 so can check for == no items Shaddai */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "hero";) )
{
if ( chkchar->basepl > 10000000 )
return TRUE;
return FALSE;
}
if ( !str_cmp(chck, "otyperoom";) )
{
OBJ_DATA *pObj;
int type;

if ( is_number(cvar) )
type = atoi(cvar);
else
type = get_otype(cvar);
if ( type < 0 || type > MAX_ITEM_TYPE )
{
progbug("OtypeRoom: bad type", mob);
return BERR;
}
lhsvl = 0;

for ( pObj = mob->in_room->first_content; pObj;
pObj = pObj->next_content )
if ( pObj->item_type == type )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "ovnumcarry";) )
{
OBJ_DATA *pObj;
int vnum = atoi(cvar);

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug("OvnumCarry: bad vnum", mob);
return BERR;
}
lhsvl = 0;

for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;

if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "otypecarry";) )
{
OBJ_DATA *pObj;
int type;

if ( is_number(cvar) )
type = atoi(cvar);
else
type = get_otype(cvar);
if ( type < 0 || type > MAX_ITEM_TYPE )
{
progbug("OtypeCarry: bad type", mob);
return BERR;
}
lhsvl = 0;
for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->item_type == type )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 Shaddai */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "ovnumwear";) )
{
OBJ_DATA *pObj;
int vnum = atoi(cvar);

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug("OvnumWear: bad vnum", mob);
return BERR;
}
lhsvl = 0;
for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->wear_loc != WEAR_NONE &&
pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "otypewear";) )
{
OBJ_DATA *pObj;
int type;

if ( is_number(cvar) )
type = atoi(cvar);
else
type = get_otype(cvar);
if ( type < 0 || type > MAX_ITEM_TYPE )
{
progbug("OtypeWear: bad type", mob);
return BERR;
}
lhsvl = 0;
for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->wear_loc != WEAR_NONE &&
pObj->item_type == type )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 so can have == 0 Shaddai */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "ovnuminv";) )
{
OBJ_DATA *pObj;
int vnum = atoi(cvar);

if ( vnum < 1 || vnum > MAX_VNUMS )
{
progbug("OvnumInv: bad vnum", mob);
return BERR;
}
lhsvl = 0;

for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->wear_loc == WEAR_NONE
&& pObj->pIndexData->vnum == vnum )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed 1 to 0 so can have == 0 */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "otypeinv";) )
{
OBJ_DATA *pObj;
int type;

if ( is_number(cvar) )
type = atoi(cvar);
else
type = get_otype(cvar);
if ( type < 0 || type > MAX_ITEM_TYPE )
{
progbug("OtypeInv: bad type", mob);
return BERR;
}
lhsvl = 0;
for ( pObj = mob->first_carrying; pObj; pObj = pObj->next_content )
if ( pObj->wear_loc == WEAR_NONE
&& pObj->item_type == type )
lhsvl+=pObj->count;
rhsvl = is_number(rval) ? atoi(rval) : -1;
/* Changed below from 1 to 0 for == 0 Shaddai */
if ( rhsvl < 0 )
rhsvl = 0;
if ( !*opr )
strcpy(opr, "==";);
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( chkchar )
{
if ( !str_cmp(chck, "ispacifist";) )
{
return (IS_NPC(chkchar) && xIS_SET(chkchar->act, ACT_PACIFIST));
}
if ( !str_cmp(chck, "ismobinvis";) )
{
return (IS_NPC(chkchar) && xIS_SET(chkchar->act, ACT_MOBINVIS));
}
if ( !str_cmp(chck, "mobinvislevel";) )
{
return (IS_NPC(chkchar) ?
mprog_veval(chkchar->mobinvis, opr, atoi(rval), mob) : FALSE);
}
if ( !str_cmp(chck, "ispc";) )
{
return IS_NPC(chkchar) ? FALSE : TRUE;
}
if ( !str_cmp(chck, "isnpc";) )
{
return IS_NPC(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "cansee";) )
{
return can_see( mob , chkchar );
}
if ( !str_cmp(chck, "ispassage";) )
{
if ( find_door( chkchar, rval , TRUE ) == NULL )
return FALSE;
else
return TRUE;
}
if ( !str_cmp(chck, "isopen" ) )
{
EXIT_DATA *pexit;

if ( (pexit = find_door( chkchar, rval, TRUE)) == NULL )
return FALSE;
if (!IS_SET (pexit->exit_info, EX_CLOSED))
return TRUE;
return FALSE;
}
if ( !str_cmp(chck, "islocked" ) )
{
EXIT_DATA *pexit;

if ( (pexit = find_door( chkchar, rval, TRUE)) == NULL )
return FALSE;
if (IS_SET (pexit->exit_info, EX_LOCKED))
return TRUE;
return FALSE;
}
if ( !str_cmp(chck, "ispkill";) )
{
return IS_PKILL(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isdevoted";) )
{
return IS_DEVOTED(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "canpkill";) )
{
return CAN_PKILL(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "ismounted";) )
{
return (chkchar->position == POS_MOUNTED);
}
if ( !str_cmp(chck, "ismorphed";) )
{
return (chkchar->morph != NULL) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isnuisance" ) )
{
return (!IS_NPC(chkchar)? chkchar->pcdata->nuisance? TRUE: FALSE: FALSE);
}
if ( !str_cmp(chck, "isgood";) )
{
return IS_GOOD(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isneutral";) )
{
return IS_NEUTRAL(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isevil";) )
{
return IS_EVIL(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isfight";) )
{
return who_fighting(chkchar) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isimmort";) )
{
return (get_trust(chkchar) >= LEVEL_IMMORTAL);
}
if ( !str_cmp(chck, "ischarmed";) )
{
return IS_AFFECTED(chkchar, AFF_CHARM) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isflying";) )
{
return IS_AFFECTED(chkchar, AFF_FLYING) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "isthief";) )
{
return ( !IS_NPC(chkchar) && xIS_SET(chkchar->act, PLR_THIEF) );
}
if ( !str_cmp(chck, "isattacker";) )
{
return ( !IS_NPC(chkchar) && xIS_SET(chkchar->act, PLR_ATTACKER) );
}
if ( !str_cmp(chck, "iskiller";) )
{
return ( !IS_NPC(chkchar) && xIS_SET(chkchar->act, PLR_KILLER) );
}
if ( !str_cmp(chck, "isfollow";) )
{
return (chkchar->master != NULL
&& chkchar->master->in_room == chkchar->in_room);
}
if( !str_cmp( chck, "isdead" ) )
{
return ( xIS_SET( chkchar->affected_by, AFF_DEAD ) );
}

if ( !str_cmp(chck, "isaffected";) )
{
int value = get_aflag(rval);

if ( value < 0 || value > MAX_BITS )
{
progbug("Unknown affect being checked", mob);
return BERR;
}
return IS_AFFECTED(chkchar, value) ? TRUE : FALSE;
}
if ( !str_cmp(chck, "numfighting";) )
{
return mprog_veval(chkchar->num_fighting-1, opr, atoi(rval), mob );
}
if ( !str_cmp(chck, "hitprcnt";) )
{
return mprog_veval(chkchar->hit/chkchar->max_hit, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "inroom";) )
{
return mprog_veval(chkchar->in_room->vnum, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "wasinroom";) )
{
if ( !chkchar->was_in_room )
return FALSE;
return mprog_veval(chkchar->was_in_room->vnum, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "sex";) )
{
return mprog_veval(chkchar->sex, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "position";) )
{
return mprog_veval(chkchar->position, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "doingquest";) )
{
return IS_NPC(chkchar) ? FALSE
: mprog_veval(chkchar->pcdata->quest_number, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "ishelled";) )
{
return IS_NPC(chkchar) ? FALSE
: mprog_veval(chkchar->pcdata->release_date, opr, atoi(rval), mob);
}

if ( !str_cmp(chck, "level";) )
{
return mprog_veval(get_trust(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "goldamt";) )
{
return mprog_veval(chkchar->gold, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "class";) )
{
if ( IS_NPC(chkchar) )
return mprog_seval(npc_class[chkchar->class], opr, rval, mob);
return mprog_seval((char *)class_table[chkchar->class]->who_name,
opr, rval, mob);
}
if ( !str_cmp(chck, "weight" ) )
{
return mprog_veval(chkchar->carry_weight, opr, atoi(rval), mob );
}
if ( !str_cmp(chck, "hostdesc";) )
{
if ( IS_NPC(chkchar) || !chkchar->desc->host )
return FALSE;
return mprog_seval(chkchar->desc->host, opr, rval, mob);
}
if ( !str_cmp(chck, "multi";) )
{
CHAR_DATA *ch;
int lhsvl = 0;

for( ch = first_char; ch; ch = ch->next )
if( !IS_NPC( chkchar ) && !IS_NPC( ch )
&& ch->desc && chkchar->desc && !str_cmp( ch->desc->host, chkchar->desc->host ) )

lhsvl++;
rhsvl = atoi(rval);
if ( rhsvl < 0 ) rhsvl = 0;
if ( !*opr ) strcpy( opr, "==" );
return mprog_veval(lhsvl, opr, rhsvl, mob);
}
if ( !str_cmp(chck, "race";) )
{
if ( IS_NPC(chkchar) )
return mprog_seval(npc_race[chkchar->race], opr, rval, mob);
return mprog_seval((char *)race_table[chkchar->race]->race_name,
opr, rval, mob);
}
if ( !str_cmp(chck, "morph" ) )
{
if ( chkchar->morph == NULL )
return FALSE;
if ( chkchar->morph->morph == NULL )
return FALSE;
return mprog_veval(chkchar->morph->morph->vnum, opr, rhsvl, mob );
}
if ( !str_cmp(chck, "nuisance";) )
{
if ( IS_NPC( chkchar ) || !chkchar->pcdata->nuisance )
return FALSE;
return mprog_veval(chkchar->pcdata->nuisance->flags, opr, rhsvl, mob );
}
if ( !str_cmp(chck, "clan";) )
{
if ( IS_NPC(chkchar) || !chkchar->pcdata->clan )
return FALSE;
return mprog_seval(chkchar->pcdata->clan->name, opr, rval, mob);
}
/* Check added to see if the person isleader of == clan Shaddai */
if (!str_cmp (chck, "isleader";))
{
CLAN_DATA *temp;
if ( IS_NPC ( chkchar ) )
return FALSE;
if ( (temp = get_clan( rval )) == NULL )
return FALSE;
if ( mprog_seval(chkchar->name, opr, temp->leader, mob)
|| mprog_seval(chkchar->name, opr, temp->number1, mob)
|| mprog_seval(chkchar->name, opr, temp->number2, mob) )
return TRUE;
else
return FALSE;
}

/* Is char wearing some eq on a specific wear loc? -- Gorog */
if (!str_cmp (chck, "wearing";))
{
OBJ_DATA *obj;
int i=0;
for (obj=chkchar->first_carrying; obj; obj=obj->next_content)
{
i++;
/*
if ( chkchar==obj->carried_by )
pager_printf(chkchar, "count=%d obj name=%s\n\r", i, obj->name);
*/
if ( chkchar==obj->carried_by
&& obj->wear_loc > -1
&& !str_cmp(rval, item_w_flags[obj->wear_loc]) )
return TRUE;
}
return FALSE;
}
/* Is char wearing some specific vnum? -- Gorog */
if (!str_cmp (chck, "wearingvnum";))
{
OBJ_DATA *obj;

if ( !is_number(rval) )
return FALSE;
for (obj=chkchar->first_carrying; obj; obj=obj->next_content)
{
if ( chkchar==obj->carried_by
&& obj->wear_loc > -1
&& obj->pIndexData->vnum == atoi(rval) )
return TRUE;
}
return FALSE;
}

/* Is char carrying a specific piece of eq? -- Gorog */
if (!str_cmp (chck, "carryingvnum";))
{
int vnum;

if ( !is_number(rval) )
return FALSE;
vnum = atoi(rval);
if ( !chkchar->first_carrying )
return FALSE;
return (carryingvnum_visit(chkchar, chkchar->first_carrying, vnum));
}

/* Check added to see if the person isleader of == clan Gorog */
if (!str_cmp (chck, "isclanleader";))
{
CLAN_DATA *temp;
if ( IS_NPC ( chkchar ) )
return FALSE;
if ( (temp = get_clan( rval )) == NULL )
return FALSE;
if ( mprog_seval(chkchar->name, opr, temp->leader, mob ) )
return TRUE;
else
return FALSE;
}
if (!str_cmp (chck, "isclan1";))
{
CLAN_DATA *temp;
if ( IS_NPC ( chkchar ) )
return FALSE;
if ( (temp = get_clan( rval )) == NULL )
return FALSE;
if ( mprog_seval(chkchar->name, opr, temp->number1, mob ) )
return TRUE;
else
return FALSE;
}
if (!str_cmp (chck, "isclan2";))
{
CLAN_DATA *temp;
if ( IS_NPC ( chkchar ) )
return FALSE;
if ( (temp = get_clan( rval )) == NULL )
return FALSE;
if ( mprog_seval(chkchar->name, opr, temp->number2, mob ) )
return TRUE;
else
return FALSE;
}
if ( !str_cmp(chck, "council";) )
{
if ( IS_NPC(chkchar) || !chkchar->pcdata->council )
return FALSE;
return mprog_seval(chkchar->pcdata->council->name, opr, rval, mob);
}
if ( !str_cmp(chck, "deity";) )
{
if (IS_NPC(chkchar) || !chkchar->pcdata->deity )
return FALSE;
return mprog_seval(chkchar->pcdata->deity->name, opr, rval, mob);
}
if ( !str_cmp(chck, "guild";) )
{
if ( IS_NPC(chkchar) || !IS_GUILDED(chkchar) )
return FALSE;
return mprog_seval(chkchar->pcdata->clan->name, opr, rval, mob);
}
if ( !str_cmp(chck, "clantype";) )
{
if ( IS_NPC(chkchar) || !chkchar->pcdata->clan )
return FALSE;
return mprog_veval(chkchar->pcdata->clan->clan_type, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "isflagged";) )
{
VARIABLE_DATA *vd;
int vnum = mob->pIndexData->vnum;
int flag = 0;
char *p;

if ( argc < 3 )
{
return BERR;
}
if ( argc > 3 )
flag = atoi(argv[3]);
if ( (p=strchr(argv[2], ':')) != NULL )
{
*p++ = '\0';
vnum = atoi(p);
}
if ( (vd=get_tag(chkchar, argv[2], vnum)) == NULL )
return FALSE;

flag = abs(flag) % MAX_BITS;
switch(vd->type)
{
case vtSTR:
case vtINT:
return FALSE;
case vtXBIT:
return xIS_SET(*(EXT_BV*)vd->data, flag) ? TRUE : FALSE;
}
return FALSE;
}
/*
* abits and qbits
*/
if( !str_cmp( chck, "hasabit" ) )
{
int number;

if( is_number( rval ) )
{
number = atoi( rval );

if( get_abit( chkchar, number ) == NULL )
return mprog_veval( 0, opr, 1, mob );
else
return mprog_veval( 1, opr, 1, mob );
}
progbug( "hasabit: bad abit number", mob );
return BERR;
}

/*
* abits and qbits
*/
if( !str_cmp( chck, "hasqbit" ) )
{
int number;

if( is_number( rval ) )
{
number = atoi( rval );

if( get_qbit( chkchar, number ) == NULL )
return mprog_veval( 0, opr, 1, mob );
else
return mprog_veval( 1, opr, 1, mob );
}
progbug( "hasqbit: bad qbit number", mob );
return BERR;
}
if ( !str_cmp(chck, "istagged";) )
{
VARIABLE_DATA *vd;
int vnum = mob->pIndexData->vnum;
char *p;

if ( argc < 3 )
{
return BERR;
}
if ( argc > 3 )
vnum = atoi(argv[3]);
if ( (p=strchr(argv[2], ':')) != NULL )
{
*p++ = '\0';
vnum = atoi(p);
}
if ( (vd=get_tag(chkchar, argv[2], vnum)) == NULL )
return FALSE;

if ( !*opr && !*rval )
return TRUE;
switch(vd->type)
{
case vtSTR:
return mprog_seval(vd->data, opr, rval, mob);
case vtINT:
return mprog_veval((int)vd->data, opr, atoi(rval), mob);
case vtXBIT:
return FALSE; /* for now */
}
return FALSE;
}
if ( !str_cmp(chck, "waitstate";) )
{
if ( IS_NPC( chkchar ) || !chkchar->wait )
return FALSE;
return mprog_veval(chkchar->wait, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "asupressed";) )
{
return mprog_veval( get_timer( chkchar, TIMER_ASUPRESSED ), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "favor";) )
{
if ( IS_NPC(chkchar) || !chkchar->pcdata->favor )
return FALSE;
return mprog_veval(chkchar->pcdata->favor, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "hps";) )
{
return mprog_veval(chkchar->hit, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "mana";) )
{
return mprog_veval(chkchar->mana, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "str";) )
{
return mprog_veval(get_curr_str(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "wis";) )
{
return mprog_veval(get_curr_wis(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "int";) )
{
return mprog_veval(get_curr_int(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "spd";) )
{
return mprog_veval(get_curr_dex(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "con";) )
{
return mprog_veval(get_curr_con(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "cha";) )
{
return mprog_veval(get_curr_cha(chkchar), opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "lck";) )
{
return mprog_veval(get_curr_lck(chkchar), opr, atoi(rval), mob);
}
if( !str_cmp( chck, "split" ) )
{
if( is_split( chkchar ) )
return TRUE;
else
return FALSE;
}

if (!str_cmp(chck, "iscarrying";)) {
int iwear;
OBJ_DATA *pObj;
int vnum = atoi(rval);

if (vnum < 1 || vnum > 2097152000) {
progbug("iscarrying: bad vnum", mob) ;
return BERR ;
}

if (str_cmp(opr, "==";)) {
progbug("iscarrying: bad check", mob) ;
return BERR ;
}

for (pObj = chkchar->first_carrying; pObj; pObj = pObj->next_content)
{
if (pObj->pIndexData->vnum == vnum)
{
for ( iwear = 0; iwear < MAX_WEAR; iwear++ )
{
if ( pObj->wear_loc == iwear )
{
if ( pObj->pIndexData->vnum == vnum)
return FALSE;
}
}
return TRUE ;
}
}
return FALSE;
}
if ( !str_cmp(chck, "iswearing";) )
{
OBJ_DATA *pobj;
int vnum = atoi( rval );
int iwear;

if ( vnum < 1 || vnum > 2097152000 )
{
progbug("iswearing: bad vnum", mob);
return BERR;
}

if ( str_cmp(opr, "==";))
{
progbug("iswearing: bad check", mob);
return BERR;
}

for ( iwear = 0; iwear < MAX_WEAR; iwear++ )
{
for ( pobj = chkchar->first_carrying; pobj; pobj = pobj->next_content)
{
if ( pobj->wear_loc == iwear )
{
if ( pobj->pIndexData->vnum == vnum)
return TRUE;
}
}
}
return FALSE;
}
}
if ( chkobj )
{
if ( !str_cmp(chck, "objtype";) )
{
return mprog_veval(chkobj->item_type, opr, atoi(rval), mob);
}
if( !str_cmp( chck, "leverpos" ) )
{
int isup = FALSE, wantsup = FALSE;

if( chkobj->item_type != ITEM_SWITCH && chkobj->item_type != ITEM_LEVER && chkobj->item_type != ITEM_PULLCHAIN && chkobj->item_type != ITEM_BUTTON )
return FALSE;

if( IS_SET( obj->value[0], TRIG_UP ) )
isup = TRUE;
if( !str_cmp( rval, "up" ) )
wantsup = TRUE;

return mprog_veval( wantsup, opr, isup, mob );
}

if ( !str_cmp(chck, "objval0";) )
{
return mprog_veval(chkobj->value[0], opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "objval1";) )
{
return mprog_veval(chkobj->value[1], opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "objval2";) )
{
return mprog_veval(chkobj->value[2], opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "objval3";) )
{
return mprog_veval(chkobj->value[3], opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "objval4";) )
{
return mprog_veval(chkobj->value[4], opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "objval5";) )
{
return mprog_veval(chkobj->value[5], opr, atoi(rval), mob);
}
}
/*
* The following checks depend on the fact that cval[1] can only contain
* one character, and that NULL checks were made previously.
*/
if ( !str_cmp(chck, "number";) )
{
if ( chkchar )
{
if ( !IS_NPC(chkchar) )
return FALSE;
lhsvl = (chkchar == mob) ? chkchar->gold : chkchar->pIndexData->vnum;
return mprog_veval(lhsvl, opr, atoi(rval), mob);
}
return mprog_veval(chkobj->pIndexData->vnum, opr, atoi(rval), mob);
}
if ( !str_cmp(chck, "time";) )
{
return mprog_veval(time_info.hour, opr, atoi(rval), mob );
}
if ( !str_cmp(chck, "month";) )
{
return mprog_veval(time_info.month, opr, atoi(rval), mob );
}
if ( !str_cmp(chck, "name";) )
{
if ( chkchar )
return mprog_seval(chkchar->name, opr, rval, mob);
return mprog_seval(chkobj->name, opr, rval, mob);
}

if ( !str_cmp(chck, "rank";) ) /* Shaddai */
{
if ( chkchar && !IS_NPC( chkchar ) )
return mprog_seval(chkchar->pcdata->rank, opr, rval, mob);
return FALSE;
}

if ( !str_cmp(chck, "mortinworld";) ) /* -- Gorog */
{
DESCRIPTOR_DATA *d;
for ( d = first_descriptor; d; d = d->next )
if ( d->connected == CON_PLAYING
&& d->character
&& get_trust(d->character) < LEVEL_IMMORTAL
&& nifty_is_name(d->character->name, cvar) )
return TRUE;
return FALSE;
}

if ( !str_cmp(chck, "mortinroom";) ) /* -- Gorog */
{
CHAR_DATA *ch;
for ( ch = mob->in_room->first_person; ch; ch = ch->next_in_room )
if ( (!IS_NPC(ch))
&& get_trust(ch) < LEVEL_IMMORTAL
&& nifty_is_name(ch->name, cvar) )
return TRUE;
return FALSE;
}

if ( !str_cmp(chck, "mortinarea";) ) /* -- Gorog */
{
CHAR_DATA *ch;
for ( ch = first_char; ch; ch = ch->next )
if ( (!IS_NPC(ch))
&& ch->in_room->area == mob->in_room->area
&& get_trust(ch) < LEVEL_IMMORTAL
&& nifty_is_name(ch->name, cvar) )
return TRUE;
return FALSE;
}


if ( !str_cmp(chck, "mortcount";) ) /* -- Gorog */
{
CHAR_DATA *tch;
ROOM_INDEX_DATA *room;
int count = 0;
int rvnum = atoi( cvar );

room = get_room_index ( rvnum ? rvnum : mob->in_room->vnum );

for ( tch = room?room->first_person:NULL; tch; tch = tch->next_in_room )
if ( (!IS_NPC(tch))
&& get_trust(tch) < LEVEL_IMMORTAL )
count++;
return mprog_veval(count, opr, atoi(rval), mob);
}


if ( !str_cmp(chck, "mobcount";) ) /* -- Gorog */
{
CHAR_DATA *tch;
ROOM_INDEX_DATA *room;
int count = -1;
int rvnum = atoi( cvar );

room = get_room_index ( rvnum ? rvnum : mob->in_room->vnum );

for ( tch = room?room->first_person:NULL; tch; tch = tch->next_in_room )
if ( (IS_NPC(tch)) )
count++;
return mprog_veval(count, opr, atoi(rval), mob);
}


if ( !str_cmp(chck, "charcount";) ) /* -- Gorog */
{
CHAR_DATA *tch;
ROOM_INDEX_DATA *room;
int count = -1;
int rvnum = atoi( cvar );

room = get_room_index ( rvnum ? rvnum : mob->in_room->vnum );

for ( tch = room?room->first_person:NULL; tch; tch = tch->next_in_room )

if ( ((!IS_NPC(tch))
&& get_trust(tch) < LEVEL_IMMORTAL)
|| IS_NPC(tch) ) /* mortal or mob */
count++;
return mprog_veval(count, opr, atoi(rval), mob);
}

/* ifcheck pl --Gohan */
if( !str_cmp( chck, "pl";) )
{
return mprog_veval( chkchar->basepl, opr, atoi(rval), mob );
}

/*
* Ok... all the ifchecks are done, so if we didnt find ours then something
* odd happened. So report the bug and abort the MUDprogram (return error)
*/
}
progbug( "Unknown ifcheck", mob );
return BERR;

}
       
Post is unread #17 Oct 3, 2009, 2:04 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Life got hectic for a bit on my end. So I still haven't had a chance to delve into this further. And it's looking like I won't get the chance to until Monday being that tomorrow is my first wedding anniversary. Odd that it's been a year already... Anyway, I'll poke at this on Monday if everything goes well tonight.
       
Post is unread #18 Oct 4, 2009, 1:54 am   Last edited Oct 4, 2009, 1:59 am by Kayle
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

So, I tossed this in one of my existing projects this morning. And, I'm not real sure what the hell it's supposed to be doing. At the moment, I don't really see what the hell I was thinking at the time, or how I thought this would work. Or even how I got it to work. The project I wrote this on has long since died out, and I don't have a copy of any of it anymore to tell. So, I'll keep playing with it, but I think the snippet might need an update and that little bit removed because I don't think it works. :P

[Edit:] Looking it over, the whole snippet could use a rewrite. Maybe I'll do that one of these days.
       
Post is unread #19 Oct 4, 2009, 7:53 am
Go to the top of the page
Go to the bottom of the page

6Dragons
Fledgling
GroupMembers
Posts48
JoinedNov 23, 2008

if you can't get kayles to work try this one.

http://www.auricmud.com/snippets/variables.html
       
Pages:<< prev 1 next >>