Coloca a versão quando for postar coisas do gênero.
1.0.
local TELEPORTED_CREATURES = {}
local TELEPORT_LOW_HEALTH = {
{name = "Demon", to = {x=1,y=1,z=7}, percent=80},
{name = "Demon", to = {x=1,y=1,z=7}, percent=60},
{name = "Demon", to = {x=1,y=1,z=7}, percent=40},
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if creature:isMonster() then
for n, m in pairs(TELEPORT_LOW_HEALTH) do
if m.name == creature:getName() and creature:getHealth() <= (creature:getMaxHealth() / 100) * m.percent then
local mid = creature:getId()
if not TELEPORTED_CREATURES[mid] or Position(TELEPORTED_CREATURES[mid]) ~= Position(m.to) then
TELEPORTED_CREATURES[mid] = m.to
creature:teleportTo(m.to, false)
break
end
end
end
end
return primaryDamage, primaryType, -secondaryDamage, secondaryType
end
0.3.6pl1.
local TELEPORTED_CREATURES = {}
local TELEPORT_LOW_HEALTH = {
{name = "Demon", to = {x=1,y=1,z=7}, percent=80},
{name = "Demon", to = {x=1,y=1,z=7}, percent=60},
{name = "Demon", to = {x=1,y=1,z=7}, percent=40},
}
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(cid) then
for n, m in pairs(TELEPORT_LOW_HEALTH) do
if m.name == getCreatureName(cid) and getCreatureHealth(cid) <= (getCreatureMaxHealth(cid) / 100) * m.percent then
local pos = m.to.x..","..m.to.y..","..m.to.z
if not TELEPORTED_CREATURES[cid] or TELEPORTED_CREATURES[cid] ~= pos then
TELEPORTED_CREATURES[cid] = pos
doTeleportThing(cid, m.to, false)
break
end
end
end
end
return true
end
São creaturescripts. Basta configurar o script no creaturescripts.xml e colocar no xml da criatura:
<script>
<event name="nome_do_evento_q_vc_configurou"/>
</script>