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
|
untyped
global function DropPodSpawn_Init
global function SpawnPlayersInDropPod
struct {
array< entity > droppods
} file
void function DropPodSpawn_Init()
{
AddCallback_OnRoundEndCleanup( CleanupSpawningDropPods )
}
void function CleanupSpawningDropPods()
{
foreach ( entity pod in file.droppods )
{
if( IsValid( pod ) )
pod.Destroy()
}
file.droppods.clear()
}
void function SpawnPlayersInDropPod( array< entity > players, vector targetOrigin, vector angles, float destructionTime = -1 )
{
entity pod = CreateDropPod( targetOrigin, angles )
pod.EndSignal( "OnDestroy" )
file.droppods.append( pod )
svGlobal.levelEnt.EndSignal( "CleanUpEntitiesForRoundEnd" )
// TODO: we need to make a door for this, CreateDropPodDoor in _droppod_fireteam is just busted for some reason tho
entity camera = CreateEntity( "point_viewcontrol" )
camera.SetParent( pod, "ATTACH", false )
camera.SetLocalOrigin( < 0, 150, 450 > )
camera.SetAngles( < 60, -90, 0 > )
foreach ( entity player in players )
{
if( !IsValid( player ) )
continue
if ( !IsAlive( player ) )
player.RespawnPlayer( null )
player.SetOrigin( pod.GetOrigin() )
player.SetAngles( pod.GetAngles() )
player.SetParent( pod )
player.FreezeControlsOnServer()
AddCinematicFlag( player, CE_FLAG_HIDE_MAIN_HUD )
player.SetViewEntity( camera, true )
}
// wait for this
LaunchAnimDropPod( pod, "pod_testpath", targetOrigin, angles )
if( !GamePlaying() )
return
foreach ( entity player in players )
{
if( !IsValid( player ) )
continue
player.ClearParent()
player.ClearViewEntity()
player.UnfreezeControlsOnServer()
RemoveCinematicFlag( player, CE_FLAG_HIDE_MAIN_HUD )
}
// wait a frame, otherwise this won't properly work
WaitFrame()
vector doorPos = pod.GetAttachmentOrigin( pod.LookupAttachment( "hatch" ) )
if( !GamePlaying() )
return
foreach ( entity player in players )
{
if( !IsValid( player ) )
continue
vector viewAngles = doorPos - player.GetOrigin()
viewAngles.x = 3.0
player.SetAngles( viewAngles )
}
if ( destructionTime != -1 )
{
wait destructionTime
pod.Dissolve( ENTITY_DISSOLVE_NORMAL, < 0, 0, 0 >, 0 )
file.droppods.remove( file.droppods.find( pod ) )
}
}
|