1
0
forked from noxious/server

Fix character movement speed, fix for diagonal movement and disabled it by default

This commit is contained in:
2024-09-07 18:08:10 +02:00
parent 2ecc65b14c
commit 194c5d23af
6 changed files with 40 additions and 22 deletions

View File

@ -1,25 +1,35 @@
import config from '../config'
class Rotation {
static calculate(X1: number, Y1: number, X2: number, Y2: number): number {
let rotation = 0
if (X1 > X2 && Y1 > Y2) {
rotation = 7
} else if (X1 < X2 && Y1 < Y2) {
rotation = 3
} else if (X1 > X2 && Y1 < Y2) {
rotation = 5
} else if (X1 < X2 && Y1 > Y2) {
rotation = 1
} else if (X1 > X2) {
rotation = 6
} else if (X1 < X2) {
rotation = 2
} else if (Y1 < Y2) {
rotation = 4
} else if (Y1 > Y2) {
rotation = 0
if (config.ALLOW_DIAGONAL_MOVEMENT) {
if (X1 > X2 && Y1 > Y2) {
rotation = 7
} else if (X1 < X2 && Y1 < Y2) {
rotation = 3
} else if (X1 > X2 && Y1 < Y2) {
rotation = 5
} else if (X1 < X2 && Y1 > Y2) {
rotation = 1
}
}
if (rotation === 0) {
if (X1 > X2) {
rotation = 6
} else if (X1 < X2) {
rotation = 2
} else if (Y1 < Y2) {
rotation = 4
} else if (Y1 > Y2) {
rotation = 0
}
}
return rotation
}
}
export default Rotation
export default Rotation