Skip to content

Commit

Permalink
Unify remaining spawn handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
caligari87 committed Sep 6, 2020
1 parent 52663b7 commit ec214ab
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 26 deletions.
4 changes: 0 additions & 4 deletions mapinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ GameInfo {
AddEventHandlers = "UaS_Bootstrap"
AddEventHandlers = "UaS_Scarcity_Handler"
AddEventHandlers = "UaS_FragRemovalHandler"
AddEventHandlers = "UaS_Ally_Spawner"
AddEventHandlers = "UaS_AI_Bootstrap"
AddEventHandlers = "UaS_VisWeps_Bootstrap"
AddEventHandlers = "UaS_Sling_Spawner"
AddEventHandlers = "UaS_Glowstick_Spawner"
AddEventHandlers = "UaS_Flare_Spawner"
AddEventHandlers = "UaS_YOLO_Handler"
}
4 changes: 2 additions & 2 deletions modules/allies/spawner.zsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UaS_Ally_Spawner : EventHandler {
extend class UaS_Spawner {
double spawnChance;

override void WorldLoaded(WorldEvent e) {
Expand All @@ -8,7 +8,7 @@ class UaS_Ally_Spawner : EventHandler {
}

//Spawn allied marines randomly
override void WorldThingSpawned(WorldEvent e) {
void AllySpawns(WorldEvent e) {
bool replaced = false;

// Conditions for skipping spawns
Expand Down
2 changes: 1 addition & 1 deletion modules/hunger/spawner.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extend class UaS_Spawner {
if(UaS.RandomChance(0.5)) { toSpawnClass = 'UaS_WaterRation'; }

//Spawn rations on backpacks, with a chance of an extra ration
if(e.Thing.GetClassName() == "Backpack") {
if(e.Thing.GetClassName() == "HDBackpack") {
UaS.SpawnStuff('UaS_FoodRation', 1, spawnPos);
UaS.SpawnStuff('UaS_WaterRation', 1, spawnPos);
}
Expand Down
8 changes: 4 additions & 4 deletions modules/items/flare.zsc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class UaS_Flare_Spawner : EventHandler {
extend class UaS_Spawner {
//Set up spawns
override void WorldThingSpawned(WorldEvent e) {
void FlareSpawns(WorldEvent e) {
if(level.maptime > 1) { return; }
if(!e.Thing) { return; }
if(e.Thing is "Inventory" && Inventory(e.Thing).Owner) { return; }
Expand All @@ -9,10 +9,10 @@ class UaS_Flare_Spawner : EventHandler {
e.thing.GetClassName() == "HDAmBox" ||
e.Thing.GetClassName() == "PortableStimpack" ||
e.Thing.GetClassName() == "PortableMedikit" ||
e.Thing.GetClassName() == "HDBP");
e.Thing.GetClassName() == "HDBackpack");

if(spawnable) {
UaS.SpawnStuff('UaS_flare', randompick[flare](0, 0, 1), e.Thing.pos);
UaS.SpawnStuff('UaS_flare', randompick[flare](0, 0, 0, 1), e.Thing.pos);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions modules/items/glowstick.zsc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class UaS_Glowstick_Spawner : EventHandler {
//Set up spawns
override void WorldThingSpawned(WorldEvent e) {
extend class UaS_Spawner {
void GlowstickSpawns(WorldEvent e) {
if(level.maptime > 1) { return; }
if(!e.Thing) { return; }
if(e.Thing is "Inventory" && Inventory(e.Thing).Owner) { return; }
Expand All @@ -9,10 +8,10 @@ class UaS_Glowstick_Spawner : EventHandler {
e.thing.GetClassName() == "HDAmBox" ||
e.Thing.GetClassName() == "PortableStimpack" ||
e.Thing.GetClassName() == "PortableMedikit" ||
e.Thing.GetClassName() == "HDBP");
e.Thing.GetClassName() == "HDBackpack");

if(spawnable) {
UaS.SpawnStuff('UaS_Glowstick', randompick[glowstick](0, 0, 1, 2), e.Thing.pos);
UaS.SpawnStuff('UaS_Glowstick', randompick[glowstick](0, 0, 0, 1), e.Thing.pos);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions modules/items/laser.zsc
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
extend class UaS_Spawner {
void LLMSpawns(WorldEvent e) {
if(level.maptime > 1) { return; }
if(!e.Thing) { return; }
if(e.Thing is "Inventory" && Inventory(e.Thing).Owner) { return; }

bool spawnable = (
e.thing.GetClassName() == "PortableLiteAmp" ||
e.Thing.GetClassName() == "HDAmBox" ||
e.Thing.GetClassName() == "HDBackpack");

if(spawnable) {
UaS.SpawnStuff('UaS_LaserLightModule', randompick[llm](0, 1), e.Thing.pos);
}
}
}


class UaS_LaserLightModule : HDPickup {
int mode;
bool activated;
Expand Down
6 changes: 3 additions & 3 deletions modules/items/sling.zsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UaS_Sling_Spawner : EventHandler {
override void WorldThingSpawned(WorldEvent e) {
extend class UaS_Spawner {
void SlingSpawns(WorldEvent e) {
if(level.maptime > 1) { return; }
if(!e.Thing) { return; }
if(e.Thing is "Inventory" && Inventory(e.Thing).Owner) { return; }
Expand All @@ -17,7 +17,7 @@ class UaS_Sling_Spawner : EventHandler {
e.Thing.GetClassName() == "bossrifle"
);

if (spawnable && UaS.RandomChance(0.1)) { UaS.SpawnStuff("UaS_WeaponSling", 1, e.Thing.pos); }
if (spawnable && UaS.RandomChance(0.2)) { UaS.SpawnStuff("UaS_WeaponSling", 1, e.Thing.pos); }
}
}

Expand Down
13 changes: 6 additions & 7 deletions modules/spawner/spawner.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ class UaS_Spawner : EventHandler {
}

// Stuff that only spawns on map start
if (level.maptime != 1) { return; }

bool llmspawns = (
e.Thing is 'PortableLiteAmp' ||
e.Thing is 'HDBackpack' ||
e.Thing is 'HDAmBox');
if(llmspawns) { UaS.SpawnStuff('UaS_LaserLightModule', 0.5, e.Thing.pos); }
if (level.maptime > 1) { return; }

HungerSpawns(e);
AllySpawns(e);
SlingSpawns(e);
GlowstickSpawns(e);
FlareSpawns(e);
LLMSpawns(e);
}
}

0 comments on commit ec214ab

Please sign in to comment.