1. found mob, go to him - pawn.Alive=true
2. kill mob - pawn.Alive=true
3. loot corpse, dead body dissapeared - only now pawn.Alive=false
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<onLoad>
--- func ---
function TargetInRange(_range)
local pawncount = 0
local thepawn = nil
local mindist = _range
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
local obj = objectList:getObject(i);
if( obj ~= nil and obj.Type == PT_MONSTER) then
local pawn = CPawn(obj.Address);
local dist = distance(pawn.X,pawn.Z,pawn.Y,player.X,player.Z,player.Y)
if (_range >= dist) and pawn.Alive and pawn.Attackable then
pawncount = pawncount + 1
if mindist > dist then
thepawn = pawn
mindist = dist
end
end
cprintf(cli.white, "Target: %s range: %s\n", pawn.Name, dist);
end
end
return thepawn,mindist,pawncount
end
--- main ---
while (true) do
tgt,dalnost,vsego = TargetInRange(500);
cprintf(cli.white, "Nearest: %s range: %s All tgts:%s\n", tgt.Name, dalnost, vsego);
if tgt then
player:target(tgt)
player:moveInRange(tgt, 10, true)
-- player:fight() player:checkSkills(true, tgt)
player:update()
RoMScript("UseSkill(1,1)")
tgt:update()
if tgt.Alive then cprintf(cli.white, utf82oem_russian("Alive\n")) end
end
player:sleep()
end
</onLoad>
</waypoints>untill corps disappered.