BulawOw
Soul of Shinobi
- Joined
- Sep 15, 2014
- Messages
- 204
- Solutions
- 8
- Reaction score
- 62
LUA:
local spellEvents = {}
local spellOriginalOutfits = {}
local config1 = {
OUTFIT_FIRST = 1013,
OUTFIT_LAST = 1016,
}
local config2 = {
OUTFIT_FIRST = 1023,
OUTFIT_LAST = 1026,
}
local config3 = {
OUTFIT_FIRST = 1018,
}
local function copyOutfit(creatureId, newLooktype)
local originalOutfit = spellOriginalOutfits[creatureId]
local outfit = {
lookType = newLooktype,
lookHead = originalOutfit.lookHead,
lookBody = originalOutfit.lookBody,
lookLegs = originalOutfit.lookLegs,
lookFeet = originalOutfit.lookFeet,
lookAddons = originalOutfit.lookAddons,
lookMount = originalOutfit.lookMount
}
return outfit
end
local function setOriginalOutfit(creature, lookType)
creature = Creature(creature)
if not creature or creature:isRemoved() then
return
end
creature:setOutfit(spellOriginalOutfits[creature:getId()])
end
local function animateGateThird(creature, lookType)
creature = Creature(creature)
if not creature or creature:isRemoved() then
return
end
creature:setOutfit(copyOutfit(creature:getId(), lookType))
if lookType == config3.OUTFIT_FIRST then
spellEvents[creature:getId()] = addEvent(setOriginalOutfit, 100, creature)
else
spellEvents[creature:getId()] = addEvent(animateGateThird, 200, creature)
end
end
local function animateGateSecond(creature, lookType)
creature = Creature(creature)
if not creature or creature:isRemoved() then
return
end
local pos = creature:getPosition()
local playerOffset = creature:getPosition()
playerOffset.x = playerOffset.x + 1
playerOffset.y = playerOffset.y + 1
creature:setOutfit(copyOutfit(creature:getId(), lookType))
if lookType == config2.OUTFIT_LAST then
spellEvents[creature:getId()] = addEvent(animateGateThird, 300, creature, config3.OUTFIT_FIRST)
Game.sendAnimatedText("text2", pos, 180)
playerOffset:sendMagicEffect(86)
else
spellEvents[creature:getId()] = addEvent(animateGateSecond, 100, creature, lookType + 1)
end
end
local function animateGate(creature, lookType)
creature = Creature(creature)
if not creature or creature:isRemoved() then
return
end
local pos = creature:getPosition()
creature:setOutfit(copyOutfit(creature:getId(), lookType))
if lookType == config1.OUTFIT_LAST then
spellEvents[creature:getId()] = addEvent(animateGateSecond, 1000, creature, config2.OUTFIT_FIRST)
Game.sendAnimatedText("text1", pos, 180)
else
spellEvents[creature:getId()] = addEvent(animateGate, 50, creature, lookType + 1)
end
end
function onCastSpell(creature, variant)
local originalOutfit = creature:getOutfit()
spellOriginalOutfits[creature:getId()] = originalOutfit
spellOriginalOutfits[creature:getId()] = copyOutfit(creature:getId(), originalOutfit.lookType)
if spellEvents[creature:getId()] then
stopEvent(spellEvents[creature:getId()])
end
spellEvents[creature:getId()] = addEvent(animateGate, 10, creature, config1.OUTFIT_FIRST, position)
end
Just like in title how is the structure if its stable (probably not cause i had to turn off safe scripts ;p) if not maybe how can i improve it, etc.
Thanks in advance