Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.60 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE muclient>
  3.  
  4. <muclient>
  5. <plugin
  6. name="Auto_Quaff"
  7. author="Abelinc/Lunk"
  8. id="91db3f0b6bb87464ca75f5c7"
  9. language="Lua"
  10. purpose="Quaffs potions if in battle and health/mana/moves falls below preset limit"
  11. date_written="2010-02-26"
  12. requires="4.98"
  13. version="2"
  14. save_state="y"
  15. >
  16. <description trim="y">
  17. <![CDATA[
  18. Install this plugin to automatically quaff a potion when your health falls
  19. below a preset limit.
  20.  
  21. qff ---> Displays the current values of variables
  22.  
  23. qff bag * ---> Sets the container to get potions from to *
  24.  
  25. qff hp pot * ---> Sets hp potion to *
  26.  
  27. qff mn pot * ---> Sets mn potion to *
  28.  
  29. qff mv pot * ---> Sets mv potion to *
  30.  
  31. qff hp per * ---> Sets the HP percent you must fall below to quaff to *
  32.  
  33. qff mn per * ---> Sets the MN percent you must fall below to quaff to *
  34.  
  35. qff mv per * ---> Sets what MV percent you must fall below to quaff to *
  36.  
  37. qff on/off ---> Turns the actions of the plugin on or off
  38.  
  39. qff debug on/off ---> Turns debug information to the screen on/off
  40. ]]>
  41. </description>
  42.  
  43. </plugin>
  44.  
  45. <!-- configure quaffing limits -->
  46.  
  47.  
  48. <aliases>
  49.  
  50. <alias
  51. name="autoquaff"
  52. script="qff_settings"
  53. match="^qff ?(hp per|mn per|mv per|hp pot|mn pot|mv pot|bag|on|off|help|debug)?( [a-z0-9]+)?"
  54. enabled="y"
  55. regexp="y"
  56. ignore_case="y"
  57. sequence="100"
  58. >
  59. </alias>
  60.  
  61. </aliases>
  62.  
  63. <script>
  64. <![CDATA[
  65.  
  66. require "checkplugin"
  67. require "serialize"
  68. require "commas"
  69. require "gmcphelper"
  70.  
  71. function OnPluginBroadcast (msg, id, name, text)
  72. -- Look for GMCP handler.
  73. if (id == '3e7dedbe37e44942dd46d264') then
  74. if (text == "char.vitals") then
  75. res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char")
  76.  
  77. luastmt = "gmcpdata = " .. gmcparg
  78. assert (loadstring (luastmt or "")) ()
  79. do_autoquaff ()
  80. end
  81. end
  82. end
  83.  
  84. function do_autoquaff ()
  85. if (os.time () - autoquaff_lastfired) > 3 then -- if we've fired within 3 seconds, don't bother with other checks, do nothing
  86. if qff_enable == "yes" then -- if not enabled, don't do anything
  87. if (gmcpval("status.state")) == "8" then -- if fighting
  88. if tonumber ((tonumber(gmcpval("vitals.hp"))/tonumber(gmcpval("maxstats.maxhp"))*100)) < tonumber (qff_hp_per) then -- if HP in trouble
  89. Send ("g " .. qff_hp_pot .. " " .. qff_bag)
  90. Send ("quaff " .. qff_hp_pot)
  91. autoquaff_lastfired = os.time ()
  92. else
  93. if qff_debug == "on" then
  94. ColourNote ("yellow", "", "We've got plenty of health. No need to fire. Health is at " .. tonumber(gmcpval("vitals.hp")))
  95. end
  96. end -- end HP check
  97. end -- end if fighting
  98. end -- end if enabled check
  99. end -- end 3 second time check
  100.  
  101. if (os.time () - autoquaff_lastfired) > 3 then -- if we've fired within 3 seconds, don't bother with other checks, do nothing
  102. if qff_enable == "yes" then -- if not enabled, don't do anything
  103. if (gmcpval("status.state")) == "8" then -- if fighting
  104. if tonumber ((tonumber(gmcpval("vitals.mana"))/tonumber(gmcpval("maxstats.maxmana"))*100)) < tonumber (qff_mn_per) then -- if MN in trouble
  105. Send ("g " .. qff_mn_pot .. " " .. qff_bag)
  106. Send ("quaff " .. qff_mn_pot)
  107. autoquaff_lastfired = os.time ()
  108. else
  109. if qff_debug == "on" then
  110. ColourNote ("yellow", "", "We've got plenty of mana. No need to fire. Mana is at " .. tonumber(gmcpval("vitals.mana")))
  111. end
  112. end -- end MN check
  113. end -- end if fighting
  114. end -- end if enabled check
  115. end -- end 3 second time check
  116.  
  117. if (os.time () - autoquaff_lastfired) > 3 then -- if we've fired within 3 seconds, don't bother with other checks, do nothing
  118. if qff_enable == "yes" then -- if not enabled, don't do anything
  119. if (gmcpval("status.state")) == "8" then -- if fighting
  120. if tonumber ((tonumber(gmcpval("vitals.moves"))/tonumber(gmcpval("maxstats.maxmoves"))*100)) < tonumber (qff_mv_per) then -- if MV in trouble
  121. Send ("g " .. qff_mv_pot .. " " .. qff_bag)
  122. Send ("quaff " .. qff_mv_pot)
  123. autoquaff_lastfired = os.time ()
  124. else
  125. if autoquaff_debug == "on" then
  126. ColourNote ("yellow", "", "We've got plenty of moves. No need to fire. Moves is at " .. tonumber(gmcpval("vitals.moves")))
  127. end
  128. end -- end MV check
  129. end -- end if fighting
  130. end -- end if enabled check
  131. end -- end 3 second time check
  132. end -- do_autoquaff
  133.  
  134. function qff_settings (name, line, wildcards)
  135. if wildcards [1] == "" then
  136. qff_tellme ()
  137. elseif wildcards [1] == "on" then
  138. qff_enable = "yes"
  139. ColourNote ("yellow", "", "Autoquaff plugin enabled.")
  140. elseif wildcards [1] == "off" then
  141. qff_enable = "no"
  142. ColourNote ("yellow", "", "Autoquaff plugin disabled.")
  143. elseif wildcards [1] == "help" then
  144. qff_help ()
  145. else
  146. if wildcards [2] == false then
  147. ColourNote ("yellow", "", "You need to provide a value.")
  148. end
  149. if wildcards [1] == "debug" then
  150. if ((wildcards [2] == " on") or (wildcards [2] == " off")) then
  151. qff_debug = wildcards [2]
  152. ColourNote ("yellow", "", "Turning debug" .. qff_debug)
  153. else ColourNote ("yellow", "", "Correct values are 'on' or 'off'.")
  154. end
  155. elseif wildcards [1] == "hp pot" then
  156. qff_hp_pot = wildcards [2]
  157. elseif wildcards [1] == "mn pot" then
  158. qff_mn_pot = wildcards [2]
  159. elseif wildcards [1] == "mv pot" then
  160. qff_mv_pot = wildcards [2]
  161.  
  162. elseif wildcards [1] == "bag" then
  163. qff_bag = wildcards [2]
  164. ColourNote ("yellow", "", "Set autoquaff bag to " .. qff_bag)
  165.  
  166. elseif tonumber (wildcards [2]) > 99 then
  167. ColourNote ("yellow", "", "Try a smaller value.")
  168. else
  169. if wildcards [1] == "hp per" then
  170. qff_hp_per = tonumber (wildcards [2])
  171. ColourNote ("yellow", "", "Set autoquaff hp percent to " .. qff_hp_per)
  172. elseif wildcards [1] == "mn per" then
  173. qff_mn_per = tonumber (wildcards [2])
  174. ColourNote ("yellow", "", "Set autoquaff mn percent to " .. qff_mn_per)
  175. elseif wildcards [1] == "mv per" then
  176. qff_mv_per = tonumber (wildcards [2])
  177. ColourNote ("yellow", "", "Set autoquaff mv percent to " .. qff_mv_per)
  178. elseif wildcards [1] == "hp pot" then
  179. qff_hp_pot = (wildcards [2])
  180. ColourNote ("yellow", "", "Set autoquaff hp potion to " .. qff_hp_pot)
  181. elseif wildcards [1] == "mn pot" then
  182. qff_mn_pot = (wildcards [2])
  183. ColourNote ("yellow", "", "Set autoquaff mn potion to " .. qff_mn_pot)
  184. elseif wildcards [1] == "mv pot" then
  185. qff_mv_pot = (wildcards [2])
  186. ColourNote ("yellow", "", "Set autoquaff mv potion to " .. qff_mv_pot)
  187. end
  188. end
  189. end
  190. end -- autoquaff_settings
  191.  
  192. function qff_tellme (name, line, wildcards)
  193. ColourNote ("yellow", "", "bag : " .. qff_bag)
  194. ColourNote ("yellow", "", "hp percent : " .. qff_hp_per)
  195. ColourNote ("yellow", "", "mn percent : " .. qff_mn_per)
  196. ColourNote ("yellow", "", "mv percent : " .. qff_mv_per)
  197. ColourNote ("yellow", "", "hp potion : " .. qff_hp_pot)
  198. ColourNote ("yellow", "", "mn potion : " .. qff_mn_pot)
  199. ColourNote ("yellow", "", "mv potion : " .. qff_mv_pot)
  200. end
  201.  
  202. function qff_help (name, line, wildcards)
  203. ColourNote ("teal", "", world.GetPluginInfo (world.GetPluginID (), 3))
  204. return true -- done
  205. end -- autoquaff_help
  206.  
  207. function OnPluginInstall ()
  208.  
  209. if GetVariable ("enabled") == "false" then
  210. ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
  211. check (EnablePlugin(GetPluginID (), false))
  212. return
  213. end -- they didn't enable us last time
  214.  
  215. OnPluginEnable () -- do initialization stuff
  216.  
  217. end -- OnPluginInstall
  218.  
  219. function OnPluginEnable ()
  220. qff_hp_per = GetVariable ("qff_hp_per")
  221. if qff_hp_per == nil then
  222. SetVariable ("qff_hp_per", tonumber(30))
  223. end
  224. qff_hp_per = GetVariable ("qff_hp_per")
  225.  
  226. qff_mn_per = GetVariable ("qff_mn_per")
  227. if qff_mn_per == nil then
  228. SetVariable ("qff_mn_per", tonumber(30))
  229. end
  230. qff_mn_per = GetVariable ("qff_mn_per")
  231.  
  232. qff_mv_per = GetVariable ("qff_mv_per")
  233. if qff_mv_per == nil then
  234. SetVariable ("qff_mv_per", tonumber(30))
  235. end
  236. qff_mv_per = GetVariable ("qff_mv_per")
  237.  
  238. qff_hp_pot = GetVariable ("qff_hp_pot")
  239. if qff_hp_pot == nil then
  240. SetVariable ("qff_hp_pot", "heal")
  241. end
  242. qff_hp_pot = GetVariable ("qff_hp_pot")
  243.  
  244. qff_mn_pot = GetVariable ("qff_mn_pot")
  245. if qff_mn_pot == nil then
  246. SetVariable ("qff_mn_pot", "lotus")
  247. end
  248. qff_mn_pot = GetVariable ("qff_mn_pot")
  249.  
  250. qff_mv_pot = GetVariable ("qff_mv_pot")
  251. if qff_mv_pot == nil then
  252. SetVariable ("qff_mv_pot", "tea")
  253. end
  254. qff_mv_pot = GetVariable ("qff_mv_pot")
  255.  
  256. qff_bag = GetVariable ("qff_bag")
  257. if qff_bag == nil then
  258. SetVariable ("qff_bag", "bag")
  259. end
  260. qff_bag = GetVariable ("qff_bag")
  261.  
  262. if GetVariable ("qff_debug") == nil then
  263. SetVariable ("qff_debug", "off")
  264. end
  265. qff_debug = GetVariable ("qff_debug")
  266. if GetVariable ("qff_enable") == nil then
  267. SetVariable ("qff_enable", "yes")
  268. end
  269. qff_enable = GetVariable ("qff_enable")
  270. autoquaff_lastfired = os.time ()
  271. Send_GMCP_Packet("request char")
  272. end -- OnPluginEnable
  273.  
  274. function OnPluginSaveState ()
  275. SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
  276. SetVariable ("qff_hp_per", qff_hp_per)
  277. SetVariable ("qff_mn_per", qff_mn_per)
  278. SetVariable ("qff_mv_per", qff_mv_per)
  279. SetVariable ("qff_hp_pot", qff_hp_pot)
  280. SetVariable ("qff_mn_pot", qff_mn_pot)
  281. SetVariable ("qff_mv_pot", qff_mv_pot)
  282. SetVariable ("qff_bag", qff_bag)
  283. SetVariable ("qff_debug", qff_debug)
  284. SetVariable ("qff_enable", qff_enable)
  285. end -- OnPluginSaveState
  286.  
  287. ]]>
  288. </script>
  289.  
  290. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement