landsandboat/scripts/effects/level_restriction.lua

39 lines
1.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.LEVEL_RESTRICTION
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)
2021-04-01 15:10:15 -04:00
if target:getObjType() == xi.objType.PC then
target:levelRestriction(effect:getPower())
target:messageBasic(xi.msg.basic.LEVEL_IS_RESTRICTED, effect:getPower()) -- <target>'s level is restricted to <param>
target:clearTrusts()
if xi.settings.map.DESPAWN_JUGPETS_BELOW_MINIMUM_LEVEL then
local pet = target:getPet()
local masterLevel = target:getMainLvl()
if
pet and
pet:getObjType() == xi.objType.PET and
target:hasJugPet() and -- hasJugPet checks m_PBaseEntity->PPet's check type, not the target's pet type.
masterLevel < pet:getMinimumPetLevel()
then
target:despawnPet()
end
end
end
end
2016-01-16 01:26:33 -05:00
effectObject.onEffectTick = function(target, effect)
end
2016-01-16 01:26:33 -05:00
effectObject.onEffectLose = function(target, effect)
if target:getObjType() == xi.objType.PC then
target:levelRestriction(0)
end
2018-09-30 12:27:15 -06:00
end
return effectObject