player:haveTarget() isn't for checking if you have a target at all, it is for checking if you have a viable target and part of the checks is if the target is targeting character or party member,
So let's look at how that affects your code.
Code: Select all
local tgt = player:findEnemy(nil,nil,attacksPartner,nil)
this will either find a target or won't.
This will check if you found a target and tgt is the pawn info for that target if it exists.
Code: Select all
print( "attacking " .. tgt.Name );
simple print to tell you there is a target.
tells the bot to target the pawn/mob.
checks if target is viable according to the rules of rombot which factors in everything, including profile settings.
attack mob
Ok so here you have already decided there is something to target because tgt ~= nil, so this is the else for if target is viable according to rombot rules.
So because you know target ~= nil then you don't need the check for player:haveTarget() unless you are worried about anitKS, since you obviously have a function to check for mobs targeting partners then no need.
Code: Select all
local tgt = player:findEnemy(nil,nil,attacksPartner,nil)
if( tgt ~= nil) then
print( "attacking " .. tgt.Name );
player:target( tgt );
player:fight();
That will do what you wanted =)