Help with a resting script

Wolfie

New member
hi all i just started looking into scripting in ash and im basically just looking to make a basic script for between battle this is what i have so far but its not working maybe someone out there could help me to learn why!

also im hoping to have this work in conjunction with the auto stop battle at x% id like it to stop battle at 20%hp left then rest to heal maybe setting it to heal until im almost full hp or full hp whichever is closest to not wasting a turn. but that will come later for now i just need to take it 1 step at a time to learn it.
thanks in advance for any help
Wolfie

Code:
 void main()
 {
 if ( (my_hp() < (my_maxhp()-80%)) )
 {
 cli_execute( "rest");
 }
 else
 (
 print("Current hp is too high to rest");
 }
  }
 
[quote author=Wolfie link=topic=103.msg379#msg379 date=1145629800]
hi all i just started looking into scripting in ash and im basically just looking to make a basic script for between battle this is what i have so far but its not working maybe someone out there could help me to learn why![/quote]

I do believe we could try! :) First thing I notice is your if statement. The math is a bit wrong. If you are looking to rest at 20% or less of max hit points, your if statement could look like this:
Code:
if( my_hp() < ( my_maxhp() / 5))
There are other ways, but this is the simplest to me.

Also, if you are setting this to a between battle script, I would personally remove the else / print lines. But that is an issue of personal taste, so do not feel like you should follow my suggestion.

[quote author=Wolfie link=topic=103.msg379#msg379 date=1145629800]
also im hoping to have this work in conjunction with the auto stop battle at x% id like it to stop battle at 20%hp left then rest to heal maybe setting it to heal until im almost full hp or full hp whichever is closest to not wasting a turn. but that will come later for now i just need to take it 1 step at a time to learn it.
[/quote]

I haven't messed with autostop... But I would think that autostop doesn't stop the battle. It stops mafia from continuing with the set of adventures. I could be wrong about this though. If I am not wrong, then your check for hit point value is already serving that purpose.

As for resting until you are near full hit points... This gets complicated. As far as I know, there isn't a way to check which residence you have... So there is no easy way to set the script to accurately rest.

But a simple way might be to rest up to at least, say, 90% of max?

Code:
if( my_hp() < ( my_maxhp() / 5))
{
   while( my_hp) < ( my_maxhp() * 0.9))
   {
     cli_execute( "rest");
   }
}

What this does, is after it rest once, it checks your current hp versus your max hp. If you are still not at least 90%, it rests again, and checks. Rinse, repeat.

And if I went a little to fast for you, feel free to keep asking. I have an easy time picking up programming, and have difficulty realizing others are not the same. :)
 

macman104

Member
the autostop feature is a little different. There's the autohalt, which actually halts from battle and opens it up in the minibrowser for you to battle, and then there's autoheal condition, which AFTER a battle, it goes to heal. So you'll have to choose which one you're looking for. The autostop requires you to finish the battle.
 

Wolfie

New member
i got it working thank you all kindly for your help now instead of starting another thread ive another prolly simple to answer question :)

can any of the cli commands be implemented into an ash script using
Code:
cli_execute( "commandhere");
or is it just certain commands usable in that manner? and if it is just certain commands usable in that manner is there a listing of them?

ok so it turned out to be a couple of questions :p but thanks in advance to any replies
:)
Wolfie
 
Top