1818
1919import Client from "../Client"
2020import { AccessLevel , maxPlayerLevel } from "../config" ;
21+
22+ import ObjectEntity from "../Entity/Object" ;
23+ import LivingEntity from "../Entity/Live" ;
24+
2125import AbstractBoss from "../Entity/Boss/AbstractBoss" ;
2226import Defender from "../Entity/Boss/Defender" ;
2327import FallenBooster from "../Entity/Boss/FallenBooster" ;
2428import FallenOverlord from "../Entity/Boss/FallenOverlord" ;
2529import Guardian from "../Entity/Boss/Guardian" ;
2630import Summoner from "../Entity/Boss/Summoner" ;
27- import LivingEntity from "../Entity/Live" ;
31+
2832import ArenaCloser from "../Entity/Misc/ArenaCloser" ;
2933import FallenAC from "../Entity/Misc/Boss/FallenAC" ;
30- import Mothership from "../Entity/Misc/Mothership" ;
3134import FallenSpike from "../Entity/Misc/Boss/FallenSpike" ;
3235import FallenMegaTrapper from "../Entity/Misc/Boss/FallenMegaTrapper" ;
36+
37+ import Mothership from "../Entity/Misc/Mothership" ;
3338import Dominator from "../Entity/Misc/Dominator" ;
34- import ObjectEntity from "../Entity/Object" ;
39+
3540import AbstractShape from "../Entity/Shape/AbstractShape" ;
3641import Crasher from "../Entity/Shape/Crasher" ;
3742import Pentagon from "../Entity/Shape/Pentagon" ;
3843import Square from "../Entity/Shape/Square" ;
3944import Triangle from "../Entity/Shape/Triangle" ;
45+
4046import AutoTurret from "../Entity/Tank/AutoTurret" ;
4147import Bullet from "../Entity/Tank/Projectile/Bullet" ;
4248import TankBody from "../Entity/Tank/TankBody" ;
49+
50+ import { TeamEntity } from "../Entity/Misc/TeamEntity" ;
4351import { AIState } from "../Entity/AI" ;
4452import { Entity , EntityStateFlags } from "../Native/Entity" ;
4553import { saveToVLog } from "../util" ;
@@ -60,6 +68,7 @@ export const enum CommandID {
6068 gameGodmode = "game_godmode" ,
6169 gameAnnounce = "game_announce" ,
6270 gameGoldenName = "game_golden_name" ,
71+ gameNeutral = "game_neutral" ,
6372 adminSummon = "admin_summon" ,
6473 adminKillAll = "admin_kill_all" ,
6574 adminKillEntity = "admin_kill_entity" ,
@@ -154,6 +163,12 @@ export const commandDefinitions = {
154163 description : "Toggles the golden nickname color that appears upon using cheats" ,
155164 permissionLevel : AccessLevel . FullAccess ,
156165 isCheat : false
166+ } ,
167+ game_neutral : {
168+ id : CommandID . gameNeutral ,
169+ description : "Sets your tank's team to the neutral team" ,
170+ permissionLevel : AccessLevel . FullAccess ,
171+ isCheat : false
157172 } ,
158173 admin_summon : {
159174 id : CommandID . adminSummon ,
@@ -194,23 +209,23 @@ export const commandCallbacks = {
194209 game_set_level : ( client : Client , levelArg : string ) => {
195210 const level = parseInt ( levelArg ) ;
196211 const player = client . camera ?. cameraData . player ;
197- if ( isNaN ( level ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) ) return ;
212+ if ( ! isFinite ( level ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) ) return ;
198213 const finalLevel = client . accessLevel == AccessLevel . FullAccess ? level : Math . min ( maxPlayerLevel , level ) ;
199214 client . camera ?. setLevel ( finalLevel ) ;
200215 } ,
201216 game_set_score : ( client : Client , scoreArg : string ) => {
202217 const score = parseInt ( scoreArg ) ;
203218 const camera = client . camera ?. cameraData ;
204219 const player = client . camera ?. cameraData . player ;
205- if ( isNaN ( score ) || score > Number . MAX_SAFE_INTEGER || score < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
220+ if ( ! isFinite ( score ) || score > Number . MAX_SAFE_INTEGER || score < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
206221 camera . score = score ;
207222 } ,
208223 game_set_stat_max : ( client : Client , statIdArg : string , statMaxArg : string ) => {
209224 const statId = StatCount - parseInt ( statIdArg ) ;
210225 const statMax = parseInt ( statMaxArg ) ;
211226 const camera = client . camera ?. cameraData ;
212227 const player = client . camera ?. cameraData . player ;
213- if ( statId < 0 || statId >= StatCount || isNaN ( statId ) || isNaN ( statMax ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
228+ if ( statId < 0 || statId >= StatCount || ! isFinite ( statId ) || ! isFinite ( statMax ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
214229 const clampedStatMax = Math . max ( statMax , 0 ) ;
215230 camera . statLimits [ statId as Stat ] = clampedStatMax ;
216231 camera . statLevels [ statId as Stat ] = Math . min ( camera . statLevels [ statId as Stat ] , clampedStatMax ) ;
@@ -220,22 +235,27 @@ export const commandCallbacks = {
220235 const statPoints = parseInt ( statPointsArg ) ;
221236 const camera = client . camera ?. cameraData ;
222237 const player = client . camera ?. cameraData . player ;
223- if ( statId < 0 || statId >= StatCount || isNaN ( statId ) || isNaN ( statPoints ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
238+ if ( statId < 0 || statId >= StatCount || ! isFinite ( statId ) || ! isFinite ( statPoints ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
224239 camera . statLevels [ statId as Stat ] = statPoints ;
225240 } ,
226241 game_add_upgrade_points : ( client : Client , pointsArg : string ) => {
227242 const points = parseInt ( pointsArg ) ;
228243 const camera = client . camera ?. cameraData ;
229244 const player = client . camera ?. cameraData . player ;
230- if ( isNaN ( points ) || points > Number . MAX_SAFE_INTEGER || points < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
245+ if ( ! isFinite ( points ) || points > Number . MAX_SAFE_INTEGER || points < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
231246 camera . statsAvailable += points ;
232247 } ,
233248 game_teleport : ( client : Client , xArg : string , yArg : string ) => {
234249 const player = client . camera ?. cameraData . player ;
235250 if ( ! Entity . exists ( player ) || ! ObjectEntity . isObject ( player ) ) return ;
251+
252+ if ( ! xArg || ! yArg ) return ;
253+
236254 const x = xArg . match ( RELATIVE_POS_REGEX ) ? player . positionData . x + parseInt ( xArg . slice ( 1 ) || "0" , 10 ) : parseInt ( xArg , 10 ) ;
237255 const y = yArg . match ( RELATIVE_POS_REGEX ) ? player . positionData . y + parseInt ( yArg . slice ( 1 ) || "0" , 10 ) : parseInt ( yArg , 10 ) ;
238- if ( isNaN ( x ) || isNaN ( y ) ) return ;
256+
257+ if ( ! isFinite ( x ) || ! isFinite ( y ) ) return ;
258+
239259 player . positionData . x = x ;
240260 player . positionData . y = y ;
241261 player . setVelocity ( 0 , 0 ) ;
@@ -293,6 +313,15 @@ export const commandCallbacks = {
293313 game_golden_name : ( client : Client , activeArg ?: string ) => {
294314 client . setHasCheated ( ! client . hasCheated ( ) ) ;
295315 } ,
316+ game_neutral : ( client : Client ) => {
317+ const team = client . camera ?. game . arena ;
318+ const player = client . camera ?. cameraData . values . player ;
319+
320+ if ( ! team || ! player ) return ;
321+ if ( ! ObjectEntity . isObject ( player ) ) return ;
322+
323+ TeamEntity . setTeam ( team , player ) ;
324+ } ,
296325 admin_summon : ( client : Client , entityArg : string , countArg ?: string , xArg ?: string , yArg ?: string ) => {
297326 const count = countArg ? parseInt ( countArg ) : 1 ;
298327 let x = parseInt ( xArg || "0" , 10 ) ;
@@ -326,11 +355,11 @@ export const commandCallbacks = {
326355 [ "Triangle" , Triangle ]
327356 ] as [ string , typeof ObjectEntity ] [ ] ) . get ( entityArg ) ;
328357
329- if ( isNaN ( count ) || count < 0 || ! game || ! TEntity ) return ;
358+ if ( ! isFinite ( count ) || count < 0 || ! game || ! TEntity ) return ;
330359
331360 for ( let i = 0 ; i < count ; ++ i ) {
332361 const boss = new TEntity ( game ) ;
333- if ( ! isNaN ( x ) && ! isNaN ( y ) ) {
362+ if ( isFinite ( x ) && isFinite ( y ) ) {
334363 boss . positionData . x = x ;
335364 boss . positionData . y = y ;
336365 }
0 commit comments