They don't always get stuck though. Sometimes it happens, but it's still annoying and ruins the game.
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
function _knockback(id,source) local shooter_x,shooter_y = player(source,"x"),player(source,"y") local zombie_x,zombie_y = player(id,"x"),player(id,"y") local direction_x,direction_y = zombie_x - shooter_x,zombie_y - shooter_y local length = math.sqrt(direction_x * direction_x + direction_y * direction_y) direction_x,direction_y = direction_x / length,direction_y / length local new_x,new_y = zombie_x + dataText[id].knockback * direction_x,zombie_y + dataText[id].knockback * direction_y local tile_x,tile_y = math.floor(new_x/32),math.floor(new_y/32) if tile(tile_x,tile_y,"walkable") then parse("setpos "..id.." "..new_x.." "..new_y) end end