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 Goto page Previous  1, 2
atuk Posted: Fri Oct 18, 2002 7:38 pm
Help with an auto-heal "program"
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Jul 17, 2007 2:53 pm   
 
This is the #IF portion of what you want.

Code:
#if (%eval( (%1*100)/@maxhp)<=75) {#if (@potion_queue=1) {drink health} {#var potion_queue 0}}


In this case if you are at or below %75 of your total health you will attempt to drink health if @potion_queue is 1.

As for the trigger pattern.

Code:
^(%d)h, (%d)m, (%d)e, (%d)p, (%d)en, (%d)w %x$
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
jcx2001
Newbie


Joined: 16 Jul 2007
Posts: 6

PostPosted: Tue Jul 17, 2007 9:40 pm   
 
I have almost got it, but I am still having one issue. It will work when my HP is at 75% but if it gets to low it will loop. I have a variable called potion_queue to try and fix that problem and my triggers are changing the value to 1 and 0, respectively. The issue is that the trigger is not registering #if (@potion_queue=1)

Here is what I'm working with

#tr {(%d)h, (%d)m, (%d)e, (%d)p, (%d)en, (%d)w %-} {#if (%eval( (%1*100)/@maxhp)<=75) {#if (@potion_queue=1) {#var potion_queue 0} {drink health}}}

Also, is there anyway to set make a does not equal symbol?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Jul 17, 2007 10:44 pm   
 
Yes you can do '<>' and '!='
_________________
Asati di tempari!
Reply with quote
jcx2001
Newbie


Joined: 16 Jul 2007
Posts: 6

PostPosted: Thu Jul 19, 2007 1:08 am   
 
#tr {(%d)h, (%d)m, (%d)e, (%d)p, (%d)en, (%d)w %-} {#if (%eval( (%1*100)/@maxhp)<=75) {#if (@potion_queue=1) {#var potion_queue 0} {drink health}}}


any ideas on why my trigger will not recognize the #if (@potion_queue=1??
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Jul 19, 2007 3:46 am   
 
Only three.

First you are saying if @potion_queue!=1 drink health. If you are editing the potion_queue variable and giving it any values besides 1 and 0 you must understand that any values other than 1 will cause you to drink health. A better way to write this would be to reverse your IF structure.

#if (@potion_queue=0) {drink health} {#var potion_queue 0}

The next is a little tricker.

When you drink health do you immediately set the potion_queue to 1 or do you wait for a trigger to fire first? If you wait for a trigger to fire first it is possible that you will sip your potion again every time you receive a prompt before you get the, "You have sipped a restorative potion." line. This could end up being many lines especially in a big fight. To avoid this you can add setting the potion_queue variable in the drink part as well.

#if (@potion_queue=1) {#var potion_queue 0} {drink health;#var potion_queue 1}

Of course the problem with this is that you are setting the potion_queue back to 0 the very next time the trigger fires and you are on low health, which could be the very next prompt. This should be avoided if possible as if you get three prompts before your health is above %75 you will drink health again every other prompt.

There are several ways to deal with THIS new issue. Usually you will receive a line something like, "You can now sip another health potion.". Make this into a trigger and have IT set your potion_queue to 0.

Another way is that the wait before you can sip another potion is usually set on a timer. Often this timer is something like 2 seconds. If you can discover this timer you can set an alarm to fire off in that amount of time. Turn on the alarm when you drink a health potion and have it turn itself off after setting the value of potion_queue to 0.

Finally the last possible issue. And it is the easiest one.

It is possible, though unlikely, that you have multiple potion_queue variables and that you need to delete one of them.

Now the most likely culprit is #2 but you should look into all three.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jul 19, 2007 10:37 am   
 
Another idea - is it possible that you meant

#if (@potion_queue=1) {drink health;#var potion_queue 0}

but typoed it? This way seems to make more sense.
_________________
Rorso's syntax colouriser.

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


Joined: 16 Jul 2007
Posts: 6

PostPosted: Thu Jul 19, 2007 11:21 pm   
 
Thanks Arminas and Fang Xianfu and everyone. It works perfectly now, it turns out it was a typo and Fang Xianfu solution worked!!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jul 20, 2007 1:11 pm   
 
Sweet, glad to hear you got it working.

It's always good when someone posts that they have a solution.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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