local boss_temp = {}
local boss_name = "xikini"
local boss_waypoints = {
{75, {x = 1000, y = 1000, z = 7}}, -- {hp_threshold, {new_pos}},
{60, {x = 1000, y = 1000, z = 7}}, -- highest
{45, {x = 1000, y = 1000, z = 7}}, -- to
{30, {x = 1000, y = 1000, z = 7}}, -- lowest
{15, {x = 1000, y = 1000, z = 7}} -- thresholds
}
local boss_battle_area = {
{x = 1000, y = 1000, z = 7}, -- top left
{x = 1000, y = 1000, z = 7} -- bottom right
}
local function tp_thing(cid, position)
doTeleportThing(cid, position)
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if boss_temp[cid] == nil then
-- make sure it's a monster
if not isMonster(cid) then
return true
end
-- make sure it's losing health
if type ~= STATSCHANGE_HEALTHLOSS then
return true
end
-- ensure it's the correct monster
if getCreatureName(cid):lower() ~= boss_name:lower() then
return true
end
-- ensure the correct monster is in the specified area
local cid_pos = getThingPos(cid)
if cid_pos.x < boss_battle_area[1].x or cid_pos.x > boss_battle_area[2].x then
return true
end
if cid_pos.y < boss_battle_area[1].y or cid_pos.y > boss_battle_area[2].y then
return true
end
if cid_pos.z > boss_battle_area[1].z or cid_pos.z < boss_battle_area[2].z then
return true
end
-- it's the correct monster, let's start tracking it
boss_temp[cid] = 1
-- if no more thesholds
elseif boss_temp[cid] == 0 then
return true
end
-- check if boss has reached an hp_threshold
-- if (1% of total hp * threshold) <= (current_hp - damage about to be taken) then
if getCreatureMaxHealth(cid) / 100 * boss_waypoints[boss_temp[cid]][1] >= getCreatureHealth(cid) - value then
addEvent(tp_thing, 0, cid, boss_waypoints[boss_temp[cid]][2])
boss_temp[cid] = boss_temp[cid] + 1
-- check if more thresholds
if boss_temp[cid] > #boss_waypoints then
boss_temp[cid] = 0
end
return true
end
return true
end