Page 1 of 1

how to make char walk backwards to a position?

Posted: Wed May 21, 2014 10:27 am
by silinky
hi, i have a weird question :)
can i make the char to walk backwards between 2 waypoints?
if yes, how?
can i implement this into player:moveto()?

thanks!

Re: how to make char walk backwards to a position?

Posted: Wed May 21, 2014 12:53 pm
by Administrator
You could probably modify it to do that with a little work. Just change the forward movement to backwards, and reverse the argument order for atan2 (this essentially would rotate the target angle by 180°).

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 2:18 am
by silinky
hmm i will try :)
thx!

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 2:50 am
by lisa
If it is purely between 2 locations and no others and you know there won't any other variables to affect it then you could just walk backwards a set amount of time. You would need to make sure to face the direction you want first and then do it and the time to walk backwards would require testing to get it right.

Code: Select all

			keyboardHold( settings.hotkeys.MOVE_BACKWARD.key);
			yrest(3000);
			keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key)

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 3:07 am
by ZZZZZ
lisa wrote:If it is purely between 2 locations and no others and you know there won't any other variables to affect it then you could just walk backwards a set amount of time. You would need to make sure to face the direction you want first and then do it and the time to walk backwards would require testing to get it right.

Code: Select all

			keyboardHold( settings.hotkeys.MOVE_BACKWARD.key);
			yrest(3000);
			keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key)
That's what I did to solve my gate healing issue. You want the healer to be standing at max range so mages and 'through-wall' skills can't hit you.

Code: Select all

repeat
	keyboardPress(settings.hotkeys.MOVE_BACKWARD.key)
	player:update()
until distance(player, gateTarget) > 250

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 3:18 am
by lisa
would look funny steping back a little at a time, if you actually had to worry about what people saw you could do.

Code: Select all

         keyboardHold( settings.hotkeys.MOVE_BACKWARD.key);
         repeat
                  player:updateXYZ()
                  yrest(1)
         until distance(player, gateTarget) > 250
         keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key)

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 3:40 am
by ZZZZZ
It was fast enough that it backed up constantly. At least it did when I was testing it. Probably better off doing it your way just in case it was running slower at some point.

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 4:25 am
by lisa
well the difference would be in the motion, if you don't have motion files then you may not notice it.
With motion though and key pressing constantly it would look like it was changing from walk back to still to walk back repeatedly but with holding key it would just be walking backwards.

Re: how to make char walk backwards to a position?

Posted: Thu May 22, 2014 5:36 pm
by silinky
thanks!
the problem is, that it should walk backwards to a set coordinate and kite a boss in a circle, while it should spam a dps macro. so when the boss gets into a range of 120, it should go backwards to the next waypoint coordinates.

basically:
1. have a waypoint file with some waypoints, or a table with coordinates, for example:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<!-- #  1 --><waypoint x="-30482" z="1229" y="-478">	</waypoint>
	<!-- #  2 --><waypoint x="-30656" z="1267" y="-471">	</waypoint>
	<!-- #  3 --><waypoint x="-30697" z="1394" y="-452">	</waypoint>
	<!-- #  4 --><waypoint x="-30605" z="1504" y="-445">	</waypoint>
	<!-- #  5 --><waypoint x="-30492" z="1480" y="-446">	</waypoint>
	<!-- #  6 --><waypoint x="-30402" z="1387" y="-455">	</waypoint>
	<!-- #  7 --><waypoint x="-30399" z="1233" y="-475">	</waypoint>
</waypoints>
2. if the aggroed boss comes closer than 120, move to next waypoint (with a greater than normal speed)
3. while keep spaming the dps macro (made with diyce, but that is besides the point i think.

i tried teleporting, but it was too erratic, and the char died from server error. basically the bot should kite the boss in a circle (set in the waypoint), untill it kills it.

i hope it is clearer now, and i hope somebody smarter than me can help. this is how it looks so far, but it is very alpha and nubish yet. and it doesn't work with teleport.

help :oops:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<onLoad>
		changeProfileOption("TARGET_LEVELDIF_BELOW", 10)
		changeProfileOption("TARGET_LEVELDIF_ABOVE", 1)
		teleport_SetStepPause(100)
		
		waypointnumber = 7
		index = waypointnumber
		
		function gotonextWP(index)
			if index == 0 then
				teleport(-30482,1229,-478)
				lookatTarget(-30399,1233,-475)
			end
			if index == 1 then
				teleport(-30656,1267,-471)
				lookatTarget(-30482,1229,-478)
			end
			if index == 2 then
				teleport(-30697,1394,-452)
				lookatTarget(-30656,1267,-471)
			end
			if index == 3 then
				teleport(-30605,1504,-445)
				lookatTarget(-30697,1394,-452)
			end
			if index == 4 then
				teleport(-30492,1480,-446)
				lookatTarget(-30605,1504,-445)
			end
			if index == 5 then
				teleport(-30402,1387,-455)
				lookatTarget(-30492,1480,-446)
			end
			if index == 6 then
				teleport(-30399,1233,-475)
				lookatTarget(-30402,1387,-455)
			end
		end
		
		

		function lookatTarget(X,Z,Y)   
			local angle  = math.atan2(Z - player.Z, X - player.X);
			local yangle = math.atan2(Y - player.Y, ((X - player.X)^2 + (Z - player.Z)^2)^.5 );                  
			player:faceDirection(angle, yangle);
			camera:setRotation(angle);
		end
		
		function getaway()
		printf(math.fmod(index,waypointnumber))
			gotonextWP(math.fmod(index,waypointnumber))
			index = index+1
		end
		
		--	do this indefinitely
		while (true) do
			if CountMobs(1, 120) then
				RoMScript("KillSequence()") -- this also takes care of the targetting of the boss so it won't target adds
				getaway()
				yrest(100)
			end
		end
	</onLoad>
</waypoints>

Re: how to make char walk backwards to a position?

Posted: Fri May 30, 2014 8:54 am
by silinky
i did it finally in another way, no need to complicate myself needlessly.
i used this waypoint as starter, and set the room center as centerpoint. now i can successfully kite bosses

Image