landsandboat/scripts/items/chicken_knife.lua
Skold fcd81c9f7d [lua] Chicken Knife
Fixes the speed boost of Chicken Knife
2026-05-03 22:37:41 -04:00

31 lines
1.1 KiB
Lua

-----------------------------------
-- ID: 17615
-- Chicken Knife
-----------------------------------
local itemObject = {}
itemObject.onItemEquip = function(player, item)
player:addListener('ATTACK', 'CHICKEN_KNIFE_ATTACK', function(playerArg, mob)
local dLvl = mob:getMainLvl() - playerArg:getMainLvl()
if dLvl >= 1 then
-- exponential approx to data points from retail capture
local chance = utils.clamp(100 * 0.0096906 * math.exp(0.176839 * dLvl), 1.33, 33)
if math.random(1, 100) <= chance then
local effect = player:getStatusEffect(xi.effect.FLEE)
if effect then
effect:setTick(0)
effect:resetStartTime()
effect:setIcon(xi.effect.FLEE)
else
player:addStatusEffect(xi.effect.FLEE, { power = 10000, duration = 30, origin = player })
end
end
end
end)
end
itemObject.onItemUnequip = function(player, item)
player:removeListener('CHICKEN_KNIFE_ATTACK')
end
return itemObject