English delete this

2 replies
Goto Page
To the start Previous 1 Next To the start
15.08.22 05:33:33 pm
Up
khaled1968
User
Offline Off
I posted a script request but then I figured out that my request already exists on the site... and admin/mod may delete this ^-^;

sorry for not paying attention
edited 1×, last 15.08.22 05:54:05 pm
15.08.22 06:02:16 pm
Up
Cebra
User
Offline Off
For the first problem: Instead of the rotation of the player, use the attack angle, it would look something like this:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- aid = attacker id
-- vid = victim id
dx = player(vid, "x") - player(aid, "x")
dy = player(vid, "y") - player(aid, "y")


-- normalizing
mag = math.sqrt(dx*dx + dy*dy)
dx_norm = dx / mag
dy_norm = dy / mag

-- new position
knockback scaling = 0.05
x_new = player(vid, "x") + dx_normed * knockback scaling
y_new = player(vid, "y") + dy_normed * knockback scaling


and the second problem: with
x_new
and
y_new
you can calculate the new tile, and then check with
tile(tilex_new, tiley_new, "walkable")
if you can go there or not.

edit: whopsie, i was to fast
loading...
15.08.22 06:28:39 pm
Up
khaled1968
User
Offline Off
@user Cebra: wow! thanks
To the start Previous 1 Next To the start