Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ heal script
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Tue 22 Apr 2003 06:57 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Wed 23 Apr 2003 02:33 AM (UTC) Amended on Wed 30 Apr 2003 08:40 AM (UTC) by Nick Gammon
|
| Message
| 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 "person", ""
SetVariable "hp", 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 < CLng (GetVariable ("hp")) then
SetVariable "hp", %1
SetVariable "person", "%2"
end if
</send>
</trigger>
</triggers>
<aliases>
<alias
match="--heal"
enabled="y"
send_to="12"
sequence="100"
>
<send>if GetVariable ("person") <> "" _
and GetVariable ("hp") <> 999999999 then
Send "cast 'full heal' " & GetVariable ("person")
end if</send>
</alias>
</aliases>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Reply #2 on Wed 23 Apr 2003 03:03 AM (UTC) |
| Message
| 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)
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Wed 23 Apr 2003 03:22 AM (UTC) |
| Message
| |
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Reply #4 on Wed 30 Apr 2003 06:58 AM (UTC) |
| Message
| 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? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Wed 30 Apr 2003 08:26 AM (UTC) Amended on Wed 30 Apr 2003 08:40 AM (UTC) by Nick Gammon
|
| Message
| 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 > 0 then ' don't divide by zero!
if (100 * %1 / %2) < CLng (GetVariable ("hp")) then
SetVariable "hp", 100 * %1 / %2 ' save percentage
SetVariable "person", "%3"
end if
end if
</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Wed 30 Apr 2003 08:41 AM (UTC) |
| Message
| 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) > CLng (GetVariable ("hp")) then
SetVariable "hp", %2 - %1 ' save amount missing
SetVariable "person", "%3"
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 "person", ""
SetVariable "hp", 0</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #7 on Wed 30 Apr 2003 08:44 AM (UTC) |
| Message
| | 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Reply #8 on Wed 30 Apr 2003 11:55 AM (UTC) |
| Message
| the percentage one doesn't seem to be working
when i type --heal it's not sending anything | | Top |
|
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Reply #9 on Wed 30 Apr 2003 11:57 AM (UTC) |
| Message
| | scratch that, its working | | Top |
|
| Posted by
| Tarrant
(20 posts) Bio
|
| Date
| Reply #10 on Sat 03 May 2003 06:09 AM (UTC) |
| Message
| 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
| | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
35,206 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top