[Idea] Adding the concept of 'IT' for object commands

From: Gary Barnett (gbarnett@polarnet.com)
Date: 01/31/97

Last night I fired up my News Reader and read through the latest
discussions on the rec.games.mud.diku group. After reading a huge
thread on adding 'it' in object based commands; i.e.

> get bread
> eat it

I figured I'd fire up my copy of Dev Studio and see what I could
figure out.

About an hour and half later I had fully implemented the concept
into my mud.. Much easier than it would have seemed from reading
the newgroups..


In Utils.H

#define GET_OBJ_IT(ch) ((ch)->player_specials->last_obj)
#define GET_POS_IT(ch) ((ch)->player_specials->last_pos)

In structs.h (player_specials)
   struct obj_data *last_obj;
   int last_pos;

With those defines installed, it is just a matter of updating the
player's GET_OBJ_IT and GET_POS_IT fields whenever they access an
object (get, drop, wield, wear, et al).. A couple special checks
need to be made as well.

1) You drop an item.. another PC/NPC gets it.. Needs to cycle through
all the players in teh room to remove their if context if it matches
the 'gotten' object

2) A test for moving.. if you leave the room, your 'IT' context is

3) The item being purged, the zone reset removes it, etc.

In addition, a line such as this can be used to supply the object to the
relevant routine that needs to know about it:

if ( (!IS_NPC(ch)) && str_cmp(arg, "it") && (GET_OBJ_IT(ch) != 0)
    && GET_POS_IT(ch) == X)) {

(I placed these checks before the usual get_obj_in_list_vis call for the
relevant routines .. all object based commands)

note: the above X can be 0 (ground) 1 (inventory) 2 (equipment) and
is set whenever an object is accessed via a command (look at, drink,
wield, wear, remove, etc) -- Used to supply the position of the object
so that the test can fail for the 'current' object being out of position
for the relevant action.. i.e. drinking an item on the ground. as in the
following two commands:

> drop barrel
> drink it

Just thought I'd post one method for doing this.. It's still early on,
but from what I have been able to gather, the players LOVE it :-)

I imagine that a lower level call could be used.. i.e. generic find.
>From looking at the code though, several routines would have to be
updated to use that call.. This method seemed easy, straightforward
and low overhead. (and easy to debug)


| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |

This archive was generated by hypermail 2b30 : 12/18/00 PST