Page 1 of 1

Just a small question.

Posted: Tue Aug 09, 2011 2:49 am
by NightWing91
I would like to know which function I need to still look for a target and continue fighting instead of fighting back if you are attacked.
So it want this function: player:restrnd([probability [, minrest [, maxrest]]]); but instead of fighting back, I want it to look for a target during the rest and attack it.

Is that possible?

Re: Just a small question.

Posted: Tue Aug 09, 2011 3:14 am
by rock5
You could start it in wander mode with a radius of '0' and I think it will just stand there and kill stuff. Haven't tried it though.

Re: Just a small question.

Posted: Tue Aug 09, 2011 7:25 am
by NightWing91
Thanks for the reply, but its not really what i was looking for. I wanted to farm dog meat and have 4 waypoints that i use close to each other. But i dont want the bot to run in circles, the pauses should make it more realistic, but he must keep targeting and attacking the guard dogs.

Re: Just a small question.

Posted: Tue Aug 09, 2011 8:22 am
by lisa
You could probably do a check for the dog's and if not then have a yrest.
Thing is though if there is a dog in range you should attack it regardless of if you reach the waypoint coords or not.
If it was me I would go with the wander and radius 0. increase the max target distance and start the bot in the middle of where the dogs are. I'd also set the dogs in the "mobs" profile option so it doesn't bother to attack anything else.

If you set the distance properly then basically the bot will kill dogs anytime they appear and if no dogs to kill it will move to the same spot and wait for dogs.

Re: Just a small question.

Posted: Tue Aug 09, 2011 8:42 am
by rock5
There's no option for that. You would have to use yout own code. Something like,

Code: Select all

function mobWait(_waitTime)
   local starttime = os.clock()
   repeat
      yrest(1000)
      local mob = player:findEnemy(false, nil, evalTargetDefault)
      if target then
         player:target(mob)
         player:update()
         player:fight()
         break
      end
   until os.clock() - starttime > _waitTime
end
Put this in the onLoad section of your waypoint file. At the waypoints add

Code: Select all

mobWait(10000)
This should wait 10 seconds for a mob, kill it then move to the next waypoint. Use whatever pause time you like. If you want it to continue waiting after killing the mob, remove the "break".

Note: This is untested.

Although what Lisa said is probably easier and should work.

Re: Just a small question.

Posted: Thu Oct 13, 2011 4:37 am
by silinky
hi all, and rock5 :)

i used this function but for some reason on the second waypoint ( i am guessing where the mobwait occurs) just stands there not even fighting back to mobs.
can you tell my how can i fix this?
thanks!

Re: Just a small question.

Posted: Thu Oct 13, 2011 4:53 am
by rock5
There is a bug. I did say it was untested.

Code: Select all

      if target then
should be

Code: Select all

      if mob then
Also, I think '_waitTime' should be given in seconds not miliseconds. So '10' for 10 seconds.

Re: Just a small question.

Posted: Thu Oct 13, 2011 11:17 am
by silinky
lol i should have seen it myself.

anyway, thanks for the helpful reply :)