aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/class/cai_basenpc.nut
blob: 631e01fc0d2435c18d0eca61cdab2c811cc1d862 (plain)
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
untyped

global function IsCrawling
global function CodeCallback_RegisterClass_CAI_BaseNPC
global function SetSpawnOption_AISettings
global function SetSpawnOption_Alert
global function SetSpawnOption_NotAlert
global function SetSpawnOption_Ordnance
global function SetSpawnOption_OwnerPlayer
global function SetSpawnOption_Sidearm
global function SetSpawnOption_SquadName
global function SetSpawnOption_Special
global function SetSpawnOption_Melee
global function SetSpawnOption_CoreAbility
global function SetSpawnOption_Antirodeo
global function SetSpawnOption_Titanfall
global function SetSpawnOption_TitanSoulPassive1
global function SetSpawnOption_TitanSoulPassive2
global function SetSpawnOption_TitanSoulPassive3
global function SetSpawnOption_TitanSoulPassive4
global function SetSpawnOption_TitanSoulPassive5
global function SetSpawnOption_TitanSoulPassive6
global function SetSpawnOption_Warpfall
global function SetSpawnOption_Weapon
global function SetSpawnOption_NPCTitan
global function SetSpawnOption_TitanLoadout

function CodeCallback_RegisterClass_CAI_BaseNPC()
{
	#document( "SetSpawnOption_AISettings", "Specify AI Setting" )
	#document( "SetSpawnOption_Alert", "Enable spawn alerted" )
	#document( "SetSpawnOption_NotAlert", "Enable spawn alerted" )
	#document( "SetSpawnOption_Ordnance", "Specify spawn ordnance" )
	#document( "SetSpawnOption_OwnerPlayer", "This titan will be the auto titan of this player" )
	#document( "SetSpawnOption_SquadName", "Specify spawn squadname" )
	#document( "SetSpawnOption_Special", "Specify spawn tactical ability" )
	#document( "SetSpawnOption_Titanfall", "npc titan will spawn via titanfall" )
	#document( "SetSpawnOption_TitanSoulPassive1", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_TitanSoulPassive2", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_TitanSoulPassive3", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_TitanSoulPassive4", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_TitanSoulPassive5", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_TitanSoulPassive6", "Set this passive on the titan soul" )
	#document( "SetSpawnOption_Warpfall", "Titan or super spectre will spawn via warpsfall" )
	#document( "SetSpawnOption_Weapon", "Specify spawn weapon and mods" )
	#document( "SetSpawnOption_NPCTitan", "Spawn titan of type" )


	//printl( "Class Script: CAI_BaseNPC" )

	CAI_BaseNPC.ClassName <- "CAI_BaseNPC"
	CAI_BaseNPC.supportsXRay <- null

	CAI_BaseNPC.mySpawnOptions_aiSettings <- null
	CAI_BaseNPC.mySpawnOptions_alert <- null
	CAI_BaseNPC.mySpawnOptions_sidearm <- null
	CAI_BaseNPC.mySpawnOptions_titanfallSpawn <- null
	CAI_BaseNPC.mySpawnOptions_warpfallSpawn <- null
	CAI_BaseNPC.mySpawnOptions_routeTD <- null
	CAI_BaseNPC.mySpawnOptions_ownerPlayer <- null
	CAI_BaseNPC.executedSpawnOptions <- null

	function CAI_BaseNPC::HasXRaySupport()
	{
		return ( this.supportsXRay != null )
	}

	function CAI_BaseNPC::ForceCombat()
	{
		this.FireNow( "UpdateEnemyMemory", "!player" )
	}
	#document( CAI_BaseNPC, "ForceCombat", "Force into combat state by updating NPC's memory of the player." )

	function CAI_BaseNPC::InCombat()
	{
		entity enemy = expect entity( this ).GetEnemy()
		if ( !IsValid( enemy ) )
			return false

		return this.CanSee( enemy )
	}
	#document( CAI_BaseNPC, "InCombat", "Returns true if NPC is in combat" )
}



function SetSpawnOption_AISettings( entity npc, setting )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.mySpawnOptions_aiSettings = setting
}

function SetSpawnOption_Alert( entity npc )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.mySpawnOptions_alert = true
}

function SetSpawnOption_NotAlert( entity npc )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.mySpawnOptions_alert = false
}

void function SetSpawnOption_Weapon( entity npc, string weapon, array<string> mods = [] )
{
	Assert( weapon != "", "Tried to assign no weapon as a spawn weapon" )
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )

	if ( npc.IsTitan() )
	{
		npc.ai.titanSpawnLoadout.primary = weapon
		npc.ai.titanSpawnLoadout.primaryMods = mods
	}
	else
	{
		NPCDefaultWeapon spawnoptionsweapon
		spawnoptionsweapon.wep = weapon
		spawnoptionsweapon.mods = mods

		npc.ai.mySpawnOptions_weapon = spawnoptionsweapon
	}
}

void function SetSpawnOption_Sidearm( entity npc, string weapon, array<string> mods = [])
{
	Assert( weapon != "", "Tried to assign no weapon as a spawn weapon" )
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )

	if ( !npc.IsTitan() )
		npc.mySpawnOptions_sidearm = { wep = weapon, mods = mods }
}

void function SetSpawnOption_Ordnance( entity npc, string ordnance, array<string> mods = [] )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.ordnance = ordnance
	npc.ai.titanSpawnLoadout.ordnanceMods = mods
}

void function SetSpawnOption_Special( entity npc, string special, array<string> mods = [] )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.special = special
	npc.ai.titanSpawnLoadout.specialMods = mods
}

void function SetSpawnOption_Antirodeo( entity npc, string antirodeo, array<string> mods = [] )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.antirodeo = antirodeo
	npc.ai.titanSpawnLoadout.antirodeoMods = mods
}

void function SetSpawnOption_Melee( entity npc, string melee )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.melee = melee
}

void function SetSpawnOption_CoreAbility( entity npc, string core )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.coreAbility = core
}

function SetSpawnOption_SquadName( entity npc, squadName )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.kv.squadname = squadName
}

function SetSpawnOption_Titanfall( entity npc )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	Assert( npc.IsTitan(), "npc is for titans only" )
	npc.mySpawnOptions_titanfallSpawn = true
}

function SetSpawnOption_Warpfall( entity npc )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	Assert( npc.IsTitan() || npc.GetClassName() == "npc_super_spectre", "npc is for titans and superspectres only" )
	npc.mySpawnOptions_warpfallSpawn = true
}

function SetSpawnOption_OwnerPlayer( entity npc, entity player )
{
	Assert( IsValid( player ) )
	Assert( player.IsPlayer() )
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.mySpawnOptions_ownerPlayer = player
}

function SetSpawnOption_TitanSoulPassive1( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive1 = passive
}

function SetSpawnOption_TitanSoulPassive2( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive2 = passive
}

function SetSpawnOption_TitanSoulPassive3( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive3 = passive
}

function SetSpawnOption_TitanSoulPassive4( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive4 = passive
}

function SetSpawnOption_TitanSoulPassive5( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive5 = passive
}

function SetSpawnOption_TitanSoulPassive6( entity npc, string passive )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout.passive6 = passive
}

function SetSpawnOption_NPCTitan( entity npc, int type )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( npc.IsTitan(), npc + " is not a Titan!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.bossTitanType = type
}


function SetSpawnOption_TitanLoadout( entity npc, TitanLoadoutDef loadout )
{
	Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" )
	Assert( npc.IsTitan(), npc + " is not a Titan!" )
	Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." )
	npc.ai.titanSpawnLoadout = loadout
}

bool function IsCrawling( entity npc )
{
	return npc.ai.crawling
}