 |
shaun.murray Magician

Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Sat Jun 14, 2008 1:47 pm
smart heal? |
How would/could I go about doing this y'all think? So, for example... I know that casting heal gives me 100 hit points, and costs me 10 spirit. At the end of the combat, I'd like it to heal me all the way up (or to a pre-defined amount...) but only up to, and not beyond. Not to mention only using the available amount of spirit...
[H: 211/34611] [S:1111/4120]
The difference is 34400 hit points. And so... I would need to cast heal 344 times, costing me 3440 spirit in the process.
Code: |
#trig {^~[H: &%dhit_cur/&%dhit_max] ~[S: &%dspi_cur/&%dspi_max]} {#var hit_difference %eval( (@hit_cur - @hit_max)\100);#var spi_difference %eval( (@spi_cur - @spi_max)\10)}
#alias {heal} {cast 'heal'}
#alias {healme} {%concat( "#",@hit_difference,".",heal} |
Not sure how to go about the spirit however... Or if there is a better way to do this... TIA! |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Sat Jun 14, 2008 2:53 pm |
Code: |
#trig {^~[H: (%d)/(%d)] ~[S: (%d)/(%d)~]} {
$NeededHeals = %eval((%2-%1) / 100)
$PossibleHeals = %eval(%4-%3) / 10)
#loop %min($NeededHeals, $PossibleHeals) { cast 'heal' }
}
|
|
|
_________________ The Drake Forestseer |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Jun 14, 2008 3:54 pm |
Alluran missed one open paren:
Code: |
#trig {^~[H: (%d)/(%d)] ~[S: (%d)/(%d)~]} {
$NeededHeals = %eval((%2-%1) / 100)
$PossibleHeals = %eval((%4-%3) / 10)
#loop %min($NeededHeals, $PossibleHeals) { cast 'heal' }
}
|
|
|
|
 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Jun 14, 2008 5:51 pm |
This works as well, and may be faster:
Code: |
#trig {^~[H: (%d)/(%d)] ~[S: (%d)/(%d)~]} {
$NeededHeals = (%2 - %1) / 100
$PossibleHeals = (%4 - %3) / 10
#LOOP %min( $NeededHeals, $PossibleHeals) { cast 'heal' }
}
|
|
|
_________________ Sic itur ad astra. |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Sat Jun 14, 2008 6:12 pm |
Hehe, and no-one noticed that i forgot to escape the second ] :P
|
|
_________________ The Drake Forestseer |
|
|
 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Jun 14, 2008 6:19 pm |
Actually, alluran, I tested the trigger just as you had it, and it worked. I believe that only the opening bracket needs to be escaped. It seems that if there is no opening bracket, the closing bracket is just treated as text.
|
|
_________________ Sic itur ad astra. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jun 14, 2008 10:29 pm |
You're right, a closing bracket of any kind ])} is only special if it's already been opened.
|
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Sun Jun 15, 2008 10:24 am |
And for this reason, it's always good to close it properly, otherwise if the trigger changes, you can run into issues with closing brackets being mis-interpretted
|
|
_________________ The Drake Forestseer |
|
|
 |
|
|