Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. --The tracker will monitor all statuses, including the player.
  2. function trackerAdd(name,item)
  3. --Add a status of some sort to a thing's tracker.)
  4. if name == "yourself" or name == "me" then
  5. name = "Me"
  6. end
  7. if item == nil then return end
  8.  
  9. if sys.tracker[name] == nil then
  10. trackerPop(name)
  11. end
  12. local tracker = sys.tracker[name]
  13.  
  14. if tracker[item] == false or tracker[item] == nil then
  15. tracker[item] = true
  16. sys.tracker[name] = tracker
  17. trackerCount(name,item,1)
  18. cecho("Aff: Add "..name.." "..item)
  19. end
  20. if name ~= "Me" then sys.tracker[name].collect = 0 end
  21. end
  22.  
  23. function trackerRemove(name,item)
  24. --Remove a status of some sort from a thing's tracker. Will clean out the table if there are no other entries.
  25. if name == "yourself" then
  26. name = "Me"
  27. end
  28. if item == nil then return end
  29. if sys.tracker[name] == nil then
  30. trackerPop(name)
  31. end
  32. local tracker = sys.tracker[name]
  33. if sys.tracker[name][item] == true or sys.tracker[name][item] == nil then
  34. sys.tracker[name][item] = false
  35. trackerCount(name,item,-1)
  36. cecho("Aff: Remove "..name.." "..item)
  37. end
  38. if name ~="Me" then sys.tracker[name].collect = 0 end
  39. end
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. function trackerHas(name,item)
  47. --Returns true if the searched item is on the name's tracking table.
  48.  
  49.  
  50.  
  51. if name == "Yourself" or name == "me" or name == "yourself" then
  52. name = "Me"
  53. end
  54.  
  55. local tracker = ""
  56.  
  57. if sys.tracker[name] == nil then trackerPop(name) end
  58.  
  59. tracker = sys.tracker[name]
  60.  
  61. if tracker == nil then cecho("debug") end
  62. if tracker[item] == true then
  63.  
  64. return true
  65.  
  66. else
  67.  
  68. return false
  69. end
  70.  
  71.  
  72. end
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. function trackerPop(name)
  80. if name == "yourself" or name == "Yourself" or name == "me" then
  81. name = "me"
  82. end
  83.  
  84. sys.tracker[name] = {}
  85. local tracker = {}
  86. for i=1,#db.affs.main do
  87. local x = db.affs.main[i].name
  88. tracker[x] = false
  89. end
  90. --Common Defense pop - Needs db fill
  91.  
  92. -- if me then pop all defs for class else
  93. --for i=1,#db.defs.common do
  94. -- local x = db.defs[i].name
  95. -- tracker[x] = true
  96. --end
  97. --end
  98.  
  99. for i=1,#db.curelist do
  100. local x = db.curelist[i]
  101. tracker[x] = 0
  102. end
  103. tracker["collect"] = 0
  104. tracker["hypnosis_queued"] = {}
  105. tracker["hypnotised"] = false
  106. sys.tracker[name] = tracker
  107. end
  108.  
  109.  
  110.  
  111.  
  112.  
  113. function trackerCount(name,thing,logic)
  114.  
  115. local count
  116. local current
  117. local holder = sys.tracker[name]
  118.  
  119. for i=1,table.getn(db.curelist) do
  120. current = db.curelist[i]
  121.  
  122. if table.contains(db[current],thing) then
  123. count = holder[current]
  124.  
  125. holder[current] = count + logic
  126.  
  127. if holder[current] < 0 then
  128. holder[current] = 0
  129. end
  130. end
  131. end
  132. end
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. function trackerGuessCure(name,curetype)
  141. local list = {}
  142. if sys.tracker[name] == nil then
  143. trackerPop(name)
  144. end
  145. local holder = sys.tracker[name]
  146.  
  147. if holder["shadowplant-"..curetype] == true then
  148. trackerRemove(name,"shadowplant-"..curetype)
  149. killTimer(name.."-shadowplant-deactivate")
  150. elseif holder[curetype] ~= nil then
  151. --Nada
  152. if holder[curetype] < 1 then
  153. --Iunno
  154. elseif holder[curetype] == 1 then
  155. local list = db[curetype]
  156. local pop = false
  157. for i=1,table.getn(list) do
  158. local aff = list[i]
  159. if holder[aff] == true and pop == false then
  160. trackerRemove(name,aff)
  161. pop = true
  162. end
  163. end
  164.  
  165. elseif holder[curetype] > 1 then
  166.  
  167. --This is the random selection method
  168. --Makes list of the possible cures by getting the list and removing falses. Generates int from 1 to real list size. trackerRemove the result
  169. --instill check
  170. local currentlist = db[curetype]
  171. for i=1, table.getn(db[curetype]) do
  172. local aff = currentlist[i]
  173. if holder[aff] == true then
  174. list[#list+1] = aff
  175. end
  176. end
  177. local x = math.random(1,table.getn(list))
  178. local x = list[x]
  179. trackerRemove(name,x)
  180. end
  181. end
  182. sys.tracker.curebuffer = false
  183. end
  184.  
  185. function cureBuffer(name,cure)
  186.  
  187. if name == "yourself" then return end
  188.  
  189. if sys.tracker.curebuffer ~= false then
  190. trackerGuessCure(sys.tracker.curebuffer[1],sys.tracker.curebuffer[2])
  191. end
  192. sys.tracker.curebuffer = {name, cure}
  193. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement