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
yungin
Newbie


Joined: 02 Mar 2007
Posts: 4

PostPosted: Fri Mar 02, 2007 8:29 pm   

autoheal based on prompt
 
[size=18]Hey guys hows it goin?? I've been going absolutely insane trying to get a healing trigger to work. I've been going through past thread for 2+ days reading and testing different triggers I've found to see if they work on my mud and nothing Sad

My prompt reads like this:

%h/%HHp %m/%MMn %v/%VMv (Tnl:%X) [%e] %P <- this is what i type into the mud to get my prompt to display as below.

3464/4227Hp 841/841Mn 461/461Mv (Tnl:2500) [NESWU] <--- exactly what my prompt reads right now

The first set being current / max Hp. Second set being current / max Mana. Third current / max moves. Fourth is my exp to next level. Fifth is the current exits available to me.

Here's an example of what I've tried and zMud says the pattern matches.

{(%d)/%dHP}{%d/%dMn}{%d/%dMv}{Tnl:%d} {#IF %1 > 4200} {cast cure}


If i was able to cast cure this would be the mud's output:
You feel better!



Hopefully someone can help give me some direction as to what I have wrong here. I'm totally new to setting triggers and such. Thanks for any guidance you can give.











[/size]
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Mar 02, 2007 8:34 pm   
 
You don't need all those curly brackets in there. The only difference between the trigger pattern and the MUD text should be the wildcards. The only case when this isn't true is when you want to use a special character literally in the pattern, in which case it has to be prefixed with ~. To capture the whole line, all you need is:

Pattern: (%d)/%dHP %d/%dMn %d/%dMv ~(Tnl:%d~)

The script needs no editing apart from adding a closing bracket, though you're checking if your health is GREATER than 4200. Make sure that's what you meant. So to run this from the command line, you would do:

#trig {(%d)/%dHP %d/%dMn %d/%dMv ~(Tnl:%d~)} {#if (%1 > 4200) {cast cure}}

You might also want to capture the rest of the variables for later use, including the exits:

Pattern: (%d)/(%d)HP (%d)/(%d)Mn (%d)/(%d)Mv ~(Tnl:(%d)~) ~[(%w)~]
Reply with quote
yungin
Newbie


Joined: 02 Mar 2007
Posts: 4

PostPosted: Fri Mar 02, 2007 8:45 pm   
 
oops good catch on the greater than sign lol. Thank you for that.

Now using the pattern : (%d)/(%d)HP (%d)/(%d)Mn (%d)/(%d)Mv ~(Tnl:(%d)~) ~[(%w)~]
with the other variables captured, thank you very much. The trigger fires nonstop. So my new problem would be that I dont know how to get the trigger to reference the max hp so the trigger will stop firing.


Oh yeah, I'd like to say damn you're fast!!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Mar 02, 2007 8:53 pm   
 
Heh, you're just lucky I was checking the forums when you posted ;)

I'm not sure what exactly your problem is, but it sounds like it might be related to the MUD sending a new prompt after the script sends CAST CURE, which then sets off a another CAST CURE because the HP hasn't yet updated. Is that it, or am I misunderstanding?

If it is that, the easiest way is to have the script only heal when it's not in the gap inbetween the heal command being sent and the heal happening. Something like this maybe?

#trig {prompt pattern here} {#if (%1 < 4200 and !@CureWaiting) {cast cure;#var CureWaiting 1}

#trig {You feel better!} {#var CureWaiting 0}

The ! before the @Curewaiting reverses the result, so it'll check for @CureWaiting being 0 rather than 1.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
yungin
Newbie


Joined: 02 Mar 2007
Posts: 4

PostPosted: Fri Mar 02, 2007 9:20 pm   
 
whoa boy, now i'm really lost :P betcha you're glad you were checking the forums Evil or Very Mad My prompt does appear after every 'cast cure' and continues to cast cure even when %1 is over 4200. Now based on what you have above I'd need 2 triggers to set this correctly? ok, with 2 seperate triggers it still behaves the same. Thanks so much for your help I'm going to keep digging into this one and I'll write back with what I've tried.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Mar 02, 2007 10:02 pm   
 
No need for whole prompt trigger, btw.
just make it based on HP (or Mana part in other case or whatnot) part.

#class {autoheal}
#trig {(%d)/%dHP} {#if (%1 < 4200) {cast cure;#t- autoheal}}
#class 0


This will case cure if your HP is lower than 4200. You may want to do a second trigger to re-enable the autoheal class once it has casted the heal spell (or ate/drank a healing potion or however it goes in Your mud).

#class {autoheal2}
#trigger {You feel better!} {#t+ autoheal}
#class 0

this bit will turn the autoheal back on for the next time you'll need to use it (when your HP drops lower than 4200 for example). My belief is that unless you do it, the first autoheal class will just continue the looping the healing spell or whatnot even after its needed. Thats why the autoheal2 class is good for.


Prog
Reply with quote
yungin
Newbie


Joined: 02 Mar 2007
Posts: 4

PostPosted: Fri Mar 02, 2007 11:03 pm   
 
progonoi that worked perfectly. thank you both so much for all your help. i'll be purchasing very soon. The help i've recieved on this makes me more than happy to spend the $30 for a license
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