Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Agatha = {
- lastprompt = "",
- currentprompt = "",
- Markov = {
- dictionary = {},
- replyrate = 50,
- SYSTEM_VERBS = {
- target = "target",
- attack = "target",
- kill = "target",
- get = "get",
- take = "get",
- grab = "get",
- },
- UNWANTED_WORDS = { "a", "an", "the", "that", "those", "few", "of", "in", "out", "my" },
- },
- Mapping = {
- map_capture = false,
- },
- Gradients = {
- left = "|c111111-|c222222-|c333333-|c444444-|c555555-|c666666-|c777777-|c888888-|c999999-|caaaaaa-",
- right = "|caaaaaa-|c999999-|c888888-|c777777-|c666666-|c555555-|c444444-|c333333-|c222222-|c111111-",
- },
- Afflictions = {
- last_applied = "",
- herb_queue = {},
- salve_queue = {},
- tincture_queue = {},
- pipe_queue = {},
- last_eaten = "",
- last_applied_to = "",
- slice_queue = {},
- poultice_queue = {},
- skill_queue = {},
- aff_dict = {},
- },
- Cure_dict = {
- Concoctions = {
- Herbs = {
- ash = true,
- goldenseal = true,
- kelp = true,
- lobelia = true,
- ginseng = true,
- bellwort = true,
- bloodroot = true,
- moss = true,
- },
- Salves = {
- epidermal = true,
- mending = true,
- caloric = true,
- restoration = true,
- },
- Smoked = {
- elm = true,
- valerian = true,
- },
- Elixirs = {
- immunity = true,
- },
- },
- Reanimation = {
- Slices = {
- bladder = true,
- liver = true,
- eyeball = true,
- testis = true,
- ovary = true,
- castorite = true,
- lung = true,
- kidney = true,
- },
- Poultices = {
- oculi = true,
- orbis = true,
- fumeae = true,
- jecis = true,
- },
- Tinctures = {
- demulcent = true,
- antispasmadic = true,
- },
- },
- Skills = {},
- Bodyparts = {
- torso = true,
- head = true,
- ["right leg"] = true,
- ["left leg"] = true,
- ["right arm"] = true,
- ["left arm"] = true,
- skin = true,
- },
- },
- Status = {
- States = {
- blackout = false,
- stun = false,
- asleep = false,
- writhe = false,
- },
- Balances = {
- moss_bal = true,
- try_moss = false,
- elix_bal = true,
- try_elix = false,
- herb_bal = true,
- try_herb = false,
- salve_bal = true,
- try_salve = false,
- poultice_bal = true,
- try_poultice = false,
- slice_bal = true,
- try_slice = false,
- pipe_bal = true,
- try_pipe = false,
- tincture_bal = true,
- try_tincture = false,
- balance = true,
- equilibrium = true,
- try_stand = false,
- try_attack = false,
- left_arm_bal = false,
- right_arm_bal = false,
- try_outc_moss = false,
- try_outc_lobelia = false,
- try_outc_ash = false,
- try_outc_bellwort = false,
- try_outc_goldenseal = false,
- try_outc_kelp = false,
- try_outc_bloodroot = false,
- try_outc_ginseng = false,
- focus_bal = false,
- try_focus = false,
- },
- Vitals = {
- p_health = 0,
- p_mana = 0,
- p_endu = 0,
- p_will = 0,
- c_xp = 0,
- l_xp = 0,
- p_xp = 0,
- },
- },
- Data = {
- },
- Sipper = {
- primary = "health",
- secondary = "mana",
- health_sip = 50,
- mana_sip = 50,
- health_eat = 70,
- mana_eat = 70,
- living = {
- sip_cmd = "sip",
- health = "health",
- mana = "mana",
- moss = "moss",
- },
- undead = {
- sip_cmd = "stick",
- health = "analeptic",
- mana = "stimulant",
- moss = "kidney slice",
- },
- },
- Settings = {
- auto_sip = false,
- auto_outc = false,
- auto_slice = false,
- auto_sip = true,
- auto_smoke = true,
- auto_bash = true,
- auto_salve = true,
- auto_stand = false,
- auto_poultice = false,
- auto_tincture = false,
- auto_herb = true,
- auto_target_feed = true,
- },
- }
- Agatha.Stacks = {}
- stack = {}
- function Load(silent)
- if not silent then Agatha:Announce("Loading settings.") end
- table.load( "system_settings.txt", Agatha )
- table.load( "autobasher_settings.txt", Bismuth )
- table.load( "skaiabot_settings.txt", Skaiabot )
- if not silent then Agatha:Announce("Settings loaded.") end
- end
- function Save(silent)
- if not silent then Agatha:Announce("Saving settings.") end
- table.save( "system_settings.txt", Agatha )
- table.save( "autobasher_settings.txt", Bismuth )
- table.save( "skaiabot_settings.txt", Skaiabot )
- if not silent then Agatha:Announce("Settings saved.") end
- end
- function Agatha:Error(str)
- cecho("<red>\[[AGATHA:] \"Error: " .. str .. "\"]\n")
- end
- function Agatha:StripHexCodes(str)
- local stripped = rex.gsub(str,"|c([0-9a-fA-F]{6})","")
- stripped = string.gsub(stripped,"|","")
- return stripped
- end
- function Agatha:Wrap(str,ind)
- local temp_str = str
- local lines = {}
- while string.len(temp_str)>0 do
- i = ind
- if string.sub(temp_str,i,i) == "" then
- i = 0
- table.insert(lines,temp_str)
- temp_str = ""
- end
- while i > 0 do
- if string.sub(temp_str,i,i) == " " or string.sub(temp_str,i,i) == "\!" or string.sub(temp_str,i,i) == "\?" or string.sub(temp_str,i,i) == "\"" then
- table.insert(lines, string.sub(temp_str,1,i))
- temp_str = string.sub(temp_str,i+1)
- i = 0
- else
- i = i-1
- end
- end
- end
- if string.sub(lines[#lines],string.len(lines[#lines]),string.len(lines[#lines])) ~= "\." and
- string.sub(lines[#lines],string.len(lines[#lines]),string.len(lines[#lines])) ~= "\!" and
- string.sub(lines[#lines],string.len(lines[#lines]),string.len(lines[#lines])) ~= "\?" then
- lines[#lines]=lines[#lines].."\."
- end
- return lines
- end
- function Agatha:Announce(str)
- local text = {}
- if str then
- if Agatha:StripHexCodes(str):len() > 75 then text = Agatha:Wrap(str,75) else text[1] = str end
- else
- return false
- end
- if not text[1] then text[1] = "No text to be displayed." end
- for _,v in pairs(text) do
- temp = Agatha:StripHexCodes(v)
- pad = math.floor((75-string.len(temp)))
- hecho("\n"..self.Gradients.left..string.rep("-",pad).."[ "..v.." |c999999]"..self.Gradients.right)
- end
- end
- function Agatha:UpdateVitals(...)
- if not gmcp then
- Agatha:Error("GMPC is not enabled. Please enable it under Settings and restart Mudlet.")
- return false
- end
- local args = {...}
- if args[1] then
- if args[1]:find("p") then Agatha.Status.States.prone = true else Agatha.Status.States.prone = false end
- end
- if gmcp.Char.Vitals.balance == "1" then self.Status.Balances.balance = true else self.Status.Balances.balance = false end
- if gmcp.Char.Vitals.equilibrium == "1" then self.Status.Balances.equilibrium = true else self.Status.Balances.equilibrium = false end
- if gmcp.Char.Vitals.left_arm == "1" then self.Status.Balances.left_arm_bal = true else self.Status.Balances.left_arm_bal = false end
- if gmcp.Char.Vitals.right_arm == "1" then self.Status.Balances.right_arm_bal = true else self.Status.Balances.right_arm_bal = false end
- self.Status.Vitals = {
- p_health = (gmcp.Char.Vitals.hp/gmcp.Char.Vitals.maxhp)*100,
- p_mana = (gmcp.Char.Vitals.mp/gmcp.Char.Vitals.maxmp)*100,
- p_endu = (gmcp.Char.Vitals.ep/gmcp.Char.Vitals.maxep)*100,
- p_will = (gmcp.Char.Vitals.wp/gmcp.Char.Vitals.maxwp)*100,
- l_xp = self.Status.Vitals.c_xp,
- c_xp = gmcp.Char.Vitals.xp,
- p_xp = (gmcp.Char.Vitals.xp/gmcp.Char.Vitals.maxxp)*100,
- t_xp = gmcp.Char.Vitals.maxxp
- }
- end
- function Agatha:AutoSipper()
- local sip_cmd = ""
- if self.Settings.auto_sip then
- if not self.Status.Balances.try_elix and self.Status.Balances.elix_bal then
- if self.Status.Vitals["p_" .. self.Sipper.primary] < self.Sipper[ self.Sipper.primary .. "_sip"] then
- sip_cmd = self.Sipper[gmcp.Char.Vitals.status].sip_cmd .. " " .. self.Sipper[gmcp.Char.Vitals.status][self.Sipper.primary]
- elseif self.Status.Vitals["p_" .. self.Sipper.secondary] < self.Sipper[self.Sipper.secondary .. "_sip"] then
- sip_cmd = self.Sipper[gmcp.Char.Vitals.status].sip_cmd .. " " .. self.Sipper[gmcp.Char.Vitals.status][self.Sipper.secondary]
- end
- end
- if sip_cmd ~= "" then
- send(sip_cmd)
- self.Status.Balances.try_elix = true
- end
- if not self.Status.Balances.try_moss and self.Status.Balances.moss_bal then
- if self.Status.Vitals.p_health <= self.Sipper.health_eat or self.Status.Vitals.p_mana <= self.Sipper.mana_eat then
- send("outc "..self.Sipper[gmcp.Char.Vitals.status].moss)
- send("eat "..self.Sipper[gmcp.Char.Vitals.status].moss)
- self.Status.Balances.try_moss = true
- end
- end
- end
- end
- function Agatha:AutoBash()
- if Agatha.Settings.auto_bash and Bismuth.Attack.cmd and Bismuth.Targets[1] and not Agatha.Status.Balances.try_attack then
- local attack_now = false
- Agatha.Status.Balances.try_attack = true
- if Bismuth.Attack.needs_equ and Agatha.Status.Balances.equilibrium then
- attack_now = true
- elseif Bismuth.Attack.needs_bal and Agatha.Status.Balances.balance then
- attack_now = true
- elseif Bismuth.Attack.needs_armbal and (Agatha.Status.Balances.left_arm_bal or Agatha.Status.Balances.right_arm_bal) then
- attack_now = true
- end
- if attack_now then
- local atk_output = string.gsub(Bismuth.Attack.cmd, "@TAR", Bismuth.Targets[1])
- atk_output = string.gsub(atk_output , "\|", "\;")
- send(atk_output)
- end
- end
- end
- function Agatha:ParseSkills()
- skills = {}
- for i,v in pairs(gmcp.Char.Skills.Groups) do
- skills[i] = yajl.to_value(gmcp.Char.Skills.Groups[i])
- end
- end
- function Agatha:CreateInterface()
- local mapx = 1300
- local mapy = 600
- createMiniConsole("minimap",1000,800,350,285)
- setBackgroundColor("minimap",0,0,0,0);
- setMiniConsoleFontSize("minimap", 10)
- setWindowWrap("minimap", 90);
- setTextFormat("minimap",55,0,0,0,0,255,0,0,0);
- moveWindow("minimap", mapx, mapy)
- resizeWindow("minimap", 350, 285)
- end
- function Agatha:StudyString(str)
- -- This function takes a string, removes punctuation, shrinks spaces, and
- -- breaks the string into a table of individual words, which are then added
- -- to Agatha's dictionary.
- input = string.lower(str)
- input = string.gsub(input, "[\.,!?]", "")
- input = string.gsub(input, " ", " ")
- input = string.split(input, " ")
- -- We iterate through the table and use the remember_word function
- -- to add each entry to the dictionary, using the preceding word as
- -- the parent.
- for k,v in pairs(input) do
- if k ~= #input then
- Agatha:RememberWord(input[k+1],input[k])
- end
- end
- Save(true)
- -- if a random number between 0 and 100 exeeds the replyrate chance, we generate a reply from Agatha.
- if math.random(100) <= self.Markov.replyrate then Agatha:GenerateString(input[math.random(#input)], math.random(20)) end
- end
- function Agatha:ShowDictionary()
- -- displays the contents of the dictionary. This can get pretty huge - several hundred lines or so.
- Agatha:Announce("The dictionary currently contains:")
- for k,v in pairs(self.Markov.dictionary) do
- echo("\n" .. k .. ":\n [")
- for i,j in pairs(v) do
- echo(j .. ", ")
- end
- echo("]")
- end
- end
- function Agatha:RememberWord(word, parent)
- -- this function takes a word and a parent and adds them to the dictionary.
- -- if the dictionary doesn't have an entry for 'parent', we create it.
- if self.Markov.dictionary[parent] == nil then
- self.Markov.dictionary[parent] = {}
- end
- -- we search the dictionary entry to see if 'word' is already present.
- -- if it isn't, we add it.
- newword_found = 0
- for _,y in pairs(self.Markov.dictionary[parent]) do
- if word == y
- then newword_found = 1
- break
- end
- end
- if newword_found == 0 then table.insert(self.Markov.dictionary[parent],word) end
- end
- function Agatha:GenerateString(seed, len)
- -- this function takes a seed word and a string length, and generates a semi-random
- -- string of 'len' words based on the seed.
- i = 0
- mark_output = seed
- while i <= len and self.Markov.dictionary[seed] ~= nil do
- j = math.random(#self.Markov.dictionary[seed])
- seed = self.Markov.dictionary[seed][j]
- mark_output = mark_output .. " " .. seed
- i = i+1
- end
- -- we add some punctuation to give Agatha a bit of life.
- i = math.random(20)
- if i < 10 then mark_output = mark_output .. "."
- elseif i >= 10 and i < 15 then mark_output = mark_output .. "!"
- elseif i >=15 and i <= 20 then mark_output = mark_output .. "?"
- end
- -- capitalize individual letters 'I' and output the string.
- mark_output = string.gsub(mark_output, " i ", " I ")
- hecho("|cffffffAGATHA |ccccccctells you, \"|cffffff"..string.upper(mark_output:sub(1,1))..mark_output:sub(2).."|ccccccc\"")
- end
- function Agatha:ParseString(str)
- -- this function is not finished or really used for anything.
- -- it parses a string sent to Agatha and attempts to derive a
- -- useable Aetolia command from it - ie. 'Agatha, get that pack'
- -- would be reduced to 'get pack'.
- -- Agatha learns from anything said to her via atell, commands included.
- Agatha:StudyString(str)
- temp_str = " " .. str .. " "
- temp_str = string.gsub(temp_str, "[\.\,\!\?]", "")
- for _,v in pairs(self.Markov.UNWANTED_WORDS) do
- temp_str = string.gsub(temp_str, " " .. v .. " ", " ")
- end
- words = {}
- verbs = {}
- nouns = {}
- for s in string.gmatch(temp_str, "%w+") do
- words[#words+1] = s
- end
- -- for all the entries in the 'words' table, we compare them to our list of acceptable verbs
- -- and our table of possible targets in the room and our inventory (room and inventory contents
- -- are tracked via triggers)
- -- for k,v in ipairs(words) do
- -- for i, j in pairs(self.Markov.SYSTEM_VERBS) do
- -- if v == i then
- -- verbs[#verbs+1] = j
- -- end
- -- end
- -- for i, j in pairs(environment.room_contents) do
- -- if string.find(j.longname, v) ~= nil then
- -- nouns[#nouns+1] = j.shortname
- -- end
- -- end
- -- end
- end
- function stack:new()
- local obj = {}
- setmetatable(obj, self)
- self.__index = self
- return obj
- end
- function stack:add(str)
- self[#self+1] = str
- Agatha:Announce("|cffffffAdded to queue: "..self[#self])
- end
- function stack:pop(str)
- if self[1] then
- local temp = self[1]
- table.remove(self,1)
- return temp
- else
- return false
- end
- end
- function stackInit()
- Agatha.Stacks = {}
- for k,v in pairs({"bal","equ","sync"}) do
- Agatha.Stacks[v] = stack:new()
- end
- end
- Load()
- Agatha:CreateInterface()
- stackInit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement