delete this
2 replies



15.08.22 05:33:33 pm
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
sorry for not paying attention

edited 1×, last 15.08.22 05:54:05 pm
For the first problem: Instead of the rotation of the player, use the attack angle, it would look something like this:
and the second problem: with
edit: whopsie, i was to fast
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
-- 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...



