Re: Query on timed events

From: Johan Eenfeldt (d95joe@csd.uu.se)
Date: 04/02/96


On Tue, 2 Apr 1996, the root of all evil wrote:

> >    So basically what I need to know, is how could I get a command
> >    to wait 30 seconds, check for the status of the victims flag
> >    and if the flag is on teleport the victim to a battle room, or
> >    if it is off, the whole thing abort and game play continue normally.
> 
> Here's a simple way to add an event system, its a little hairy to code if 
> your not familiar with linked lists, but the concept is easy and you 
> should be able to tweak it to suit your needs...
> 
> An event_data structure... I use:
> 
> struct event_data {
>    struct char_data *ch;            /* char this event happens to */
>    int cmd;			    /* command number             */
>    char *args;                      /* typed in args              */
>    int count;                       /* pulses to event completion */
>    struct event_data *next;         /* next command event in list */
> };

 [some code snipped]

One thing to remember if implementing an event system like this is that 
if it is activated after a player have logged out, for example, the *ch 
pointer is no longer valid, and Bad Things might happen...

The solution? Either search through all the events every time a 
free_char() call is made, or use some other system to store the char_data
reference.

For the record, my event queue system have player/mob/obj id (and balanced 
binary searchtrees...), but the other solution is probably easier to 
implement.

/ Johan Eenfeldt
  Student, Computer Science Department @ Uppsala University
  d95joe@csd.uu.se



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