Skip to content

Commit d23e712

Browse files
Merge pull request #2916 from QuentinGruber/fix/zombieAirdropCrossFire
fix/zombieAirdropCrossFire
2 parents 44b3921 + 331dc2c commit d23e712

3 files changed

Lines changed: 61 additions & 48 deletions

File tree

‎data/2016/sampleData/defaultconfig.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ airdrop:
8585
minimumPlayers: 10
8686
# Drop at a random valid spot in the caller's grid cell. This is experimental, use at your own risk.
8787
useNavmesh: true
88+
# Spawn a horde of zombies around the crate once it has landed
89+
spawnZombiesOnLanding: true
90+
zombiesPerAirdrop: 15
91+
zombieSpawnRadius: 0.5
8892
types:
8993
normal:
9094
planeSpeed: 140000

‎src/servers/ZoneServer2016/managers/airdropmanager.ts‎

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
import { ZoneClient2016 } from "../classes/zoneclient";
1414
import { ExplosiveEntity } from "../entities/explosiveentity";
1515
import { AirdropConfig, AirdropTypeConfig } from "../models/config";
16+
import { ZombieWalker } from "../entities/zombiewalker";
17+
18+
const debug = require("debug")("airdropManager");
1619

1720
interface 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()) {

‎src/servers/ZoneServer2016/models/config.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ export interface AirdropConfig {
191191
minimumPlayers: number;
192192
/** Use the navmesh to drop at a random valid spot in the caller's grid cell. */
193193
useNavmesh: boolean;
194+
/** Spawn a horde of zombies around the crate once it has landed. */
195+
spawnZombiesOnLanding: boolean;
196+
/** Zombies spawned around each landed crate. */
197+
zombiesPerAirdrop: number;
198+
/** Distance from the crate, in world units, the zombies spawn at. */
199+
zombieSpawnRadius: number;
194200
/** Overrides per airdrop type, keyed by name (normal, bombing, ...). */
195201
types: Record<string, Partial<AirdropTypeConfig>>;
196202
}

0 commit comments

Comments
 (0)