function Game.Rule:OnTakeDamage(victim, attacker, damage, weapontype, hitbox)
if (attacker ~= nil and victim:IsMonster()) then
local X = (attacker.position.x - victim.position.x)
local Y = (attacker.position.y - victim.position.y)
local XY = math.abs(X)/(math.abs(X)+math.abs(Y))
local YX = math.abs(Y)/(math.abs(X)+math.abs(Y))
X = math.ceilN((math.abs(X*2) / math.nan(X)) * XY)
Y = math.ceilN((math.abs(Y*2) / math.nan(Y)) * YX)
attacker.position = {x=victim.position.x+X, y=victim.position.y+Y, z=victim.position.z+1}
end
end
function math.ceilN(x)
if x > 0 then
return math.ceil(x)
else
return math.floor(x)
end
end
function math.nan(x)
if x >= 0 then
return x-0.1
elseif x < 0 then
return x+0.1
end
end
추천 :
2