This is just a direction for you to try. I offer no support for it so if you are not a good programmer then don't even bother with it.
blademagical wrote:what i must change in my micromacro to my char attack first the mobs that are attacking me first, because here my character are being attacked by 3 mobs and he got a new target and dont attack first the mobs that are attacking me first, plz what i can do to my char kill first all the mobs are already attacking me first to take after a new target? ty =)
Open player.lua and look at function function CPlayer:fight() for the section resembling the following code. (My local copy of this bot has drifted away from Elviron's code a little so you might not see an exact one to one correlation of lines of code.)
Code: Select all
local target = self:getTarget();
local lastHitTime = os.time();
local lastTargetHP = target.HP;
local PlayerHP = self.HP; -- will use to detect if being attacked by other than player's target
local lastPlayerHP = PlayerHP;
local dist = distance(self.X, self.Z, target.X, target.Z);
while( self:haveTarget() ) do
cprintf(cli.yellow,"DBG: target[%d] at dist (%d) has %d HP\n",target.Address,dist,target.HP);
if( self.HP == 0 ) then -- If we die, break
self.Fighting = false;
-- QN why isn't unregisterTimer used before this return?
if( settings.profile.options.COMBAT_TYPE == "melee" ) then
cprintf(cli.red,"DBG: unregisterTimer timedAttack\n");
unregisterTimer("timedAttack");
end
return; -- function CPlayer:fight()
end;
PlayerHP = self.HP
if( PlayerHP < lastPlayerHP ) then -- see if the current target has also targeted the player
if( target:getTarget().Address == self.Address ) then
printf("Target is hostile\n");
else -- reduction in HP must be due to another mob
printf("Target is passive but player just lost %d HP\n",lastPlayerHP-self.HP);
player:clearTarget(); -- allow a new target to be selected
return; -- function CPlayer:fight
end;
end;
lastPlayerHP = PlayerHP
target = self:getTarget();
-- cprintf(cli.pink,"DBG: checking pots and skills\n");
self:checkPotions();
The relevant piece is the code between
PlayerHP = self.HP
and
lastPlayerHP = PlayerHP
(you must scroll to see it)
If it is not obvious what this code does then please don't try using it.
You may also need to tweak the following within the function CPlayer:moveTo(waypoint, ignoreCycleTargets)
Code: Select all
while( dist > 25.0 ) do
if( self.HP == 0 ) then
return; -- function CPlayer:moveTo
end;
-- after 1 SECOND (not 1mS) of movement allow the targeting of mobs enroute
-- before this it was simply time to see if any mobs were attacking player
if( canTarget == false and os.difftime(os.time(), startTime) > 2 ) then -- was 1 second
canTarget = true;
end
notice I allow 2 seconds before selecting new targets - the default of 1 second was too short for me
enjoy!