Skip to content

Commit d5bc0e5

Browse files
committed
add S2 sentry spawners using a trigger area
1 parent 4265b99 commit d5bc0e5

File tree

5 files changed

+740
-40
lines changed

5 files changed

+740
-40
lines changed

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/ActorSpawner/ActorSpawner.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ AddActor = MOSRotating
2828
ActorClassName = AHuman
2929
AddCustomValue = StringValue // Tech name of the desired actor, if in Specific mode.
3030
ActorTechName = Base.rte
31+
AddCustomValue = StringValue // AI mode to set for the spawned actor. Values: SENTRY, BRAINHUNT, GOLDDIG
32+
AIMode = SENTRY
3133
AddCustomValue = NumberValue // Whether to spawn the actor with equipment or not. If in Specific mode, will equip the actor as if in Random mode.
3234
SpawnEquipment = 1
3335
AddCustomValue = StringValue // Values: Specific, Light, Medium, Heavy, CQB, Scout, Sniper, Grenadier, Engineer, Random. See DeliveryCreationHandler .lua instructions for the infantry types.

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/ActorSpawner/ActorSpawner.lua

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ function ActorSpawnerFunctions.PrepareNewActor(self)
3434

3535
actor.Pos = self.Pos;
3636
actor.Team = self.Team;
37+
38+
if self:GetStringValue("AIMode") == "SENTRY" then
39+
actor.AIMode = Actor.AIMODE_SENTRY;
40+
elseif self:GetStringValue("AIMode") == "BRAINHUNT" then
41+
actor.AIMode = Actor.AIMODE_BRAINHUNT;
42+
elseif self:GetStringValue("AIMode") == "GOLDDIG" then
43+
actor.AIMode = Actor.AIMODE_GOLDDIG;
44+
end
45+
3746
self.nextActor = actor;
3847
end
3948

@@ -107,7 +116,7 @@ function Create(self)
107116
end
108117

109118
self.deliveryCreationHandler = require("Activities/Utility/DeliveryCreationHandler");
110-
self.deliveryCreationHandler:Initialize(self.Activity, true);
119+
self.deliveryCreationHandler:Initialize(self.Activity, false);
111120

112121
self.saveLoadHandler = require("Activities/Utility/SaveLoadHandler");
113122
self.saveLoadHandler:Initialize(true);
@@ -151,7 +160,6 @@ function Create(self)
151160
end
152161

153162
function ThreadedUpdate(self)
154-
155163
if self.Activity.ActivityState == Activity.EDITING then
156164
self.Frame = 0;
157165
else
@@ -161,18 +169,32 @@ function ThreadedUpdate(self)
161169
if self.triggerType ~= "ManualOnly" then
162170
self.Triggered = false;
163171

164-
if self.triggerType == "Constant" then
165-
self.Triggered = true;
166-
elseif self.actorCheckTimer:IsPastSimMS(self.actorCheckDelay) then
167-
self.actorCheckTimer:Reset();
168-
169-
local ownTeamActors = 0;
170-
local enemyTeamActors = 0;
171-
local totalActors = 0;
172-
173-
if self.triggerType == "Area" then
174-
for box in self.triggerArea.Boxes do
175-
for actor in MovableMan:GetMOsInBox(box, -1, true) do
172+
if not self.Deactivated then
173+
if self.triggerType == "Constant" then
174+
self.Triggered = true;
175+
elseif self.actorCheckTimer:IsPastSimMS(self.actorCheckDelay) then
176+
self.actorCheckTimer:Reset();
177+
178+
local ownTeamActors = 0;
179+
local enemyTeamActors = 0;
180+
local totalActors = 0;
181+
182+
if self.triggerType == "Area" then
183+
for box in self.triggerArea.Boxes do
184+
for actor in MovableMan:GetMOsInBox(box, -1, true) do
185+
if IsActor(actor) then
186+
totalActors = totalActors + 1;
187+
if actor.Team == self.Team then
188+
ownTeamActors = ownTeamActors + 1;
189+
else
190+
enemyTeamActors = enemyTeamActors + 1;
191+
end
192+
end
193+
end
194+
end
195+
else -- ought be Range
196+
local actorList = MovableMan:GetMOsInRadius(self.Pos, self.triggerRange, -1, true);
197+
for actor in actorList do
176198
if IsActor(actor) then
177199
totalActors = totalActors + 1;
178200
if actor.Team == self.Team then
@@ -183,30 +205,18 @@ function ThreadedUpdate(self)
183205
end
184206
end
185207
end
186-
else -- ought be Range
187-
local actorList = MovableMan:GetMOsInRadius(self.Pos, self.triggerRange, -1, true);
188-
for actor in actorList do
189-
if IsActor(actor) then
190-
totalActors = totalActors + 1;
191-
if actor.Team == self.Team then
192-
ownTeamActors = ownTeamActors + 1;
193-
else
194-
enemyTeamActors = enemyTeamActors + 1;
195-
end
196-
end
197-
end
208+
209+
if self.triggerBehavior == "OnlyOwnTeam" and ownTeamActors > 0 and enemyTeamActors == 0 then
210+
self.Triggered = true;
211+
elseif self.triggerBehavior == "OwnTeam" and ownTeamActors > 0 then
212+
self.Triggered = true;
213+
elseif self.triggerBehavior == "EnemyTeam" and enemyTeamActors > 0 then
214+
self.Triggered = true;
215+
elseif self.triggerBehavior == "Empty" and totalActors == 0 then
216+
self.Triggered = true;
217+
end
198218
end
199-
end
200-
201-
if self.triggerBehavior == "OnlyOwnTeam" and ownTeamActors > 0 and enemyTeamActors == 0 then
202-
self.Triggered = true;
203-
elseif self.triggerBehavior == "OwnTeam" and ownTeamActors > 0 then
204-
self.Triggered = true;
205-
elseif self.triggerBehavior == "EnemyTeam" and enemyTeamActors > 0 then
206-
self.Triggered = true;
207-
elseif self.triggerBehavior == "Empty" and totalActors == 0 then
208-
self.Triggered = true;
209-
end
219+
end
210220
end
211221

212222
if (self.Triggered and self.spawnTimer:IsPastSimMS(self.spawnDelay)) or self.manualTrigger then

Data/Browncoats.rte/Activities/RefineryAssaultFunctions.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,12 @@ function RefineryAssault:SetupStartingActors()
958958
-- Actor spawner setup
959959
self.saveTable.stage2CounterAttSpawners = {};
960960
for par in MovableMan.AddedParticles do
961+
if par:IsInGroup("Actor Spawners") then
962+
par:SendMessage("ActorSpawner_ReplaceDeliveryCreationHandler", self.deliveryCreationHandler:GetHandlerAsSerialized(self.saveLoadHandler));
963+
end
964+
961965
if par.PresetName == "Refinery S2 Counterattacker Spawner" then
962-
print("DETECTED SPAWNER")
963966
table.insert(self.saveTable.stage2CounterAttSpawners, par);
964-
par:SendMessage("ActorSpawner_ReplaceDeliveryCreationHandler", self.deliveryCreationHandler:GetHandlerAsSerialized(self.saveLoadHandler));
965967
end
966968
end
967969

Data/Browncoats.rte/Scenes/Objects/ActorSpawners/ActorSpawners.ini

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ AddActor = MOSRotating
1010
ActorClassName = AHuman
1111
AddCustomValue = StringValue // Tech name of the desired actor, if in Specific mode.
1212
ActorTechName = Base.rte
13+
AddCustomValue = StringValue // AI mode to set for the spawned actor. Values: SENTRY, BRAINHUNT, GOLDDIG
14+
AIMode = SENTRY
1315
AddCustomValue = NumberValue // Whether to spawn the actor with equipment or not. If in Specific mode, will equip the actor as if in Random mode.
1416
SpawnEquipment = 1
1517
AddCustomValue = StringValue // Values: Specific, Light, Medium, Heavy, CQB, Scout, Sniper, Grenadier, Engineer, Random. See DeliveryCreationHandler .lua instructions for the infantry types.
@@ -40,4 +42,50 @@ AddActor = MOSRotating
4042
AddCustomValue = StringValue // Message to listen for that activates this spawner. Object received will set the SpawnAmount.
4143
ActivationMessage = ActivateSpawner_RefineryS2CounterattackerSpawner
4244
AddCustomValue = NumberValue // Whether to start deactivated or not. Useful for manual trigger situations.
43-
StartDeactivated = 1
45+
StartDeactivated = 1
46+
47+
///////////////////////////////////////////////////////////////////////
48+
// Stage 2 Sentries
49+
50+
AddActor = MOSRotating
51+
CopyOf = Generic Actor Spawner
52+
PresetName = Refinery S2 Sentry Spawner
53+
AddCustomValue = StringValue // PresetName of the desired actor, if in Specific mode.
54+
ActorPresetName = Green Dummy
55+
AddCustomValue = StringValue // ClassName of the desired actor, if in Specific mode.
56+
ActorClassName = AHuman
57+
AddCustomValue = StringValue // Tech name of the desired actor, if in Specific mode.
58+
ActorTechName = Base.rte
59+
AddCustomValue = StringValue // AI mode to set for the spawned actor. Values: SENTRY, BRAINHUNT, GOLDDIG
60+
AIMode = SENTRY
61+
AddCustomValue = NumberValue // Whether to spawn the actor with equipment or not. If in Specific mode, will equip the actor as if in Random mode.
62+
SpawnEquipment = 1
63+
AddCustomValue = StringValue // Values: Specific, Light, Medium, Heavy, CQB, Scout, Sniper, Grenadier, Engineer, Random. See DeliveryCreationHandler .lua instructions for the infantry types.
64+
// Specific will use the actor defined above. Random will choose any of the DCH types (minus Scout and Engineer).
65+
SpawnType = Random
66+
AddCustomValue = NumberValue // Time between spawns if trigger criteria is met.
67+
SpawnTimer = 0
68+
AddCustomValue = NumberValue // Amount of spawns before deactivation. Note: Manual triggering will ALWAYS decrement this, but also optionally ignore it being at 0 with a bool true object.
69+
SpawnAmount = 1
70+
AddCustomValue = NumberValue // Actors spawn as the same Team as the Actor Spawner, but this will allow you to pass in a different team to the DeliveryCreationHandler to generate an actor
71+
// of a different tech. This also works with the virtual team system but you MUST make sure everything is set up correctly and that you have replaced DCH with a message.
72+
// -1 uses Base.rte, so to disable any overriding behavior use -2.
73+
CustomTeamToUseForDCHGeneration = -2
74+
AddCustomValue = StringValue // Values: Range, Area, Constant, ManualOnly
75+
TriggerType = Area
76+
AddCustomValue = NumberValue // Range to use if TriggerType is Range.
77+
TriggerRange = 300
78+
AddCustomValue = StringValue // Area name to use if TriggerType is Area.
79+
SceneTriggerArea = SpawnerTriggerArea_RefineryS2SentrySpawner
80+
AddCustomValue = StringValue // Behavior to use for Range and Area trigger types. Values: OnlyOwnTeam, OwnTeam, EnemyTeam, Empty
81+
TriggerBehavior = EnemyTeam
82+
AddCustomValue = NumberValue // Whether to send the Spawned messages globally, or locally just to activity. Global messages can have poor performance.
83+
SendMessageOnSpawnGlobally = 1
84+
AddCustomValue = StringValue // Message to send on spawning an actor. Object sent is amount of remaining spawns.
85+
MessageOnSpawn = Spawned_RefineryS2SentrySpawner
86+
AddCustomValue = StringValue // Message to listen for that deactivates this spawner.
87+
DeactivationMessage = DeactivateSpawner_RefineryS2SentrySpawner
88+
AddCustomValue = StringValue // Message to listen for that activates this spawner. Object received will set the SpawnAmount.
89+
ActivationMessage = ActivateSpawner_RefineryS2SentrySpawner
90+
AddCustomValue = NumberValue // Whether to start deactivated or not. Useful for manual trigger situations.
91+
StartDeactivated = 0

0 commit comments

Comments
 (0)