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
|
global function GamemodeSpeedball_Init
struct {
entity flagBase
entity flag
entity flagCarrier
} file
void function GamemodeSpeedball_Init()
{
PrecacheModel( CTF_FLAG_MODEL )
PrecacheModel( CTF_FLAG_BASE_MODEL )
// gamemode settings
SetRoundBased( true )
SetRespawnsEnabled( false )
SetShouldUseRoundWinningKillReplay( true )
Riff_ForceTitanAvailability( eTitanAvailability.Never )
Riff_ForceSetEliminationMode( eEliminationMode.Pilots )
ScoreEvent_SetupEarnMeterValuesForMixedModes()
SetupGenericFFAChallenge()
AddSpawnCallbackEditorClass( "script_ref", "info_speedball_flag", CreateFlag )
AddCallback_GameStateEnter( eGameState.Prematch, CreateFlagIfNoFlagSpawnpoint )
AddCallback_GameStateEnter( eGameState.Playing, ResetFlag )
AddCallback_GameStateEnter( eGameState.WinnerDetermined,GamemodeSpeedball_OnWinnerDetermined)
AddCallback_OnTouchHealthKit( "item_flag", OnFlagCollected )
AddCallback_OnPlayerKilled( OnPlayerKilled )
SetTimeoutWinnerDecisionFunc( TimeoutCheckFlagHolder )
AddCallback_OnRoundEndCleanup ( ResetFlag )
ClassicMP_SetCustomIntro( ClassicMP_DefaultNoIntro_Setup, ClassicMP_DefaultNoIntro_GetLength() )
ClassicMP_ForceDisableEpilogue( true )
}
void function CreateFlag( entity flagSpawn )
{
entity flagBase = CreatePropDynamic( CTF_FLAG_BASE_MODEL, flagSpawn.GetOrigin(), flagSpawn.GetAngles() )
entity flag = CreateEntity( "item_flag" )
flag.SetValueForModelKey( CTF_FLAG_MODEL )
flag.MarkAsNonMovingAttachment()
DispatchSpawn( flag )
flag.SetModel( CTF_FLAG_MODEL )
flag.SetOrigin( flagBase.GetOrigin() + < 0, 0, flagBase.GetBoundingMaxs().z + 1 > )
flag.SetVelocity( < 0, 0, 1 > )
flag.Minimap_AlwaysShow( TEAM_IMC, null )
flag.Minimap_AlwaysShow( TEAM_MILITIA, null )
flag.Minimap_SetAlignUpright( true )
file.flag = flag
file.flagBase = flagBase
}
bool function OnFlagCollected( entity player, entity flag )
{
if ( !IsAlive( player ) || flag.GetParent() != null || player.IsTitan() || player.IsPhaseShifted() )
return false
GiveFlag( player )
return false // so flag ent doesn't despawn
}
void function OnPlayerKilled( entity victim, entity attacker, var damageInfo )
{
if ( file.flagCarrier == victim )
DropFlag()
if ( victim.IsPlayer() && GetGameState() == eGameState.Playing )
if ( GetPlayerArrayOfTeam_Alive( victim.GetTeam() ).len() == 1 )
foreach ( entity player in GetPlayerArray() )
Remote_CallFunction_NonReplay( player, "ServerCallback_SPEEDBALL_LastPlayer", player.GetTeam() != victim.GetTeam() )
}
void function GiveFlag( entity player )
{
file.flag.SetParent( player, "FLAG" )
file.flagCarrier = player
SetTeam( file.flag, player.GetTeam() )
SetGlobalNetEnt( "flagCarrier", player )
thread DropFlagIfPhased( player )
EmitSoundOnEntityOnlyToPlayer( player, player, "UI_CTF_1P_GrabFlag" )
foreach ( entity otherPlayer in GetPlayerArray() )
{
MessageToPlayer( otherPlayer, eEventNotifications.SPEEDBALL_FlagPickedUp, player )
if ( otherPlayer.GetTeam() == player.GetTeam() )
EmitSoundOnEntityToTeamExceptPlayer( file.flag, "UI_CTF_3P_TeamGrabFlag", player.GetTeam(), player )
}
}
void function DropFlagIfPhased( entity player )
{
player.EndSignal( "StartPhaseShift" )
player.EndSignal( "OnDestroy" )
OnThreadEnd( function() : ( player )
{
if ( file.flag.GetParent() == player )
DropFlag()
})
while( file.flag.GetParent() == player )
WaitFrame()
}
void function DropFlag()
{
file.flag.ClearParent()
file.flag.SetAngles( < 0, 0, 0 > )
SetTeam( file.flag, TEAM_UNASSIGNED )
SetGlobalNetEnt( "flagCarrier", file.flag )
if ( IsValid( file.flagCarrier ) )
EmitSoundOnEntityOnlyToPlayer( file.flagCarrier, file.flagCarrier, "UI_CTF_1P_FlagDrop" )
foreach ( entity player in GetPlayerArray() )
MessageToPlayer( player, eEventNotifications.SPEEDBALL_FlagDropped, file.flagCarrier )
file.flagCarrier = null
}
void function CreateFlagIfNoFlagSpawnpoint()
{
if ( IsValid( file.flag ) )
return
foreach ( entity hardpoint in GetEntArrayByClass_Expensive( "info_hardpoint" ) )
{
if ( GetHardpointGroup(hardpoint) == "B" )
{
CreateFlag( hardpoint )
return
}
}
}
void function ResetFlag()
{
file.flag.ClearParent()
file.flag.SetAngles( < 0, 0, 0 > )
file.flag.SetVelocity( < 0, 0, 1 > ) // hack: for some reason flag won't have gravity if i don't do this
file.flag.SetOrigin( file.flagBase.GetOrigin() + < 0, 0, file.flagBase.GetBoundingMaxs().z * 2 > )
SetTeam( file.flag, TEAM_UNASSIGNED )
file.flagCarrier = null
SetGlobalNetEnt( "flagCarrier", file.flag )
}
int function TimeoutCheckFlagHolder()
{
if ( file.flagCarrier == null )
return TEAM_UNASSIGNED
return file.flagCarrier.GetTeam()
}
void function GamemodeSpeedball_OnWinnerDetermined()
{
if(IsValid(file.flagCarrier))
file.flagCarrier.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 )
}
string function GetHardpointGroup(entity hardpoint) //Hardpoint Entity B on Homestead is missing the Hardpoint Group KeyValue
{
if((GetMapName()=="mp_homestead")&&(!hardpoint.HasKey("hardpointGroup")))
return "B"
return string(hardpoint.kv.hardpointGroup)
}
|