Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --The tracker will monitor all statuses, including the player.
- function trackerAdd(name,item)
- --Add a status of some sort to a thing's tracker.)
- if name == "yourself" or name == "me" then
- name = "Me"
- end
- if item == nil then return end
- if sys.tracker[name] == nil then
- trackerPop(name)
- end
- local tracker = sys.tracker[name]
- if tracker[item] == false or tracker[item] == nil then
- tracker[item] = true
- sys.tracker[name] = tracker
- trackerCount(name,item,1)
- cecho("Aff: Add "..name.." "..item)
- end
- if name ~= "Me" then sys.tracker[name].collect = 0 end
- end
- function trackerRemove(name,item)
- --Remove a status of some sort from a thing's tracker. Will clean out the table if there are no other entries.
- if name == "yourself" then
- name = "Me"
- end
- if item == nil then return end
- if sys.tracker[name] == nil then
- trackerPop(name)
- end
- local tracker = sys.tracker[name]
- if sys.tracker[name][item] == true or sys.tracker[name][item] == nil then
- sys.tracker[name][item] = false
- trackerCount(name,item,-1)
- cecho("Aff: Remove "..name.." "..item)
- end
- if name ~="Me" then sys.tracker[name].collect = 0 end
- end
- function trackerHas(name,item)
- --Returns true if the searched item is on the name's tracking table.
- if name == "Yourself" or name == "me" or name == "yourself" then
- name = "Me"
- end
- local tracker = ""
- if sys.tracker[name] == nil then trackerPop(name) end
- tracker = sys.tracker[name]
- if tracker == nil then cecho("debug") end
- if tracker[item] == true then
- return true
- else
- return false
- end
- end
- function trackerPop(name)
- if name == "yourself" or name == "Yourself" or name == "me" then
- name = "me"
- end
- sys.tracker[name] = {}
- local tracker = {}
- for i=1,#db.affs.main do
- local x = db.affs.main[i].name
- tracker[x] = false
- end
- --Common Defense pop - Needs db fill
- -- if me then pop all defs for class else
- --for i=1,#db.defs.common do
- -- local x = db.defs[i].name
- -- tracker[x] = true
- --end
- --end
- for i=1,#db.curelist do
- local x = db.curelist[i]
- tracker[x] = 0
- end
- tracker["collect"] = 0
- tracker["hypnosis_queued"] = {}
- tracker["hypnotised"] = false
- sys.tracker[name] = tracker
- end
- function trackerCount(name,thing,logic)
- local count
- local current
- local holder = sys.tracker[name]
- for i=1,table.getn(db.curelist) do
- current = db.curelist[i]
- if table.contains(db[current],thing) then
- count = holder[current]
- holder[current] = count + logic
- if holder[current] < 0 then
- holder[current] = 0
- end
- end
- end
- end
- function trackerGuessCure(name,curetype)
- local list = {}
- if sys.tracker[name] == nil then
- trackerPop(name)
- end
- local holder = sys.tracker[name]
- if holder["shadowplant-"..curetype] == true then
- trackerRemove(name,"shadowplant-"..curetype)
- killTimer(name.."-shadowplant-deactivate")
- elseif holder[curetype] ~= nil then
- --Nada
- if holder[curetype] < 1 then
- --Iunno
- elseif holder[curetype] == 1 then
- local list = db[curetype]
- local pop = false
- for i=1,table.getn(list) do
- local aff = list[i]
- if holder[aff] == true and pop == false then
- trackerRemove(name,aff)
- pop = true
- end
- end
- elseif holder[curetype] > 1 then
- --This is the random selection method
- --Makes list of the possible cures by getting the list and removing falses. Generates int from 1 to real list size. trackerRemove the result
- --instill check
- local currentlist = db[curetype]
- for i=1, table.getn(db[curetype]) do
- local aff = currentlist[i]
- if holder[aff] == true then
- list[#list+1] = aff
- end
- end
- local x = math.random(1,table.getn(list))
- local x = list[x]
- trackerRemove(name,x)
- end
- end
- sys.tracker.curebuffer = false
- end
- function cureBuffer(name,cure)
- if name == "yourself" then return end
- if sys.tracker.curebuffer ~= false then
- trackerGuessCure(sys.tracker.curebuffer[1],sys.tracker.curebuffer[2])
- end
- sys.tracker.curebuffer = {name, cure}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement