@@ -13,6 +13,9 @@ import {
1313import { ZoneClient2016 } from "../classes/zoneclient" ;
1414import { ExplosiveEntity } from "../entities/explosiveentity" ;
1515import { AirdropConfig , AirdropTypeConfig } from "../models/config" ;
16+ import { ZombieWalker } from "../entities/zombiewalker" ;
17+
18+ const debug = require ( "debug" ) ( "airdropManager" ) ;
1619
1720interface DeliveryProgressData {
1821 progress : number ;
@@ -109,7 +112,7 @@ export class AirdropManager {
109112 }
110113 } ;
111114
112- // Zombie spawn-on-landing settings
115+ // Zombie spawn-on-landing settings, will be override by config
113116 public spawnZombiesOnLanding : boolean = true ;
114117 public zombiesPerAirdrop : number = 15 ;
115118 public zombieSpawnRadius : number = 0.5 ;
@@ -120,6 +123,10 @@ export class AirdropManager {
120123 applyConfig ( cfg : AirdropConfig ) {
121124 this . minimumPlayers = cfg . minimumPlayers ;
122125 this . useNavmesh = cfg . useNavmesh ?? false ;
126+ this . spawnZombiesOnLanding =
127+ cfg . spawnZombiesOnLanding ?? this . spawnZombiesOnLanding ;
128+ this . zombiesPerAirdrop = cfg . zombiesPerAirdrop ?? this . zombiesPerAirdrop ;
129+ this . zombieSpawnRadius = cfg . zombieSpawnRadius ?? this . zombieSpawnRadius ;
123130 for ( const [ name , overrides ] of Object . entries ( cfg . types ?? { } ) ) {
124131 const type = this . airdropTypes [ name ] ;
125132 if ( ! type ) continue ; // unknown type in config; nothing to tune
@@ -330,10 +337,10 @@ export class AirdropManager {
330337 ) ;
331338
332339 if ( this . spawnZombiesOnLanding ) {
333- debug ( "[AIRDROP] About to spawn zombies" ) ;
334- this . spawnAirdropZombies ( position ) ;
335- debug ( "[AIRDROP] Finished spawning zombies" ) ;
336- }
340+ debug ( "[AIRDROP] About to spawn zombies" ) ;
341+ this . spawnAirdropZombies ( position ) ;
342+ debug ( "[AIRDROP] Finished spawning zombies" ) ;
343+ }
337344 } ,
338345 Math . floor ( tickAtPos + crateDropSpeed )
339346 ) ;
@@ -501,56 +508,52 @@ export class AirdropManager {
501508 * Called once the crate has finished its delivery animation.
502509 */
503510 spawnAirdropZombies (
504- position : Float32Array ,
505- count : number = this . zombiesPerAirdrop ,
506- radius : number = this . zombieSpawnRadius
507- ) {
508- for ( let i = 0 ; i < count ; i ++ ) {
509- const angle = ( i / count ) * Math . PI * 2 ;
510-
511- const spawnPos = new Float32Array ( [
512- position [ 0 ] + Math . cos ( angle ) * radius ,
513- position [ 1 ] ,
514- position [ 2 ] + Math . sin ( angle ) * radius ,
515- 0
516- ] ) ;
517-
518- const modelId =
519- Math . random ( ) < 0.5
520- ? ModelIds . ZOMBIE_MALE_WALKER
521- : ModelIds . ZOMBIE_FEMALE_WALKER ;
511+ position : Float32Array ,
512+ count : number = this . zombiesPerAirdrop ,
513+ radius : number = this . zombieSpawnRadius
514+ ) {
515+ for ( let i = 0 ; i < count ; i ++ ) {
516+ const angle = ( i / count ) * Math . PI * 2 ;
522517
523- const rotation = eul2quat (
524- new Float32Array ( [
525- 0 ,
526- Math . random ( ) * Math . PI * 2 ,
518+ const spawnPos = new Float32Array ( [
519+ position [ 0 ] + Math . cos ( angle ) * radius ,
520+ position [ 1 ] ,
521+ position [ 2 ] + Math . sin ( angle ) * radius ,
527522 0
528- ] )
529- ) ;
523+ ] ) ;
530524
531- const characterId = this . server . generateGuid ( ) ;
532- const transientId = this . server . getTransientId ( characterId ) ;
525+ const modelId =
526+ Math . random ( ) < 0.5
527+ ? ModelIds . ZOMBIE_MALE_WALKER
528+ : ModelIds . ZOMBIE_FEMALE_WALKER ;
533529
534- const zombie = new ZombieWalker (
535- characterId ,
536- transientId ,
537- modelId ,
538- spawnPos ,
539- rotation ,
540- this . server
541- ) ;
530+ const rotation = eul2quat (
531+ new Float32Array ( [ 0 , Math . random ( ) * Math . PI * 2 , 0 ] )
532+ ) ;
542533
543- this . server . _npcs [ characterId ] = zombie ;
534+ const characterId = this . server . generateGuid ( ) ;
535+ const transientId = this . server . getTransientId ( characterId ) ;
544536
545- console . log (
546- `[AIRDROP ZOMBIE] spawned ${ characterId } ` +
547- `model=${ modelId } ` +
548- `pos=[${ spawnPos [ 0 ] . toFixed ( 2 ) } , ` +
549- `${ spawnPos [ 1 ] . toFixed ( 2 ) } , ` +
550- `${ spawnPos [ 2 ] . toFixed ( 2 ) } ]`
551- ) ;
537+ const zombie = new ZombieWalker (
538+ characterId ,
539+ transientId ,
540+ modelId ,
541+ spawnPos ,
542+ rotation ,
543+ this . server
544+ ) ;
545+
546+ this . server . _npcs [ characterId ] = zombie ;
547+
548+ debug (
549+ `[AIRDROP ZOMBIE] spawned ${ characterId } ` +
550+ `model=${ modelId } ` +
551+ `pos=[${ spawnPos [ 0 ] . toFixed ( 2 ) } , ` +
552+ `${ spawnPos [ 1 ] . toFixed ( 2 ) } , ` +
553+ `${ spawnPos [ 2 ] . toFixed ( 2 ) } ]`
554+ ) ;
555+ }
552556 }
553- }
554557
555558 broadcastDeliveryInfo ( client : ZoneClient2016 | undefined = undefined ) {
556559 for ( const [ airdropId , airdrop ] of this . activeAirdrops . entries ( ) ) {
0 commit comments