Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.51 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <mod name="Perfect Zombie System" version="8.6" author="Vodkart" contact="tibiaking.com" enabled="yes">
  3. <config name="zombie_config"><![CDATA[
  4. zombie_config = {
  5. storages = {172100, 172101, 172102}, -- n edite
  6. players = {min = 2, max = 30}, -- min, max players no evento
  7. rewards = {items ={{2160,100},{2494,1}}, trophy = 5805},
  8. timeToStartEvent = 30, -- segundos para começar o evento
  9. CheckTime = 5, -- tempo que o TP fica aberto para os jogadores adrentarem o evento
  10. teleport = {{x=32350, y=32223, z=7}, {x=32726 , y=32425, z=10}}, -- position do tp onde aparece, position para onde o jogador vai ao entrar no tp
  11. arena = {{x=32724,y=32428,z=10},{x=32751,y=32346,z=10}}, -- area positions
  12. monster_name = "Zombie Event",
  13. timeBetweenSpawns = 20,
  14. min_Level = 8
  15. }
  16. zombie_days = {
  17. ["Monday"] = {"13:00","18:00","20:00","22:00"},
  18. ["Tuesday"] = {"13:00","18:00","22:50","22:00"},
  19. ["Wednesday"] = {"21:57","18:00","20:00","23:17"},
  20. ["Thursday"] = {"00:10","00:20","20:00","22:00"},
  21. ["Friday"] = {"13:00","18:00","21:45","22:00"},
  22. ["Saturday"] = {"13:00","18:00","20:00","22:00"},
  23. ["Sunday"] = {"13:00","18:00","20:00","22:00"}
  24. }
  25. function removeZombieTp()
  26. local t = getTileItemById(zombie_config.teleport[1], 1387).uid
  27. return t > 0 and doRemoveItem(t) and doSendMagicEffect(zombie_config.teleport[1], CONST_ME_POFF)
  28. end
  29. function ZerarStoragesZombie()
  30. for _, stor in pairs(zombie_config.storages) do
  31. setGlobalStorageValue(stor, 0)
  32. end
  33. end
  34. function getPlayersInZombieEvent()
  35. local t = {}
  36. for _, pid in pairs(getPlayersOnline()) do
  37. if isInRange(getPlayerPosition(pid), zombie_config.arena[1], zombie_config.arena[2]) and getPlayerAccess(pid) < 3 then
  38. t[#t+1] = pid
  39. end
  40. end
  41. return t
  42. end
  43. function getZombieRewards(cid, items)
  44. local backpack = doPlayerAddItem(cid, 1999, 1) -- backpackID
  45. for _, i_i in ipairs(items) do
  46. local item, amount = i_i[1],i_i[2]
  47. if isItemStackable(item) or amount == 1 then
  48. doAddContainerItem(backpack, item, amount)
  49. else
  50. for i = 1, amount do
  51. doAddContainerItem(backpack, item, 1)
  52. end
  53. end
  54. end
  55. end
  56. function isWalkable(pos, creature, proj, pz)-- by Nord
  57. if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  58. if getTopCreature(pos).uid > 0 and creature then return false end
  59. if getTileInfo(pos).protection and pz then return false, true end
  60. local n = not proj and 3 or 2
  61. for i = 0, 255 do
  62. pos.stackpos = i
  63. local tile = getTileThingByPos(pos)
  64. if tile.itemid ~= 0 and not isCreature(tile.uid) then
  65. if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  66. return false
  67. end
  68. end
  69. end
  70. return true
  71. end
  72. function HaveCreatureZombie(area, remove)
  73. for x = area[1].x - 1, area[2].x + 1 do
  74. for y = area[1].y - 1, area[2].y + 1 do
  75. local pos = {x=x, y=y, z=area[1].z}
  76. local m = getTopCreature(pos).uid
  77. if remove ~= false and m ~= 0 and isMonster(m) then doRemoveCreature(m) end
  78. end
  79. end
  80. end
  81. function spawnZombie()
  82. if #getPlayersInZombieEvent() > 1 then
  83. local pos = {x=math.random(zombie_config.arena[1].x, zombie_config.arena[2].x), y=math.random(zombie_config.arena[1].y,zombie_config.arena[2].y), z=zombie_config.arena[1].z}
  84. if not isWalkable(pos, false, false, false) then
  85. spawnZombie()
  86. else
  87. doCreateMonster(zombie_config.monster_name, pos, false, false, false)
  88. doSendDistanceShoot({x = pos.x - math.random(4, 6), y = pos.y - 5, z = pos.z}, pos, CONST_ANI_FIRE)
  89. addEvent(doSendMagicEffect, 150, pos, CONST_ME_HITBYFIRE)
  90. addEvent(doSendMagicEffect, 150, pos, CONST_ME_FIREAREA)
  91. doSendMagicEffect(pos, CONST_ME_MORTAREA)
  92. setGlobalStorageValue(zombie_config.storages[2], getGlobalStorageValue(zombie_config.storages[2]) <= 0 and 1 or getGlobalStorageValue(zombie_config.storages[2])+1)
  93. doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(zombie_config.storages[2]) .. " zombies in the zombie event!", MESSAGE_STATUS_CONSOLE_RED)
  94. addEvent(spawnZombie, zombie_config.timeBetweenSpawns *1000)
  95. end
  96. end
  97. end
  98. function CheckZombieEvent(delay)
  99. if getGlobalStorageValue(zombie_config.storages[1]) ~= (zombie_config.players.max+1) then
  100. if delay > 0 and getGlobalStorageValue(zombie_config.storages[1]) < zombie_config.players.max then
  101. doBroadcastMessage("Zombie event starting in " .. delay .. " minutes! The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
  102. elseif delay == 0 and getGlobalStorageValue(zombie_config.storages[1]) < zombie_config.players.min then
  103. for _, cid in pairs(getPlayersInZombieEvent()) do
  104. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  105. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  106. end
  107. removeZombieTp()
  108. doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. zombie_config.players.min .. " players is needed!", MESSAGE_STATUS_WARNING)
  109. ZerarStoragesZombie()
  110. elseif delay == 0 and getGlobalStorageValue(zombie_config.storages[1]) >= zombie_config.players.min then
  111. removeZombieTp()
  112. doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(zombie_config.storages[1]) .. " players]! The event will soon start.")
  113. for _, var in pairs(getPlayersInZombieEvent()) do
  114. doPlayerSendTextMessage(var, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. zombie_config.timeToStartEvent .. " seconds! Good luck!")
  115. end
  116. addEvent(spawnZombie, zombie_config.timeToStartEvent*1000)
  117. end
  118. addEvent(CheckZombieEvent, 60000, delay-1)
  119. end
  120. end]]></config>
  121. <event type="statschange" name="ZombieStats" event="script"><![CDATA[
  122. domodlib('zombie_config')
  123. if isPlayer(cid) and isMonster(attacker) and getCreatureName(attacker) == zombie_config.monster_name then
  124. if isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
  125. if #getPlayersInZombieEvent() > 1 then
  126. doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
  127. local corpse = doCreateItem(getPlayerSex(cid) == 1 and 3058 or 6081, 1, getPlayerPosition(cid))
  128. doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
  129. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  130. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  131. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  132. if #getPlayersInZombieEvent() == 1 then
  133. local winner = getPlayersInZombieEvent()[1]
  134. doBroadcastMessage(getCreatureName(winner)..' has survived at zombie event!')
  135. local goblet = doPlayerAddItem(winner, zombie_config.rewards.trophy, 1)
  136. doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(winner) .. " for winning the Zombie event.")
  137. getZombieRewards(winner, zombie_config.rewards.items)
  138. doTeleportThing(winner, getTownTemplePosition(getPlayerTown(winner)), false)
  139. doSendMagicEffect(getPlayerPosition(winner), CONST_ME_TELEPORT)
  140. doBroadcastMessage(getPlayerName(winner).." won the Zombie event! Congratulations!")
  141. HaveCreatureZombie(zombie_config.arena, true)
  142. ZerarStoragesZombie()
  143. end
  144. else
  145. doBroadcastMessage("No one survived in the Zombie Event.", MESSAGE_EVENT_ADVANCE)
  146. HaveCreatureZombie(zombie_config.arena, true)
  147. ZerarStoragesZombie()
  148. end
  149. return false
  150. end
  151. end
  152. return true]]></event>
  153. <globalevent name="Zombie_Start" interval="60" event="script"><![CDATA[
  154. domodlib('zombie_config')
  155. function onThink(interval, lastExecution)
  156. if zombie_days[os.date("%A")] then
  157. local hrs = tostring(os.date("%X")):sub(1, 5)
  158. if isInArray(zombie_days[os.date("%A")], hrs) and getGlobalStorageValue(zombie_config.storages[3]) <= 0 then
  159. local tp = doCreateItem(1387, 1, zombie_config.teleport[1])
  160. doItemSetAttribute(tp, "aid", 45110)
  161. CheckZombieEvent(zombie_config.CheckTime)
  162. setGlobalStorageValue(zombie_config.storages[1], 0)
  163. setGlobalStorageValue(zombie_config.storages[2], 0)
  164. HaveCreatureZombie(zombie_config.arena, true)
  165. end
  166. end
  167. return true
  168. end]]></globalevent>
  169. <event type="login" name="Zombie_Login" event="script"><![CDATA[
  170. domodlib('zombie_config')
  171. function onLogin(cid)
  172. registerCreatureEvent(cid, "ZombieBattle")
  173. registerCreatureEvent(cid, "ZombieStats")
  174. if isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
  175. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  176. end
  177. return true
  178. end]]></event>
  179. <event type="combat" name="ZombieBattle" event="script"><![CDATA[
  180. domodlib('zombie_config')
  181. if isPlayer(cid) and isPlayer(target) and isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
  182. doPlayerSendCancel(cid, "You may not attack this player.") return false
  183. end
  184. return true
  185. ]]></event>
  186. <movevent type="StepIn" actionid ="45110" event="script"><![CDATA[
  187. domodlib('zombie_config')
  188. function onStepIn(cid, item, position, fromPosition)
  189. if not isPlayer(cid) then return true end
  190. if getPlayerAccess(cid) > 3 then return doTeleportThing(cid, zombie_config.teleport[2]) end
  191. if getPlayerLevel(cid) < zombie_config.min_Level then
  192. doTeleportThing(cid, fromPosition, true)
  193. doPlayerSendCancel(cid, "You need to be at least level " .. zombie_config.min_Level .. ".")
  194. doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  195. return true
  196. end
  197. if getGlobalStorageValue(zombie_config.storages[1]) <= zombie_config.players.max then
  198. doTeleportThing(cid, zombie_config.teleport[2])
  199. setGlobalStorageValue(zombie_config.storages[1], getGlobalStorageValue(zombie_config.storages[1])+1)
  200. doBroadcastMessage(getPlayerName(cid) .. " entered the Zombie event! Currently " .. getGlobalStorageValue(zombie_config.storages[1]) .. " players have joined!", MESSAGE_STATUS_CONSOLE_RED)
  201. if getGlobalStorageValue(zombie_config.storages[1]) == zombie_config.players.max then
  202. setGlobalStorageValue(zombie_config.storages[1], getGlobalStorageValue(zombie_config.storages[1])+1)
  203. removeZombieTp()
  204. doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(zombie_config.storages[1])-1 .. " players]! The event will soon start.")
  205. for _, var in pairs(getPlayersInZombieEvent()) do
  206. doPlayerSendTextMessage(var, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. zombie_config.timeToStartEvent .. " seconds! Good luck!")
  207. end
  208. addEvent(spawnZombie, zombie_config.timeToStartEvent*1000)
  209. end
  210. end
  211. return true
  212. end]]></movevent>
  213. <talkaction words="/zombiestart;!zombiestart" access="5" event="buffer"><![CDATA[
  214. domodlib('zombie_config')
  215. if getGlobalStorageValue(zombie_config.storages[3]) > 0 then
  216. doPlayerSendCancel(cid, "The event is already starting.") return true
  217. elseif not param or not tonumber(param) then
  218. doPlayerSendCancel(cid, "Use only numbers.") return true
  219. end
  220. local param = tonumber(param) <= 0 and 1 or tonumber(param)
  221. local tp = doCreateItem(1387, 1, zombie_config.teleport[1])
  222. doItemSetAttribute(tp, "aid", 45110)
  223. CheckZombieEvent(tonumber(param))
  224. ZerarStoragesZombie()
  225. setGlobalStorageValue(zombie_config.storages[3], 1)
  226. HaveCreatureZombie(zombie_config.arena, true)
  227. ]]></talkaction>
  228. <globalevent name="ZombieDebug-Start" type="start" event="buffer"><![CDATA[
  229. domodlib('zombie_config')
  230. ZerarStoragesZombie()
  231. return true]]></globalevent>
  232. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement