1 #using scripts\shared\ai_shared;
2 #using scripts\shared\math_shared;
3 #using scripts\shared\spawner_shared;
4 #using scripts\shared\ai\archetype_utility;
6 #insert scripts\shared\shared.gsh;
7 #insert scripts\shared\ai\phalanx.gsh;
8 #insert scripts\shared\archetype_shared\archetype_shared.gsh;
14 assert( IsArray( sentients ) );
16 foreach ( index, sentient
in sentients )
18 if ( IsDefined( sentient) && IsAlive( sentient ) )
26 phalanxType, tier, phalanxPosition, forward, maxTierSize, spawner = undefined )
30 if ( !IsSpawner( spawner ) )
36 angles = VectorToAngles( forward );
38 foreach ( index, position
in positions )
40 if ( index >= maxTierSize )
47 navMeshPosition = GetClosestPointOnNavMesh(
56 sentient = spawner
spawner::spawn(
true,
"", navMeshPosition, angles );
63 sentients[ sentients.size ] = sentient;
71 inflictor, attacker,
damage, flags, meansOfDamage, weapon, point, dir, hitLoc, offsetTime, boneIndex, modelIndex )
75 isExplosive = IsInArray(
80 "MOD_PROJECTILE_SPLASH",
84 if ( isExplosive && IsDefined( inflictor ) && IsDefined( inflictor.weapon ) )
86 weapon = inflictor.weapon;
88 distanceToEntity = Distance( entity.origin, inflictor.origin );
93 if ( weapon.explosionradius > 0 )
95 fractionDistance = ( weapon.explosionradius - distanceToEntity ) / weapon.explosionradius;
99 return Int( Max(
damage * fractionDistance, 1 ) );
107 switch ( phalanxType )
187 assert(
"Unknown phalanx type \"" + phalanxType +
"\"." );
190 assert(
"Unknown phalanx tier \"" + tier +
"\"." );
195 spawner = GetSpawnerArray( tier,
"targetname" );
197 assert( spawner.size >= 0,
198 "No spawners for the phalanx system were found, make sure you include " +
199 "the \"game/map_source/_prefabs/ai/robot_phalanx.map\" prefab within your " +
200 "map to use the system." );
201 assert( spawner.size == 1,
202 "Too many spawners for the phalanx system were found, make sure you " +
203 "don't include multiple copies of the " +
204 "\"game/map_source/_prefabs/ai/robot_phalanx.map\" prefab in your map." );
211 assert( IsArray( sentients ) );
213 foreach ( index, sentient
in sentients )
215 if ( IsDefined( sentient ) && IsAlive( sentient ) && sentient HasPath() )
217 navMeshPosition = GetClosestPointOnNavMesh(
220 sentient UsePosition( navMeshPosition );
221 sentient ClearPath();
228 assert( IsArray( sentients ) );
230 foreach ( index, sentient
in sentients )
232 if ( IsDefined( sentient ) && IsAlive( sentient ) )
234 sentient.ignoreall =
true;
241 assert( IsActor( sentient ) );
244 if ( sentient.archetype ===
"human" )
246 sentient.allowPain =
false;
248 sentient SetAvoidanceMask(
"avoid none" );
262 angles = VectorToAngles( forward );
264 assert( sentients.size <= positions.size,
265 "There must be enough positions for the phalanx tier to move to." );
267 foreach ( index, sentient
in sentients )
269 if ( IsDefined( sentient ) && IsAlive( sentient ) )
271 assert( IsVec( positions[ index ] ),
272 "Must have a formation position for position(" + index +
") in tier " +
273 tier +
" of formation " + phalanxType );
277 navMeshPosition = GetClosestPointOnNavMesh(
280 sentient UsePosition( navMeshPosition );
290 foreach ( index, sentient
in sentients )
292 if ( IsDefined( sentient ) && IsAlive( sentient ) )
294 liveSentients[ index ] = sentient;
298 return liveSentients;
303 if ( IsDefined( sentient ) && IsAlive( sentient ) )
305 sentient ClearUsePosition();
306 sentient PathMode(
"move delayed",
true, RandomFloatRange( 0.5, 1 ) );
313 if ( sentient.archetype ===
"human" )
315 sentient.allowPain =
true;
317 sentient SetAvoidanceMask(
"avoid all" );
331 foreach ( index, sentient
in sentients )
337 wait RandomFloatRange( 0.5, 5 );
343 if ( IsDefined( sentient ) && IsAlive( sentient ) )
345 sentient.ignoreall =
false;
351 assert( IsArray( sentients ) );
353 foreach ( index, sentient
in sentients )
361 return ( vector[0] * Cos( angle ) - vector[1] * Sin( angle ),
362 vector[0] * Sin( angle ) + vector[1] * Cos( angle ),
368 while ( [[ phalanx ]]->_UpdatePhalanx() )
466 tierOneSpawner = undefined,
467 tierTwoSpawner = undefined,
468 tierThreeSpawner = undefined )
470 assert( IsString( phalanxType ) );
471 assert( IsInt( breakingPoint ) );
472 assert( IsVec( origin ) );
473 assert( IsVec( destination ) );
482 forward = VectorNormalize( destination - origin );
487 phalanxType, tierName, origin, forward, maxTierSize, tierSpawners[ tierName ] );
552 wait RandomFloatRange( 5, 7 );
560 wait RandomFloatRange( 5, 7 );