Re: NEWBIE: Adding a time trigger for MOBPROGS.

From: Ric Klaren (ric@student.utwente.nl)
Date: 06/07/96


Hi

On Fri, 7 Jun 1996, Fionn Colvin wrote:

> Hi all,
>        I'd like to add a new trigger for mob progs so mobs can do stuff 
> depending on what the time is. I followed the outline in the docs for 
> making a new trigger. Below is the function I added to mobprog.c. However 
> it doesn't work. I know its a bit clumsy. Any ideas as to what I should 
> be doing?

> >time_prog 10~
> Shout its 10am.
> ~

I presume you add this to the prog structs of the mob? (hey another 
stupid question ;)

> int mprog_time_trigger(struct char_data *mob)
> {
>   MPROG_DATA *mprg;
> 
>   for (mprg = mob_index[mob->nr].mobprogs; mprg != NULL; mprg = mprg->next)
>     if (mprg->type & TIME_PROG) {
>       if (time_info.hours == atoi(mprg->arglist))
>         return 1;
>       else
>         return -1;
>     }
>   return -1;
> }

Should this execute the prog? If yes: you don't make a call to 
mprog_driver (that's the part of the code that executes the actual 
trigger 'code'

> Also at current I think that It will just keep doing the stuff 
> in act_time while time is equal to whatever the arg for the prog is. How 
> could I make it so it only does the command once per day?

act_time??? that correct? anyways I just had a look at the code dunno for 
sure where to add the call to this trigger.. have to look into it... 
great idea tough time triggers! (doin' a bit of a rewrite on the 
Mobprogram parser at the moment in an attempt to make it faster (we wanna 
loose all special C routs in the mud) first beta versions are running 
quite stable. Let me know wether you got it working (I'll make a post as 
soon as I get my stuff running (at a releasable level))

On second look! look in weather.c function called another_hour if that 
one's called every hour to update gametime then that's the place to add 
it.... (I guess)

from mobprog.c:

void mprog_hitprcnt_trigger(struct char_data *mob, struct char_data *ch)
{

   MPROG_DATA *mprg;

   if (IS_NPC(mob) && (mob_index[mob->nr].progtypes & HITPRCNT_PROG))
      for (mprg = mob_index[mob->nr].mobprogs; mprg != NULL; mprg = 
		mprg->next)
         if ((mprg->type & HITPRCNT_PROG)
             && ((100 * mob->points.hit / mob->points.max_hit) < 
		atoi(mprg->arglist)))
         {
            mprog_driver(mprg->comlist, mob, ch, NULL, NULL);
            break;
         }
}

I guess your trigger should look more something like this one...
Like:

void mprog_time_trigger(struct char_data *mob)
{
   MPROG_DATA *mprg;
   if (IS_NPC(mob) && (mob_index[mob->nr].progtypes & HITPRCNT_PROG))
      for (mprg = mob_index[mob->nr].mobprogs; mprg != NULL; mprg = 
             mprg->next)
     if (mprg->type & TIME_PROG) 
     {
       if (time_info.hours == atoi(mprg->arglist))
            mprog_driver(mprg->comlist, mob, NULL, NULL, NULL);
       else
         return;
     }
 }

So that's another bit of cut and paste... always works... in theory.... ;)

Have a go with it... Hope it works!

Greetinx GrimReaper of Realms of Frustration

-----+++++*****************************************************+++++++++-------
- Ric Klaren - j.klaren@student.utwente.nl - ia_ric@cs.utwente.nl -------------
-----+++++*****************************************************+++++++++-------
``Why don't we just invite them to dinner and massacre them all when
they're drunk?''
``You heard the man. There's seven hundred thousand of them.''
``Ah? So it'd have to be something simple with pasta, then.''
-------------------------------------------------------------------------------
From: Interesting Times by Terry Pratchet
-----+++++*****************************************************+++++++++-------



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