Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.83 KB | None | 0 0
  1. function prompt:capture(health, mana, ego, power, endurance, willpower, fl)
  2.   self.last_health = self.health or 0
  3.   self.last_mana = self.mana or 0
  4.   self.last_ego = self.ego or 0
  5.   self.last_power = self.power or 0
  6.   self.last_endurance = self.endurance or 0
  7.   self.last_willpower = self.willpower or 0
  8.  
  9.   self.health = health
  10.   self.mana = mana
  11.   self.ego = ego
  12.   self.power = power
  13.   self.endurance = endurance
  14.   self.willpower = willpower
  15.  
  16.   self.fl = fl
  17.  
  18.   local last_cure = flags:get("last_cure") or false
  19.   local reckless = false
  20.   local paralysis = false
  21.  
  22.   if self.fl == "*" then
  23.     affs:add("blackout")
  24.     if flags:get("vapor_check") then
  25.       affs:add("vapors")
  26.       flags:clear("vapor_check")
  27.     end
  28.     if bals:get("allheale") then
  29.       flags:set("allheale", true, 0)
  30.       scan:add("elixir")
  31.     end
  32.   else
  33.     affs:del("blackout", true)
  34.     flags:clear("allheale")
  35.     EnableTrigger("prompt_blackout__", false)
  36.   end
  37.  
  38.   -- Auto-configure arm balance
  39.   if GetVariable("treant_option_armbalance") ~= "1" and (string.find(self.fl, "r") or string.find(self.fl, "l")) then
  40.     SetVariable("treant_option_armbalance", 1)
  41.     display.Info("Arm balance enabled")
  42.   end
  43.  
  44.   -- Check arm balances
  45.   if GetVariable("treant_option_armbalance") == "1" then
  46.     if string.find(self.fl, "r") then
  47.       bals:gain("rarm")
  48.       if flags:get("check_arm") == "right" and
  49.          not affs:has("clamped_right") and
  50.          not affs:has("pierced_rightarm") then
  51.         affs:limb("right", "arm", "broken")
  52.       end
  53.     else
  54.       bals:lose("rarm")
  55.       flags:clear("rarm_try")
  56.     end
  57.     if string.find(self.fl, "l") then
  58.       bals:gain("larm")
  59.       if flags:get("check_arm") == "left" and
  60.          not affs:has("clamped_left") and
  61.          not affs:has("pierced_leftarm") then
  62.         affs:limb("left", "arm", "broken")
  63.       end
  64.     else
  65.       bals:lose("larm")
  66.       flags:clear("larm_try")
  67.     end
  68.   end
  69.  
  70.   -- Check psionic channels
  71.   if GetVariable("treant_option_psionics") == "1" then
  72.     if string.find(self.fl, "s") then
  73.       bals:gain("sub")
  74.     else
  75.       bals:lose("sub")
  76.       flags:clear("sub_try")
  77.     end
  78.     if string.find(self.fl, "S") then
  79.       bals:gain("super")
  80.     else
  81.       bals:lose("super")
  82.       flags:clear("super_try")
  83.     end
  84.     if string.find(self.fl, "i") then
  85.       bals:gain("id")
  86.     else
  87.       bals:lose("id")
  88.       flags:clear("id_try")
  89.     end
  90.   end
  91.  
  92.   if string.find(self.fl, "e") then
  93.     bals:gain("eq")
  94.     affs:del("disrupted", true)
  95.     flags:clear({ "lost_eq", "concentrate_try" })
  96.     failsafe:disable("concentrate")
  97.   elseif bals:get("eq") then
  98.     flags:set("lost_eq", os.time(), 0)
  99.     bals:lose("eq")
  100.     flags:clear("eq_try")
  101.   else
  102.     local ct = os.time()
  103.     if ct - (flags:get("lost_eq") or ct) > 12 then
  104.       affs:add("disrupted")
  105.     end
  106.   end
  107.  
  108.   if string.find(self.fl, "x") then
  109.     bals:gain("bal")
  110.   else
  111.     bals:lose("bal")
  112.     flags:clear("bal_try")
  113.   end
  114.  
  115.   -- Check a few defenses/afflictions in the prompt flags
  116.   if not affs:has("blackout") then
  117.     if string.find(self.fl, "k") then
  118.       defs:add("kafe")
  119.     else
  120.       defs:del("kafe")
  121.     end
  122.  
  123.     if flags:get("last_cure") ~= "eat myrtle" then
  124.       if string.find(self.fl, "b") then
  125.         if not defs:has("sixthsense") and
  126.            not (affs:has("losteye_left") and affs:has("losteye_right")) then
  127.           affs:add("blindness")
  128.         else
  129.           affs:del("blindness", true)
  130.         end
  131.       else
  132.         affs:del("blindness", true)
  133.         defs:del("sixthsense")
  134.       end
  135.  
  136.       if string.find(self.fl, "d") then
  137.         if not defs:has("truehearing") then
  138.           affs:add("deafness")
  139.         else
  140.           affs:del("deafness", true)
  141.         end
  142.       else
  143.         affs:del("deafness", true)
  144.         defs:del("truehearing")
  145.       end
  146.     end
  147.   end
  148.  
  149.   -- Update gauges display and check healing queue, if anything has changed
  150.   local health_max = treant:max_health()
  151.   local mana_max = treant:max_mana()
  152.   local ego_max = treant:max_ego()
  153.   if health_max > 0 and (self.last_health ~= self.health or health_max ~= self.last_health_max) then
  154.     if gui then gui:update_health(health, tonumber(GetVariable("treant_health_max") or "0")) end
  155.     scan:add("healing")
  156.     self.last_health_max = health_max
  157.  
  158.     if GetVariable("treant_prompt_hmediff") == "1" then
  159.       local health_diff = self.health - self.last_health
  160.       if health_diff < 0 then
  161.         treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iH", health_diff), "silver", "", "]") end)
  162.       else
  163.         treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iH", health_diff), "silver", "", "]") end)
  164.       end
  165.     end
  166.   end
  167.   if mana_max > 0 and (self.last_mana ~= self.mana or mana_max ~= self.last_mana_max) then
  168.     if gui then gui:update_mana(mana, mana_max) end
  169.     scan:add("healing")
  170.     self.last_mana_max = mana_max
  171.  
  172.     if GetVariable("treant_prompt_hmediff") == "1" then
  173.       local mana_diff = self.mana - self.last_mana
  174.       if mana_diff < 0 then
  175.         treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iM", mana_diff), "silver", "", "]") end)
  176.       else
  177.         treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iM", mana_diff), "silver", "", "]") end)
  178.       end
  179.     end
  180.   end
  181.   if ego_max > 0 and (self.last_ego ~= self.ego or ego_max ~= self.last_ego_max) then
  182.     if gui then gui:update_ego(ego, ego_max) end
  183.     scan:add("healing")
  184.     self.last_ego_max = ego_max
  185.  
  186.     if GetVariable("treant_prompt_hmediff") == "1" then
  187.       local ego_diff = self.ego - self.last_ego
  188.       if ego_diff < 0 then
  189.         treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iE", ego_diff), "silver", "", "]") end)
  190.       else
  191.         treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iE", ego_diff), "silver", "", "]") end)
  192.       end
  193.     end
  194.   end
  195.   local endurance_max = tonumber(GetVariable("treant_endurance_max") or "0")
  196.   local willpower_max = tonumber(GetVariable("treant_willpower_max") or "0")
  197.   if endurance_max > 0 and (self.last_endurance ~= self.endurance or self.endurance_max ~= self.last_endurance_max) then
  198.     if gui then gui:update_endurance(endurance, endurance_max) end
  199.     self.last_endurance_max = endurance_max
  200.   end
  201.   if willpower_max > 0 and (self.last_willpower ~= self.willpower or self.willpower_max ~= self.last_willpower_max) then
  202.     if gui then gui:update_willpower(willpower, willpower_max) end
  203.     self.last_willpower_max = willpower_max
  204.   end
  205.   if self.last_power ~= self.power then
  206.     if gui then gui:update_power(power) end
  207.   end
  208.   if gui then gui:update_gauges() end
  209.  
  210.   -- Execute actions that have passed the anti-illusion barrier
  211.   if self.actions then
  212.     for _,f in ipairs(self.actions) do
  213.       f()
  214.     end
  215.     self.actions = nil
  216.   end
  217.  
  218.   -- Have I fallen down? Can I get up?
  219.   local pc = affs.prone_check or {}
  220.   if string.find(self.fl, "p") or affs:has("blackout") then
  221.     if #pc then
  222.       for _,pca in ipairs(pc) do
  223.         if pca == "paralysis" then
  224.           display.Debug("PARALYSIS")
  225.           paralysis = true
  226.         end
  227.  
  228.         affs:add(pca)
  229.       end
  230.     end
  231.  
  232.     flags:clear("prone_check")
  233.   else
  234.     affs:del({ "asleep", "prone", "entangled", "frozen", "paralysis", "roped", "stunned", "shackled" }, true)
  235.   end
  236.  
  237.   -- Am I perhaps dangerously reckless now?
  238.   if flags:get("damaged") and
  239.      self.health == health_max and
  240.      self.mana == mana_max and
  241.      self.ego == ego_max and
  242.      self.power == 10 then
  243.     affs:add("recklessness")
  244.     display.Debug("RECKLESS")
  245.     reckless = true
  246.   end
  247.  
  248.   -- Check for a cure that didn't do anything and reset associated afflictions
  249.   if last_cure then
  250.     -- If bedevil keeps us from curing properly, add the new affliction
  251.     if flags:get("bedevil") and bedevils[flags:get("last_cure")] then
  252.       bedevils[flags:get("last_cure")]()
  253.     else
  254.       nocure:clear(flags:get("last_cure"))
  255.     end
  256.  
  257.     flags:clear("last_cure")
  258.   end
  259.  
  260.   -- Telepathy affliction checks
  261.   if flags:get("telepathy") and flags:get("telepathy") ~= self.last_telepathy and
  262.      not (reckless or paralysis) then
  263.     affs:add({ "deadened", "focus_mind" })
  264.   end
  265.   self.last_telepathy = flags:get("telepathy")
  266.  
  267.   -- Execute actions that have been queued up for the prompt
  268.   queue:exec()
  269.  
  270.   -- Check all healing queues now
  271.   scan:check()
  272.  
  273.   -- Reset any prone type afflictions being tracked
  274.   affs.prone_check = {}
  275.  
  276.   -- Setup any critical alerts to be displayed after the prompt
  277.   prompt:alerts()
  278.  
  279.   Execute("OnPrompt " .. tostring(health) .. " " .. tostring(mana) .. " " .. tostring(ego) .. " " .. tostring(power) .. " " .. tostring(fl))
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement