[ScryMUD] SVN Commit Info r886 - trunk/mud/grrmud/server
scrymud at wanfear.com
scrymud at wanfear.com
Tue Feb 20 01:52:18 PST 2007
Author: eroper
Date: 2007-02-20 01:52:18 -0800 (Tue, 20 Feb 2007)
New Revision: 886
Modified:
trunk/mud/grrmud/server/gen_cmds.spec
trunk/mud/grrmud/server/script.cc
trunk/mud/grrmud/server/script.h
Log:
This is for MUD-386
Though the syntax is different, room_has_critter is a command to be used in
script conditionals with the following syntax:
if room_has_critter <rnum/-1> <critter_name>
It will return true if rnum has any critters whose names match critter_name.
If rnum is passed as -1 the current room is used instead.
Modified: trunk/mud/grrmud/server/gen_cmds.spec
===================================================================
--- trunk/mud/grrmud/server/gen_cmds.spec 2007-02-20 08:57:33 UTC (rev 885)
+++ trunk/mud/grrmud/server/gen_cmds.spec 2007-02-20 09:52:18 UTC (rev 886)
@@ -680,6 +680,8 @@
rofl(i, &(cooked_strs[1]), pc, (*(pc.getCurRoom()))); return 0;
roll ~
if ((i != 1) || (j != 1)) roll(i, j, pc); else roll(i, &(cooked_strs[1]), pc, (*(pc.getCurRoom()))); return 0;
+room_has_critter ~
+return room_has_critter( pc, i, &(cooked_strs[1]) );
# IMM Commands - R
rclear ~
return rclear(i, pc);
Modified: trunk/mud/grrmud/server/script.cc
===================================================================
--- trunk/mud/grrmud/server/script.cc 2007-02-20 08:57:33 UTC (rev 885)
+++ trunk/mud/grrmud/server/script.cc 2007-02-20 09:52:18 UTC (rev 886)
@@ -1859,3 +1859,30 @@
}
}//parseScriptCommand
+//Checks rm_num (the current room if -1) for the presence of any critters named
+//crit_name. Return value should be treated as a bool.
+int room_has_critter(critter& pc, int rm_num, String* crit_name) {
+
+ room* p_room = NULL;
+
+ if ( rm_num == -1 ) {
+ p_room = pc.getCurRoom();
+ } else {
+ p_room = &room_list[rm_num];
+ }
+
+ int retval = ( p_room->haveCritNamed( 1, crit_name, pc ) != NULL ) ;
+
+ if ( mudlog.ofLevel(SCRIPT) ) {
+ mudlog << "Testing room number "
+ << p_room->getRoomNum()
+ << " for the presence of critter: "
+ << *crit_name
+ << " --result: "
+ << retval
+ << endl;
+ }
+
+ return retval;
+
+}//room_has_critter()
Modified: trunk/mud/grrmud/server/script.h
===================================================================
--- trunk/mud/grrmud/server/script.h 2007-02-20 08:57:33 UTC (rev 885)
+++ trunk/mud/grrmud/server/script.h 2007-02-20 09:52:18 UTC (rev 886)
@@ -77,6 +77,9 @@
int align_greater_than(int val, critter& pc);
int align_less_than(int val, critter& pc);
+//Checks rm_num (the current room if -1) for the presence of any critters named
+//crit_name. Return value should be treated as a bool.
+int room_has_critter(critter& pc, int rm_num, String* crit_name);
int does_own(critter& pc, int obj1, int obj2, int obj3, int obj4,
int obj5, int obj6);
More information about the ScryMUD
mailing list