Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <mod name="Battle Boats" version="1.0" author="" contact="" enabled="yes">
- <description>
- Add this to lib/functions:
- czekaj = coroutine.yield
- function czekanie(c)
- if(coroutine.status(c) ~= 'dead') then
- local _, czas = coroutine.resume(c)
- addEvent(czekanie, czas, c)
- end
- end
- function zacznijCzekac(f)
- if(type(f) == 'function') then
- local c = coroutine.create(f)
- czekanie(c)
- end
- end
- function doPlayerRemoveAllStoragesFromBattleBoats(cid)
- setPlayerStorageValue(cid, 11610, -1)
- setPlayerStorageValue(cid, 11611, -1)
- setPlayerStorageValue(cid, 11612, -1)
- setPlayerStorageValue(cid, 11613, -1)
- setPlayerStorageValue(cid, 11614, -1)
- setPlayerStorageValue(cid, 11616, -1)
- setPlayerStorageValue(cid, 11618, -1)
- setPlayerStorageValue(cid, 11619, -1)
- setPlayerStorageValue(cid, 11620, -1)
- setPlayerStorageValue(cid, 11622, -1)
- end
- function doRemoveAllGlobStoragesFromBattleBoats()
- setGlobalStorageValue(11615, -1)
- setGlobalStorageValue(11617, -1)
- setGlobalStorageValue(11621, -1)
- setGlobalStorageValue(11622, -1)
- setGlobalStorageValue(11623, -1)
- end
- -------------------------------------------
- Add this to login.lua:
- registerCreatureEvent(cid, "BattleKill")
- -------------------------------------------
- [id] = {
- HERE YOU HAVE ALL ITEMS WHICH ARE NEEDED TO THIS EVENT
- }
- [amount] = {
- HERE YOU HAVE ALL AMOUNT OF ITEMS WHICH ARE NEEDED TO THIS EVENT
- }
- [timer] = {
- HERE YOU HAVE TIME AFTER THING WILL STARTS (IN SECONDS!)
- present = for how many seconds (now is 10sec) present will be places on random area
- dragons = for how many seconds (now is 1sec) dragon will be spawned
- startEvent = after how many seconds event will start (now is 60sec)
- blockitems = after how many seconds player be able to use for ex. bomb or ambush (now is 30sec)
- check = for how many seconds (now is 20sec) event will check ready players which are registred in event
- kickout = for how many seconds (now is 60sec) player will be kickout from the event if he didn't come to any of the free boats
- }
- [presents] = {
- HERE YOU MUST PAST POSITIONS WHERE PRESENT CAN FALL FROM THE SKY
- }
- [dragons] = {
- x = {
- HERE YOU MUST PAST POSITIONS "X" - AREA WHERE DRAGON WILL BE SPAWNED. THIS ARE WHERE PRESENT CAN BE CREATED.
- {1024, 1028},
- IT MEANS FROM X TO X, AND YOU MUST SET NOW IN POSITION "Y", HERE:
- {196, 200},
- }
- y = {
- HERE YOU MUST PAST POSITIONS "Y" - AREA WHERE DRAGON WILL BE SPAWNED. THIS ARE WHERE PRESENT CAN BE CREATED.
- {196, 200},
- IT MEANS FROM Y TO Y, AND YOU MUST SET NOW IN POSITION "X", HERE:
- {1024, 1028},
- }
- }
- start = STORAGE,
- plynie = STORAGE,
- strona = STORAGE,
- palenie = STORAGE,
- stop = STORAGE,
- smok = STORAGE,
- zapisany = STORAGE,
- playersCount = STORAGE,
- gotowy = STORAGE,
- gotowy_e = STORAGE,
- gotowy_w = STORAGE,
- blockbomb = STORAGE,
- zakonczone = STORAGE,
- wystartowal = STORAGE,
- startPosition = POSITION WHERE PLAYER WILL BE TELEPORTED AFTER JOINING TO THE EVENT,
- playersNeededToStartEvent = HOW MANY PLAYERS IS NEEDED TO START EVENT,
- max = MAX OF THE PLAYER WHICH CAN JOIN TO THE EVENT,
- przeszkoda = IF THE BOAT COLLIDER WITH THIS ID OF ITEMS WILL STARTS TO BURN,
- rewardsId = ITEMS OD IDS WHICH PLAYER CAN REACH AFTER WINNING EVENT,
- crystal_counts = IF REWARD = 2160 (CRYSTAL COINS) THEN HERE YOU MUST SET AMOUNT OF CC,
- speed = DON'T SET IT!,
- waters = ID OF WATERS WHERE PLAYER CAN USE BOMB OR AMBUSH
- </description>
- <config name="q"><![CDATA[
- q = {
- start = 11610,
- plynie = 11611,
- strona = 11612,
- palenie = 11613,
- stop = 11614,
- smok = 11615,
- zapisany = 11616,
- playersCount = 11617,
- gotowy = 11618,
- gotowy_e = 11619,
- gotowy_w = 11620,
- blockbomb = 11621,
- zakonczone = 11622,
- wystartowal = 11623,
- startPosition = {x = 1753, y = 1002, z = 7},
- playersNeededToStartEvent = 2,
- max = 10,
- przeszkoda = {3330, 3332, 3331, 3333, 7575, 7576, 7577, 7578, 7579, 7580, 7581, 3587, 3589, 3591, 3592, 3594, 3596},
- rewardsId = {2160, 2148, 2000, 2195},
- crystal_counts = 50,
- speed = 1000,
- waters = {4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825},
- i = {
- id = {
- present = 9074,
- backpack = 1988,
- bomb = 5468,
- ambush = 7496,
- aid_kit = 6105
- },
- amount = {
- bomb = 3,
- ambush = 2,
- aid_kit = 1
- },
- timer = {
- present = 20,
- dragons = 1,
- startEvent = 60,
- blockitems = 30,
- check = 20,
- kickout = 60
- },
- presents = {
- {x = 1731, y = 1015, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1725, y = 1004, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1721, y = 1000, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1741, y = 990, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1726, y = 979, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1718, y = 973, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1754, y = 973, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1738, y = 963, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1727, y = 943, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1751, y = 938, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1767, y = 954, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1768, y = 988, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1782, y = 988, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
- {x = 1776, y = 1017, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE}
- },
- dragons = {
- x = {
- {1725, 1728},
- {1749, 1752},
- {1766, 1769},
- {1737, 1740},
- {1753, 1756},
- {1716, 1719},
- {1724, 1727},
- {1766, 1769},
- {1781, 1784},
- {1740, 1743},
- {1719, 1722},
- {1723, 1726},
- {1730, 1733},
- {1774, 1777}
- },
- y = {
- {941, 944},
- {936, 939},
- {952, 955},
- {961, 964},
- {971, 974},
- {972, 975},
- {978, 981},
- {986, 989},
- {987, 990},
- {989, 992},
- {999, 1002},
- {1003, 1006},
- {1014, 1017},
- {1011, 1014}
- },
- },
- }
- }
- ]]></config>
- <movevent type="StepIn" actionid="9049" event="script"><![CDATA[
- domodlib('q')
- function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
- if getPlayerStorageValue(cid, q.zapisany) == 1 then
- if getPlayerStorageValue(cid, q.gotowy_e) == 1 then
- doMoveCreature(cid, WEST)
- elseif getPlayerStorageValue(cid, q.gotowy_w) == 1 then
- doMoveCreature(cid, EAST)
- return true
- end
- return true
- end
- return true
- end
- ]]></movevent>
- <movevent type="StepIn" actionid="9050" event="script"><![CDATA[
- domodlib('q')
- function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
- if getPlayerStorageValue(cid, q.zapisany) == 1 then
- if getPlayerStorageValue(cid, q.zakonczone) == 1 then
- if isPlayer(getTopCreature({x = getCreaturePosition(cid).x + 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}).uid) == false then
- if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from helmet place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from neclace place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from backpack place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from armor place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from left hand.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from right hand.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from legs place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from feet place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ring place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ammo place.")
- doTeleportThing(cid, fromPosition)
- else
- doCleanTile({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x + 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x + 2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x + 3, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_WATERSPLASH)
- doMoveCreature(cid, EAST)
- doCreatureSetNoMove(cid, true)
- setPlayerStorageValue(cid, q.gotowy_e, 1)
- setPlayerStorageValue(cid, q.gotowy, 1)
- setGlobalStorageValue(q.gotowy, getGlobalStorageValue(q.gotowy)+1)
- doPlayerSendTextMessage(cid, 4, "Congratulations, you are ready to take part in Battle Boats.")
- doPlayerPopupFYI(cid, "[Battle Boats]\n- Your task is to avoid obstacles, dangerous dragons, killing peoples and marine surprises survive.\n\nCommands to use ship:\n!swim go - ship start swim,\n!swim stop - ship stop swim,\n!swim up - direction set to north,\n!swim down - direction set to south,\n!swim left - direction set to west,\n!swim right - direction set to east,\n!swim fast - your boat will swim faster,\n!swim slow - your boat will swim slower.") return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "This boat is occupied by someone else.")
- doTeleportThing(cid, fromPosition)
- return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "Prepare to send your full equipment to your deposit. After registration you will can boat ride.")
- doTeleportThing(cid, fromPosition)
- return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "You didn't sign up for the competition, you are not allowed to move on!")
- doTeleportThing(cid, fromPosition)
- return true
- end
- end
- ]]></movevent>
- <movevent type="StepIn" actionid="9051" event="script"><![CDATA[
- domodlib('q')
- function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
- if getPlayerStorageValue(cid, q.zapisany) == 1 then
- if getPlayerStorageValue(cid, q.zakonczone) == 1 then
- if isPlayer(getTopCreature({x = getCreaturePosition(cid).x - 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}).uid) == false then
- if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from helmet place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from neclace place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from backpack place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from armor place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from left hand.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from right hand.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from legs place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from feet place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ring place.")
- doTeleportThing(cid, fromPosition)
- elseif getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ammo place.")
- doTeleportThing(cid, fromPosition)
- else
- doCleanTile({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x - 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x - 2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doCleanTile({x = getCreaturePosition(cid).x - 3, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_WATERSPLASH)
- doPlayerSendTextMessage(cid, 4, "Congratulations, you are ready to take part in Battle Boats.")
- doMoveCreature(cid, WEST)
- doCreatureSetNoMove(cid, true)
- setPlayerStorageValue(cid, q.gotowy_w, 1)
- setPlayerStorageValue(cid, q.gotowy, 1)
- setGlobalStorageValue(q.gotowy, getGlobalStorageValue(q.gotowy)+1)
- doPlayerPopupFYI(cid, "[Battle Boats]\n- Your task is to avoid obstacles, dangerous dragons, killing peoples and marine surprises survive.\n\nCommands to use ship:\n!swim go - ship start swim,\n!swim stop - ship stop swim,\n!swim up - direction set to north,\n!swim down - direction set to south,\n!swim left - direction set to west,\n!swim right - direction set to east,\n!swim fast - your boat will swim faster,\n!swim slow - your boat will swim slower.")
- return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "This boat is occupied by someone else.")
- doTeleportThing(cid, fromPosition)
- return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "Prepare to send your full equipment to your deposit. After registration you will can boat ride.")
- doTeleportThing(cid, fromPosition)
- return true
- end
- else
- doPlayerSendTextMessage(cid, 4, "You didn't sign up for the competition, you are not allowed to move on!")
- doTeleportThing(cid, fromPosition)
- return true
- end
- end
- ]]></movevent>
- <action itemid="7496" event="script" allowfaruse="1"><![CDATA[
- domodlib('q')
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local exhaust = {
- storage = 7971,
- duration = 2
- }
- local l = {
- [NORTH] = {3587,3589,3591},
- [SOUTH] = {3591,3589,3587},
- [WEST] = {3592,3594,3596},
- [EAST] = {3596,3594,3592}
- }
- if(not isInArray(q.waters, itemEx.itemid)) then
- doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
- return true
- end
- if(getPlayerStorageValue(cid, q.start) ~= 1) then
- doPlayerSendCancel(cid, "You cannot use this object.")
- return true
- end
- if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) < exhaust.duration then
- doPlayerSendCancel(cid, "You are exhausted.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == -1 then
- doPlayerSendCancel(cid, "You cannot use this object.")
- elseif getGlobalStorageValue(q.blockbomb) >= 1 then
- doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == 0 then
- exhaustion.set(cid, exhaust.storage, exhaust.duration)
- zacznijCzekac(function()
- doRemoveItem(item.uid, 1)
- doSendDistanceShoot({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, toPosition, 35)
- doSendAnimatedText(toPosition, "3", TEXTCOLOR_LIGHTBLUE)
- doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
- czekaj(1000)
- doSendAnimatedText(toPosition, "2", TEXTCOLOR_LIGHTBLUE)
- doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
- czekaj(1000)
- doSendAnimatedText(toPosition, "1", TEXTCOLOR_LIGHTBLUE)
- doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
- czekaj(1000)
- local szansa = math.random(1, 50)
- local odglos = {"GRRROAR!", "Zchhhhhh!", "Grooaaaaar", "Aaa... CHOO!", "You... will be.... eaten!!"}
- local losowy = math.random(1, table.maxn(odglos))
- doCreatureSay(cid, odglos[losowy], TALKTYPE_MONSTER, false, 0, toPosition)
- doSendMagicEffect(toPosition, CONST_ME_WATERCREATURE)
- local list = getSpectators(toPosition, 1, 1, false) or {}
- if #list > 0 then
- for _, creature in pairs(list) do
- if isPlayer(creature) and getPlayerStorageValue(creature, q.zapisany) == 1 and (getPlayerStorageValue(creature, q.gotowy_e) == 1 or getPlayerStorageValue(creature, q.gotowy_w) == 1) then
- if(szansa < 26) then
- setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
- doSendMagicEffect(getCreaturePosition(creature), 53)
- doCreatureAddHealth(creature, (-getCreatureMaxHealth(creature))+1)
- addEvent(function()
- doCreatureAddHealth(creature, getCreatureMaxHealth(creature))
- stopEvent(plyn)
- if getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y+i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x-i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- end
- doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), false)
- doSendMagicEffect(getPlayerPosition(creature), CONST_ME_TELEPORT)
- if getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid, 1)
- end
- doPlayerRemoveAllStoragesFromBattleBoats(creature)
- doPlayerSendTextMessage(creature, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
- doBroadcastMessage("".. getCreatureName(creature) .." has been eaten by Water Dragon, he end his voyage.", 22)
- end, 1000)
- elseif(szansa >= 25) then
- doSendMagicEffect(getCreaturePosition(creature), 53)
- doPlayerSendTextMessage(creature, 4, "It's unbelievable, you have managed to survive the start of the sea monster!")
- end
- elseif isMonster(creature) then
- doRemoveCreature(creature)
- end
- end
- end
- end)
- end
- return true
- end
- ]]></action>
- <action itemid="5468" event="script" allowfaruse="1"><![CDATA[
- domodlib('q')
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local exhaust = {
- storage = 7972,
- duration = 2
- }
- local uderzenie = {1, 2, 3}
- local random = math.random(1, table.maxn(uderzenie))
- local pozycja1 = {x = toPosition.x, y = toPosition.y-1, z = toPosition.z}
- local pozycja2 = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z}
- local pozycja3 = {x = toPosition.x-1, y = toPosition.y, z = toPosition.z}
- local pozycja4 = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z}
- if(not isInArray(q.waters, itemEx.itemid)) then
- doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
- return true
- end
- if(getPlayerStorageValue(cid, q.start) ~= 1) then
- doPlayerSendCancel(cid, "You cannot use this object.")
- return true
- end
- if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) < exhaust.duration then
- doPlayerSendCancel(cid, "You are exhausted.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == -1 then
- doPlayerSendCancel(cid, "You cannot use this object.")
- elseif getGlobalStorageValue(q.blockbomb) >= 1 then
- doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == 0 then
- exhaustion.set(cid, exhaust.storage, exhaust.duration)
- doSendDistanceShoot({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, toPosition, CONST_ANI_FIRE)
- if(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 1) then
- doSendMagicEffect(toPosition, CONST_ME_EXPLOSIONHIT)
- doSendMagicEffect(pozycja1, CONST_ME_EXPLOSIONHIT)
- doSendMagicEffect(pozycja2, CONST_ME_EXPLOSIONHIT)
- doSendMagicEffect(pozycja4, CONST_ME_EXPLOSIONHIT)
- doSendMagicEffect(pozycja3, CONST_ME_EXPLOSIONHIT)
- doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
- if isPlayer(getTopCreature(toPosition).uid) then
- local obrazenia1a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/5)
- doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/5))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1a .. " damage.")
- elseif isPlayer(getTopCreature(pozycja1).uid) then
- local obrazenia1b = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/5)
- doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/5))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1b .. " damage.")
- elseif isPlayer(getTopCreature(pozycja2).uid) then
- local obrazenia1c = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/5)
- doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/5))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1c .. " damage.")
- elseif isPlayer(getTopCreature(pozycja4).uid) then
- local obrazenia1d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/5)
- doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/5))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1d .. " damage.")
- elseif isPlayer(getTopCreature(pozycja3).uid) then
- local obrazenia1e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/5)
- doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/5))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1e .. " damage.")
- end
- doRemoveItem(item.uid, 1)
- elseif(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 2) then
- doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
- doSendMagicEffect(pozycja1, CONST_ME_HITBYFIRE)
- doSendMagicEffect(pozycja2, CONST_ME_HITBYFIRE)
- doSendMagicEffect(pozycja4, CONST_ME_HITBYFIRE)
- doSendMagicEffect(pozycja3, CONST_ME_HITBYFIRE)
- doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
- if isPlayer(getTopCreature(toPosition).uid) then
- local obrazenia2a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/4)
- doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/4))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2a .. " damage.")
- elseif isPlayer(getTopCreature(pozycja1).uid) then
- local obrazenia2c = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/4)
- doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/4))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2b .. " damage.")
- elseif isPlayer(getTopCreature(pozycja2).uid) then
- local obrazenia2b = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/4)
- doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/4))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2c .. " damage.")
- elseif isPlayer(getTopCreature(pozycja4).uid) then
- local obrazenia2d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/4)
- doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/4))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2d .. " damage.")
- elseif isPlayer(getTopCreature(pozycja3).uid) then
- local obrazenia2e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/4)
- doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/4))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2e .. " damage.")
- end
- doRemoveItem(item.uid, 1)
- elseif(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 3) then
- doSendMagicEffect(toPosition, CONST_ME_FIREAREA)
- doSendMagicEffect(pozycja1, CONST_ME_FIREAREA)
- doSendMagicEffect(pozycja2, CONST_ME_FIREAREA)
- doSendMagicEffect(pozycja4, CONST_ME_FIREAREA)
- doSendMagicEffect(pozycja3, CONST_ME_FIREAREA)
- doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
- if isPlayer(getTopCreature(toPosition).uid) then
- local obrazenia3a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/3)
- doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/3))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3a .. " damage!")
- elseif isPlayer(getTopCreature(pozycja1).uid) then
- local obrazenia3b = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/3)
- doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/3))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3b .. " damage!")
- elseif isPlayer(getTopCreature(pozycja2).uid) then
- local obrazenia3c = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/3)
- doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/3))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3c .. " damage!")
- elseif isPlayer(getTopCreature(pozycja4).uid) then
- local obrazenia3d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/3)
- doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/3))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3d .. " damage!")
- elseif isPlayer(getTopCreature(pozycja3).uid) then
- local obrazenia3e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/3)
- doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/3))
- doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3e .. " damage!")
- end
- doRemoveItem(item.uid, 1)
- else
- doPlayerSendCancel(cid, "Your bomb has been destroyed in water cause you failed with locate purpose.")
- doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
- doSendMagicEffect(pozycja1, CONST_ME_LOSEENERGY)
- doSendMagicEffect(pozycja2, CONST_ME_LOSEENERGY)
- doSendMagicEffect(pozycja4, CONST_ME_LOSEENERGY)
- doSendMagicEffect(pozycja3, CONST_ME_LOSEENERGY)
- local gdzie = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 255}
- doCreateItem(7109, 1, gdzie)
- doRemoveItem(item.uid, 1)
- addEvent(function()
- doRemoveItem(getTileItemById(gdzie, 7109).uid, 1)
- end, 2500)
- return true
- end
- end
- return true
- end
- ]]></action>
- <action itemid="9074" event="script"><![CDATA[
- domodlib('q')
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local items = {q.i.id[3], q.i.id[4], q.i.id[5], 0}
- local amount = {1, 2}
- local random_item = items[math.random(1, #items)]
- local item_name = getItemNameById(random_item)
- local random_amount = amount[math.random(1, #amount)]
- if(random_item == 0) then
- doCreatureAddHealth(cid, -(math.random(20,100)))
- doSendMagicEffect(pozycja1, CONST_ME_EXPLOSIONHIT)
- doPlayerSendTextMessage(cid, 4, "It was a trap! Present box gave you fire!")
- else
- doPlayerAddItem(cid, random_item, random_amount)
- doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
- doPlayerSendTextMessage(cid, 4, "Present box gave you ".. random_amount .."x of ".. item_name ..".")
- end
- return true
- end
- ]]></action>
- <action itemid="6105" event="script"><![CDATA[
- domodlib('q')
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local exhaust = {
- storage = 7973,
- duration = 2
- }
- if(getPlayerStorageValue(cid, q.start) ~= 1) then
- doPlayerSendCancel(cid, "You cannot use this object.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == -1 then
- doPlayerSendCancel(cid, "You cannot use this object.")
- elseif getGlobalStorageValue(q.blockbomb) >= 1 then
- doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
- return true
- end
- if getGlobalStorageValue(q.blockbomb) == 0 then
- if(getPlayerStorageValue(cid, q.start) == 1) then
- if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) >= exhaust.duration then
- exhaustion.set(cid, exhaust.storage, exhaust.duration)
- if getCreatureHealth(cid) == getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) == -1 then
- doPlayerSendCancel(cid, "You don't need first aid kits.")
- elseif getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) == -1 then
- doCreatureAddHealth(cid, (getCreatureMaxHealth(cid)/2))
- doPlayerSendCancel(cid, "You have healed your character, +50% of the maximum life.")
- doRemoveItem(item.uid, 1)
- elseif getCreatureHealth(cid) == getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) > -1 then
- setPlayerStorageValue(cid, q.palenie, -1)
- doPlayerSendCancel(cid, "Your boat has been repaired, now is fully operational.")
- doRemoveItem(item.uid, 1)
- elseif getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) > -1 then
- setPlayerStorageValue(cid, q.palenie, tonumber(getPlayerStorageValue(cid, q.palenie))-1)
- doCreatureAddHealth(cid, (getCreatureMaxHealth(cid)/3))
- doPlayerSendCancel(cid, "You have healed your character, +33% of the maximum life and your boat has been repaired, now is almost fully operational.")
- doRemoveItem(item.uid, 1)
- return true
- end
- else
- doPlayerSendCancel(cid, "You are exhausted.")
- return true
- end
- else
- doPlayerSendCancel(cid, "You cannot use this object.")
- return true
- end
- end
- return true
- end
- ]]></action>
- <globalevent name="BattleBoatsStart" interval="3000" event="script"><![CDATA[
- domodlib('q')
- function onThink(interval, lastExecution, thinkInterval)
- if getGlobalStorageValue(q.start) == 1 then
- for _, pid in ipairs(getPlayersOnline()) do
- if getPlayerStorageValue(pid, q.gotowy) == 1 then
- doSendAnimatedText(getCreaturePosition(pid), "I'M READY", TEXTCOLOR_LIGHTBLUE)
- end
- end
- return true
- end
- return true
- end
- ]]></globalevent>
- <talkaction words="!boat" event="script"><![CDATA[
- domodlib('q')
- function onSay(cid, words, param, channel)
- if getGlobalStorageValue(q.start) == 1 and getGlobalStorageValue(q.zakonczone) ~= 1 then
- if getPlayerStorageValue(cid, q.zapisany) == -1 then
- if getTilePzInfo(getPlayerPosition(cid)) == true then
- if getGlobalStorageValue(q.playersCount) < q.max then
- setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)+1)
- if getGlobalStorageValue(q.playersCount) == q.max then
- doPlayerSendCancel(cid, "Amount of participants is full.")
- else
- doBroadcastMessage("" .. getPlayerName(cid) .. " has been joined to Battle Boats! Actually we have: " .. getGlobalStorageValue(q.playersCount) .. " players!", 19)
- end
- setPlayerStorageValue(cid, q.zapisany, 1)
- doTeleportThing(cid, q.startPosition)
- doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
- else
- doPlayerSendCancel(cid, "Battle Boats is full.")
- return true
- end
- else
- doPlayerSendCancel(cid, "You must be in protection zone to participate in the event.")
- return true
- end
- else
- doPlayerSendCancel(cid, "You are already registered in this event.")
- return true
- end
- else
- doPlayerSendCancel(cid, "At the moment there are no records for this event.")
- return true
- end
- return true
- end
- ]]></talkaction>
- <talkaction words="!start_boat" event="script"><![CDATA[
- domodlib('q')
- function checkAgain()
- if getGlobalStorageValue(q.playersCount) < q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
- doBroadcastMessage("[Battle Boats]\nEvent won't start bacause too few people were willing to participate!")
- doRemoveAllGlobStoragesFromBattleBoats()
- for _, pid in ipairs(getPlayersOnline()) do
- if(getPlayerStorageValue(pid, q.zapisany) == 1) then
- if getPlayerStorageValue(pid, q.playerCount) > 0 then
- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
- doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
- doPlayerRemoveAllStoragesFromBattleBoats(pid)
- end
- end
- end
- end
- return true
- end
- function startEventBoats(cid)
- if getGlobalStorageValue(q.playersCount) >= q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
- addEvent(check, q.i.timer.check * 1000, cid)
- doBroadcastMessage("[Battle Boats]\nRegistration is completed! Preparations for the event!", 22)
- setGlobalStorageValue(q.zakonczone, 1)
- for _, pid in ipairs(getPlayersOnline()) do
- if(getPlayerStorageValue(pid, q.zapisany) == 1) then
- setPlayerStorageValue(pid, q.zakonczone, 1)
- local parcel = doPlayerAddItem(pid, 2595, 1)
- doAddContainerItem(parcel, 2599, 1)
- doPlayerSendTextMessage(pid, 4, "You have received parcel, pack your all equipment (including BP) to it and send it to your city. Then go over to one of 11 boats.")
- addEvent(function(pid)
- if isPlayer(pid) and getPlayerStorageValue(pid, q.zapisany) == 1 and getPlayerStorageValue(pid, q.gotowy_e) ~= 1 and getPlayerStorageValue(pid, q.gotowy_w) ~= 1 then
- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
- doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
- doPlayerSendTextMessage(pid, 4, "You has been kick out form the event cause waiting time has passed for you.")
- doPlayerRemoveAllStoragesFromBattleBoats(pid)
- setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
- end
- addEvent(checkAgain, q.i.timer.kickout * 1000)
- end, q.i.timer.kickout * 1000, pid)
- end
- end
- elseif getGlobalStorageValue(q.playersCount) < q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
- doBroadcastMessage("[Battle Boats]\nEvent won't start bacause too few people were willing to participate!")
- doRemoveAllGlobStoragesFromBattleBoats()
- for _, pid in ipairs(getPlayersOnline()) do
- if getPlayerStorageValue(pid, q.playerCount) > 0 then
- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
- doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
- doPlayerRemoveAllStoragesFromBattleBoats(pid)
- end
- end
- end
- return true
- end
- function check(cid)
- local l = {
- [NORTH] = {3587,3589,3591},
- [SOUTH] = {3591,3589,3587},
- [WEST] = {3592,3594,3596},
- [EAST] = {3596,3594,3592}
- }
- zacznijCzekac(function()
- if getGlobalStorageValue(q.gotowy) < getGlobalStorageValue(q.playersCount) then
- for _, pid in ipairs(getPlayersOnline()) do
- if getPlayerStorageValue(pid, q.gotowy) == 1 then
- doPlayerSendTextMessage(pid, 4, "Event will start for few seconds, we are waiting for all participants (" .. getGlobalStorageValue(q.gotowy) .. "/".. getGlobalStorageValue(q.playersCount) ..").")
- end
- end
- addEvent(check, q.i.timer.check * 1000, cid)
- elseif getGlobalStorageValue(q.gotowy) >= getGlobalStorageValue(q.playersCount) then
- setGlobalStorageValue(q.blockbomb, 30)
- setGlobalStorageValue(q.wystartowal, 1)
- zacznijCzekac(function()
- for i = 1, q.i.timer.blockitems do
- if getGlobalStorageValue(q.blockbomb) > 0 then
- setGlobalStorageValue(q.blockbomb, getGlobalStorageValue(q.blockbomb)-1)
- elseif getGlobalStorageValue(q.blockbomb) == 0 then
- return true
- end
- czekaj(1000)
- end
- end)
- for _, pid in ipairs(getPlayersOnline()) do
- if getPlayerStorageValue(pid, q.zapisany) == 1 then
- if getPlayerStorageValue(pid, q.gotowy_e) == 1 then
- local poz = getCreaturePosition(pid)
- local bp = doPlayerAddItem(pid, q.i.id.backpack, 1)
- doAddContainerItem(bp, q.i.id.bomb, q.i.amount.bomb)
- doAddContainerItem(bp, q.i.id.ambush, q.i.amount.ambush)
- doAddContainerItem(bp, q.i.id.aid_kit, q.i.amount.aid_kit)
- doPlayerSendTextMessage(pid, 4, "Event will start for 5 seconds, system automatically takes you to the arena.")
- local exhaust = createConditionObject(CONDITION_EXHAUST)
- setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
- doAddCondition(pid, exhaust)
- doMoveCreature(pid, EAST)
- doMoveCreature(pid, SOUTH)
- doCreatureSetLookDirection(pid, 1)
- setPlayerStorageValue(pid, q.gotowy, 0)
- czekaj(5000)
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreatureSetLookDirection(pid, 1)
- end
- doTeleportThing(pid, {x = poz.x + 6, y = poz.y + 1, z = poz.z})
- for n = 1, 3 do
- local i = n - 2
- doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z})
- doCreatureSetLookDirection(pid, 1)
- end
- doCreatureSay(pid, "Good luck!", TALKTYPE_ORANGE_1)
- setPlayerStorageValue(pid, q.start, 1)
- setPlayerStorageValue(pid, q.strona, 1)
- doPlayerSendTextMessage(pid, 4, "Good luck! Event finally started!\n30 seconds of protection!")
- elseif getPlayerStorageValue(pid, q.gotowy_w) == 1 then
- local poz = getCreaturePosition(pid)
- local bp = doPlayerAddItem(pid, q.i.id.backpack, 1)
- doAddContainerItem(bp, q.i.id.bomb, q.i.amount.bomb)
- doAddContainerItem(bp, q.i.id.ambush, q.i.amount.ambush)
- doAddContainerItem(bp, q.i.id.aid_kit, q.i.amount.aid_kit)
- doPlayerSendTextMessage(pid, 4, "Event will start for 5 seconds, system automatically takes you to the arena.")
- local exhaust = createConditionObject(CONDITION_EXHAUST)
- setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
- doAddCondition(pid, exhaust)
- doMoveCreature(pid, WEST)
- doMoveCreature(pid, SOUTH)
- doCreatureSetLookDirection(pid, 3)
- setPlayerStorageValue(pid, q.gotowy, 0)
- czekaj(5000)
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreatureSetLookDirection(pid, 3)
- end
- doTeleportThing(pid, {x = poz.x - 7, y = poz.y + 1, z = poz.z})
- for n = 1, 3 do
- local i = n - 2
- doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z})
- doCreatureSetLookDirection(pid, 3)
- end
- doCreatureSay(pid, "Good luck!", TALKTYPE_ORANGE_1)
- setPlayerStorageValue(pid, q.start, 1)
- setPlayerStorageValue(pid, q.strona, 2)
- doPlayerSendTextMessage(pid, 4, "Good luck! Event finally started!\n30 seconds of protection!")
- end
- end
- end
- addEvent(postawPrezent, q.i.timer.present * 1000)
- addEvent(sprawdzIlosc, 1000)
- addEvent(doBroadcastMessage, 11000, "[Battle Boats]\nThe event has been started! Enjoy and have fun!", 22)
- return true
- end
- end)
- return true
- end
- function sprawdzIlosc()
- local l = {
- [NORTH] = {3587,3589,3591},
- [SOUTH] = {3591,3589,3587},
- [WEST] = {3592,3594,3596},
- [EAST] = {3596,3594,3592}
- }
- if getGlobalStorageValue(q.wystartowal) == 1 then
- if getGlobalStorageValue(q.playersCount) == 1 then
- addEvent(function()
- for _, pid in ipairs(getPlayersOnline()) do
- if isPlayer(pid) and getPlayerStorageValue(pid, q.zapisany) == 1 and (getPlayerStorageValue(pid, q.gotowy_e) == 1 or getPlayerStorageValue(pid, q.gotowy_w) == 1) then
- if getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y+i, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x+i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y-i, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- end
- end
- doPlayerRemoveAllStoragesFromBattleBoats(pid)
- doPlayerSendTextMessage(pid, 4, "Thanks for using Battle Boats. You have won Battle Boats.")
- doBroadcastMessage("Congratulations! ".. getCreatureName(pid) .." won Battle Boats!", 22)
- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
- doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
- if getPlayerSlotItem(pid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(pid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(pid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid, 1)
- end
- doRemoveAllGlobStoragesFromBattleBoats()
- local random_item = q.rewardsId[math.random(1, #q.rewardsId)]
- local item_name = getItemNameById(random_item)
- if(random_item == 2160) then
- doPlayerAddItem(pid, random_item, q.crystal_counts)
- doPlayerSendTextMessage(pid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. q.crystal_counts .." ".. item_name .."s!")
- else
- doPlayerAddItem(pid, random_item, 1)
- doPlayerSendTextMessage(pid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. item_name .."!")
- end
- return true
- end
- end
- end, 2000)
- elseif getGlobalStorageValue(q.playersCount) == 0 then
- doBroadcastMessage("Battle Boats has been end!")
- doRemoveAllGlobStoragesFromBattleBoats()
- else
- addEvent(sprawdzIlosc, 1000)
- return true
- end
- end
- end
- function postawPrezent()
- local random = math.random(1, table.maxn(q.i.presents))
- if getGlobalStorageValue(q.playersCount) > 1 and getGlobalStorageValue(q.wystartowal) == 1 then
- doSendDistanceShoot({x = q.i.presents[random].x - 7, y = q.i.presents[random].y - 5, z = q.i.presents[random].z}, q.i.presents[random], 35)
- addEvent(function()
- doSendMagicEffect(q.i.presents[random], CONST_ME_WATERSPLASH)
- doCreateItem(q.i.id.present, 1, q.i.presents[random])
- end, 150)
- for _, pid in ipairs(getPlayersOnline()) do
- if getPlayerStorageValue(pid, start) == 1 then
- doPlayerSendTextMessage(pid, 4, "Suprise package fell from the sky on a nearby Island, watch out for dragons flying alongside a package!")
- end
- end
- addEvent(postawPrezent, q.i.timer.present * 1000)
- return true
- end
- end
- function onSay(cid, words, param, channel)
- doBroadcastMessage("We invite everyone to attend the Battle Boats! Event will start for ".. q.i.timer.startEvent/60 .." minutes! If you are willing to participate, type the command !boat", 22)
- setGlobalStorageValue(q.playersCount, 0)
- setGlobalStorageValue(q.gotowy, 0)
- setGlobalStorageValue(q.start, 1)
- addEvent(startEventBoats, q.i.timer.startEvent * 1000, cid)
- return true
- end
- ]]></talkaction>
- <talkaction words="!swim" event="script"><![CDATA[
- domodlib('q')
- local l = {
- [NORTH] = {3587,3589,3591},
- [SOUTH] = {3591,3589,3587},
- [WEST] = {3592,3594,3596},
- [EAST] = {3596,3594,3592}
- }
- function smoki()
- local rand = math.random(1, #q.i.dragons.x)
- local pos = {x = math.random(q.i.dragons.x[rand][1], q.i.dragons.x[rand][2]), y = math.random(q.i.dragons.y[rand][1], q.i.dragons.y[rand][2]), z = 7, stackpos = 253}
- local szansa = math.random(1, 75)
- doSendMagicEffect(pos, CONST_ME_WATERCREATURE)
- local list = getSpectators(pos, 1, 1, false) or {}
- if #list > 0 then
- for _, creature in pairs(list) do
- if isPlayer(creature) then
- if(szansa < 26) then
- setGlobalStorageValue(smok, 0)
- doSendMagicEffect(getCreaturePosition(creature), 53)
- doCreatureAddHealth(creature, -getCreatureMaxHealth(creature))
- addEvent(function()
- doCreatureAddHealth(creature, getCreatureMaxHealth(creature))
- stopEvent(plyn)
- if getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[NORTH][2] then
- for n = 1, 3 do
- local i = n - 2
- local kawalek = {x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
- local ppos = {x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
- local lodz = getThingFromPos(kawalek)
- doRemoveItem(lodz.uid, 1)
- end
- elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[EAST][2] then
- for n = 1, 3 do
- local i = n - 2
- local kawalek = {x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
- local ppos = {x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
- local lodz = getThingFromPos(kawalek)
- doRemoveItem(lodz.uid, 1)
- end
- end
- doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), false)
- doSendMagicEffect(getPlayerPosition(creature), CONST_ME_TELEPORT)
- if getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid, 1)
- end
- doPlayerRemoveAllStoragesFromBattleBoats(creature)
- doPlayerSendTextMessage(creature, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
- doBroadcastMessage("".. getCreatureName(creature) .." has been eaten by Water Dragon, he end his voyage.", 22)
- end, 1000)
- elseif(szansa >= 25) then
- doSendMagicEffect(getCreaturePosition(creature), 53)
- doPlayerSendTextMessage(creature, 4, "It's unbelievable, you have managed to survive the start of the sea monster!")
- end
- elseif isMonster(creature) then
- doRemoveCreature(creature)
- end
- end
- end
- addEvent(smoki, q.i.timer.dragons * 1000)
- return true
- end
- function palenie(cid)
- if(getPlayerStorageValue(cid, q.palenie) == -1 or getPlayerStorageValue(cid, q.palenie) == 0) then
- setPlayerStorageValue(cid, q.palenie, tonumber(getPlayerStorageValue(cid, q.palenie))+1)
- doPlayerSendCancel(cid, "You hit into the obstacle, your boat began to burn, you will be putting out the flames for 5 seconds.")
- doCreatureAddHealth(cid, (-getCreatureMaxHealth(cid)/3))
- if getPlayerStorageValue(cid, q.strona) == 3 then
- doCreateItem(1487, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1488, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- elseif getPlayerStorageValue(cid, q.strona) == 4 then
- doCreateItem(1487, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1488, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- elseif getPlayerStorageValue(cid, q.strona) == 1 then
- doCreateItem(1487, 1, {x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1488, 1, {x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- elseif getPlayerStorageValue(cid, q.strona) == 2 then
- doCreateItem(1487, 1, {x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- doCreateItem(1488, 1, {x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
- end
- setPlayerStorageValue(cid, q.stop, 1)
- addEvent(function()
- doRemoveItem(getTileItemById(getCreaturePosition(cid), 1489).uid, 1)
- if getPlayerStorageValue(cid, q.strona) == 3 then
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z}, 1488).uid, 1)
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}, 1487).uid, 1)
- elseif getPlayerStorageValue(cid, q.strona) == 4 then
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z}, 1487).uid, 1)
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}, 1488).uid, 1)
- elseif getPlayerStorageValue(cid, q.strona) == 1 then
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1487).uid, 1)
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1488).uid, 1)
- elseif getPlayerStorageValue(cid, q.strona) == 2 then
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1488).uid, 1)
- doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1487).uid, 1)
- end
- setPlayerStorageValue(cid, q.stop, 0)
- end, 5000)
- elseif(getPlayerStorageValue(cid, q.palenie) == 1) then
- doPlayerSendCancel(cid, "You hit into the obstacle, your boat will not survive the collision. You have finished yours voyage.")
- doCreatureAddHealth(cid, (-getCreatureMaxHealth(cid)/3)+1)
- for i = 1, 3 do
- local kierunki = {EAST, WEST, NORTH, SOUTH}
- local kier = getPlayerStorageValue(cid, q.strona)
- local kierunek = kier > 0 and kierunki[kier]
- if not isInArray({1, 2, 3, 4}, kier) then
- stopEvent(palenie)
- else
- if kierunek == n then
- kierunek = s
- elseif kierunek == s then
- kierunek = n
- elseif kierunek == e then
- kierunek = w
- elseif kierunek == w then
- kierunek = e
- end
- end
- local plus =
- {
- x1 = {0, 1, 0, -1},
- x3 = {0, -1, 0, 1},
- y1 = {-1, 0, 1, 0},
- y3 = {1, 0, -1, 0}
- }
- local czesci = {
- {x = getCreaturePosition(cid).x+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y1[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
- {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
- {x = getCreaturePosition(cid).x+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y3[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
- }
- lodz = getThingFromPos(czesci[i])
- doRemoveItem(lodz.uid, 1)
- end
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
- if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
- end
- doPlayerRemoveAllStoragesFromBattleBoats(cid)
- doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
- doBroadcastMessage("".. getCreatureName(cid) .." has broke his boat and he end his voyage.", 22)
- return true
- end
- return true
- end
- function plyn(cid)
- if(getGlobalStorageValue(smok) ~= 1) then
- addEvent(smoki, 1000)
- setGlobalStorageValue(smok, 1)
- end
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[NORTH][1] then
- if(getPlayerStorageValue(cid, q.strona) == 3) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-2, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- elseif(getPlayerStorageValue(cid, q.strona) == 4) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+2, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- end
- else
- if(getPlayerStorageValue(cid, q.strona) == 1) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x+2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- elseif(getPlayerStorageValue(cid, q.strona) == 2) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x-2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- end
- end
- local plus =
- {
- x = {0, 1, 0, -1},
- y = {-1, 0, 1, 0},
- x1 = {0, 1, 0, -1},
- x3 = {0, -1, 0, 1},
- x4 = {0, -2, 0, 2},
- y1 = {-1, 0, 1, 0},
- y2 = {0, 0, 0, 0},
- y3 = {1, 0, -1, 0},
- y4 = {2, 0, -2, 0}
- }
- local kierunki = {EAST, WEST, NORTH, SOUTH}
- local kier = getPlayerStorageValue(cid, q.strona)
- local kierunek = kier > 0 and kierunki[kier]
- if not isInArray({1, 2, 3, 4}, kier) then
- stopEvent(plyn)
- else
- if kierunek == n then
- kierunek = s
- elseif kierunek == s then
- kierunek = n
- elseif kierunek == e then
- kierunek = w
- elseif kierunek == w then
- kierunek = e
- end
- local czesci = {
- {x = getCreaturePosition(cid).x+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y1[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
- {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
- {x = getCreaturePosition(cid).x+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y3[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
- }
- local npos = {
- {x = getCreaturePosition(cid).x+plus.x[kierunek+1]+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1]+plus.y1[kierunek+1], z = getCreaturePosition(cid).z},
- {x = getCreaturePosition(cid).x+plus.x[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1], z = getCreaturePosition(cid).z},
- {x = getCreaturePosition(cid).x+plus.x[kierunek+1]+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1]+plus.y3[kierunek+1], z = getCreaturePosition(cid).z}
- }
- for i = 1, 3 do
- lodz = getThingFromPos(czesci[i])
- doRemoveItem(lodz.uid, 1)
- doCreateItem(l[kierunek][i], 1, npos[i])
- while getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).itemid > 0 do
- doTeleportThing(getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).uid, npos[i])
- end
- end
- doSendMagicEffect({x = getCreaturePosition(cid).x+plus.x4[kierunek+1], y = getCreaturePosition(cid).y+plus.y4[kierunek+1], z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- return {x = getCreaturePosition(cid).x+plus.x[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1], z = getCreaturePosition(cid).z}
- end
- return true
- end
- function onSay(cid, words, param, channel)
- if(param == '') then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Available commands: go, stop, right, left, up, down, fast, slow.")
- return true
- end
- if(param == ('go' or 'stop' or 'up' or 'down' or 'left' or 'right' or 'fast' or 'slow')) then
- if(getPlayerStorageValue(cid, q.start) ~= 1) then
- return false
- end
- end
- if(getPlayerStorageValue(cid, q.start) ~= 1) then
- doPlayerSendCancel(cid, "You cannot use this command not participating in the game.")
- return false
- end
- if(getPlayerStorageValue(cid, q.stop) == 1) then
- doPlayerSendCancel(cid, "You cannot do nothing while your ship is on fire.")
- return true
- end
- if(param == 'stop') then
- if(getPlayerStorageValue(cid, q.plynie) == 1) then
- stopEvent(plyn)
- doPlayerSendCancel(cid, "You stopped your boat.")
- setPlayerStorageValue(cid, q.plynie, -1)
- elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
- doPlayerSendCancel(cid, "Your boat is not moving.")
- end
- return true
- end
- if(param == 'fast') then
- if(getPlayerStorageValue(cid, q.plynie) == 1) then
- q.speed = 500
- doPlayerSendCancel(cid, "Your boat began to flow faster.")
- elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
- doPlayerSendCancel(cid, "Your boat is not moving.")
- end
- return true
- end
- if(param == 'slow') then
- if(getPlayerStorageValue(cid, q.plynie) == 1) then
- q.speed = 1000
- doPlayerSendCancel(cid, "Your boat began to flow slower.")
- elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
- doPlayerSendCancel(cid, "Your boat is not moving.")
- end
- return true
- end
- if(param == 'go') then
- if(getPlayerStorageValue(cid, q.plynie) == 1) then
- doPlayerSendCancel(cid, "Currently, your boat is in motion.")
- elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) and (getPlayerStorageValue(cid, q.strona) > 0) then
- setPlayerStorageValue(cid, q.plynie, 1)
- zacznijCzekac(function()
- while (getPlayerStorageValue(cid, q.plynie) == 1) do
- addEvent(plyn, 1, cid)
- czekaj(q.speed)
- end
- end)
- doPlayerSendCancel(cid, "Your boat was launched.")
- elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) and (getPlayerStorageValue(cid, q.strona) <= 0) then
- doPlayerSendCancel(cid, "You cannot start, firstly u must set direction where u want to go.")
- end
- return true
- end
- if(param == 'right') then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- doCreatureSetLookDirection(cid, 1)
- end
- setPlayerStorageValue(cid, q.strona, 1)
- else
- doPlayerSendCancel(cid, "This is impossible in reality...")
- end
- return true
- end
- if(param == 'left') then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- doCreatureSetLookDirection(cid, 3)
- end
- setPlayerStorageValue(cid, q.strona, 2)
- else
- doPlayerSendCancel(cid, "This is impossible in reality...")
- end
- return true
- end
- if(param == 'up') then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
- doCreatureSetLookDirection(cid, 0)
- end
- setPlayerStorageValue(cid, q.strona, 3)
- else
- doPlayerSendCancel(cid, "This is impossible in reality...")
- end
- return true
- end
- if(param == 'down') then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
- for n = 1, 3 do
- local i = n - 2
- doSendMagicEffect({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
- end
- stopEvent(plyn)
- setPlayerStorageValue(cid, q.plynie, 0)
- addEvent(palenie, 1, cid)
- return true
- end
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
- doCreatureSetLookDirection(cid, 2)
- end
- setPlayerStorageValue(cid, q.strona, 4)
- else
- doPlayerSendCancel(cid, "This is impossible in reality...")
- end
- return true
- end
- return true
- end
- ]]></talkaction>
- <event type="kill" name="BattleKill" event="script"><![CDATA[
- domodlib('re')
- function onKill(cid, target, lastHit)
- local l = {
- [NORTH] = {3587,3589,3591},
- [SOUTH] = {3591,3589,3587},
- [WEST] = {3592,3594,3596},
- [EAST] = {3596,3594,3592}
- }
- if not(isPlayer(target)) or not(isPlayer(cid)) then
- return true
- end
- if getPlayerStorageValue(cid, q.zapisany) == 1 or getPlayerStorageValue(cid, q.gotowy) == 1 then
- if getGlobalStorageValue(q.start) == 1 then
- setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
- if getGlobalStorageValue(q.playersCount) > 1 then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- end
- end
- doPlayerRemoveAllStoragesFromBattleBoats(cid)
- if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
- end
- doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
- doBroadcastMessage("".. getCreatureName(cid) .." has been killed by ".. getCreatureName(target) ..".", 22)
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
- elseif getGlobalStorageValue(q.playersCount) == 1 then
- if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
- end
- elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
- for n = 1, 3 do
- local i = n - 2
- doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
- doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
- end
- end
- doPlayerRemoveAllStoragesFromBattleBoats(cid)
- doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
- doBroadcastMessage("".. getCreatureName(cid) .." has been killed by ".. getCreatureName(target) ..".", 22)
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
- if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
- end
- if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
- doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
- end
- doRemoveAllGlobStoragesFromBattleBoats()
- local random_item = q.rewardsId[math.random(1, #q.rewardsId)]
- local item_name = getItemNameById(random_item)
- if(random_item == 2160) then
- doPlayerAddItem(cid, random_item, q.crystal_counts)
- doPlayerSendTextMessage(cid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. q.crystal_counts .." ".. item_name .."s!")
- else
- doPlayerAddItem(cid, random_item, 1)
- doPlayerSendTextMessage(cid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. item_name .."!")
- end
- return true
- end
- end
- return true
- end
- return true
- end
- ]]></event>
- </mod>
Advertisement
Add Comment
Please, Sign In to add comment