Page 1 of 1

Stay for a while and attac monsters, then move on

Posted: Wed Nov 02, 2011 3:33 pm
by Rickster
I would like to have the bot to move to one location (waypoint) and "rest" there for a while. But it should attack a monster as soon as it spawns. After finishing the monster the bot should stay in this place for the rest of his rest ;)

e.g. the bot should stay at a place for 20sec. after 10 secs a monsters spawns and the bot starts to fight for about 2 secs. after the death of the monster the bot waits ats this place for another 8secs.

I dont need exact timing, but a solution thats works like this.

Thanks
Ric

Re: Stay for a while and attac monsters, then move on

Posted: Wed Nov 02, 2011 3:54 pm
by BillDoorNZ
pretty sure the player:rest() function will do that for you

Code: Select all

function CPlayer:rest(_restmin, _restmax, _resttype, _restaddrnd)
-- rest to restore mana and healthpoint if under a certain level
-- this function could also be used, if you want to rest in a waypoint file, it will
-- detect aggro while resting and fight back
--
--  player:rest( _restfix,[ _restrnd[, time|full[, _restaddrnd]]])
--
-- _restmin  ( minimum rest time in sec)
-- _restmax  ( maximum rest time sec)
-- _resttype ( time / full )  time = rest the given time  full = stop resting after being full   default = time
-- _restaddrnd  ( max random addition after being full in sec)
--
--
-- e.g.
-- player:rest(20)                 will rest for 20 seconds.
-- player:rest(60, 80)             will rest between 60 and 80 seconds.
-- player:rest(90, 130, "full")     will rest up to between 90 and 130 seconds, and stop resting
--                                 if being full
-- player:rest(20, 60, "full, 20") will rest up to between 20 and 60 seconds, and stop resting
--                                 if being full, and wait after that between 1-20 seconds
--
-- to look not so bottish, please use the random time options!!!

Re: Stay for a while and attac monsters, then move on

Posted: Wed Nov 02, 2011 5:09 pm
by Rickster
i tried your solution and it only does its work half the way.
when using

Code: Select all

player:rest(...)
it stops resting and fighting back when getting aggro.
if the monster is in combat range, but doesnt fight the character, the bot sill rests ... but i want the bot to stop resting and attack the monster in combat range.

Re: Stay for a while and attac monsters, then move on

Posted: Wed Nov 02, 2011 9:04 pm
by lisa
So basically you want to get yourself in a loop in that spot looking for enemies and move on after the specified time.

Code: Select all

_time = os.time()
repeat 
player:update()
player:checkSkills(true);
local mob = player:findenemy()
if mob then 
player:target(mob)
player:fight()
end
until os.time() - _time >= 5000
untested but add that to a spot in your WP and see how you go.

Re: Stay for a while and attac monsters, then move on

Posted: Thu Nov 03, 2011 4:50 pm
by kanta
I use the following code as a userfunction:

Code: Select all

function KillWhileWaiting(timetowait)
   local timetowait = timetowait or 60 --sets to 60 if no value for timetowait
   local starttime = os.time()
   repeat
      player:clearTarget();
      player:target(player:findEnemy())
      if player:haveTarget() then
         player:fight();
      end
   until os.time() - starttime >= timetowait
end
just change (timetowait) to however many seconds you want to stand there. Such as:

Code: Select all

   <!-- # 35 --><waypoint x="-8090" z="43434" y="379">   
   KillWhileWaiting(5)
   </waypoint>
character gets to the waypoint, looks for something to kill for 5 seconds then moves to the next waypoint.

Re: Stay for a while and attac monsters, then move on

Posted: Sun Dec 11, 2011 2:31 am
by Rickster
I have not been looking to this thread for a long time :-/
Your ideas look great. Have to use them ... :)

ric