Advertisement
Guest User

Untitled...

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