Targetting problem
Posted: Sun Feb 19, 2012 11:47 am
Hi!
I am trying to build an assist script, similar to PartyHealer, for a strong char to protect a weaker one.
I have the following piece of code to attack any mobs that attack the protected char:
attacksPartner() checks the target of all mobs and returns true if their target is the protected char.
This code does work nicely if both chars are in a party.
It fails if there is no party. findEnemy successfully returns the mob, but haveTarget() returns false.
Why?
maniac
I am trying to build an assist script, similar to PartyHealer, for a strong char to protect a weaker one.
I have the following piece of code to attack any mobs that attack the protected char:
Code: Select all
local tgt = player:findEnemy(nil,nil,attacksPartner,nil)
if( tgt ~= nil) then
print( "attacking " .. tgt.Name );
player:target( tgt );
if player:haveTarget() then
player:fight();
else
print( "no tgt" );
end
This code does work nicely if both chars are in a party.
It fails if there is no party. findEnemy successfully returns the mob, but haveTarget() returns false.
Why?
maniac