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
|
global function AiGameModes_Init
global function AiGameModes_SetNPCWeapons
global function AiGameModes_SpawnDropShip
global function AiGameModes_SpawnDropPod
global function AiGameModes_SpawnReaper
global function AiGameModes_SpawnTitan
global function GetValidIntroDropShipSpawn
const INTRO_DROPSHIP_CUTOFF = 2000
struct
{
table< string, array<string> > npcWeaponsTable // npcs have their default weapon in aisettings file
} file
void function AiGameModes_Init()
{
}
//------------------------------------------------------
void function AiGameModes_SetNPCWeapons( string npcClass, array<string> weapons )
{
if ( !( npcClass in file.npcWeaponsTable ) )
file.npcWeaponsTable[ npcClass ] <- []
file.npcWeaponsTable[ npcClass ] = weapons
}
//------------------------------------------------------
void function AiGameModes_SpawnDropShip( vector pos, vector rot, int team, int count, void functionref( array<entity> guys ) squadHandler = null )
{
string squadName = MakeSquadName( team, UniqueString( "" ) )
CallinData drop
drop.origin = pos
drop.yaw = rot.y
drop.dist = 768
drop.team = team
drop.squadname = squadName
SetDropTableSpawnFuncs( drop, CreateSoldier, count )
SetCallinStyle( drop, eDropStyle.ZIPLINE_NPC )
thread RunDropshipDropoff( drop )
WaitSignal( drop, "OnDropoff" )
array< entity > guys = GetNPCArrayBySquad( squadName )
foreach ( guy in guys )
{
SetUpNPCWeapons( guy )
guy.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE )
}
if ( squadHandler != null )
thread squadHandler( guys )
}
void function AiGameModes_SpawnDropPod( vector pos, vector rot, int team, string content /*( ͡° ͜ʖ ͡°)*/, void functionref( array<entity> guys ) squadHandler = null, int flags = 0 )
{
entity pod = CreateDropPod( pos, <0,0,0> )
InitFireteamDropPod( pod, flags )
waitthread LaunchAnimDropPod( pod, "pod_testpath", pos, rot )
string squadName = MakeSquadName( team, UniqueString( "" ) )
array<entity> guys
for ( int i = 0; i < 4 ;i++ )
{
entity npc = CreateNPC( content, team, pos,<0,0,0> )
DispatchSpawn( npc )
SetSquad( npc, squadName )
SetUpNPCWeapons( npc )
npc.SetParent( pod, "ATTACH", true )
npc.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE )
guys.append( npc )
}
ActivateFireteamDropPod( pod, guys )
// start searching for enemies
if ( squadHandler != null )
thread squadHandler( guys )
}
const float REAPER_WARPFALL_DELAY = 4.7 // same as fd does
void function AiGameModes_SpawnReaper( vector pos, vector rot, int team, string aiSettings = "", void functionref( entity reaper ) reaperHandler = null )
{
float reaperLandTime = REAPER_WARPFALL_DELAY + 1.2 // reaper takes ~1.2s to warpfall
thread HotDrop_Spawnpoint( pos, team, reaperLandTime, false, damagedef_reaper_fall )
wait REAPER_WARPFALL_DELAY
entity reaper = CreateSuperSpectre( team, pos, rot )
reaper.EndSignal( "OnDestroy" )
// reaper highlight
Highlight_SetFriendlyHighlight( reaper, "sp_enemy_pilot" )
reaper.Highlight_SetParam( 1, 0, < 1,1,1 > )
SetDefaultMPEnemyHighlight( reaper )
Highlight_SetEnemyHighlight( reaper, "enemy_titan" )
SetSpawnOption_Titanfall( reaper )
SetSpawnOption_Warpfall( reaper )
if ( aiSettings != "" )
SetSpawnOption_AISettings( reaper, aiSettings )
HideName( reaper ) // prevent flash a name onto it
DispatchSpawn( reaper )
reaper.WaitSignal( "WarpfallComplete" )
ShowName( reaper ) // show name again after drop
if ( reaperHandler != null )
thread reaperHandler( reaper )
}
// copied from cl_replacement_titan_hud.gnut
void function HotDrop_Spawnpoint( vector origin, int team, float impactTime, bool hasFriendlyWarning = false, int damageDef = -1 )
{
array<entity> targetEffects = []
vector surfaceNormal = < 0, 0, 1 >
int index = GetParticleSystemIndex( $"P_ar_titan_droppoint" )
if( hasFriendlyWarning )
{
entity effectFriendly = StartParticleEffectInWorld_ReturnEntity( index, origin, surfaceNormal )
SetTeam( effectFriendly, team )
EffectSetControlPointVector( effectFriendly, 1, FRIENDLY_COLOR_FX )
effectFriendly.kv.VisibilityFlags = ENTITY_VISIBLE_TO_FRIENDLY
effectFriendly.DisableHibernation() // prevent it from fading out
targetEffects.append( effectFriendly )
}
entity effectEnemy = StartParticleEffectInWorld_ReturnEntity( index, origin, surfaceNormal )
SetTeam( effectEnemy, team )
EffectSetControlPointVector( effectEnemy, 1, ENEMY_COLOR_FX )
effectEnemy.kv.VisibilityFlags = ENTITY_VISIBLE_TO_ENEMY
effectEnemy.DisableHibernation() // prevent it from fading out
targetEffects.append( effectEnemy )
// so enemy npcs will mostly avoid them
entity damageAreaInfo
if ( damageDef > -1 )
{
damageAreaInfo = CreateEntity( "info_target" )
DispatchSpawn( damageAreaInfo )
AI_CreateDangerousArea_DamageDef( damageDef, damageAreaInfo, team, true, true )
}
wait impactTime
// clean up
foreach( entity targetEffect in targetEffects )
{
if ( IsValid( targetEffect ) )
EffectStop( targetEffect )
}
if ( IsValid( damageAreaInfo ) )
damageAreaInfo.Destroy()
}
// including aisettings stuff specifically for at bounty titans
const float TITANFALL_WARNING_DURATION = 5.0
void function AiGameModes_SpawnTitan( vector pos, vector rot, int team, string setFile, string aiSettings = "", void functionref( entity titan ) titanHandler = null )
{
entity titan = CreateNPCTitan( setFile, TEAM_BOTH, pos, rot )
SetSpawnOption_Titanfall( titan )
SetSpawnOption_Warpfall( titan )
// modified: do a hotdrop spawnpoint warning
thread HotDrop_Spawnpoint( pos, team, TITANFALL_WARNING_DURATION, false, damagedef_titan_fall )
if ( aiSettings != "" )
SetSpawnOption_AISettings( titan, aiSettings )
DispatchSpawn( titan )
if ( titanHandler != null )
thread titanHandler( titan )
}
void function SetUpNPCWeapons( entity guy )
{
string className = guy.GetClassName()
array<string> mainWeapons
if ( className in file.npcWeaponsTable )
mainWeapons = file.npcWeaponsTable[ className ]
if ( mainWeapons.len() == 0 ) // no valid weapons
return
// take off existing main weapons, or sometimes they'll have a archer by default
foreach ( entity weapon in guy.GetMainWeapons() )
guy.TakeWeapon( weapon.GetWeaponClassName() )
if ( mainWeapons.len() > 0 )
{
string weaponName = mainWeapons[ RandomInt( mainWeapons.len() ) ]
guy.GiveWeapon( weaponName )
guy.SetActiveWeaponByName( weaponName )
}
}
// Checks if we can spawn a dropship at a node, this should guarantee dropship ziplines
array<entity> function GetValidIntroDropShipSpawn( array<entity> introNodes )
{
array<entity> introShipSpawns
if ( GetZiplineDropshipSpawns().len() == 0 )
return []
foreach ( node in introNodes )
{
entity closestNode = GetClosest( GetZiplineDropshipSpawns(), node.GetOrigin() )
SetTeam( closestNode, node.GetTeam() )
if ( Distance( closestNode.GetOrigin(), node.GetOrigin() ) < INTRO_DROPSHIP_CUTOFF )
introShipSpawns.append( closestNode )
}
return introShipSpawns
}
|