Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.66 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <mod name="Ultimate Survival" version="1.0" author="Omega" enabled="yes">
  3. <config name="ultimatelib"><![CDATA[
  4. USurvival = {
  5.     posi = {x=579, y=337, z=14},
  6.    posf = {x=609, y=353, z=14},
  7.    posc = {x=594, y=345, z=14},
  8.    waves = {
  9.    [1] = {monsters = {'dragon', 'dragon lord'}, count = 1, reward = {exp = 0, item = 2148, amount = 1, money = 100}},
  10.    [2] = {monsters = {'dragon lord', 'frost dragon'}, count = 2, reward = {exp = 0, item = 2152, amount = 1, money = 1000}},
  11.    [3] = {monsters = {'hydra', 'serpent spawn'}, count = 3, reward = {exp = 0, item = 2494, amount = 1, money = 10000}},
  12.    },
  13.    exhaust = 1 * 24 * 60 * 60, -- Tempo em segundos até poder entrar novamente na arena (1 * 24 * 60 * 60 = 1 dia)
  14.    final_reward = {item = 2160, amount = 100, exp = 10000, money = 100000},    
  15.   storage_ex = 607069,
  16.   storage_wave = 607089,
  17.   delay = 10 -- 10 segundos entra uma wave e outra
  18. }
  19. SurvivaConfig = {{x = 148, y = 42, z = 6},{x = 148, y = 45, z = 6}} -- pos começo e final ali onde fica a alavanca
  20. function getPlayersOnLevers()
  21. local t = {}
  22.      for _, cid in pairs(getPlayersOnline()) do
  23.          if isInRange(getPlayerPosition(cid), SurvivaConfig[1], SurvivaConfig[2]) then
  24.             t[#t+1] = cid
  25.          end
  26.      end
  27. return t
  28. end
  29. function isWalkable(pos)-- by Nord / editado por Omega
  30.    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then
  31.        return false
  32.    elseif isCreature(getTopCreature(pos).uid) then
  33.        return false
  34.    elseif getTileInfo(pos).protection then
  35.        return false
  36.    elseif hasProperty(getThingFromPos(pos).uid, 3) or hasProperty(getThingFromPos(pos).uid, 7) then
  37.        return false
  38.    end
  39. return true
  40. end
  41. function doSpawnMonsters(monsters, pos, radius, limit)
  42.    if not pos.x or not pos.y or not pos.z or not type(monsters) == 'table' then
  43.        return false
  44.    end
  45.        local radius = tonumber(radius)
  46.    if radius > 5 then
  47.        radius = 5
  48.    elseif radius < 2 then
  49.        radius = 2
  50.    end
  51.    if not limit or limit < 1 then
  52.        limit = 1
  53.    elseif limit > radius ^ 2 then
  54.        limit = math.floor((radius*1.5) ^ 2)
  55.    end  
  56.    local k = 0
  57.    local tries = 0
  58.    repeat
  59.        for x = pos.x - radius, pos.x + radius do
  60.            for y = pos.y - radius, pos.y + radius do
  61.                if isWalkable({x=x, y=y, z=pos.z}) then
  62.                    local monster = monsters[math.random(1, #monsters)]
  63.                    local chance = math.random(1, 100)
  64.                    if k == limit then
  65.                        break
  66.                    elseif chance <= 8 and doCreateMonster(monster, {x=x, y=y, z=pos.z}) then
  67.                        k = k + 1
  68.                    end
  69.                end
  70.            end
  71.        end
  72.        tries = tries + 1
  73.    until k >= limit or tries >= 500
  74.    return k >= limit and true or false
  75. end
  76. function getPlayersInArea(pos1,pos2)
  77.    local players = {}
  78.    if pos1.x and pos1.y and pos2.x and pos2.y and pos1.z == pos2.z then
  79.        for a = pos1.x, pos2.x do
  80.            for b = pos1.y,pos2.y do
  81.                local pos = {x=a,y=b,z=pos1.z}
  82.                if isPlayer(getTopCreature(pos).uid) then
  83.                    table.insert(players,getTopCreature(pos).uid)
  84.                end
  85.            end
  86.        end
  87.        return players
  88.    else
  89.        return false
  90.    end
  91. end
  92. function getMonstersInArea(pos1,pos2)
  93.    local players = {}
  94.    if pos1.x and pos1.y and pos2.x and pos2.y and pos1.z == pos2.z then
  95.        for a = pos1.x, pos2.x do
  96.            for b = pos1.y,pos2.y do
  97.                local pos = {x=a,y=b,z=pos1.z}
  98.                if isMonster(getTopCreature(pos).uid) then
  99.                    table.insert(players,getTopCreature(pos).uid)
  100.                end
  101.            end
  102.        end
  103.        return players
  104.    else
  105.        return false
  106.    end
  107. end
  108. function doCleanArena()
  109.    local monsters = getMonstersInArea(USurvival.posi, USurvival.posf)
  110.    for _, cid in pairs(monsters) do
  111.        doRemoveCreature(cid)
  112.    end
  113. end
  114. function doStartWave(waveID, delay)
  115. local t = getPlayersInArea(USurvival.posi, USurvival.posf)
  116. if #t > 0 then
  117.    if USurvival.waves[waveID] then
  118.        wave = USurvival.waves[waveID]
  119.        doSpawnMonsters(wave.monsters, USurvival.posc, 1, wave.count)
  120.        addEvent(doStartWave, USurvival.delay*1000, waveID+1)
  121.     for _, cid in pairs(t) do
  122.     setPlayerStorageValue(cid, USurvival.storage_wave, getPlayerStorageValue(cid, USurvival.storage_wave)+1)
  123.     doPlayerSendCancel(cid, 'proxima wave começara em '..USurvival.delay..' segundos, se preparem!.')
  124.     end
  125.    else
  126.    if #getMonstersInArea(USurvival.posi, USurvival.posf) == 0 then
  127.       for _, cid in pairs(t) do
  128.        doPlayerSendTextMessage(cid, 22, 'PARABENS! VOCE CONSEGUIU MATAR TODOS OS MONSTRO A TEMPO!')
  129.                local reward = USurvival.final_reward
  130.                if reward.item then
  131.                    doPlayerAddItem(cid, reward.item, (reward.amount or 1), false)
  132.                end
  133.                if reward.exp then
  134.                    doPlayerAddExp(cid, reward.exp)
  135.                end
  136.                if reward.money then
  137.                    doPlayerAddMoney(cid, reward.money)
  138.                end
  139.                local medal = doPlayerAddItem(cid, 5785, 1, false)
  140.                if medal then
  141.                    doItemSetAttribute(medal, 'description', 'Esta Medalha Foi Ganha Pelo Jogador '..getCreatureName(cid)..' Por Completar O Ultimate Survival.')
  142.                    doItemSetAttribute(medal,'name', 'Ultimate Survival Medal')
  143.                end
  144.                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  145.           end    
  146.     else
  147.        for _, cid in pairs(t) do
  148.            doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
  149.            doRemoveConditions(cid, false)
  150.             doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  151.             doPlayerSendTextMessage(cid, 21, 'Que Pena, voce nao conseguiu ganhar a tempo!')
  152.         local var = getPlayerStorageValue(cid, USurvival.storage_wave)-1
  153.             local reward = USurvival.waves[var].reward
  154.                   if reward.item then
  155.                      doPlayerAddItem(cid, reward.item, reward.amount or 1)
  156.                   end
  157.                   if reward.exp then
  158.                      doPlayerAddExp(cid, reward.exp)
  159.                   end
  160.                   if reward.money then
  161.                      doPlayerAddMoney(cid, reward.money)
  162.                   end
  163.        end
  164.     end
  165.    end
  166. end
  167. end
  168. ]]></config>
  169. <action actionid="4599" event="script" override="yes"><![CDATA[
  170. domodlib('ultimatelib')
  171. function onUse(cid, item)
  172.      if #getPlayersInArea(USurvival.posi, USurvival.posf) > 0 then
  173.         doPlayerSendCancel(cid, 'Alguem Ja Esta Na Arena.')
  174.         doSendMagicEffect(getThingPos(cid), 2) return true        
  175.      elseif #getPlayersOnLevers() == 0 then
  176.         doPlayerSendCancel(cid, 'Um ou mais jogadores precisam estar na posição.')
  177.         doSendMagicEffect(getThingPos(cid), 2) return true          
  178.      end
  179.        for _, pid in pairs(getPlayersOnLevers()) do
  180.                   if not isPlayer(pid) or getPlayerStorageValue(pid, USurvival.storage_ex) - os.time() > 0 then
  181.                      doPlayerSendCancel(cid, 'o jogador '..getPlayerName(pid)..' precisa esperar para ir na arena novamente.') return true
  182.                   end
  183.         end
  184.            doCleanArena()
  185.            addEvent(doStartWave, 10*1000, 1) -- COMEÇA EM 10 SEGUNDOS
  186.            for _, cid in pairs(getPlayersOnLevers()) do
  187.                doTeleportThing(cid, USurvival.posc, false)
  188.                doPlayerSendTextMessage(cid, 21, 'O Ultimate Survival Comecara Em 10 Segundos! Esteja Pronto Para Enfrentar Seu Destino e o tempo de cada wave é de '..USurvival.delay..' segundos')
  189.                setPlayerStorageValue(cid, USurvival.storage_wave, 1)
  190.                setPlayerStorageValue(cid, USurvival.storage_ex, os.time() + USurvival.exhaust)
  191.            end            
  192.            if item.itemid % 2 == 1 then
  193.                doTransformItem(item.uid, item.itemid+1)
  194.            else
  195.                doTransformItem(item.uid, item.itemid-1)
  196.            end
  197.    return true
  198. end
  199. ]]></action>
  200. <event type="login" name="US Login" event="script"><![CDATA[
  201. domodlib('ultimatelib')
  202. function onLogin(cid)
  203.    registerCreatureEvent(cid,'UltimateSurvival2')
  204.    if isInArea(getThingPos(cid), USurvival.posi, USurvival.posf) then
  205.        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  206.        doSendMagicEffect(getThingPos(cid), 10)
  207.    end
  208.    return true
  209. end
  210. ]]></event>
  211. <event type="preparedeath" name="UltimateSurvival2" event="script"><![CDATA[
  212. domodlib('ultimatelib')
  213. function onPrepareDeath(cid, killers)
  214.    if isInArea(getThingPos(cid), USurvival.posi, USurvival.posf) then
  215.        doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
  216.        doRemoveConditions(cid, false)
  217.        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  218.        doPlayerSendTextMessage(cid, 21, 'Que Pena, Voce Nao Podia\'t Derrotar O Ultimate Survival... Melhor sorte da próxima vez.')
  219.        local reward = USurvival.waves[getPlayerStorageValue(cid, USurvival.storage_wave)].reward
  220.        if reward.item then
  221.            doPlayerAddItem(cid, reward.item, reward.amount or 1)
  222.        end
  223.        if reward.exp then
  224.            doPlayerAddExp(cid, reward.exp)
  225.        end
  226.        if reward.money then
  227.            doPlayerAddMoney(cid, reward.money)
  228.        end
  229.        return false
  230.    end
  231.    return true
  232. end
  233. ]]></event>
  234. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement