Running away from a fight
Running away from a fight
Has anyone ever written some code to run away from a fight? Maybe if your hp gets too low? I chaven't been able to do it. If there is no way, I'll have to add some code for it in the bot.
I tried clearing target, targeting myself, setting waypoint type to travel. Nothing works. It breaks from the fight but reengages the mob.
I tried clearing target, targeting myself, setting waypoint type to travel. Nothing works. It breaks from the fight but reengages the mob.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Running away from a fight
Since the mob would be targeting you and not 100% hp then you will probably have to add it to the ignore list for the bot to not defend itself against it.
Code: Select all
local target = player:getTarget();
player.IgnoreTarget = target.Address;
__WPL:setForcedWaypointType("TRAVEL")
player:clearTarget()
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Running away from a fight
Thanks I'll try that.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Running away from a fight
Still can't do it.
This is what I had in the onload secion of my waypoint.Note: I've modified mount so if you put "true" as the second argument it doesn't fight before tring to mount.
After manually finding a Copper Guardener and making sure my hp went below 80% then resuming, this is what happened.
I even tried adding
I really thought that would work. But I got similar results.
This is what I had in the onload secion of my waypoint.
Code: Select all
if oldOnSkillCast == nil then oldOnSkillCast = settings.profile.events.onSkillCast end
function settings.profile.events.onSkillCast()
if 80 > (player.HP/player.MaxHP*100) then -- escape
local target = player:getTarget();
player.IgnoreTarget = target.Address;
player:clearTarget()
__WPL:setWaypointIndex(__WPL:findWaypointTag(finished))
__WPL:setForcedWaypointType("TRAVEL")
player:mount(nil,true)
else
return oldOnSkillCast()
end
endAfter manually finding a Copper Guardener and making sure my hp went below 80% then resuming, this is what happened.
Code: Select all
Moving to waypoint #100, (7618, 2476)
Resting for 5 seconds.
Paused. (Home) to continue, (CTRL+L) exit to shell, (CTRL+C) quit
Resumed.
Clearing target.
Stop resting because of aggro.
Forced waypoint type 'TRAVEL' set by user.
Waiting on aggressive enemies.
Use MACRO: Executing RoMScript "CancelPlayerBuff(2);".
Engaging enemy [Copper Gardener] in combat.
Use MACRO: MAGE_FIREBALL => Copper Gardener (18672/18672)
Clearing target.
Forced waypoint type 'TRAVEL' set by user.
Use MACRO: MAGE_FLAME => Copper Gardener (11927/18672)
Clearing target.
Forced waypoint type 'TRAVEL' set by user.
Use MACRO: MAGE_FIREBALL => Copper Gardener (0/18672)
Clearing target.
Forced waypoint type 'TRAVEL' set by user.
Fight finished. Killed 2 Copper Gardener. (fight #4 / runtime 13 minutes)Code: Select all
player.Current_waypoint_type = WPT_TRAVEL- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Running away from a fight
you might also need to add in a
I have a feeling the clear target isn't good enough, it is kind of like clicking away from target but then mob hits you and it becomes target again.
Maybe add a few prints inside player:fight() and see if you can work out what is happening?
I would definately add a print the first line of player:fight() to see if the function is being called after you try to disengage.
Also you might need a couple of " " in this line
Code: Select all
player.Fighting = false
unregisterTimer("timedAttack");
Maybe add a few prints inside player:fight() and see if you can work out what is happening?
I would definately add a print the first line of player:fight() to see if the function is being called after you try to disengage.
Also you might need a couple of " " in this line
Code: Select all
__WPL:setWaypointIndex(__WPL:findWaypointTag(finished))
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Running away from a fight
I forgot to say, I think IgnoreTarget didn't work because if it is attacking you it will ignore IgnoreTarget. That's only when it's looking for targets.
Putting a print statement at the beginning of fight was a good idea as it confirmed what I suspected and that is that it doesn't exit the fight function. After a closer look at the loop in the fight function, the only way I could see to make it break was to make it think it was taking to long to damage the target. I did this withAlso I had to move the mount to the onleavecombat section and I decided to switch to onpreSkillCast. So in the end it looks somethin like this.
I wonder if I should add a variable and maybe a function to break from a fight and maybe a function to set everything up to escape. It could be as little as just one variable for the user to change to break from a fight and they would have to do the other commands or a full function that breaks from the fight and maybe sets the waypoint type to travel. Hm... I'm not sure.
Just had an idea. Don't need a second argument for mount. Just check if player.Current_waypoint_type = WPT_TRAVEL. If so don't fight back.
Putting a print statement at the beginning of fight was a good idea as it confirmed what I suspected and that is that it doesn't exit the fight function. After a closer look at the loop in the fight function, the only way I could see to make it break was to make it think it was taking to long to damage the target. I did this with
Code: Select all
player.lastHitTime = player.lastHitTime - (settings.profile.options.MAX_FIGHT_TIME *2)Code: Select all
if oldOnPreSkillCast == nil then oldOnPreSkillCast = settings.profile.events.onPreSkillCast end
function settings.profile.events.onPreSkillCast()
if 80 > (player.HP/player.MaxHP*100) then -- escape
__WPL:setForcedWaypointType("TRAVEL")
player.Current_waypoint_type = WPT_TRAVEL
player.lastHitTime = player.lastHitTime - (settings.profile.options.MAX_FIGHT_TIME *2)
-- Code to pick right waypoint
-- Or maybe load an escape waypoint file
return false -- So it doesn't waste time casting the skill
else
return oldOnPreSkillCast()
end
end
if oldOnLeaveCombat == nil then oldOnLeaveCombat = settings.profile.events.onLeaveCombat end
function settings.profile.events.onLeaveCombat()
if player.Current_waypoint_type == WPT_TRAVEL then
player:mount(nil,true)
else
oldOnLeaveCombat()
end
endJust had an idea. Don't need a second argument for mount. Just check if player.Current_waypoint_type = WPT_TRAVEL. If so don't fight back.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Running away from a fight
I find it interesting it doesn't leave the function but when you clear target it doesn't leave the while loop, I guess that is the reaquiring target when you get hit I mentioned.
I have been thinking about it since you posted this topic and I do like options and disengaging from fight "could" be a good option but it comes down to what happens after you break the fight.
Where do you run to?
How far do you run to get away from mob?
Do you still use heal skills/potions when you run?
Do you try to mount before running?
It brings so many questions to mind and the trouble is that you would want to do different things in different situations.
I have been thinking about it since you posted this topic and I do like options and disengaging from fight "could" be a good option but it comes down to what happens after you break the fight.
Where do you run to?
How far do you run to get away from mob?
Do you still use heal skills/potions when you run?
Do you try to mount before running?
It brings so many questions to mind and the trouble is that you would want to do different things in different situations.
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Running away from a fight
Yeah, you would think that if the loop starts
then clearing the target should break from the loop. The only thing after checkskills is gettarget but that just returns player.TargetPtr. That means, somewhere in checkskills and assocciated functions, it reaquires the target but I can't find it.
I actually tested starting a fight then clearing the target. It didn't fight back again so I thought that wasn't the problem. But on second thought, it did retarget the mob which is all the bot needs. That would have to be the problem then.
As to the options, I think I'll just make it so you can disengage and leave it to the user what they want to do with it. All it realy needs is this in the while loop.Then a function such as
Then a user can do something like this in their onpreskillcast or onskillcast
But you are right, there are too many variables to do an escape function. I think I'll just provide the means to break from the fight.
Code: Select all
while( self:haveTarget() ) doI actually tested starting a fight then clearing the target. It didn't fight back again so I thought that wasn't the problem. But on second thought, it did retarget the mob which is all the bot needs. That would have to be the problem then.
As to the options, I think I'll just make it so you can disengage and leave it to the user what they want to do with it. All it realy needs is this in the while loop.
Code: Select all
if somevariable == true then
break_fight = true;
break;
endCode: Select all
function CPlayer:breakFight()
somevariable = true
endCode: Select all
if some condition then
player:breakFight()
__WPL:setForcedWaypointType("TRAVEL")
loadPaths("escape")
end- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan