(re) MobProg acts

From: ShadowLord (dkoepke@california.com)
Date: 12/06/95


On Wed, 6 Dec 1995, Sammy wrote:

> 
> Somewhere in act(), when it does the world character check, it leaves out 
> mobs.  You can take this check out to allow your mobs to respond to 
> acts.  You might also want to put a new check in so that mobs won't 
> trigger other mobs.  That way you don't have to worry so much about mob 
> trigger loops.
> 
> Sam
> 


Let's try to be a bit more specific, shall we? (not intended to be a 
flame, just a bit of a gleeful knock).

Unfortunately, from my prilimary look over of act (comm.c), I see nothing 
that prevents acts to be sent to mobiles; so, what you'll want to check 
is that the string that your mobile is supposed to catch is sent by act, 
if it's not, then it's rather obvious what your problem is (and the fix 
is just as easy). 

Also, preventing trigger loops by preventing Mobs to talk to one-another 
is awfully limiting.  Just have your code make sure that the same thing 
isn't said from the same mobile twice; just add the following in the 
mob_special_data structure:

	struct char_data * last_triggered;
	char * triggered_by;

Then, when a mob is triggered, just do:

	last_triggered = (the pointer to whomever triggered it);
	triggered_by = (the text of what they were triggered by);

Now, create a function like:

int CanTrigger(struct char_data * mob, struct char_data * ch, char *txt)
{
    if (!mob->mob_specials.last_triggered)
        return FALSE;
    if (!mob->mob_specials.triggered_by)
        return FALSE;
    
    if (ch == mob->mob_specials.last_triggered)
        return TRUE;
    else if (!strcmp(txt, mob->mob_specials.triggered_by))
        return TRUE;
    else
        return FALSE;
}


Of course, that's not just plug-and-play code and you'll need to do a bit 
of thinking (ie., what if the act_prog trigger isn't specified with a "p" 
for the entire phrase, strcmp won't fit your needs then.)  Also, where 
you put the code, etc. is up to you, I wrote this from the top of my head.

If how you implemented this works correctly, you should remove the 
limitation of mobiles recursively triggering each other, it's designed to 
stop this:

(enterance of Mr. MobA prompts MobA to say, "Hello")
Mr. MobA says: Hello

(the world "Hello" triggers MobB to respond, "Hello, $N.")
Mr. MobB says: Hello, Mr. MobA.

(which triggers Mr. MobA to say "Hello")
Mr. MobA says: Hello

[and it goes on until the Mud goes down (it would cause a crash, 
eventually, I presume), thus...]

The only limitation would be that Mobs couldn't say the same thing twice 
in the conversation, unless you wrote a mprog command to clear the 
triggered_by (perhaps should be, "triggered_by_text") and last_triggered 
(maybe should be, "triggered_by"), so that only some mobiles can repeat 
the same thing in text (of course, this would also mean you'd need to 
write the mprogs for the mobiles that this mob would interact with well 
enough to prevent the recursive behaviour).

All in all, a fairly good idea, I think.

As for the problem with mobs not being triggered by 'act', make sure that 
the MobProgs patch didn't modify comm.c


(failed to import /home/dkoepke/.signature)



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