heal script

Posted by Tarrant on Tue 22 Apr 2003 06:57 PM — 11 posts, 35,939 views.

#0
Basically I want to look at my group
and calculate who has the lowest hitpoints,
then by a key (like f1 or whatever)
automatically heal that person(cast 'full heal' person)
How would i go about doing this?

This is the output of the group command:


Your group consists of:
( Head) 846/740 hit, 192/192 move Jim
(Front) 579/579 hit, 154/154 move Joe
(Front) 539/550 hit, 160/160 move Bob
(Front) 562/562 hit, 160/160 move Jay
(Front) 323/323 hit, 109/109 move Yens
Australia Forum Administrator #1
What you need here is a couple of triggers and an alias. First a trigger to match on "Your group consists of:" - this will reset the variable "hp" to a very large number (999999999) - this is so we can tell which HP is lower than that. It also clears out the name of the person who we need to heal.

The second trigger matches on the output of the group command, and uses a small bit of script to work out which person has the lowest HP.

The alias then casts the spell on the person who had the lowest HP - you need to type that manually. I have made the alias "--heal" but you could then use the "macros" configuration screen to make a function key (eg. F2 as F1 is used for help) to send "--heal" which will then call the alias.

To use this, just copy from below the line, and go to the File menu -> Import -> Clipboard, which will import both triggers and the alias.

Make sure scripting is enabled in the scripting tab, language VBscript, and it should be ready to go.



<triggers>

  <trigger
   enabled="y"
   match="Your group consists of:"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable &quot;person&quot;, &quot;&quot;
SetVariable &quot;hp&quot;, 999999999</send>
  </trigger>

  <trigger
   custom_colour="2"
   enabled="y"
   match="^\(.*\)\s+(\d+)/\d+\s+hit,\s+\d+/\d+\s+move\s+(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if %1 &lt; CLng (GetVariable (&quot;hp&quot;)) then
  SetVariable &quot;hp&quot;, %1
  SetVariable &quot;person&quot;, &quot;%2&quot;
end if
</send>
  </trigger>

</triggers>

<aliases>
  <alias
   match="--heal"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>if GetVariable (&quot;person&quot;) &lt;&gt; &quot;&quot; _
  and GetVariable (&quot;hp&quot;) &lt;&gt; 999999999 then
 Send &quot;cast 'full heal' &quot; &amp; GetVariable (&quot;person&quot;)
end if</send>
  </alias>
</aliases>
Amended on Wed 30 Apr 2003 08:40 AM by Nick Gammon
#2
this is what i'm getting

Line 6: Value '12' too large in numeric attribute named 'send_to'. Range is 0 to 9. (trigger not loaded)
Line 18: Value '12' too large in numeric attribute named 'send_to'. Range is 0 to 9. (trigger not loaded)
Line 34: Attribute not used: send_to="12" (alias)
Line 35: Attribute not used: sequence="100" (alias)
Australia Forum Administrator #3
The inline scripting I did there is only supported in recent versions - see MUSHclient version 3.38 released.
#4
Hey nick
the triggers work great, but i'm running into a problem with the actual theory behind this thing
if i'm in a group, and say i have 100/100, but the guy tanking the monster has 300/400 hps, it would put the 100/100 guy in variable to get healed because he has the lowest hps, but he's not even hurt, i want to heal the guy with more hps that's taking the damage. so is there a way to set it up so that it calculates not who has the lowest hps but who is missing the lagrest % of their hps?
Australia Forum Administrator #5
Good point. You need to calculate and save percentages, not raw HP. This should do it:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^\(.*\)\s+(\d+)/(\d+)\s+hit,\s+\d+/\d+\s+move\s+(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>if %2 &gt; 0 then  ' don't divide by zero!
  if (100 * %1 / %2) &lt; CLng (GetVariable (&quot;hp&quot;)) then
    SetVariable &quot;hp&quot;, 100 * %1 / %2  ' save percentage
    SetVariable &quot;person&quot;, &quot;%3&quot;
  end if
end if
</send>
  </trigger>
</triggers>
Amended on Wed 30 Apr 2003 08:40 AM by Nick Gammon
Australia Forum Administrator #6
Or better still, probably, save the amount they are missing, not the amount they have. (In other words, the second wildcard minus the first).

You need to replace both triggers then, because now it needs to start at zero.


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^\(.*\)\s+(\d+)/(\d+)\s+hit,\s+\d+/\d+\s+move\s+(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>if (%2 - %1) &gt; CLng (GetVariable (&quot;hp&quot;)) then
  SetVariable &quot;hp&quot;, %2 - %1  ' save amount missing
  SetVariable &quot;person&quot;, &quot;%3&quot;
end if
</send>
  </trigger>
  <trigger
   enabled="y"
   match="Your group consists of:"
   send_to="12"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>SetVariable &quot;person&quot;, &quot;&quot;
SetVariable &quot;hp&quot;, 0</send>
  </trigger>
</triggers>
Australia Forum Administrator #7
Now, I'm not sure. Maybe percentage is better. After all, if someone has 10/90 HP they are clearly worse off than someone who has 1000/2000, however my second solution would heal the one with the largest absolute amount missing, whereas the earlier one would heal the one with the lowest percentage of HP.
#8
the percentage one doesn't seem to be working
when i type --heal it's not sending anything
#9
scratch that, its working
#10
might it be possible to display the calculated variable?
such that a line from the group output might look
like this:

(Front) 100/200 hit, 154/154 move Joe <------- 50%

i just threw in the <------, but the jist of my question is to have the percentage outputted in some kind of fashion