Page 1 of 1
Bot waits for Surprise Attack to come off cooldown
Posted: Wed Mar 02, 2011 11:59 pm
by Mushroomstamp
Code: Select all
<skill name="WARRIOR_SURPRISE_ATTACK" range="150" minrange="60" cooldown="12" />
How can I make the bot go to melee when this is on cooldown? As it is now, Bot stands at range waiting for the skill to be available again before attacking the next mob.
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 12:03 am
by rock5
A warrior is a melee character. It should be moving into melee. Do you have "COMBAT_TYPE" set to 'ranged' in your profile?
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 6:44 am
by Mushroomstamp
Combat type is left blank for default, but ranged pull is true... otherwise Surprise Attack isn't used at all because of the minimum distance requirement.
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 7:42 am
by lisa
I use this and I haven't had any issues as yet about not pulling.
Code: Select all
<option name="COMBAT_TYPE" value="" />
<option name="COMBAT_RANGED_PULL" value="true" />
<option name="COMBAT_DISTANCE" value="150" />
<skill name="WARRIOR_SURPRISE_ATTACK" modifier="" hotkey="VK_6" priority="70" pullonly="true" />
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 11:58 am
by Mushroomstamp
I don't have the pullonly option in mine... maybe that'll do the trick. So if Surprise Attack is on cooldown when your bot is ready to attack another mob, does it just bypass range pulling and start combat with a melee attack?
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 6:25 pm
by lisa
I'd have to test it on lower lvl mobs, generally my warr would start the fight with surprise attack and since it is launching itself to where the mobs are by the time it kills the 2-3 mobs that are usually together surprise attack would be off cooldown and ready to go again. With pullonly it makes sure it only uses it to start fights, so it won't get used middle of a fight and therefore still be on cooldown when you want to start next fight.
I doubt I would use warr to farm lower lvl mobs, other classes are much better suited for that.
Re: Bot ignores cooldown on Surprise Attack
Posted: Thu Mar 03, 2011 7:59 pm
by Mushroomstamp
Mobs are same level and above me - 57. I'm guessing I need an onpreskillcast to check cooldown... is that doable?
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 1:45 am
by lisa
yup that is definately possible.
I have been thinking about this situation and also similar situations for half the day.
My R/S uses vampire arrows as the pull only and if it is on cooldown then the bot waits for it to be off cooldown before pulling. I like that though because if the rogue runs in to start combat it will get multi agro 50% of the time, where as using a ranged skill to pull mobs to you will only get multi agro 10% of the time.
In the warrior situation the surprise attack launches the character at the mob instantly, if the mob is 150 yards away it would take a couple of seconds to walk to the mob anyway. So if surprise attack still has 2 seconds on cooldown then there is no benefit to running in. If it still had 5+ seconds left on cooldown then it would be better to not wait. This means you are killing mobs in under 7 seconds though.
I would be tempted to get more information about how much cooldown is left. a function for onpreskillcast that checks the cooldown left and then writes it to a file would give you a record of exactly how often and also how much cooldown is actually left. If cooldown is less then 3 seconds most of the time I would personally just leave it as is and let it wait the couple of seconds as opposed to walking to the mob.
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 2:03 am
by lisa
you would be looking at code like this
Code: Select all
<onPreSkillCast>
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
surprisecd();
end
</onPreSkillCast>
and userfunction like this
Code: Select all
function surprisecd(_acc)
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
local name, _, icon, _, rank, type, upgradeCost, isSkillable, isAvailable = RoMScript("GetSkillDetail(4,7);")
if _acc == nil then _acc = "" end
filename = getExecutionPath() .. "/profiles/skillcd" .. _acc .. ".xml";
file, err = io.open(filename, "a+");
if( not file ) then
error(err, 0);
end
file:write(" Skill Name: \"" ..name .. "\" Cooldown: \"" .. remaining .. "\" date: \"" .. os.date() .. "\"\n");
file:close();
end
It should create a file in your profile folder with name skillcd.xml (unless you put anything between the () when calling function.
It should post skill name, cooldown of surprise attack and the timestamp from your OS and each time will be added a new line with latest info at bottom of file.
Use that and you will have a record of how often surprise attack is still on CD when bot wants to use it.
EDIT: code fixed and added code to record skill name instead of character name.
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 6:55 am
by lisa
This is what my results were, half of those were multi agro because of the area I was farming in.
Code: Select all
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:39:33"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:39:56"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:40:14"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:40:26"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:40:43"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:40:56"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:41:43"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:41:55"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:42:15"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:42:41"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:43:31"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 21:43:47"
I should point out that the bot doesn't try to use the skill until it is off CD in the latest revision. So any record with a time difference of 12 seconds means it had to wait but we arn't sure how long it had to wait. So this doesn't really tell us what I wanted it to tell us. Would need to change the skills.
in profile
Code: Select all
<skill name="WARRIOR_SURPRISE_ATTACK" modifier="" hotkey="VK_5" priority="70" pullonly="true" cooldown="5" />
after changing the cooldown my results look like this
Code: Select all
Skill Name: "Surprise Attack" Cooldown: "2.2000000476837" date: "03/04/11 22:09:24"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 22:09:51"
Skill Name: "Surprise Attack" Cooldown: "0" date: "03/04/11 22:10:43"
Skill Name: "Surprise Attack" Cooldown: "4" date: "03/04/11 22:10:51"
Skill Name: "Surprise Attack" Cooldown: "0.5" date: "03/04/11 22:11:07"
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 10:53 am
by Mushroomstamp
Thanks Lisa... that's awesome.

I'll give it a try tonight when I get home. I'm 2-3 hitting these mobs so cooldown remaining is regularly 6+ seconds.
In the meantime, I'm trying to wrap my mind around how to put it all together. Would changing the combat distance when SA is on cooldown get the job done? If so, would this code work?
Code: Select all
<onPreSkillCast>
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
RoMScript("GetSkillCooldown(4,7);");
if (RoMScript("GetSkillCooldown(4,7);") > "3") then
return false
changeProfileOption("COMBAT_DISTANCE", 50);
end
end
return true
</onPreSkillCast>
If so, what would be the best way to go about changing the combat distance back to 150 for the next fight?
Thanks so much for your help.

Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 8:08 pm
by lisa
the get skill cooldown returns 2 values so I'm pretty sure you need to use it the way I had it with setting the local variables.
Code: Select all
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
I'd be more inclined to make the bot just use another skill if SA cooldown is to long, instead of trying to force it to use SA to melee mobs.
Code: Select all
<onPreSkillCast>
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining > 3 then
ATTTAAACCCKKKKKK
else return true
end
end
</onPreSkillCast>
Obviously ATTTAACCKK won't do anything you would need to decide whether you want to just use the attack skill or open with another skill like slash. Remember with melee skills they don't just stand there saying out of range they run to the target until they are in range to use it.
Also make sure you don't forget to change the profile skill cooldown, if left at the correct cooldown then bot won't even try to use SA until it is off CD and therefore it would still just stand there until the 12 seconds is up.
Also something I noticed while running my warr is if the target is closer then 60 yards and it tries to use SA it just stands there and eventually times out and then changes target to attack another mob.
Maybe rock5 might know best way to avoid this, a possible range check on the pull skill and if to close then start with a melee skill instead of trying to use the "ranged" skill.
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 9:45 pm
by Mushroomstamp
Kickass... using another skill sounds much better than changing profile options. I expect the code would need to be as follows?
Code: Select all
if remaining > 3 then
player:cast("WARRIOR_SAVAGE_WHIRLWIND");
Would it be
to just use the normal attack skill?
Rock5 gave me code a few weeks back for the timing out problem;
Code: Select all
<onPreSkillCast>
if arg1.Name == "WARRIOR_SURPRISE_ATTACK" then
local target = player:getTarget()
if 60 > distance(player.X, player.Z, target.X, target.Z) then
return false -- doesn't use the skill
end
end
return true
</onPreSkillCast>
But now, how do I combine the two onpreskillcast scripts? It hasn't liked any of my attempts. =(
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Fri Mar 04, 2011 10:36 pm
by lisa
if the return false makes it just use melee skills then could simply do
Code: Select all
<onPreSkillCast>
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining > 3 then
return false
else return true
end
end
</onPreSkillCast>
could add the 2 together like this
Code: Select all
<onPreSkillCast><![CDATA[
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining > 3 then
return false
end
local target = player:getTarget()
if 60 > distance(player.X, player.Z, target.X, target.Z) then
return false -- doesn't use the skill
end
return true
end
]]></onPreSkillCast>
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Sat Mar 05, 2011 11:55 am
by Mushroomstamp
It seems to work but, is randomly giving an onpreskillcast error that stops the bot and gets me killed. =(
" ...classes/player.lua:584: onPreSkillCast error: [string "..."]:5: attempt to compare number with nil "
How do you interpret what errors like this mean? The error has happened 3 different times and each time after running for 2-4 hours.
Profile code was pretty much exactly as given;
Code: Select all
<onPreSkillCast><![CDATA[
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining > 2 then
player:cast("WARDEN_POWER_OF_THE_WOOD_SPIRIT");
end
local target = player:getTarget()
if 60 > distance(player.X, player.Z, target.X, target.Z) then
return false -- doesn't use the skill
end
return true
end
]]></onPreSkillCast>
I just now changed it to do the distance check first, new script is;
Code: Select all
<onPreSkillCast><![CDATA[
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local target = player:getTarget()
if 60 > distance(player.X, player.Z, target.X, target.Z) then
return false -- doesn't use the skill
end
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining > 2 then
player:cast("WARDEN_POWER_OF_THE_WOOD_SPIRIT");
end
return true
end
]]></onPreSkillCast>
With this code, the error stays the same, but the " :5: " is now " :8: ".
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Sat Mar 05, 2011 9:20 pm
by lisa
the error
attempt to compare number with nil
means that it has a nil value for remaining. Which is weird if it works for a few hours before getting error.
Easiest way to make it continue is to add a check for remaining to not equal nil
Code: Select all
<onPreSkillCast><![CDATA[
if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
if remaining ~= nil and remaining > 2 then
player:cast("WARDEN_POWER_OF_THE_WOOD_SPIRIT");
end
local target = player:getTarget()
if 60 > distance(player.X, player.Z, target.X, target.Z) then
return false -- doesn't use the skill
end
return true
end
]]></onPreSkillCast>
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Sun Apr 03, 2011 2:07 am
by Mushroomstamp
I'm not sure why, but this is happening again. Bot just switches between targeting 2 mobs, never attacking either. MM window says;
"We begin the fight with ranged pulling."
"Taking too long to damage target, breaking sequence..."
It doesn't seem to matter what I change the onpreskillcast code to. It's like it's getting stuck in ranged pulling, even though it's not using my ranged skill. Any other suggestions?
Re: Bot waits for Surprise Attack to come off cooldown
Posted: Sun Apr 03, 2011 2:20 am
by rock5
Even if you completely remove the onPreSkillCast code?
Maybe it's getting stuck in a loop trying to use Surprise Attack but the mobs are out of range so your code keeps returning false? I'm not sure what could cause this. What do you have Combat Range set to in your profile?