1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
untyped
global function CodeCallback_MapInit
struct {
float introStartTime
entity militiaPod
entity imcPod
vector militiaPodFXEyePos
vector imcPodFXEyePos
} file
void function CodeCallback_MapInit()
{
AddEvacNode( GetEnt( "evac_location1" ) )
AddEvacNode( GetEnt( "evac_location2" ) )
AddEvacNode( GetEnt( "evac_location3" ) )
AddEvacNode( GetEnt( "evac_location4" ) )
SetEvacSpaceNode( GetEnt( "end_spacenode" ) )
// dissolve effects
AddDeathCallback( "player", WargamesDissolveDeadEntity )
AddDeathCallback( "npc_soldier", WargamesDissolveDeadEntity )
AddDeathCallback( "npc_spectre", WargamesDissolveDeadEntity )
AddDeathCallback( "npc_pilot_elite", WargamesDissolveDeadEntity )
AddDeathCallback( "npc_marvin", WargamesDissolveDeadEntity )
FlagClear( "Disable_Marvins" )
// currently disabled until finished: intro
if ( !IsFFAGame() )
ClassicMP_SetLevelIntro( WargamesIntroSetup, 20.0 )
}
// dissolve effects
void function WargamesDissolveDeadEntity( entity deadEnt, var damageInfo )
{
if ( deadEnt.IsPlayer() || GamePlayingOrSuddenDeath() || GetGameState() == eGameState.Epilogue )
{
deadEnt.Dissolve( ENTITY_DISSOLVE_CHAR, < 0, 0, 0 >, 0 )
EmitSoundAtPosition( TEAM_UNASSIGNED, deadEnt.GetOrigin(), "Object_Dissolve" )
}
}
// intro stuff:
void function WargamesIntroSetup()
{
PrecacheParticleSystem( FX_POD_SCREEN_IN )
PrecacheParticleSystem( $"P_pod_scan_laser_FP" )
PrecacheParticleSystem( $"P_pod_Dlight_console1" )
PrecacheParticleSystem( $"P_pod_Dlight_console2" )
PrecacheParticleSystem( $"P_pod_door_glow_FP" )
PrecacheModel( $"models/titans/ogre/ogreposeopen.mdl" )
file.militiaPod = GetEnt( "training_pod" )
file.imcPod = GetEnt( "training_pod_imc" )
AddCallback_OnClientConnected( WargamesIntro_AddPlayer )
AddCallback_GameStateEnter( eGameState.Prematch, OnPrematchStart )
}
void function WargamesIntro_AddPlayer( entity player )
{
if ( GetGameState() != eGameState.Prematch )
return
thread PlayerWatchesWargamesIntro( player )
}
void function OnPrematchStart()
{
ClassicMP_OnIntroStarted()
file.introStartTime = Time()
// set up shared objects
// this breaks glowlights, not sure why
//file.imcPod.RenderWithViewModels( true )
//file.militiaPod.RenderWithViewModels( true )
PodFXLights( file.imcPod )
PodFXLights( file.militiaPod )
FirstPersonSequenceStruct openPodSequence
openPodSequence.thirdPersonAnimIdle = "trainingpod_doors_open_idle"
thread FirstPersonSequence( openPodSequence, file.imcPod )
thread FirstPersonSequence( openPodSequence, file.militiaPod )
// militia titans/marvins
entity militiaOgre = CreatePropDynamic( $"models/titans/ogre/ogreposeopen.mdl", < -2060, 2856, -1412.5 >, < 0, 0, 0 > )
entity militiaOgreMarvin1 = CreateMarvin( TEAM_UNASSIGNED, < -2113, 2911, -1412 >, < 0, 20, 0 > )
DispatchSpawn( militiaOgreMarvin1 )
thread PlayAnim( militiaOgreMarvin1, "mv_idle_weld" )
entity militiaOgreMarvin2 = CreateMarvin( TEAM_UNASSIGNED, < -2040, 2788, -1412 >, < 0, 140, 0 > )
DispatchSpawn( militiaOgreMarvin2 )
thread PlayAnim( militiaOgreMarvin2, "mv_idle_weld" )
entity militiaOgreMarvin3 = CreateMarvin( TEAM_UNASSIGNED, < -2116, 2868, -1458 >, < 0, 127, 0 > )
DispatchSpawn( militiaOgreMarvin3 )
thread PlayAnim( militiaOgreMarvin3, "mv_turret_repair_A_idle" )
entity militiaIon = CreatePropDynamic( $"models/titans/medium/titan_medium_ajax.mdl", < -1809.98, 2790.39, -1409 >, < 0, 80, 0 > )
thread PlayAnim( militiaIon, "at_titan_activation_wargames_intro" )
entity militiaPilot = CreateElitePilot( TEAM_UNASSIGNED, < 0, 0, 0 >, < 0, 0, 0 > )
DispatchSpawn( militiaPilot )
militiaPilot.SetParent( militiaIon, "HIJACK" )
militiaPilot.MarkAsNonMovingAttachment()
militiaPilot.Anim_ScriptedPlay( "pt_titan_activation_pilot" )
militiaPilot.Anim_EnableUseAnimatedRefAttachmentInsteadOfRootMotion()
entity militiaMarvinChillin = CreateMarvin( TEAM_UNASSIGNED, < -1786, 3060, -1412 >, < 0, -120, 0 > )
DispatchSpawn( militiaMarvinChillin )
thread PlayAnim( militiaMarvinChillin, "mv_idle_unarmed" )
// imc grunts
entity imcGrunt1 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -2915, 2867, -1788 >, < 0, -137, 0 > )
thread PlayAnim( imcGrunt1, "pt_console_idle" )
entity imcGrunt2 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -2870, 2746, -1786 >, < 0, -167, 0 > )
thread PlayAnim( imcGrunt2, "pt_console_idle" )
imcGrunt2.Anim_SetInitialTime( 2.0 )
entity imcGrunt3 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -3037, 2909, -1786 >, < 0, -60, 0 > )
thread PlayAnim( imcGrunt3, "pt_console_idle" )
imcGrunt3.Anim_SetInitialTime( 4.0 )
entity imcGrunt4 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -3281, 2941, -1790 >, < 0, 138, 0 > )
thread PlayAnim( imcGrunt4, "pt_console_idle" )
imcGrunt4.Anim_SetInitialTime( 6.0 )
// launch players into intro
foreach ( entity player in GetPlayerArray() )
thread PlayerWatchesWargamesIntro( player )
// 7 seconds of nothing until we start the pod sequence
wait 7.0
FirstPersonSequenceStruct podCloseSequence
podCloseSequence.thirdPersonAnim = "trainingpod_doors_close"
podCloseSequence.thirdPersonAnimIdle = "trainingpod_doors_close_idle"
thread FirstPersonSequence( podCloseSequence, file.imcPod )
thread FirstPersonSequence( podCloseSequence, file.militiaPod )
wait 7.0
thread PodBootFXThread( file.imcPod )
thread PodBootFXThread( file.militiaPod )
wait 6.0
ClassicMP_OnIntroFinished()
// make sure we stop using viewmodels for these otherwise everyone can see them in the floor 24/7
file.imcPod.RenderWithViewModels( false )
file.militiaPod.RenderWithViewModels( false )
//PodFXCleanup( file.imcPod )
//PodFXCleanup( file.militiaPod )
// cleanup intro objects
militiaOgre.Destroy()
militiaIon.Destroy()
militiaPilot.Destroy()
militiaOgreMarvin1.Destroy()
militiaOgreMarvin2.Destroy()
militiaOgreMarvin3.Destroy()
militiaMarvinChillin.Destroy()
imcGrunt1.Destroy()
imcGrunt2.Destroy()
imcGrunt3.Destroy()
imcGrunt4.Destroy()
}
void function PlayerWatchesWargamesIntro( entity player )
{
if ( IsAlive( player ) )
player.Die()
OnThreadEnd( function() : ( player )
{
if ( IsValid( player ) )
{
RemoveCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING )
player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_EVERYONE
ClearPlayerAnimViewEntity( player )
player.EnableWeaponViewModel()
player.ClearParent()
player.UnforceStand()
player.MovementEnable()
player.ClearInvulnerable()
Remote_CallFunction_NonReplay( player, "ServerCallback_ClearFactionLeaderIntro" )
}
})
// we need to wait a frame if we killed ourselves to spawn into this, so just easier to do it all the time to remove any weirdness
WaitFrame()
player.EndSignal( "OnDestroy" )
player.EndSignal( "OnDeath" )
int factionTeam = ConvertPlayerFactionToIMCOrMilitiaTeam( player )
entity playerPod
if ( factionTeam == TEAM_IMC )
playerPod = file.imcPod
else
playerPod = file.militiaPod
// setup player
int podAttachId = playerPod.LookupAttachment( "REF" )
player.SetOrigin( playerPod.GetAttachmentOrigin( podAttachId ) )
player.SetAngles( playerPod.GetAttachmentAngles( podAttachId ) )
player.RespawnPlayer( null )
player.SetParent( playerPod, "REF" )
player.ForceStand()
if ( !HasAnimEvent( player.GetFirstPersonProxy(), "PlaySound_SimPod_DoorShut" ) )
AddAnimEvent( player.GetFirstPersonProxy(), "PlaySound_SimPod_DoorShut", PlaySound_SimPod_DoorShut )
AddCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING )
player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_OWNER
TrainingPod_ViewConeLock_PodClosed( player )
player.DisableWeaponViewModel()
player.MovementDisable()
player.SetInvulnerable()
// spawn faction leader
// no clue why client subtracts 4.5 from the time we give this, so just add it here instead
if ( factionTeam == TEAM_IMC )
Remote_CallFunction_NonReplay( player, "ServerCallback_SpawnIMCFactionLeaderForIntro", file.introStartTime + 4.5, playerPod.GetEncodedEHandle() )
else
Remote_CallFunction_NonReplay( player, "ServerCallback_SpawnMilitiaFactionLeaderForIntro", file.introStartTime + 4.5, playerPod.GetEncodedEHandle() )
// idle pod sequence
FirstPersonSequenceStruct podIdleSequence
podIdleSequence.firstPersonAnimIdle = "ptpov_trainingpod_idle"
podIdleSequence.renderWithViewModels = true
podIdleSequence.attachment = "REF"
thread FirstPersonSequence( podIdleSequence, player, playerPod )
ScreenFadeFromBlack( player, max( 0.0, ( file.introStartTime + 0.5 ) - Time() ), max( 0.0, ( file.introStartTime + 0.5 ) - Time() ) )
// also get eye positions for fx here
if ( file.imcPodFXEyePos == < 0, 0, 0 > && factionTeam == TEAM_IMC )
file.imcPodFXEyePos = player.EyePosition()
else if ( file.militiaPodFXEyePos == < 0, 0, 0 > && factionTeam == TEAM_MILITIA )
file.militiaPodFXEyePos = player.EyePosition()
// 7 seconds of nothing before we start the pod sequence
wait ( file.introStartTime + 7.0 ) - Time()
FirstPersonSequenceStruct podCloseSequence
podCloseSequence.firstPersonAnim = "ptpov_trainingpod_doors_close"
podCloseSequence.renderWithViewModels = true
podCloseSequence.attachment = "REF"
podCloseSequence.viewConeFunction = TrainingPod_ViewConeLock_SemiStrict
podCloseSequence.setInitialTime = Time() - ( file.introStartTime + 7.0 )
waitthread FirstPersonSequence( podCloseSequence, player, playerPod )
// boot sequence
EmitSoundOnEntityOnlyToPlayer( player, player, "NPE_Scr_SimPod_PowerUp" )
TrainingPod_ViewConeLock_PodClosed( player )
// 10 seconds of starting pod before we run effects and spawn players
// note, this is cool because it waits for a specific time, so we can have a blocking call directly before it just fine
wait ( file.introStartTime + 15.5 ) - Time()
Remote_CallFunction_NonReplay( player, "ServerCallback_PlayPodTransitionScreenFX" )
// need to wait no matter what the delay is here so fx will sync up
wait 3.5
entity spawnpoint = FindSpawnPoint( player, false, true )
spawnpoint.s.lastUsedTime = Time()
player.SetOrigin( spawnpoint.GetOrigin() )
player.SetAngles( spawnpoint.GetAngles() )
thread DelayedGamemodeAnnouncement( player )
}
void function DelayedGamemodeAnnouncement( entity player )
{
wait 1.0
TryGameModeAnnouncement( player )
}
void function PlaySound_SimPod_DoorShut( entity playerFirstPersonProxy ) // stolen from sp_training
{
entity player = playerFirstPersonProxy.GetOwner()
if ( !IsValid( player ) )
return
EmitSoundOnEntityOnlyToPlayer( player, player, "NPE_Scr_SimPod_DoorShut" )
}
// intro viewcones
void function TrainingPod_ViewConeLock_PodOpen( entity player )
{
player.PlayerCone_FromAnim()
player.PlayerCone_SetMinYaw( -25 )
player.PlayerCone_SetMaxYaw( 25 )
player.PlayerCone_SetMinPitch( -30 )
player.PlayerCone_SetMaxPitch( 35 )
}
void function TrainingPod_ViewConeLock_PodClosed( entity player )
{
player.PlayerCone_FromAnim()
player.PlayerCone_SetMinYaw( -25 )
player.PlayerCone_SetMaxYaw( 25 )
player.PlayerCone_SetMinPitch( -30 )
player.PlayerCone_SetMaxPitch( 30 )
}
void function TrainingPod_ViewConeLock_SemiStrict( entity player )
{
player.PlayerCone_FromAnim()
player.PlayerCone_SetMinYaw( -10 )
player.PlayerCone_SetMaxYaw( 10 )
player.PlayerCone_SetMinPitch( -10 )
player.PlayerCone_SetMaxPitch( 10 )
}
// intro pod fx
// here be dragons etc hell code probably
void function PodFXLights( entity pod )
{
// dlights
pod.s.podLightFXHandles <- []
pod.s.podLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_Dlight_console1", pod, "light_console1" ) )
pod.s.podLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_Dlight_console2", pod, "light_console2" ) )
}
void function PodFXLasers( entity pod )
{
entity leftEmitter = CreateScriptMover( pod.GetOrigin() )
pod.s.leftLaserEmitter <- leftEmitter
entity rightEmitter = CreateScriptMover( pod.GetOrigin() )
pod.s.rightLaserEmitter <- rightEmitter
thread PodFXLaserSweep( leftEmitter, pod, pod == file.imcPod ? file.imcPodFXEyePos : file.militiaPodFXEyePos, "fx_laser_L" )
thread PodFXLaserSweep( rightEmitter, pod, pod == file.imcPod ? file.imcPodFXEyePos : file.militiaPodFXEyePos, "fx_laser_R" )
}
void function PodFXLaserSweep( entity emitter, entity pod, vector eyePos, string attachment )
{
// setup emitter attachments
emitter.SetOrigin( < 5, 5, 5 > )
emitter.SetParent( pod, attachment )
float sweepTime = RandomFloatRange( 2.9, 3.15 )
vector centerAng = VectorToAngles( ( eyePos + < 0, 0, 7 > ) - emitter.GetOrigin() )
vector topAng = centerAng + < -270, 0, 0 >
vector bottomAng = centerAng + < -90, 0, 0 >
emitter.s.fxHandle <- PlayLoopFXOnEntity( $"P_pod_scan_laser_FP", emitter )
float finalCenterTime = sweepTime * 0.15
float bigSweepTime = ( sweepTime - finalCenterTime ) / 2
emitter.SetAbsAngles( topAng )
emitter.NonPhysicsRotateTo( topAng, bigSweepTime, 0.0, bigSweepTime * 0.2 )
wait bigSweepTime - 0.1
emitter.NonPhysicsRotateTo( bottomAng, bigSweepTime, 0.0, bigSweepTime * 0.2 )
wait bigSweepTime
emitter.NonPhysicsRotateTo( centerAng, finalCenterTime, 0.0, finalCenterTime * 0.2 )
}
void function PodFXGlowLights( entity pod )
{
// see sp_training:5533 (TrainingPod_GlowLightsArraySetup)
array< array< string > > glowLightGroups = [
[ "fx_glow_L_door012", "fx_glow_R_door014" ],
[ "fx_glow_L_door013", "fx_glow_R_door013" ],
[ "fx_glow_L_door014", "fx_glow_R_door012" ],
[ "fx_glow_L_door011", "fx_glow_R_door011" ],
[ "fx_glow_L_door09", "fx_glow_R_door09" ],
[ "fx_glow_L_door010", "fx_glow_R_door010" ],
[ "fx_glow_L_door07", "fx_glow_R_door07" ],
[ "fx_glow_L_door08", "fx_glow_R_door08" ],
[ "fx_glow_L_door05", "fx_glow_R_door05" ],
[ "fx_glow_L_door06", "fx_glow_R_door06" ],
[ "fx_glow_L_door03", "fx_glow_R_door03" ],
[ "fx_glow_L_door04", "fx_glow_R_door04" ],
[ "fx_glow_L_door01", "fx_glow_R_door01" ],
[ "fx_glow_L_door02", "fx_glow_R_door02" ]
]
pod.s.podGlowLightFXHandles <- []
foreach ( array<string> group in glowLightGroups )
{
foreach ( string attachName in group )
pod.s.podGlowLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_door_glow_FP", pod, attachName ) )
wait 0.1
}
}
void function PodBootFXThread( entity pod )
{
PodFXGlowLights( pod )
PodFXLasers( pod )
}
void function PodFXCleanup( entity pod )
{
foreach ( entity handle in pod.s.podLightFXHandles )
{
if ( IsValid_ThisFrame( handle ) )
{
handle.SetStopType( "DestroyImmediately" )
handle.ClearParent()
handle.Destroy()
}
}
pod.s.podLightFXHandles = []
foreach ( entity handle in pod.s.podGlowLightFXHandles )
{
if ( IsValid_ThisFrame( handle ) )
{
handle.SetStopType( "DestroyImmediately" )
handle.ClearParent()
handle.Destroy()
}
}
pod.s.podGlowLightFXHandles = []
pod.s.leftLaserEmitter.s.fxHandle.SetStopType( "DestroyImmediately" )
pod.s.leftLaserEmitter.s.fxHandle.ClearParent()
pod.s.leftLaserEmitter.s.fxHandle.Destroy()
pod.s.leftLaserEmitter.Destroy()
pod.s.rightLaserEmitter.s.fxHandle.SetStopType( "DestroyImmediately" )
pod.s.rightLaserEmitter.s.fxHandle.ClearParent()
pod.s.rightLaserEmitter.s.fxHandle.Destroy()
pod.s.rightLaserEmitter.Destroy()
}
|