It's not often where I ask for entire functions but this time I just couldn't find a good way to make something work.
I need a function that will teleport a player (overtime, but quickly) towards his mouse cursor, for the sake of this experiment it would be nice if the speed can easily be modified.
But it will only pull him up to a wall and not into the wall.
So it can't be used to go over/inside walls, just to get to them.
Similar to... Spiderman?
It should also have a limited range that can be easily modified, if the player is too far from a wall (using the limit), it will not move him at all.
This is how far I got, I couldn't really make it work very well:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local limit = 0 		 		while true do 			limit = limit + 1 			 			local rot = player(p, 'rot') 			 			if rot < -90 then rot = rot + 360 end 			 			local angle = _math.rad( _math.abs( rot + 90 ) ) - _math.pi 			local x = future_x(p) + _math.cos(angle) * 10 			local y = future_y(p) + _math.sin(angle) * 10 			 			local tx, ty = _math.floor(x / 32), _math.floor(y / 32) 			 			local property = tile(tx, ty, 'property') 			 			if property >= 1 and property <= 4 or tile(tx, ty, 'frame') == 0 or limit >= 20 then 				break 			end 			 			hc.players[p].test.f_x = x 			hc.players[p].test.f_y = y 			 			timer(limit * 15, 'parse', 'setpos ' .. p .. ' ' .. x .. ' ' .. y) 		end
Using the following functions:
1
2
3
4
5
6
7
2
3
4
5
6
7
local future_x = function(p) 	return hc.players[p].test.f_x or player(p, 'x') end local future_y = function(p) 	return hc.players[p].test.f_y or player(p, 'y') end