1
[CreatureEvents] Target attack direccion Jue Ene 08, 2015 1:01 pm
[Admin] God Maya
![[Admin] God Maya](https://2img.net/u/2712/30/40/04/avatars/1-92.jpg)
Administrador

bueno este un script unico que ni la tibia global lo tiene y gracia a un persona que daremos los creditos mas abajo, se hiso posible. se trata de que cuando atakas a un moustro o un player su personaje siempre gira a la dirección de su objetivo al atacar.
![[CreatureEvents] Target attack direccion 0CpELzV](https://i.imgur.com/0CpELzV.gif)
bueno instalando:
nos vamos a:
data\creaturescripts\scripts |
copiamos cualquier archivo y renombramos por target.lua y pegamos esto dentro
- Código:
function onAttack(cid, target)
if isCreature(cid) and isCreature(target) then
dir = getDirectionTo(getCreaturePosition(cid), getCreaturePosition(target))
doCreatureSetLookDirection(cid, dir)
end
return true
end
es muy psible que el primer script este con problema por eso dejamos el segundo para que no sufran de problemas
- Código:
function getDistance(fromPos, toPos)
local pos = {
x = fromPos.x - toPos.x
y = fromPos.y - toPos.y
z = fromPos.z
}
return pos
end
function onAttack(cid, target)
if isCreature(cid) and isCreature(target) then
local pos = getDistance(getCreaturePosition(cid), getCreaturePosition(target))
dir = getDirectionTo(getCreaturePosition(cid), getCreaturePosition(target))
if isInArray({0,1,2,3}, dir) then
doCreatureSetLookDirection(cid, dir)
else
if pos.y > 0 then
doCreatureSetLookDirection(cid, 0)
else
doCreatureSetLookDirection(cid, 2)
end
end
end
return true
end
ahora en la misma carpeta buscamos el archivo llamado login.lua y añadimos esta linea
- Código:
registerCreatureEvent(cid, "targetCreature")
luego nos vamos a:
Data/creaturescripts/creaturescripts.xml |
y añadimos esta tag
- Código:
<event type="attack" name="targetCreature" script="target.lua"/>
Testado em TFS 0.3.6 Cliente 8.54.
creditos: xWhiteWolf

![[CreatureEvents] Target attack direccion YNU5B25](https://i.imgur.com/yNU5B25.png)