Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
russ3z
Newbie


Joined: 18 Nov 2005
Posts: 5

PostPosted: Fri Feb 25, 2011 3:14 pm   

How to evaluate multiple triggers dependent on an initial trigger?
 
In trying to script a percent failure rate for spells, I have tried the following:

#CLASS {WeaveFailRate}
#VAR pft {0}
#TRIGGER {channel '%1'} {pft = %subchar( %1, " ", "")}
#TRIGGER {You begin to weave the appropriate flows...} {

-In this game, spells are 'weaves' and casting is 'channeling.' So, to cast 'create food' is [channel 'create food'], with the variable pft then taking on the value createfood.

Once a spell is input, the "You begin to weave" message immediately follows.
Now, after this there are basically 3 possibilities. Either something interrupts and you don't get to cast, which does not count as either a pass or fail, or you fail, or you pass.

The 'neither' trigger would be like {Ouch! You couldn't maintain the flows.|Cancelled.|You can't summon enough energy to weave the flow.} - 3 different messages that show you were interrupted.

The Fail trigger is {You lost control of Saidar!}

The Pass trigger is simply {OK.} but since this is used for Other messages in the game, I only want it to trigger in this case when I have already triggers the Cast message above.

So the Question is, how can I evaluate these 3 trigger types within the framework of having already triggered {You begin to weave the appropriate flows...} ? Also bear in mind that various other actions can take place during the time it is taking to cast, so these 3 messages may or may not come immediately after the "You weave" message.
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: Fri Feb 25, 2011 4:28 pm   
 
[edit][/edit]


Last edited by Myrkul on Thu Apr 14, 2011 10:59 pm; edited 1 time in total
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Fri Feb 25, 2011 5:16 pm   
 
I think your best bet would be to create a class which contains three different triggers, one for each of the possible outcomes, and have those three triggers in a class which is enabled and disabled as needed. ie they're only enabled when you see 'You begin to weave the appropriate flows...' and then all three are disabled the moment you see any one of the three outcomes. You'll also want to set up an alias to send the channel command, rather than trying to do it with a trigger as you have it now, since that won't work.

So, something like this...

Code:
#CLASS {WeaveFailRate}
#VAR pft ""
#ALIAS chan {channel '%-1';#VAR pft %replace(%-1, " ", "")}
#TRIGGER {^You begin to weave the appropriate flows...} {#T+ WeaveFailRate|Channelling}
#CLASS {WeaveFailRate|Channelling} {disable}
#TRIGGER {^{Ouch! You couldn't maintain the flows.|Cancelled.|You can't summon enough energy to weave the flow.}$} {#T- WeaveFailRate|Channelling;MORE CODE GOES HERE}
#TRIGGER {^You lost control of Saidar!$} {#T- WeaveFailRate|Channelling;MORE CODE GOES HERE}
#TRIGGER {^OK.$} {#T- WeaveFailRate|Channelling;MORE CODE GOES HERE}
#CLASS 0


To use this, you would type chan create food Notice that there's no longer a need for quotes, but channelling at specific targets wouldn't be possible with that alias. ie. you couldn't type channel 'lightning bolt' DraxDrax. You may want to change that alias so that it has a name other than 'chan' and can correctly parse targetted spells (assuming that's something your mud supports). Otherwise, I think that's about what you intend. Replace the MORE CODE GOES HERE placeholders as appropriate to do the percentage calculations however you'd like to do those.
Reply with quote
russ3z
Newbie


Joined: 18 Nov 2005
Posts: 5

PostPosted: Fri Feb 25, 2011 5:32 pm   
 
Thanks. I was considering the extra classes, and it looks like that's the way to go.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net