landsandboat/scripts/effects/dynamis.lua

66 lines
2.2 KiB
Lua
Raw Permalink Normal View History

2016-01-16 01:26:33 -05:00
-----------------------------------
2021-04-01 15:10:15 -04:00
-- xi.effect.DYNAMIS
2016-01-16 01:26:33 -05:00
-----------------------------------
---@type TEffect
local effectObject = {}
2016-01-16 01:26:33 -05:00
effectObject.onEffectGain = function(target, effect)
target:setLocalVar('dynamis_lasttimeupdate', effect:getTimeRemaining() / 1000)
end
2016-01-16 01:26:33 -05:00
effectObject.onEffectTick = function(target, effect)
2021-04-01 15:10:15 -04:00
if target:getCurrentRegion() == xi.region.DYNAMIS then
local lastTimeUpdate = target:getLocalVar('dynamis_lasttimeupdate')
local remainingTimeLimit = effect:getTimeRemaining() / 1000
local message = 0
if lastTimeUpdate > 600 and remainingTimeLimit < 600 then
message = 600
elseif lastTimeUpdate > 300 and remainingTimeLimit < 300 then
message = 300
elseif lastTimeUpdate > 60 and remainingTimeLimit < 60 then
message = 60
elseif lastTimeUpdate > 30 and remainingTimeLimit < 30 then
message = 30
elseif lastTimeUpdate > 10 and remainingTimeLimit < 10 then
message = 10
2018-10-01 23:32:12 -06:00
end
if message ~= 0 then
local time = message
local minutes = 0
if time >= 60 then
minutes = 1
time = time / 60
end
if time == 1 then
target:messageSpecial(zones[target:getZoneID()].text.DYNAMIS_TIME_UPDATE_1, time, minutes)
else
target:messageSpecial(zones[target:getZoneID()].text.DYNAMIS_TIME_UPDATE_2, time, minutes)
end
target:setLocalVar('dynamis_lasttimeupdate', message)
2018-10-01 23:32:12 -06:00
end
else
2021-04-01 15:10:15 -04:00
target:delStatusEffectSilent(xi.effect.DYNAMIS)
end
end
2016-01-16 01:26:33 -05:00
effectObject.onEffectLose = function(target, effect)
2021-04-01 15:10:15 -04:00
target:delKeyItem(xi.ki.CRIMSON_GRANULES_OF_TIME)
target:delKeyItem(xi.ki.AZURE_GRANULES_OF_TIME)
target:delKeyItem(xi.ki.AMBER_GRANULES_OF_TIME)
target:delKeyItem(xi.ki.ALABASTER_GRANULES_OF_TIME)
target:delKeyItem(xi.ki.OBSIDIAN_GRANULES_OF_TIME)
if target:getCurrentRegion() == xi.region.DYNAMIS then
if effect:getTimeRemaining() == 0 then
target:messageSpecial(zones[target:getZoneID()].text.DYNAMIS_TIME_EXPIRED)
target:disengage()
target:startCutscene(100)
end
end
end
2016-01-16 01:26:33 -05:00
return effectObject