Page 1 of 1

random jumping idea

Posted: Mon Nov 02, 2009 4:38 am
by raff
Hi,

cause i think it looks more human, if the bot will randomly jump, i wrote this function:

Code: Select all

	function randomjump()
	
	if( math.random(100) > 50 ) then
		keyboardHold(settings.hotkeys.JUMP.key);
		yrest(500);
		keyboardRelease(settings.hotkeys.JUMP.key);
end
end
So, when i will put

Code: Select all

randomjump();
in every waypoint, it works good for me.

But my question is:

is it possible to write a random timer that goes down from a random time like 10-40sek and then it will run this code?

Then it wouldnt be so hard to put randomjump(); between every waypoint

Re: random jumping idea

Posted: Mon Nov 02, 2009 4:47 am
by d003232
raff wrote:is it possible to write a random timer that goes down from a random time like 10-40sek and then it will run this code?
You could remeber the last jump with

Code: Select all

player.LastJump = os.time();
JumpGap = 10 + math.random(30)
and then do the check for that gap value

Code: Select all

if( os.difftime(os.time(), player.LastJump) > JumpGap ) then
...
I agree that the walking of the bot look not very human. In my opinion it is much to straight. And I think only to jump from time to time is not enough. If you jump to often, and I suppose ever 30 seconds is to often it looks also bottish. And perhaps that function should be called while walking, not while reaching a waypoint. Because of the fights between the waypoints, if would be difficult to find a good gap value ... I suppose you don't want to jump at every waypoit reach? :-)



Think if you see one farming at a place. After two hours he is still there farming and jumping. That also looks not so great.

I would like to have a some options to configure the walking. One option/timer for random jumps and some for walking not so straight.

Re: random jumping idea

Posted: Mon Nov 02, 2009 5:25 am
by raff
thanks for your fast answer :),

yes 30sek are really too often, of course it would be much better when it would triggered while walking, my lua skills arent good, that was the the only solution for me :P, but i'm still reading about lua, this bot motivates me to learn more about lua :)

Re: random jumping idea

Posted: Mon Nov 02, 2009 5:54 am
by d003232
raff wrote:thanks for your fast answer :),

yes 30sek are really too often, of course it would be much better when it would triggered while walking, my lua skills arent good, that was the the only solution for me :P, but i'm still reading about lua, this bot motivates me to learn more about lua :)
take a look at 'player:moveto'. I suppose that would be the right place for a global solution. But be carefully, that function is also used to move closer while into a fight.

Re: random jumping idea

Posted: Mon Nov 02, 2009 8:29 pm
by raff
thanks for your help d003232 :)

so i tried it at first with that code:

Code: Select all

if player:moveTo(CWaypoint(posX, posZ), true) and
	math.random(100) > 80 then
		keyboardHold(settings.hotkeys.JUMP.key);
		yrest(500);
		keyboardRelease(settings.hotkeys.JUMP.key);
but without success, bot will go to a empty waypoint after run this code.

a friend of mine helped me alot and wrote this code for me:

Code: Select all

if (self.Battling == false and self.Fighting == false) then
	JumpGap = 40 + math.random(120);
	
	if (not LastJump) then
		print("No last jump, jumping.");
		keyboardHold(settings.hotkeys.JUMP.key);
		yrest(500);
		keyboardRelease(settings.hotkeys.JUMP.key);
		LastJump = os.time();
	else
		if( os.difftime(os.time(), LastJump) > JumpGap ) then
			print("Jumping after "..os.difftime(os.time(), LastJump).."s ("..JumpGap.."s cooldown)");
			keyboardHold(settings.hotkeys.JUMP.key);
			yrest(500);
			keyboardRelease(settings.hotkeys.JUMP.key);
			LastJump = os.time();
		else
	end
end
end
i added this code in player.lua line 1140, this works for me without adding something to my waypoints