-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathArenaCloser.ts
More file actions
87 lines (66 loc) · 3.11 KB
/
ArenaCloser.ts
File metadata and controls
87 lines (66 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
DiepCustom - custom tank game server that shares diep.io's WebSocket protocol
Copyright (C) 2022 ABCxFF (github.com/ABCxFF)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
import GameServer from "../../Game";
import TankBody from "../Tank/TankBody";
import { Color, PhysicsFlags, PositionFlags, Stat, Tank } from "../../Const/Enums";
import { CameraEntity } from "../../Native/Camera";
import { AI, AIState, Inputs } from "../AI";
/**
* Represents the Arena Closers that end the game.
*/
export default class ArenaCloser extends TankBody {
/** Size of a level 0 Arena Closer. */
public static BASE_SIZE = 175;
/** The AI that controls how the AC moves. */
public ai: AI;
public constructor(game: GameServer) {
const inputs = new Inputs();
const camera = new CameraEntity(game);
super(game, camera, inputs);
camera.cameraData.values.player = this;
camera.setLevel(300);
this.scaleFactor = 1;
this.scale(ArenaCloser.BASE_SIZE / this.baseSize);
this.relationsData.values.team = game.arena;
this.ai = new AI(this);
this.ai.inputs = inputs;
this.ai.viewRange = Infinity;
this.setTank(Tank.ArenaCloser);
this.nameData.values.name = "Arena Closer";
this.styleData.values.color = Color.Neutral;
this.positionData.values.flags |= PositionFlags.canMoveThroughWalls;
this.physicsData.values.flags |= PhysicsFlags.canEscapeArena;
for (let i = Stat.MovementSpeed; i < Stat.BodyDamage; ++i) camera.setStat(i as Stat, 7);
this.ai.aimSpeed = this.barrels[0].bulletAccel * 1.6;
this.setInvulnerability(true);
// TODO(ABC):
// Fix all the stats
this.ai.movementSpeed = this.cameraEntity.cameraData.values.movementSpeed = 5;
this.healthData.values.health = this.healthData.values.maxHealth = 10000;
this.damagePerTick = 45;
}
public tick(tick: number) {
this.inputs = this.ai.inputs;
if (this.ai.state === AIState.idle) {
const angle = this.positionData.values.angle + this.ai.passiveRotation;
const mag = Math.sqrt((this.inputs.mouse.x - this.positionData.values.x) ** 2 + (this.inputs.mouse.y - this.positionData.values.y) ** 2);
this.inputs.mouse.set({
x: this.positionData.values.x + Math.cos(angle) * mag,
y: this.positionData.values.y + Math.sin(angle) * mag
});
}
super.tick(tick);
}
}