Forum

> > Trash > delete this
Forums overviewTrash overviewLog in to reply

English delete this

2 replies
To the start Previous 1 Next To the start

closed moved delete this

khaled1968
User Off Offline

Quote
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

old Re: delete this

Cebra
User Off Offline

Quote
For the first problem: Instead of the rotation of the player, use the attack angle, it would look something like this:
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
To the start Previous 1 Next To the start
Log in to replyTrash overviewForums overview