OTG

Mob Health tag on Svo Custom Prompt

OTG
Jul 25th, 2014
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. At the end of this process, you will be able to use the @otgMH tag in Svo's custom prompt to display denizen health.
  2.  
  3. Firstly, you need to adjust the default prompt to use Achaea's internal custom prompt. Don't worry, this won't break Svo's custom prompt or defence tracking. Enter the following line into the command box of Mudlet when connected to Achaea:
  4.  
  5. CONFIG PROMPT CUSTOM *hh, *mm *b*d-*r-((*T))
  6.  
  7. -- NEW! Importable xml file: http://1drv.ms/1scGUXh
  8.  
  9. Create a trigger, call it something sensible like Grab mob health from prompt
  10. Pattern (set to perl regex):
  11. ^(\d+)h, (\d+)m (\w+)-(?:\w+|-|)-\(\((\d+)\%\)\)-
  12.  
  13. Script:
  14. mobHealthPct = matches[6] or matches[5]
  15.  
  16.  
  17. This has now assigned the mob health percentage from the prompt to variable mobHealthPct
  18.  
  19. Create a new script, copy in the following functions (to just before the line ========= ):
  20.  
  21. mobHealthPct = mobHealthPct or 0 --sets up the variable, without this your prompt is blank until yout hit something
  22.  
  23. function promptMobHealth()
  24.  
  25. local h = tonumber(mobHealthPct)
  26. mhc = "blanched_almond"
  27.  
  28. if h == 0 then
  29. mhc = ""
  30. return mhc --this will hide the tag when the mob is killed
  31. elseif h < 5 then
  32. mhc = "red" --nearly dead
  33. elseif h < 25 then
  34. mhc = "orange_red" --grievously wounded
  35. elseif h < 50 then
  36. mhc = "dark_orange" --injured
  37. elseif h < 75 then
  38. mhc = "orange" --slightly injured
  39. end
  40.  
  41. mhc = " <"..mhc..">("..h.."%)<reset>"
  42.  
  43. return mhc
  44.  
  45. end
  46.  
  47. function clearMobHealth() --sets the mobHealthPct to 0 when the mob is killed
  48. if gmcp.Char.Items.Remove.location == "room" then
  49. if gmcp.Char.Items.Remove.item.id == gmcp.Char.Status.target then
  50. mobHealthPct = 0
  51. promptMobHealth()
  52. end
  53. end
  54. end
  55.  
  56. function addPromptDef()
  57. svo.adddefinition("@otgMH", "promptMobHealth()")
  58. end
  59.  
  60. registerAnonymousEventHandler("svo system loaded", "addPromptDef")
  61. registerAnonymousEventHandler("gmcp.Char.Items.Remove", "clearMobHealth")
  62.  
  63. =========
  64. Assuming you have a prompt trigger somewhere to fire updates, add in the line
  65. promptMobHealth()
  66.  
  67. If not, create a new trigger, give it a name like "Fire on prompt" and enter the following:
  68. Pattern (set to Lua function):
  69. return isPrompt()
  70.  
  71. Script:
  72. promptMobHealth()
  73.  
  74.  
  75. Once all this is done, you need to register the custom prompt tag (only this time, it will be autoregisted when Svo next loads) by entering the following on the command line of Mudlet:
  76. vlua addPromptDef()
  77.  
  78. You should now be able to use @otgMH in your Svo custom prompt.
  79.  
  80. If you think this is useful, feel free to make any donations to Klendathu :)
  81.  
  82. If there's any bugs, or you need some help, send me a message.
Advertisement
Add Comment
Please, Sign In to add comment