Register forum user name Search FAQ

Gammon Forum

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 ➜ Perlscript ➜ The -Definitive- Heal Script

The -Definitive- Heal Script

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Jakevanderpuy   (22 posts)  Bio
Date Wed 25 Jun 2003 03:50 PM (UTC)

Amended on Wed 25 Jun 2003 05:17 PM (UTC) by Jakevanderpuy

Message
This is a VERY complicated idea. Just so you know. But any tips or parts of what might be required to go into this would be greatly appreciated from anyone. I'll be checking this regularily to talk over any discussion.

Also, I don't know if this would be easier to program in VB or something either...what do you people think? Perl seems pretty straight-forward.

Script Requisites:

1) Parse group data recieved from Mud after inputing the 'info' (see following code) command. Take data and stick it into NEW window that is in the lower right-hand part of the Mushclient window. The new window will have the same data as the original info code but each characters name will be highlighted in colors corresponding to health: Blue = 75%+, Yellow 75%-45%, Red = 45% or less. (Maybe it would be easier to set this up with a trigger and parse it like that instead of a new window...I have heard Perl and widget sets don't play nice)

inf

Group: Dancin'
(11:F1)  [       Liath]   (12:F2)  [        Tryx]   (13:F3)  [       Nekoa]   
(21:M1)  [------------]   (22:M2)  [------------]   (23:M3)  [------------]   
(31:B1)  [------------]   (32:B2)  [------------]   (33:B3)  [------------]   
Characters            Rank    Pos    In room  Follow    H     ME    PE  
Liath                 Leader  11:F1  Yes      No      100%  100%   58%
Tryx                  Member  12:F2  Yes      Yes      97%   100%   100%
Nekoa                 Member  13:F3  Yes      Yes      57%   100%   100%


2) Left-click will send 'c heal name' to world.
Ex. left-click nekoa-->world.send = "c heal nekoa"
(or something)

3) There is an 'auto heal' function activated by input of 'auto heal'. This function will poll the world for information to parse by repeatedly sending 'info' every 3 seconds. The data from the world (see code above) will update the new window...and should anyone's Hitpoints (H) be below 45% 'c heal name' will automatically be sent.
--------------------------------------------------------
I'm thinking the alias should go something like this:
<aliases>
  <alias
   match="say *"
   enabled="y"
   sequence="100"
  >
  <send>say &amp;W%1</send>
  </alias>
</aliases>


But HOW do I get the $new_str var into it?
----------------------------------------------

The Mud that this is going to be primarily used on is known as Shattered Kingdoms.

mud.shatteredkingdoms.org:1996

http://www.shatteredkingdoms.org
http://three_sixteen.maniaserv.com/forum/

(sorry, I've been playing with the code function quite a bit...I won't edit this post anymore.)
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #1 on Wed 25 Jun 2003 05:47 PM (UTC)
Message
I SUPPOSE it would be ok if the script just responded to something like 'auto heal' and parsed the info for one's group, instead of the whole 'nother window thing.
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #2 on Wed 25 Jun 2003 06:47 PM (UTC)

Amended on Wed 25 Jun 2003 06:55 PM (UTC) by Shadowfyr

Message
Hmm. You would have to pick Perl... lol I can provide you with a VB version though, which hopefully you can convert. ;)

Also, right now the idea of a seperate window isn't going to fly. There simply isn't one you can use unless you open a second world and that makes life 1000 times more complex. So here is my idea:

<triggers>
  <trigger
   enabled="y"
   group="Heal_Link"
   keep_evaluating="y"
   match="^(/w+)/s+(Member|Leader)/s+(/S+)/s+(Yes|No)/s+(Yes|No)/s+(/d{1,3))%/s+(/d{1,3))%/s+(/d{1,3))%"
   name="Heal_Link"
   omit_from_output="y"
   regexp="y"
   script="Heal_Link"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Note: The above retrieves 'all' data. I figured it was as easy to do that
as retrieve only part, since sub groups like (Yes|No) will get passed anyway
and you would still end up with 5 wild cards. Three extras are no big deal
and since it gets them, you can still use them for something.

sub Heal_link (name, output, wilds)
  Hue = int(120 * (wilds(6)/100))      ' Set color in range from Green to Red
  'Hue = 360 - int(120*(wilds(6)/100)) ' Set color in range from Blue to Red

  Sat = 255 ' This is how 'grey' it is. 255 means the color has no greying.

  Lum = int (155 * wilds(6)/100) + 100 ' Set from full to 39% of how 'bright' the color is.

  Forecolor = HSLtoRGB (Hue, Sat, Lum) ' Get our new color.

  ' Check to see if they are in the room before making a link.
  if wilds(4) = "Yes" then
    hyperlink "c heal " & wilds(1), output, "c heal " & wilds(1), Forecolor, "black", 0
  else
    ' If they where not in the room, color it, but don't give a link.
    colournote Forecolor, "black", output
  end if
end if

function HSLtoRGB (Hue, Sat, Lum) 'I know it works, don't ask me how. ;)
  dim rm1, rm2, Temp, Temp2, Red, Green, Blue
  Lum = Lum / 255
  Sat = Sat / 255
  if Sat = 0 then
    Temp = Lum * 255
    Red = Temp
    Green = Temp
    Blue = Temp
  else
    if Lum <= 0.5 then
	rm2 = Lum + Lum * Sat
    else
	rm2 = Lum + Sat - Lum * Sat
    end if
    rm1 = 2 * Lum - rm2
    Temp = rm1
    Red = FindColor(Temp, rm2, Hue + 120)
    Temp = rm1
    Green = FindColor(Temp, rm2, Hue)
    Temp = rm1
    Blue = FindColor(Temp, rm2, Hue - 120)
  end if
  Red = Cint(Red)
  Temp = Hex(Red)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp
  Temp = Hex(Green)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp2 + Temp
  Temp = Hex(Blue)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp2 + Temp
  HSLtoRGB = Temp2
end function

function FindColor (rm1, rm2, rh)
  if rh > 360 then
    rh = rh - 360
  else
    if rh < 0 then
      rh = rh + 360
    end if
  end if
  'world.note rm1
  if rh < 60 then
    rm1 = rm1 + (rm2 - rm1) * rh / 60
  else
    if rh < 180 then
      rm1 = rm2
    else
      if rh < 240 then
        rm1 = rm1 + (rm2 - rm1) * (240 - rh) / 60
      end if
    end if
  end if
  FindColor = rm1 * 255
end function

This should do one better than what you wanted, except for the extra window thing. It will replace each line with a hyperlink that when clicked will heal the person that the link is associated with. It also ranges the color of each link from Blue, to purple then red or green, then yellow and finally red depending on which of the lines you have a ' in front of. Right now it is set for Green to Red. It is also smart enough that it will not create a hyperlink if the individual is not actually 'in the room' at the time.

Of course this is in VB, so if you want to use perl you will need to find someone that knows how to convert it. ;)
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #3 on Wed 25 Jun 2003 07:16 PM (UTC)
Message
W O W

o.O

That was QUICK!

Thankyou.
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #4 on Fri 05 Sep 2003 05:51 AM (UTC)
Message
I'm actually having a lot of trouble getting this to work.

I know how to import the trigger and all that, but I'm confused about the script itself. Do I just copy and paste all the stuff you wrote (the subroutine and functions) into a text file and rename it *.vbs? Then I go to the scripting menu and look up the script, right.

When I type info then on the mud nothing happens, though.
Must mean the trigger isn't matching, eh?

If anyone has time(5 min) it'd be nice if you could check this out for me.
Connect info: mud.shatteredkingdoms.org:1996
command to type after you've created (takes like 2min): help groups
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #5 on Fri 05 Sep 2003 06:05 PM (UTC)

Amended on Fri 05 Sep 2003 06:13 PM (UTC) by Shadowfyr

Message
Hmm. May have the trigger wrong there... If you look closely you will see these in there:

(/d{1,3))%

This isn't exactly right, they should be:

(/d{1,3})%
       ^
       |
      This was wrong.


That may be the only problem, but since I didn't test it... It should work like you said, by having the script in a .vbs file and the trigger copied into mushclient's trigger editor. However, with the above error, it wouldn't work at all. Also, the last 'end if' in the Heal_Link sub needs to be 'end sub'. This should have given you an error when it tried to load.


Ack.. Just kill me now..... I really messed up on this thing. :p Here is the correct trigger:

^(\w+)\s+(Member|Leader)\s+(\S+)\s+(Yes|No)\s+(Yes|No)\s+(\d{1,3})\%\s+(\d{1,3})\%\s+(\d{1,3})\%

Notice how I also had every bloody \ backwards and that the % needed to have them as well... Ooops!

Second problem:
sub Heal_link (name, output, wilds)
  Hue = int(90 * (wilds(6)/100))      ' Set color in range from Green to Red **
  'Hue = 360 - int(120*(wilds(6)/100)) ' Set color in range from Blue to Red
  Sat = 255 ' This is how 'grey' it is. 255 means the color has no greying.
  Lum = int (28 * wilds(6)/100) + 100 ' Set from full to 39% of how 'bright' the color is. ***
  Forecolor = "#" & HSLtoRGB (Hue, Sat, Lum) ' Get our new color. ****
  ' Check to see if they are in the room before making a link.
  if wilds(4) = "Yes" then
    hyperlink "c heal " & wilds(1), output, "c heal " & wilds(1), Forecolor, "black", 0
    note " " '*****
  else
    ' If they where not in the room, color it, but don't give a link.
    colournote Forecolor, "black", output
  end if
end sub


It should now work as advertised with the above changes. I ran a quick test using your example and it all seems to perform correctly now. ;)

An explaination of the changes:

**
I tweaked this line a bit. A maximum of 120 doesn't show a change very quickly (it needs to hit around 75% to show an obvious change in color), so I changed this to 90, now it shows an immediate shift in color by 95%. The reason for this gap between pure Green and a visible difference is probably due to our eyes being red-green and blue-green sensitive. We literally see green twice, so any small changes get swallowed by our vision, this leave a "huge" range of hues that all look alike to us.

***
If you had 100%, then it would pass 255, which made 'the result white, not green. Oops! The correct maximum Lum should be 128.

****
I forgot that HSLtoRGB doesn't add the #, so it has to be tacked on here.

*****
Had to add this line. Hyperlinks do not add a line break themselves. Duh!
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #6 on Sat 06 Sep 2003 06:43 PM (UTC)

Amended on Sat 06 Sep 2003 06:45 PM (UTC) by Jakevanderpuy

Message
I picked up on the closing tags, the appropriate parantheses, and even the linebreak but the rest of this stuff went right over my head. Mad props to Shadowfyr for his timely followup.

I just have one more, small request. (I'm working on the other idea of a separate window and will post once I get it figured.)

I want to be able to highlight the name of the person in the group formation itself. Highlighting the name in the member line is OK, but in a combat situation it makes it hard to click on the right name.


                   |--Highlight THESE names--|
                   V                         V
Group: Us 
(11:F1)  [       Blahb]   (12:F2)  [      Gharab]   (13:F3)  [------------]    
(21:M1)  [------------]   (22:M2)  [------------]   (23:M3)  [------------]    
(31:B1)  [------------]   (32:B2)  [------------]   (33:B3)  [------------]    
Characters            Rank    Pos    In room  Follow    H     ME    PE  
Blahb                 Leader  11:F1  Yes      No        9%  100%  100% 
Gharab                Member  12:F2  Yes      Yes      85%  100%  100% 



*I also find that it makes it easier to have the Hue integer at 75 as well...more accurate since there is a little bit of builtin lag time for spells.
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #7 on Sat 06 Sep 2003 07:23 PM (UTC)
Message
Hmm. That is not really a 'small' request. You could capture the names and turn them all into links, but not color them. Those lines have already arrived by the time you find out what the values are. However, if you did create a link for each of the names in that first bit, you would have to omit all of them from output and rebuild the whole time section by section in the script. If everthing on those lines is one color then you could manage it like this:
<triggers>
  <trigger
   enabled="y"
   group="Heal_Link"
   keep_evaluating="y"
   match="^(\(\S+\)\s+[)(.*)(]\s+\(\S+\)\s+[)(.*)(]\s+\(\S+\)\s+[)(.*)(])"
   name="Head_Link"
   omit_from_output="y"
   regexp="y"
   script="Head_Link"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

sub Head_Link(name, output, wilds)
  StColor = "Silver" 'Change this to match the normal line color.
  colourtell StColor, "black", wilds(1)
  if wilds(2) <> "------------" then
    hyperlink "c heal " & trim(wilds(2)), wilds(2), "c heal " & trim(wilds(2)), "cyan", "black", 0
  else
    colourtell StColor, "black", wilds(2)
  end if
  colourtell StColor, "black", wilds(3)
  if wilds(4) <> "------------" then
    hyperlink "c heal " & trim(wilds(4)), wilds(4), "c heal " & trim(wilds(4)), "cyan", "black", 0
  else
    colourtell StColor, "black", wilds(4)
  end if
  colourtell StColor, "black", wirlds(5)
  if wilds(6) <> "------------" then
    hyperlink "c heal " & trim(wilds(6)), wilds(6), "c heal " & trim(wilds(6)), "cyan", "black", 0
  else
    colourtell StColor, "black", wilds(6)
  end if
  colournote StColor, "black", wilds(7)
end sub

This will make every name on those lines a link in cyan, but like I said, they can't and won't reflect the 'state' of those players. To do that would require capturing all the lines, then later coloring the whole lot in a single shot. That would be slower and very complicated to manage.
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #8 on Sat 06 Sep 2003 09:25 PM (UTC)
Message
I understand that it would be very complicated to manage, but...the only thing that matters is I'm able to tell if someone is hurt, and be able to click up on them in the group formation. This will do that perfectly! Fantastic!


Many thanks, Shadowfyr.
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.


23,068 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.