Page 1 of 1
check if in agro before casting home sweet home
Posted: Sat Jun 11, 2016 11:54 am
by beanybabe
I noticed if using mount and ride past mobs some times Iam still under agro when I try to cast home sweet home in this function and it fails.
viewtopic.php?f=21&t=6321
I can increase the timer and hope for agro to drop or is there a way to check for agro
if not agro then cast homesweethome ....
Re: check if in agro before casting home sweet home
Posted: Wed Jun 22, 2016 12:34 pm
by kenzu38
To check for aggro:
Code: Select all
player:updateBattling()
if player.Battling then
-- you have aggro
end
However, since you are using it for a userfunction, it's better to add in code to fight with the aggroed mobs:
Code: Select all
player:updateBattling()
while player.Battling do
player:target(player:findEnemy(true))
player:fight()
player:updateBattling()
end
-- use home sweet home
Re: check if in agro before casting home sweet home
Posted: Sun Jun 26, 2016 11:58 pm
by beanybabe
Thank you.
What happens is when the quest status goes to complete I set wp to travel and mount then ride thru the mobs back to quest person. There is just enough distance the mobs do not follow but aggro is still set. The time can vary depending on mob aggro'd. Currently I just wait many seconds before trying to cast the home recall.
I was hoping a check for aggro could eliminate that wait or lesson it. This is also handy if you are going to teleport or recall if you are in aggro the spell will fail also.
I changed it a bit and will try this to replace yrest(4000) . Will need to test if player update needs in the repeat loop.
Code: Select all
player:updateBattling() -- you have aggro
repeat
yrest(200)
untill player.Battling
Re: check if in agro before casting home sweet home
Posted: Tue Jun 28, 2016 2:23 am
by kenzu38
Yes, you will have to update it inside the loop.
Code: Select all
player:updateBattling()
while player.Battling do
yrest()
player:updateBattling()
end
Re: check if in agro before casting home sweet home
Posted: Tue Jun 28, 2016 5:46 pm
by beanybabe
Here is what I ended up with this works fast, it needed a *not* this worked well will add it to more wp
Code: Select all
repeat -- you have aggro wait for aggro to drop
player:updateBattling()
yrest(500) -- little delay to lessen server updates.
until not player.Battling
Re: check if in agro before casting home sweet home
Posted: Thu Jul 28, 2016 9:51 am
by beanybabe
thanks again kenzu38 found another use for aggro check when opening chests in mirror.