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.
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!!!
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.
_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.
Remember no matter you do in life to always have a little fun while you are at it
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: