Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: 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!
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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' }
}
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: 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.
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: Sat Jun 14, 2008 6:12 pm   
 
Hehe, and no-one noticed that i forgot to escape the second ] :P
_________________
The Drake Forestseer
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: 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.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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