Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function prompt:capture(health, mana, ego, power, endurance, willpower, fl)
- self.last_health = self.health or 0
- self.last_mana = self.mana or 0
- self.last_ego = self.ego or 0
- self.last_power = self.power or 0
- self.last_endurance = self.endurance or 0
- self.last_willpower = self.willpower or 0
- self.health = health
- self.mana = mana
- self.ego = ego
- self.power = power
- self.endurance = endurance
- self.willpower = willpower
- self.fl = fl
- local last_cure = flags:get("last_cure") or false
- local reckless = false
- local paralysis = false
- if self.fl == "*" then
- affs:add("blackout")
- if flags:get("vapor_check") then
- affs:add("vapors")
- flags:clear("vapor_check")
- end
- if bals:get("allheale") then
- flags:set("allheale", true, 0)
- scan:add("elixir")
- end
- else
- affs:del("blackout", true)
- flags:clear("allheale")
- EnableTrigger("prompt_blackout__", false)
- end
- -- Auto-configure arm balance
- if GetVariable("treant_option_armbalance") ~= "1" and (string.find(self.fl, "r") or string.find(self.fl, "l")) then
- SetVariable("treant_option_armbalance", 1)
- display.Info("Arm balance enabled")
- end
- -- Check arm balances
- if GetVariable("treant_option_armbalance") == "1" then
- if string.find(self.fl, "r") then
- bals:gain("rarm")
- if flags:get("check_arm") == "right" and
- not affs:has("clamped_right") and
- not affs:has("pierced_rightarm") then
- affs:limb("right", "arm", "broken")
- end
- else
- bals:lose("rarm")
- flags:clear("rarm_try")
- end
- if string.find(self.fl, "l") then
- bals:gain("larm")
- if flags:get("check_arm") == "left" and
- not affs:has("clamped_left") and
- not affs:has("pierced_leftarm") then
- affs:limb("left", "arm", "broken")
- end
- else
- bals:lose("larm")
- flags:clear("larm_try")
- end
- end
- -- Check psionic channels
- if GetVariable("treant_option_psionics") == "1" then
- if string.find(self.fl, "s") then
- bals:gain("sub")
- else
- bals:lose("sub")
- flags:clear("sub_try")
- end
- if string.find(self.fl, "S") then
- bals:gain("super")
- else
- bals:lose("super")
- flags:clear("super_try")
- end
- if string.find(self.fl, "i") then
- bals:gain("id")
- else
- bals:lose("id")
- flags:clear("id_try")
- end
- end
- if string.find(self.fl, "e") then
- bals:gain("eq")
- affs:del("disrupted", true)
- flags:clear({ "lost_eq", "concentrate_try" })
- failsafe:disable("concentrate")
- elseif bals:get("eq") then
- flags:set("lost_eq", os.time(), 0)
- bals:lose("eq")
- flags:clear("eq_try")
- else
- local ct = os.time()
- if ct - (flags:get("lost_eq") or ct) > 12 then
- affs:add("disrupted")
- end
- end
- if string.find(self.fl, "x") then
- bals:gain("bal")
- else
- bals:lose("bal")
- flags:clear("bal_try")
- end
- -- Check a few defenses/afflictions in the prompt flags
- if not affs:has("blackout") then
- if string.find(self.fl, "k") then
- defs:add("kafe")
- else
- defs:del("kafe")
- end
- if flags:get("last_cure") ~= "eat myrtle" then
- if string.find(self.fl, "b") then
- if not defs:has("sixthsense") and
- not (affs:has("losteye_left") and affs:has("losteye_right")) then
- affs:add("blindness")
- else
- affs:del("blindness", true)
- end
- else
- affs:del("blindness", true)
- defs:del("sixthsense")
- end
- if string.find(self.fl, "d") then
- if not defs:has("truehearing") then
- affs:add("deafness")
- else
- affs:del("deafness", true)
- end
- else
- affs:del("deafness", true)
- defs:del("truehearing")
- end
- end
- end
- -- Update gauges display and check healing queue, if anything has changed
- local health_max = treant:max_health()
- local mana_max = treant:max_mana()
- local ego_max = treant:max_ego()
- if health_max > 0 and (self.last_health ~= self.health or health_max ~= self.last_health_max) then
- if gui then gui:update_health(health, tonumber(GetVariable("treant_health_max") or "0")) end
- scan:add("healing")
- self.last_health_max = health_max
- if GetVariable("treant_prompt_hmediff") == "1" then
- local health_diff = self.health - self.last_health
- if health_diff < 0 then
- treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iH", health_diff), "silver", "", "]") end)
- else
- treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iH", health_diff), "silver", "", "]") end)
- end
- end
- end
- if mana_max > 0 and (self.last_mana ~= self.mana or mana_max ~= self.last_mana_max) then
- if gui then gui:update_mana(mana, mana_max) end
- scan:add("healing")
- self.last_mana_max = mana_max
- if GetVariable("treant_prompt_hmediff") == "1" then
- local mana_diff = self.mana - self.last_mana
- if mana_diff < 0 then
- treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iM", mana_diff), "silver", "", "]") end)
- else
- treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iM", mana_diff), "silver", "", "]") end)
- end
- end
- end
- if ego_max > 0 and (self.last_ego ~= self.ego or ego_max ~= self.last_ego_max) then
- if gui then gui:update_ego(ego, ego_max) end
- scan:add("healing")
- self.last_ego_max = ego_max
- if GetVariable("treant_prompt_hmediff") == "1" then
- local ego_diff = self.ego - self.last_ego
- if ego_diff < 0 then
- treant:suffix(function () ColourTell("silver", "", " [", "salmon", "", string.format("%+iE", ego_diff), "silver", "", "]") end)
- else
- treant:suffix(function () ColourTell("silver", "", " [", "lightgreen", "", string.format("%+iE", ego_diff), "silver", "", "]") end)
- end
- end
- end
- local endurance_max = tonumber(GetVariable("treant_endurance_max") or "0")
- local willpower_max = tonumber(GetVariable("treant_willpower_max") or "0")
- if endurance_max > 0 and (self.last_endurance ~= self.endurance or self.endurance_max ~= self.last_endurance_max) then
- if gui then gui:update_endurance(endurance, endurance_max) end
- self.last_endurance_max = endurance_max
- end
- if willpower_max > 0 and (self.last_willpower ~= self.willpower or self.willpower_max ~= self.last_willpower_max) then
- if gui then gui:update_willpower(willpower, willpower_max) end
- self.last_willpower_max = willpower_max
- end
- if self.last_power ~= self.power then
- if gui then gui:update_power(power) end
- end
- if gui then gui:update_gauges() end
- -- Execute actions that have passed the anti-illusion barrier
- if self.actions then
- for _,f in ipairs(self.actions) do
- f()
- end
- self.actions = nil
- end
- -- Have I fallen down? Can I get up?
- local pc = affs.prone_check or {}
- if string.find(self.fl, "p") or affs:has("blackout") then
- if #pc then
- for _,pca in ipairs(pc) do
- if pca == "paralysis" then
- display.Debug("PARALYSIS")
- paralysis = true
- end
- affs:add(pca)
- end
- end
- flags:clear("prone_check")
- else
- affs:del({ "asleep", "prone", "entangled", "frozen", "paralysis", "roped", "stunned", "shackled" }, true)
- end
- -- Am I perhaps dangerously reckless now?
- if flags:get("damaged") and
- self.health == health_max and
- self.mana == mana_max and
- self.ego == ego_max and
- self.power == 10 then
- affs:add("recklessness")
- display.Debug("RECKLESS")
- reckless = true
- end
- -- Check for a cure that didn't do anything and reset associated afflictions
- if last_cure then
- -- If bedevil keeps us from curing properly, add the new affliction
- if flags:get("bedevil") and bedevils[flags:get("last_cure")] then
- bedevils[flags:get("last_cure")]()
- else
- nocure:clear(flags:get("last_cure"))
- end
- flags:clear("last_cure")
- end
- -- Telepathy affliction checks
- if flags:get("telepathy") and flags:get("telepathy") ~= self.last_telepathy and
- not (reckless or paralysis) then
- affs:add({ "deadened", "focus_mind" })
- end
- self.last_telepathy = flags:get("telepathy")
- -- Execute actions that have been queued up for the prompt
- queue:exec()
- -- Check all healing queues now
- scan:check()
- -- Reset any prone type afflictions being tracked
- affs.prone_check = {}
- -- Setup any critical alerts to be displayed after the prompt
- prompt:alerts()
- Execute("OnPrompt " .. tostring(health) .. " " .. tostring(mana) .. " " .. tostring(ego) .. " " .. tostring(power) .. " " .. tostring(fl))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement