Page 1 of 1

replacement?

Posted: Mon Jan 30, 2012 1:43 am
by jdawg78
hey im looking for a replacement for yrest(); and player:rest(); i want my bot to wait after each waypoint but remain to attack, not just defend itself if nessecary. any solutions?

Re: replacement?

Posted: Mon Jan 30, 2012 3:00 am
by lisa
player:restrnd([probability [, minrest [, maxrest]]]);

e.g. 'player:restrnd(30, 3, 10);' Rest with a probability from 30% at that waypoint for between 3 and 10 seconds. The bot will fight back if attacked while resting and continue after that.

Re: replacement?

Posted: Mon Jan 30, 2012 12:08 pm
by jdawg78
The bot will fight back if attacked while resting and continue after that.
i want it to not just attack if attacked, but to attack if the enemy is within range.

Re: replacement?

Posted: Mon Jan 30, 2012 1:11 pm
by rock5
So you want it kill mobs at a waypoint for a period of time before moving on? That should be easy enough but making sure you don't go astray will be a bit more tricky. The best way is to make a function that looks for and kills mobs that are within a certain distance from the waypoint.

Code: Select all

function KillMobsFor(_seconds)
	-- Where you started
	local currentwp= CWaypoint( player.X, player.Z)
	
	local mob
	local starttime = os.clock()
	repeat
		mob = player:findEnemy(nil,nil,evalTargetDefault)
		if mob and settings.profile.options.MAX_TARGET_DIST > distance(mob.X,mob.Z,currentwp.X,currentwp.Z) then
			player:target(mob)
			player:update()
			player:fight()
		else
			-- No mob found. Move back to wp if necessary.
			if distance(player.X,player.Z,currentwp.X,currentwp.Z) > 100 then
				player:moveTo(currentwp)
			end
		end
		yrest(1000)
		player:update()
	until os.clock() - starttime > _seconds
end
Put this in the onload section of your waypoint (or make a userfunction out of it so that you can use it in more than one file). Then call it at the waypoints where you want it to wait and kill for awhile.

Eg.

Code: Select all

KillMobsFor(30)
Will kill mobs for 30 seconds then move to next waypoint. It will only target mobs that are within "MAX_TARGET_DIST" from the waypoint and if it doesn't detect a mob, it will move back to the waypoint if farther than 100. I'm not sure if you wanted it to do that but I'm not sure how else to make sure it doesn't go too far.

Warning: This is untested.

Re: replacement?

Posted: Mon Jan 30, 2012 7:41 pm
by jdawg78
thanks rock5, pretty much what i wanted ill see if i can tweak it and put it to use. :D