powolnik commited on
Commit
96c9e7e
·
1 Parent(s): 8ca2499

Domination again... this time for real

Browse files
Code_Reference/Domination/CineLobbyController.verse ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using { /Fortnite.com/Devices }
4
+ using { /Verse.org/Simulation }
5
+
6
+ ##################################################################
7
+ # Our game features a looping cinematic in the pregame. This class simply tells that cinematic to stop!
8
+ # The second cleanup cinematic resets all the material parameters
9
+ ##################################################################
10
+ cinematic_lobby_controller := class(creative_device):
11
+
12
+ @editable
13
+ CineLobby_Sequence:cinematic_sequence_device := cinematic_sequence_device{}
14
+ @editable
15
+ CineLobby_Cleanup_Sequence:cinematic_sequence_device := cinematic_sequence_device{}
16
+
17
+
18
+ OnBegin<override>()<suspends>:void=
19
+ CineLobby_Sequence.Stop()
20
+ CineLobby_Cleanup_Sequence.Play()
Code_Reference/Domination/DominationSpawnManager.verse ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using { /Fortnite.com/Devices }
4
+ using { /Fortnite.com/Teams }
5
+ using { /Verse.org/Simulation }
6
+ using { /Verse.org/Simulation/Tags }
7
+
8
+ ## This device manages the player spawners
9
+ ## An intial set of spawners starts enabled
10
+ ## After a short time, the initial spawners are disabled
11
+ ## From there, team spawns associated with each capture point are enabled/disabled based off a weighting score
12
+ ## Owning the point adds 1 to the weighting score (or -1 if team 2)
13
+ ## Each ally in the area adds 1 to the weighting score (or -1 if team 2)
14
+ ## If the weighting score is > 0, team 1 can spawn near the point.
15
+ ## If the weighting score is < 0, team 2 can spawn near the point
16
+
17
+ ##################################################################
18
+ ## Event Handler Class - We'll spawn one of these per capture point and bind events through it
19
+ ##################################################################
20
+ capture_point_event_handler := class:
21
+
22
+ CapturePointIndex:int
23
+ DominationSpawnManagerRef:domination_spawn_manager
24
+ TeamCollectionRef:fort_team_collection
25
+
26
+ var CaptureWeightOfThisPoint:int = 0
27
+ var PlayerWeightOfThisPoint:float = 0.0
28
+ WeightForEachPlayer:float = 0.5
29
+
30
+ # If Team 1, we return 1. If Team 2, we return -1.
31
+ GetTeamDirectionOfAgent<private>(MyAgent:agent)<transacts>:int=
32
+ if (FirstTeam := TeamCollectionRef.GetTeams()[0]):
33
+ if (TeamCollectionRef.IsOnTeam[MyAgent, FirstTeam]):
34
+ return 1
35
+ return -1
36
+
37
+ # Set state of capture point
38
+ OnCaptured(MyAgent:agent):void=
39
+ set CaptureWeightOfThisPoint = GetTeamDirectionOfAgent(MyAgent)
40
+ DominationSpawnManagerRef.CalculateWeightForPoint(CapturePointIndex)
41
+
42
+ # Shift player weighting of point as players enter or leave
43
+ PlayerEnteredLargeZone(MyAgent:agent):void=
44
+ set PlayerWeightOfThisPoint = PlayerWeightOfThisPoint + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
45
+ DominationSpawnManagerRef.CalculateWeightForPoint(CapturePointIndex)
46
+ PlayerLeftLargeZone(MyAgent:agent):void=
47
+ set PlayerWeightOfThisPoint = PlayerWeightOfThisPoint - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
48
+ DominationSpawnManagerRef.CalculateWeightForPoint(CapturePointIndex)
49
+
50
+
51
+ ##################################################################
52
+ ## Domination Spawn Manager Class
53
+ ##################################################################
54
+ domination_spawn_manager := class(creative_device):
55
+
56
+ # Player Spawner Device Groups - Populated by searching for Verse tags
57
+ var SpawnPointGroupInitial:[]player_spawner_device = array{}
58
+ var SpawnPointGroupsCapPoint:[][]player_spawner_device = array{array{}, array{}, array{}}
59
+
60
+ # Capture Zone
61
+ @editable
62
+ CapturePoints:[]capture_area_device = array{}
63
+ @editable
64
+ LargeZones:[]player_counter_device = array{}
65
+
66
+ # Initial Spawners will disable after this many seconds
67
+ InitialGroupDisableTime:float = 5.0
68
+
69
+ # Cap Point Event Handler Class Refs
70
+ var CapturePointListeners:[]capture_point_event_handler = array{}
71
+
72
+
73
+ # OnBegin will run when the game starts
74
+ OnBegin<override>()<suspends>:void=
75
+ BeginPlayEventSubscriptions()
76
+ FindAndCacheSpawnDevices()
77
+ DisableInitialSpawnGroup()
78
+
79
+
80
+ # Subscribe to events from our attribute triggers
81
+ BeginPlayEventSubscriptions<private>():void=
82
+ for (I -> EachCapPoint:CapturePoints):
83
+ MyHandler := capture_point_event_handler:
84
+ CapturePointIndex := I
85
+ DominationSpawnManagerRef := Self
86
+ TeamCollectionRef := Self.GetPlayspace().GetTeamCollection()
87
+
88
+ set CapturePointListeners = CapturePointListeners + array{MyHandler}
89
+
90
+ EachCapPoint.ControlChangeEvent.Subscribe(MyHandler.OnCaptured)
91
+
92
+ if (EachLargeZone := LargeZones[I]):
93
+ EachLargeZone.CountedEvent.Subscribe(MyHandler.PlayerEnteredLargeZone)
94
+ EachLargeZone.RemovedEvent.Subscribe(MyHandler.PlayerLeftLargeZone)
95
+
96
+
97
+ # Get all our various Player Spawner devices, and store them in the appropriate arrays
98
+ FindAndCacheSpawnDevices<private>():void=
99
+ InitialSpawnPoints:[]creative_object_interface = GetCreativeObjectsWithTag(DominationSpawnTags.Tag_SpawnGroup_Initial{})
100
+ for (FoundDevice : InitialSpawnPoints, DeviceAsSpawner:= player_spawner_device[FoundDevice]):
101
+ set SpawnPointGroupInitial = SpawnPointGroupInitial + array{DeviceAsSpawner}
102
+
103
+ GroupTags:[]tag = array:
104
+ DominationSpawnTags.Tag_SpawnGroup_GroupA{}
105
+ DominationSpawnTags.Tag_SpawnGroup_GroupB{}
106
+ DominationSpawnTags.Tag_SpawnGroup_GroupC{}
107
+
108
+ for (I -> GroupTag:GroupTags):
109
+ FoundSpawnGroup:[]creative_object_interface := GetCreativeObjectsWithTag(GroupTag)
110
+ for (FoundDevice : FoundSpawnGroup, DeviceAsSpawner:= player_spawner_device[FoundDevice]):
111
+ if:
112
+ set SpawnPointGroupsCapPoint[I] = SpawnPointGroupsCapPoint[I] + array{DeviceAsSpawner}
113
+
114
+
115
+ # Turn off initial spawn points
116
+ DisableInitialSpawnGroup<private>()<suspends>:void=
117
+ Sleep(InitialGroupDisableTime)
118
+ for (SpawnPoint : SpawnPointGroupInitial):
119
+ SpawnPoint.Disable()
120
+
121
+
122
+ # Whenever the CapPointCaptureWeight or CapPointPlayerWeight for a point changes, this runs to see who should be allowed to spawn from the associated spawn group
123
+ CalculateWeightForPoint(PointIndex:int):void=
124
+ var WeightOfPoint:int = 0
125
+
126
+ if:
127
+ CapPointData := CapturePointListeners[PointIndex]
128
+ CapPlayerWeightToInt := Floor[CapPointData.PlayerWeightOfThisPoint]
129
+ then:
130
+ set WeightOfPoint = CapPointData.CaptureWeightOfThisPoint + CapPlayerWeightToInt
131
+
132
+ for (SpawnDevice:SpawnPointGroupsCapPoint[PointIndex]):
133
+ var DeviceIsTeam1:logic = false
134
+ DeviceTags := SpawnDevice.GetTags()
135
+ if (DeviceTags.Has[DominationSpawnTags.Tag_TeamOwnership_Team1{}]):
136
+ set DeviceIsTeam1 = true
137
+
138
+ if (DeviceIsTeam1?):
139
+ if (WeightOfPoint > 0):
140
+ SpawnDevice.Enable()
141
+ else:
142
+ SpawnDevice.Disable()
143
+ else:
144
+ if (WeightOfPoint < 0):
145
+ SpawnDevice.Enable()
146
+ else:
147
+ SpawnDevice.Disable()
Code_Reference/Domination/DominationVOController.verse ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using { /Fortnite.com/Devices }
4
+ using { /Fortnite.com/Teams }
5
+ using { /Verse.org/Simulation }
6
+
7
+
8
+ ##################################################################
9
+ ## Event Handler Class - We'll spawn one of these per capture point and bind events through it
10
+ ##################################################################
11
+ vo_cappoint_event_handler := class:
12
+ CapturePointIndex:int
13
+ VOControlRef:domination_vo_controller
14
+
15
+ # Only play losing control audio if the point has been captured. Otherwise you get 'losing control' vo for neutral points at the start of game.
16
+ var HasBeenCaptured:logic = false
17
+
18
+ OnCaptured(MyAgent:agent):void=
19
+ VOControlRef.UpdateCapturePointTracking(MyAgent, CapturePointIndex)
20
+ VOControlRef.QueueVO_PointCapturedOrLost(MyAgent, CapturePointIndex)
21
+
22
+ set HasBeenCaptured = true
23
+
24
+ OnStartedCapture(MyAgent:agent):void=
25
+ if (HasBeenCaptured?):
26
+ VOControlRef.QueueVO_PointCaptureStarted(MyAgent, CapturePointIndex)
27
+
28
+
29
+ ##################################################################
30
+ ## VO Controller Device Class
31
+ ##################################################################
32
+
33
+ audioqueue_type := enum:
34
+ CaptureStarted
35
+ CaptureOrLost
36
+ AllPointsCaptured
37
+
38
+ audioqueue_entry:= struct:
39
+ InitiatingAgent:agent
40
+ CapturePointID:int
41
+ AudioEventType:audioqueue_type
42
+
43
+ domination_vo_controller := class(creative_device):
44
+
45
+ # Capture Zone
46
+ @editable
47
+ CapturePoints:[]capture_area_device = array{}
48
+
49
+ # Audio Players
50
+ @editable
51
+ VO_PointCaptured:[]audio_player_device = array{}
52
+ @editable
53
+ VO_PointLost_A:[]audio_player_device = array{}
54
+ @editable
55
+ VO_PointLost_B:[]audio_player_device = array{}
56
+ @editable
57
+ VO_PointLost_C:[]audio_player_device = array{}
58
+
59
+ @editable
60
+ VO_PointStartedLosing_A:[]audio_player_device = array{}
61
+ @editable
62
+ VO_PointStartedLosing_B:[]audio_player_device = array{}
63
+ @editable
64
+ VO_PointStartedLosing_C:[]audio_player_device = array{}
65
+
66
+ @editable
67
+ VO_SelectLoadout:audio_player_device = audio_player_device{}
68
+
69
+ @editable
70
+ FriendlyTeamIsDominating:[]audio_player_device = array{}
71
+ @editable
72
+ EnemyTeamIsDominating:[]audio_player_device = array{}
73
+
74
+ # Hud Messages
75
+ @editable
76
+ HUDMessage_PointCaptured:[]hud_message_device = array{}
77
+ @editable
78
+ HUDMessage_PointLost:[]hud_message_device = array{}
79
+ @editable
80
+ HUDMessage_LosingPoint:[]hud_message_device = array{}
81
+
82
+ # Cycle Audio Clips to avoid repeats
83
+ var AudioIndex_CapOrLost:int = 0
84
+ var AudioIndex_Losing:int = 0
85
+
86
+ # Domination State
87
+ var CapturePointOwnership:[]int = array{0,0,0}
88
+ var AnyTeamIsDominating:logic = false
89
+
90
+ # VO Play Cooldown
91
+ VOCooldownTime:float = 2.0
92
+ var VOIsOnCooldown:logic = false
93
+
94
+ # Audio queue for important messages
95
+ var AudioToPlayQueue:[]audioqueue_entry = array{}
96
+
97
+ # Class Selector Device Ref
98
+ @editable
99
+ ClassSelectUI:class_selector_ui_device = class_selector_ui_device{}
100
+ @editable
101
+ ClassSelectOpenedRouter:attribute_evaluator_device = attribute_evaluator_device{}
102
+ var ValidAudioTargets:[]agent = array{}
103
+ var ValidClassSelectAudioTargets:[]agent = array{}
104
+
105
+
106
+ @editable
107
+ GameIntroHUDMessage:hud_message_device = hud_message_device{}
108
+
109
+
110
+ # Cache Listener Classes to Prevent GC - In the future you won't need to do this!
111
+ var CachedListeners:[]vo_cappoint_event_handler = array{}
112
+
113
+
114
+ OnBegin<override>()<suspends>:void=
115
+ # Create an event handler class for each capture point, and subscribe
116
+ for (I->EachCapPoint : CapturePoints):
117
+ MyHandler := vo_cappoint_event_handler:
118
+ CapturePointIndex := I
119
+ VOControlRef := Self
120
+ EachCapPoint.ControlChangeEvent.Subscribe(MyHandler.OnCaptured)
121
+ EachCapPoint.ControlChangeStartsEvent.Subscribe(MyHandler.OnStartedCapture)
122
+ set CachedListeners = CachedListeners + array{MyHandler}
123
+
124
+ # Player spawned in world event (we don't play audio until the player has spawned once and heard the intro VO)
125
+ ClassSelectUI.ClassSelectedEvent.Subscribe(PlayerSpawnedIntoWorld)
126
+ # Player entered class UI
127
+ ClassSelectOpenedRouter.PassEvent.Subscribe(ClassSelectUIOpen)
128
+
129
+
130
+ ClassSelectUIOpen <private>(MyAgent:agent):void=
131
+ if (not ValidClassSelectAudioTargets.Find[MyAgent]):
132
+ set ValidClassSelectAudioTargets = ValidClassSelectAudioTargets + array{MyAgent}
133
+ VO_SelectLoadout.Play(MyAgent)
134
+
135
+
136
+ PlayerSpawnedIntoWorld<private>(MyAgent:agent):void=
137
+ if (not ValidAudioTargets.Find[MyAgent]):
138
+ spawn{AddPlayerToValidAudioTargets(MyAgent)}
139
+
140
+
141
+ AddPlayerToValidAudioTargets<private>(MyAgent:agent)<suspends>:void=
142
+ # After a delay to account for initial class popup, permit audio
143
+ Sleep(0.5)
144
+ GameIntroHUDMessage.Show(MyAgent)
145
+ Sleep(2.0)
146
+ if (not ValidAudioTargets.Find[MyAgent]):
147
+ set ValidAudioTargets = ValidAudioTargets + array{MyAgent}
148
+
149
+
150
+ UpdateCapturePointTracking(MyAgent:agent, CapturePointID:int):void=
151
+ TeamCollection := GetPlayspace().GetTeamCollection()
152
+ if:
153
+ Team1 := TeamCollection.GetTeams()[0]
154
+ TeamCollection.IsOnTeam[MyAgent, Team1]
155
+ set CapturePointOwnership[CapturePointID]=1
156
+ else if:
157
+ set CapturePointOwnership[CapturePointID]=-1
158
+
159
+ if (Abs(CapturePointOwnership[0] + CapturePointOwnership[1] + CapturePointOwnership[2]) = 3):
160
+ set AnyTeamIsDominating = true
161
+ else:
162
+ set AnyTeamIsDominating = false
163
+
164
+
165
+ ##################################################################
166
+ # Play VO Methods
167
+ # These should not be used directly. Instead use the Audio Queue
168
+ ##################################################################
169
+ PlayVO_PointCapturedOrLost<private>(MyAgent:agent, CapturePointID:int, SkipDominationCheck:logic):void=
170
+ # Increment VO Index
171
+ set AudioIndex_CapOrLost = AudioIndex_CapOrLost + 1
172
+
173
+ # For each player in the game, play the appropriate audio & associated HUD message
174
+ TeamCollection := GetPlayspace().GetTeamCollection()
175
+ for (EachPlayer : GetPlayspace().GetPlayers()):
176
+ if (TeamCollection.GetTeamAttitude[MyAgent, EachPlayer] = team_attitude.Friendly):
177
+ HUDMessageToShow:?hud_message_device = option{ HUDMessage_PointCaptured[CapturePointID] }
178
+
179
+ if (AnyTeamIsDominating? and not SkipDominationCheck?):
180
+ PlayVOForPlayer(EachPlayer, FriendlyTeamIsDominating, AudioIndex_CapOrLost, HUDMessageToShow)
181
+ else:
182
+ PlayVOForPlayer(EachPlayer, VO_PointCaptured, AudioIndex_CapOrLost, HUDMessageToShow)
183
+
184
+ else:
185
+ HUDMessageToShow:?hud_message_device = option{ HUDMessage_PointLost[CapturePointID] }
186
+
187
+ if (AnyTeamIsDominating? and not SkipDominationCheck?):
188
+ PlayVOForPlayer(EachPlayer, EnemyTeamIsDominating, AudioIndex_CapOrLost, HUDMessageToShow)
189
+ else:
190
+ VOPointLostArray := array{VO_PointLost_A, VO_PointLost_B, VO_PointLost_C}
191
+ if (VOToPlay := VOPointLostArray[CapturePointID]):
192
+ PlayVOForPlayer(EachPlayer, VOToPlay, AudioIndex_CapOrLost, HUDMessageToShow)
193
+
194
+
195
+ PlayPointCaptureStartedVO<private>(MyAgent:agent, CapturePointID:int):void=
196
+ # Increment VO Index
197
+ set AudioIndex_Losing = AudioIndex_Losing + 1
198
+
199
+ # For each enemy (we don't tell friendlies capture has tarted), play VO and associated hud message
200
+ TeamCollection := GetPlayspace().GetTeamCollection()
201
+ for (EachPlayer : GetPlayspace().GetPlayers()):
202
+ if (TeamCollection.GetTeamAttitude[MyAgent, EachPlayer] <> team_attitude.Friendly):
203
+ HUDMessageToShow:?hud_message_device = option{ HUDMessage_LosingPoint[CapturePointID] }
204
+
205
+ VOPointLostArray := array{VO_PointStartedLosing_A, VO_PointStartedLosing_B, VO_PointStartedLosing_C}
206
+ if (VOToPlay := VOPointLostArray[CapturePointID]):
207
+ PlayVOForPlayer(EachPlayer, VOToPlay, AudioIndex_Losing, HUDMessageToShow)
208
+
209
+
210
+ PlayVOForPlayer<private>(MyAgent:agent, DeviceList:[]audio_player_device, ClipIndex:int, OptionalHUDMessage:?hud_message_device):void=
211
+ # Make sure the incoming device list is populated!
212
+ if (DeviceList.Length = 0):
213
+ return
214
+ # Is player a valid audio target?
215
+ if (not ValidAudioTargets.Find[MyAgent]):
216
+ return
217
+
218
+ if (Device := DeviceList[Mod[ClipIndex, DeviceList.Length]]):
219
+ Device.Play(MyAgent)
220
+ if (HUDMessage := OptionalHUDMessage?):
221
+ HUDMessage.Show(MyAgent)
222
+
223
+
224
+ ##################################################################
225
+ # Audio Queue Management
226
+ ##################################################################
227
+ QueueVO_PointCapturedOrLost(MyAgent:agent, CapturePointID:int):void=
228
+ if (AnyTeamIsDominating?):
229
+ EnqueueAudioEntry(MyAgent, CapturePointID, audioqueue_type.AllPointsCaptured)
230
+ else:
231
+ EnqueueAudioEntry(MyAgent, CapturePointID, audioqueue_type.CaptureOrLost)
232
+
233
+
234
+ QueueVO_PointCaptureStarted(MyAgent:agent, CapturePointID:int):void=
235
+ # Only add these to the queue if they're the only audio to play.
236
+ # They aren't important enough to queue up compared to other audio sources.
237
+ if (AudioToPlayQueue.Length = 0):
238
+ EnqueueAudioEntry(MyAgent, CapturePointID, audioqueue_type.CaptureStarted)
239
+
240
+
241
+ EnqueueAudioEntry<private>(MyAgent:agent, CaptureID:int, AudioType:audioqueue_type):void=
242
+ set AudioToPlayQueue = AudioToPlayQueue + array:
243
+ audioqueue_entry{InitiatingAgent := MyAgent, CapturePointID := CaptureID, AudioEventType := AudioType}
244
+
245
+ spawn { PlayQueuedVO() }
246
+
247
+
248
+ PlayQueuedVO<private>()<suspends>:void =
249
+ if (VOIsOnCooldown?):
250
+ return
251
+
252
+ set VOIsOnCooldown = true
253
+
254
+ loop:
255
+ if:
256
+ NextAudioToPlay := AudioToPlayQueue[0]
257
+ set AudioToPlayQueue = AudioToPlayQueue.RemoveElement[0]
258
+ then:
259
+ case (NextAudioToPlay.AudioEventType):
260
+ audioqueue_type.CaptureStarted =>
261
+ PlayPointCaptureStartedVO(NextAudioToPlay.InitiatingAgent, NextAudioToPlay.CapturePointID)
262
+ audioqueue_type.CaptureOrLost =>
263
+ PlayVO_PointCapturedOrLost(NextAudioToPlay.InitiatingAgent, NextAudioToPlay.CapturePointID, true)
264
+ audioqueue_type.AllPointsCaptured =>
265
+ PlayVO_PointCapturedOrLost(NextAudioToPlay.InitiatingAgent, NextAudioToPlay.CapturePointID, false)
266
+
267
+ # Sleep between each play
268
+ Sleep(VOCooldownTime)
269
+ else:
270
+ break
271
+
272
+ set VOIsOnCooldown = false
Code_Reference/Domination/GameFeatureData.uasset ADDED
Binary file (1.83 kB). View file
 
Code_Reference/Domination/SequencerRandomizer.verse ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using { /Fortnite.com/Devices }
4
+ using { /Verse.org/Random }
5
+ using { /Verse.org/Simulation }
6
+
7
+ ################################################################################
8
+ ## This device references an array of Cinematic Sequence Devices, and plays them randomly with a variable cooldown in between.
9
+ ################################################################################
10
+ sequencer_randomization_device := class<concrete>(creative_device):
11
+
12
+ # Array of Cinematic Sequence Devices to randomize between
13
+ @editable
14
+ SequencerList : []cinematic_sequence_device = array{}
15
+
16
+ # Minimum / Maximum time to wait before triggering another sequence
17
+ @editable
18
+ CooldownMin:float = 120.0
19
+ @editable
20
+ CooldownMax:float = 240.0
21
+
22
+ # If we have more than 1 sequence to choose from, should we prevent the same sequence playing two times in a row?
23
+ @editable
24
+ PreventBackToBackRepeats:logic = true
25
+
26
+
27
+ # OnBegin will run when the game starts
28
+ OnBegin<override>()<suspends>:void=
29
+ if (SequencerList.Length > 0):
30
+ QueueSequence(GetRandomInt(0, SequencerList.Length-1))
31
+
32
+
33
+ # Wait a random amount of time, then play the sequence
34
+ QueueSequence<private>(Index:int)<suspends>:void=
35
+ CooldownTime:float = GetRandomFloat(CooldownMin, CooldownMax)
36
+ Sleep(CooldownTime)
37
+
38
+ if (MySequencer := SequencerList[Index]):
39
+ MySequencer.Play()
40
+
41
+ QueueSequence(GetNextIndexToPlay(Index))
42
+
43
+
44
+ # Decide the next sequence index, either completely random, or excluding the last-played sequence
45
+ GetNextIndexToPlay<private>(LastIndex:int):int=
46
+ if (SequencerList.Length > 1 and PreventBackToBackRepeats?):
47
+ var IndexToReturn:int = LastIndex + GetRandomInt(1, SequencerList.Length-1)
48
+ if(set IndexToReturn = Mod[IndexToReturn, SequencerList.Length]):
49
+ return IndexToReturn
50
+
51
+ return GetRandomInt(0, SequencerList.Length-1)
Code_Reference/Domination/capturepoint_lighting_control.verse ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using { /Fortnite.com/Devices }
4
+ using { /Verse.org/Simulation }
5
+
6
+ ##################################################################
7
+ # We want a bit more control over our capture point lighting than what the default capture device light can do
8
+ # This script plays a cinematic sequence device for each capture point depending on which team owns it
9
+ # Within the sequence, we set our lighting values to desired color & intensity
10
+ ##################################################################
11
+
12
+ capturepoint_lighting_control := class(creative_device):
13
+
14
+ @editable
15
+ CapturePoints:[]capture_area_device = array{}
16
+ @editable
17
+ Sequencers_Team1:[]cinematic_sequence_device = array{}
18
+ @editable
19
+ Sequencers_Team2:[]cinematic_sequence_device = array{}
20
+
21
+ OnBegin<override>()<suspends>:void=
22
+ for (i -> EachCapPoint : CapturePoints):
23
+ case (i):
24
+ 0 => EachCapPoint.ControlChangeEvent.Subscribe(CaptureChange_A)
25
+ 1 => EachCapPoint.ControlChangeEvent.Subscribe(CaptureChange_B)
26
+ 2 => EachCapPoint.ControlChangeEvent.Subscribe(CaptureChange_C)
27
+ _ =>
28
+
29
+ CaptureChange_A(MyAgent:agent):void=
30
+ PointCaptured(MyAgent, 0)
31
+ CaptureChange_B(MyAgent:agent):void=
32
+ PointCaptured(MyAgent, 1)
33
+ CaptureChange_C(MyAgent:agent):void=
34
+ PointCaptured(MyAgent, 2)
35
+
36
+ PointCaptured(MyAgent:agent, CaptureIndex:int):void=
37
+ TeamCollection := GetPlayspace().GetTeamCollection()
38
+ if:
39
+ Team1Sequence := Sequencers_Team1[CaptureIndex]
40
+ Team2Sequence := Sequencers_Team2[CaptureIndex]
41
+ then:
42
+ if (TeamCollection.IsOnTeam[MyAgent, TeamCollection.GetTeams()[0]]):
43
+ Team1Sequence.Play()
44
+ Team2Sequence.Stop()
45
+ else:
46
+ Team1Sequence.Stop()
47
+ Team2Sequence.Play()