Created
July 22, 2021 21:31
-
-
Save Zbizu/cca536d6c72dbef8afe2fccb695284ff to your computer and use it in GitHub Desktop.
Timer on magic wall rune (server side)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- replace your mw script with this | |
local combat = Combat() | |
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) | |
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL) | |
local function tile_timer(id, pos, delay, color) | |
if not Tile(pos):getItemById(id) then | |
return true | |
end | |
if delay ~= 1 then | |
addEvent(tile_timer, 1000, id, pos, delay - 1, color) | |
end | |
local people = Game.getSpectators(pos, 7, 7, 5, 5, false, true) | |
if not people then | |
return true | |
end | |
for i = 1, #people do | |
people[i]:sendTextMessage(MESSAGE_EXPERIENCE, "Magic wall will disappear in " .. delay .. " second" .. (delay > 1 and "s" or "") .. ".", pos, delay, color) | |
end | |
end | |
function onCastSpell(creature, variant, isHotkey) | |
local c = combat:execute(creature, variant) | |
if c then | |
tile_timer(ITEM_MAGICWALL, variantToPosition(variant), 20, TEXTCOLOR_LIGHTBLUE) | |
end | |
return c | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment