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
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 12:46 pm   

automated healing for merentha
 
Ok this one is a lil out of my league but if someone can help me figure this one out I'll should be able to get a feel for how to do some of the more serious codeing.

Please Note that I'm not trying to create scripts to make a bot. I'm doing this soley for the purpose of learning how to code. With that said.

What I'm trying to do is create a code to "apply salve" once my hp is 50% or less than its max. The veriables for both of those are already made from other triggers.

Heres the 2 catches. one salve takes a few seconds before you can apply it again. Next I don't want to apply salve while I'm in combat.

So i need something that checks my hps vs hpsmax probably a bunch of if statesmates for each type of combat i do and a timer that checks how long since the last salve applications and loops the trigger to make sure all the conditions are right for another application.

I'm not asking someone to make this for me but I don't know what the syntax would look like. If someone could make an example that checks the @hp vs @hpsmax with a couple if statments and a timer with a loop i can should be able to take it from there.
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 3:33 pm   
 
Ok I've been playing around with this for awhile and made some progress but I havn't quite gotten it right. What I'm doing is everytime a monster dies, I check my current hp vs my max and if its below 50% I apply salve wait 5 seconds and check again and possible apply salve. How do I loop this. This is what I got so far

Code:
#IF (@hps<=@hpsmax/2) {apply salve} {}
#WAIT 5000
#IF (@hps<=@hpsmax/2) {apply salve} {}
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 6:37 pm   
 
Well I've made more progress but it seems I've done something wrong.
Heres what I got so far.
Code:
#if (@hps<=@hpsmax/2) {
  #REPEAT %round( @hpsmax-@hps/200) {apply salve} {}
  #WAIT 2500
  }

could someone tell me whats wrong with this code? I just don't understand.
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Jul 28, 2005 7:01 pm   
 
#if (@hps<=@hpsmax/2) {
#REPEAT %round( @hpsmax-@hps/200) {apply salve}
#WAIT 2500
} {}

?...not sure.
Never used #repeat, and not sure if you are using the way it looks.
You want to have it repeated the # of times of your maxhp minus your current hp divided by 200?
Think u need to %eval the math part there with a nested eval:

#REPEAT %round( %eval (@hpsmax-%eval (@hps/200))) {apply salve}

just my thought of the script from something that i have:
%eval( @exppersecond-%eval( %eval( @exppersecond/100)*100)) exp per second for @battletime seconds.
_________________
http://www.Aardwolf.com
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 8:51 pm   
 
hmm. No luck. it still just spams apply salve a bunch of times. any other ideas? It's like it doesn't use the wait or calculate how many times to loop it properly.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Jul 28, 2005 9:56 pm   
 
Use a prompt trigger and an alarm.

#trigger {whatever your prompt is} {#IF (@currenthealth <= (@maxhealth / 2)) {#T+ tApplySalveAlarm;apply salve} {#T- tApplySalveAlarm}} {nocr|prompt}

#alarm "tApplySalveAlarm" *5 {apply salve}
_________________
EDIT: I didn't like my old signature
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jul 28, 2005 10:38 pm   
 
Best suggestion I can give is very similar to Matt's. Use your prompt trigger to apply your salve and set a variable to indicate that you must wait to apply again. Then use an alamr to clear that variable. Psuedo code follows:

#CLASS SalveControl
#VARIABLE DoSalve {1} {1}
#TRIGGER {^prompt (%d)/(%d) hp} {#VAR HP {%1};#VAR MaxHP {%2};#IF (@InCombat=0) {#IF (@DoSalve) {#IF (%eval(%1<=%2/2)) {#VAR DoSalve {0};#T+ SalveAlarm}}}} "" {prompt|nocr}
#ALARM "SalveAlarm" {*3} {#VAR DoSalve 1;#T- SalveAlarm}
#CLASS 0
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Jul 28, 2005 10:43 pm   
 
Using #WAIT in a Trigger is a VERY bad idea.
http://zuggsoft.com/zmud/timers.htm
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 11:11 pm   
 
Wow while effective it causes other problems. Useing the Alarm off the prompt will cause the trigger to fire even when I'm in combat which is something I want to avoid. Useing when the mob dies fires the trigger off but the alarm stays turned on. Lastly I'd like it to apply salve enough times to bring my currenthp up to close to max, not just bring it above the point where the trigger goes off. Any other ideas?
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Thu Jul 28, 2005 11:24 pm   
 
Vijilante wrote:
Best suggestion I can give is very similar to Matt's. Use your prompt trigger to apply your salve and set a variable to indicate that you must wait to apply again. Then use an alamr to clear that variable. Psuedo code follows:

#CLASS SalveControl
#VARIABLE DoSalve {1} {1}
#TRIGGER {^prompt (%d)/(%d) hp} {#VAR HP {%1};#VAR MaxHP {%2};#IF (@InCombat=0) {#IF (@DoSalve) {#IF (%eval(%1<=%2/2)) {#VAR DoSalve {0};#T+ SalveAlarm}}}} "" {prompt|nocr}
#ALARM "SalveAlarm" {*3} {#VAR DoSalve 1;#T- SalveAlarm}
#CLASS 0


Yikes. Wish I woulda saw this before i started my last post. Only real problems with this is I'm not sure what the code for the @InCombat would look like and I dont think that would fill my hp up, just bring me past the point of where the trig fires.

Still working on it and decided to try something a lil different. Unfortunately it still doesn't repeat the proper number of times or have any delay between applications.
Code:
#if (@hps<=@hpsmax/2) {
  #REPEAT %round( %eval( @hpsmax-%eval( @hps/200))) {apply salve}
  #CONDITION {} {apply salve} {Wait|Param=2500}
  } {}


Heres another Version I've been trying but I can't seem to get it to work either
Code:
#if (@hps<=@hpsmax/2) {%exec( "#Loop @salveapplications {#ALARM +3 {apply salve}")}
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