‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
archetype_human.gsc
Go to the documentation of this file.
1 #using scripts\shared\ai_shared;
2 #using scripts\shared\array_shared;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\math_shared;
6 #using scripts\shared\spawner_shared;
7 #using scripts\shared\gameskill_shared;
8 #using scripts\shared\util_shared;
9 
10 // COMMON AI SYSTEMS INCLUDES
11 #using scripts\shared\ai\systems\ai_blackboard;
12 #using scripts\shared\ai\systems\ai_interface;
13 #using scripts\shared\ai\systems\animation_state_machine_utility;
14 #using scripts\shared\ai\systems\behavior_tree_utility;
15 #using scripts\shared\ai\systems\blackboard;
16 #using scripts\shared\ai\systems\destructible_character;
17 #using scripts\shared\ai\systems\gib;
18 #using scripts\shared\ai\archetype_cover_utility;
19 #using scripts\shared\ai\archetype_mocomps_utility;
20 
21 // BLACKBOARD
22 #using scripts\shared\ai\archetype_human_blackboard;
23 
24 // NOTETRACKS
25 #using scripts\shared\ai\archetype_notetracks;
26 
27 // BEHAVIORS
28 #using scripts\shared\ai\archetype_human_exposed;
29 #using scripts\shared\ai\archetype_human_cover;
30 #using scripts\shared\ai\archetype_human_locomotion;
31 
32 // INTERFACE
33 #using scripts\shared\ai\archetype_human_interface;
34 
35 #using scripts\shared\ai\archetype_utility;
36 
37 #insert scripts\shared\archetype_shared\archetype_shared.gsh;
38 #insert scripts\shared\ai\systems\animation_state_machine.gsh;
39 #insert scripts\shared\ai\systems\blackboard.gsh;
40 #insert scripts\shared\ai\systems\behavior.gsh;
41 #insert scripts\shared\ai\systems\behavior_tree.gsh;
42 #insert scripts\shared\ai\systems\gib.gsh;
43 #insert scripts\shared\shared.gsh;
44 #insert scripts\shared\version.gsh;
45 
46 #precache( "fx", "weapon/fx_hero_annhilatr_death_blood" );
47 
48 function autoexec ‪init()
49 {
50  // INIT BLACKBOARD
53 
55 
57  "actor",
60  1,
61  "int");
62 
63  /#
64  level.__ai_forceGibs = GetDvarInt( "ai_forceGibs" );
65  #/
66 }
67 
68 function private ‪ArchetypeHumanInit()
69 {
70  entity = self;
71 
74 
75  locomotionTypes = ‪array( "alt1", "alt2", "alt3", "alt4" );
76  altIndex = entity GetEntityNumber() % locomotionTypes.size;
77 
78  ‪Blackboard::SetBlackBoardAttribute( entity, ‪HUMAN_LOCOMOTION_VARIATION, locomotionTypes[ altIndex ] );
79 
80  if ( ‪IS_TRUE( entity.hero ) )
81  {
83  }
84 }
85 
86 function private ‪ArchetypeHumanBlackboardInit() // self = AI
87 {
88  // CREATE BLACKBOARD
90 
91  // CREATE INTERFACE
93 
94  // USE UTILITY BLACKBOARD
96 
97  // CREATE HUMAN BLACKBOARD
99 
100  // REGISTER ANIMSCRIPTED CALLBACK
101  self.___ArchetypeOnAnimscriptedCallback = &‪ArchetypeHumanOnAnimscriptedCallback;
102  self.___ArchetypeOnBehaveCallback = &‪ArchetypeHumanOnBehaveCallback;
103 
104  // ENABLE DEBUGGING IN ODYSSEY
106 
107  // THREAD PRE BULLET FIRE CALLBACK
108  self thread ‪gameskill::accuracy_buildup_before_fire( self );
109 
110  // RUN SNIPER GLINT AND LASER IF ACCURATE FIRE IS ON
111  if( self.accurateFire )
112  {
113  self thread ‪AiUtility::preShootLaserAndGlintOn( self );
114  self thread ‪AiUtility::postShootLaserAndGlintOff( self );
115  }
116 
119 }
120 
121 function private ‪ArchetypeHumanOnBehaveCallback( entity )
122 {
123  // Animscripted left the AI at cover.
124  if ( ‪AiUtility::isAtCoverCondition( entity ) )
125  {
128  }
129 
130  // Prevent an AI that just left anim script from throwing a grenade.
131  grenadeThrowInfo = SpawnStruct();
132  grenadeThrowInfo.grenadeThrower = entity;
134  "human_grenade_throw",
135  grenadeThrowInfo,
137 }
138 
139 function private ‪ArchetypeHumanOnAnimscriptedCallback( entity ) // self/entity = AI
140 {
141  // UNREGISTER THE BLACKBOARD
142  entity.__blackboard = undefined;
143 
144  // REREGISTER BLACKBOARD
146 
147  // Reapply the current vignette_mode
148  vignetteMode = ‪ai::GetAiAttribute( entity, "vignette_mode" );
149  ‪HumanSoldierServerUtils::VignetteModeCallback( entity, "vignette_mode", vignetteMode, vignetteMode );
150 }
151 
152 #define CLOSE_EXPLOSIVE SQR(60)
153 function private ‪humanGibKilledOverride(
154  inflictor, attacker, ‪damage, meansOfDeath, weapon, dir, hitLoc, offsetTime )
155 {
156  entity = self;
157 
158  // Only allow human gibbing at a 50% rate.
159  if ( ‪math::cointoss() )
160  {
161  return ‪damage;
162  }
163 
164  attackerDistance = 0;
165 
166  if ( IsDefined( attacker ) )
167  {
168  attackerDistance = DistanceSquared( attacker.origin, entity.origin );
169  }
170 
171  isExplosive = IsInArray(
172  ‪array(
173  "MOD_CRUSH",
174  "MOD_GRENADE",
175  "MOD_GRENADE_SPLASH",
176  "MOD_PROJECTILE",
177  "MOD_PROJECTILE_SPLASH",
178  "MOD_EXPLOSIVE" ),
179  meansOfDeath );
180 
181  forceGibbing = false;
182 
183  if ( IsDefined( weapon.weapclass ) && weapon.weapclass == "turret" )
184  {
185  forceGibbing = true;
186 
187  // Annihilate AI's from turrent explosives that are inflicted at a close distance.
188  if ( IsDefined( inflictor ) )
189  {
190  isDirectExplosive = IsInArray(
191  ‪array(
192  "MOD_GRENADE",
193  "MOD_GRENADE_SPLASH",
194  "MOD_PROJECTILE",
195  "MOD_PROJECTILE_SPLASH",
196  "MOD_EXPLOSIVE" ),
197  meansOfDeath );
198 
199  isCloseExplosive = DistanceSquared( inflictor.origin, entity.origin ) <= ‪CLOSE_EXPLOSIVE;
200 
201  if ( isDirectExplosive && isCloseExplosive )
202  {
204  }
205  }
206  }
207 
208  if ( forceGibbing || isExplosive ||
209  ( IsDefined( level.__ai_forceGibs ) && level.__ai_forceGibs ) ||
210  ( weapon.doGibbing && ( attackerDistance <= ‪SQR( weapon.maxGibDistance ) ) ) )
211  {
212  // Enable spawning gib pieces.
213  ‪GibServerUtils::ToggleSpawnGibs( entity, true );
215 
216  // TODO(David Young 2-15-15): Currently humans don't support head gibbing.
217  // TryGibbingHead( entity, damage, hitLoc, isExplosive );
218  ‪TryGibbingLimb( entity, ‪damage, hitLoc, isExplosive || forceGibbing );
219  ‪TryGibbingLegs( entity, ‪damage, hitLoc, isExplosive );
220  }
221 
222  return ‪damage;
223 }
224 
225 function private ‪TryGibbingHead( entity, ‪damage, hitLoc, isExplosive )
226 {
227  if ( isExplosive )
228  {
229  ‪GibServerUtils::GibHead( entity );
230  }
231  else if ( IsInArray( ‪array( "head", "neck", "helmet" ), hitLoc ) )
232  {
233  ‪GibServerUtils::GibHead( entity );
234  }
235 }
236 
237 function private ‪TryGibbingLimb( entity, ‪damage, hitLoc, isExplosive )
238 {
239  if ( isExplosive )
240  {
241  randomChance = RandomFloatRange( 0, 1 );
242 
243  if ( randomChance < 0.5 )
244  {
245  // 50% chance
247  }
248  else
249  {
250  // 50% chance
252  }
253  }
254  else if ( IsInArray( ‪array( "left_hand", "left_arm_lower", "left_arm_upper" ), hitLoc ) )
255  {
257  }
258  else if ( IsInArray( ‪array( "right_hand", "right_arm_lower", "right_arm_upper" ), hitLoc ) )
259  {
261  }
262  else if ( IsInArray( ‪array( "torso_upper" ), hitLoc ) && ‪math::cointoss() )
263  {
264  // Award a random gib.
265  if ( ‪math::cointoss() )
266  {
268  }
269  else
270  {
272  }
273  }
274 }
275 
276 function private ‪TryGibbingLegs( entity, ‪damage, hitLoc, isExplosive, attacker )
277 {
278  if ( isExplosive )
279  {
280  randomChance = RandomFloatRange( 0, 1 );
281 
282  if ( randomChance < 0.33 )
283  {
284  // 33% chance
286  }
287  else if ( randomChance < 0.66 )
288  {
289  // 33% chance
291  }
292  else
293  {
294  // 34% chance
295  ‪GibServerUtils::GibLegs( entity );
296  }
297  }
298  else if ( IsInArray( ‪array( "left_leg_upper", "left_leg_lower", "left_foot" ), hitLoc ) )
299  {
301  }
302  else if ( IsInArray( ‪array( "right_leg_upper", "right_leg_lower", "right_foot" ), hitLoc ) )
303  {
305  }
306  else if ( IsInArray( ‪array( "torso_lower" ), hitLoc ) && ‪math::cointoss() )
307  {
308  // Award a random gib.
309  if ( ‪math::cointoss() )
310  {
312  }
313  else
314  {
316  }
317  }
318 }
319 
320 function ‪DamageOverride( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex )
321 {
322  entity = self;
323 
324  entity ‪DestructServerUtils::HandleDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex );
325 
326  if( isDefined( eAttacker) && !isPlayer( eAttacker ) && !isVehicle( eAttacker ) )
327  {
328  dist = DistanceSquared( entity.origin, eAttacker.origin );
329 
330  if( dist < 256*256 )
331  {
332  iDamage = Int( iDamage * 10 );
333  }
334  else
335  {
336  iDamage = Int( iDamage * 1.5 );
337  }
338  }
339 
340  if ( sWeapon.name == "incendiary_grenade" )
341  {
342  iDamage = entity.health;
343  }
344 
345  return iDamage;
346 }
347 
348 #namespace HumanSoldierServerUtils;
349 
350 function ‪cqbAttributeCallback( entity, attribute, oldValue, value )
351 {
352  if ( value )
353  {
354  entity AsmChangeAnimMappingTable( 2 );
355  }
356  else
357  {
358  if( entity ‪ai::get_behavior_attribute( "useAnimationOverride" ) )
359  entity AsmChangeAnimMappingTable( 1 );
360  else
361  entity AsmChangeAnimMappingTable( 0 );
362  }
363 }
364 
365 function ‪forceTacticalWalkCallback( entity, attribute, oldValue, value )
366 {
367  entity.ignorerunAndgundist = value;
368 }
369 
370 function ‪moveModeAttributeCallback( entity, attribute, oldValue, value )
371 {
372  entity.ignorepathenemyfightdist = false;
373 
374  switch ( value )
375  {
376  case "normal":
377  break;
378  case "rambo":
379  entity.ignorepathenemyfightdist = true;
380  break;
381  }
382 }
383 
384 function ‪UseAnimationOverrideCallback( entity, attribute, oldValue, value )
385 {
386  if ( value )
387  {
388  entity AsmChangeAnimMappingTable( 1 );
389  }
390  else
391  {
392  entity AsmChangeAnimMappingTable( 0 );
393  }
394 }
395 
396 function ‪VignetteModeCallback( entity, attribute, oldValue, value )
397 {
398  switch ( value )
399  {
400  case "off":
401  entity.pushable = true;
402  entity PushActors( false );
403  entity PushPlayer( false );
404  entity SetAvoidanceMask( "avoid all" );
405  entity SetSteeringMode( "normal steering" );
406  break;
407  case "slow":
408  entity.pushable = false;
409  entity PushActors( false );
410  entity PushPlayer( true );
411  entity SetAvoidanceMask( "avoid ai" );
412  entity SetSteeringMode( "vignette steering" );
413  break;
414  case "fast":
415  entity.pushable = false;
416  entity PushActors( true );
417  entity PushPlayer( true );
418  entity SetAvoidanceMask( "avoid none" );
419  entity SetSteeringMode( "vignette steering" );
420  break;
421  default:
422  break;
423  }
424 }
425 
426 // end #namespace HumanSoldierServerUtils;
‪COVER_MODE
‪#define COVER_MODE
Definition: blackboard.gsh:41
‪AddAIOverrideDamageCallback
‪function AddAIOverrideDamageCallback(entity, callback, addToFront)
Definition: archetype_utility.gsc:542
‪ArchetypeHumanOnBehaveCallback
‪function private ArchetypeHumanOnBehaveCallback(entity)
Definition: archetype_human.gsc:121
‪ArchetypeHumanBlackboardInit
‪function private ArchetypeHumanBlackboardInit()
Definition: archetype_human.gsc:86
‪DamageOverride
‪function DamageOverride(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex)
Definition: archetype_human.gsc:320
‪humanGibKilledOverride
‪function private humanGibKilledOverride(inflictor, attacker, damage, meansOfDeath, weapon, dir, hitLoc, offsetTime)
Definition: archetype_human.gsc:153
‪preShootLaserAndGlintOn
‪function preShootLaserAndGlintOn(ai)
Definition: archetype_utility.gsc:3051
‪VignetteModeCallback
‪function VignetteModeCallback(entity, attribute, oldValue, value)
Definition: archetype_human.gsc:396
‪AddAIOverrideKilledCallback
‪function AddAIOverrideKilledCallback(entity, callback)
Definition: archetype_utility.gsc:618
‪UseAnimationOverrideCallback
‪function UseAnimationOverrideCallback(entity, attribute, oldValue, value)
Definition: archetype_human.gsc:384
‪ArchetypeHumanInit
‪function private ArchetypeHumanInit()
Definition: archetype_human.gsc:68
‪GibLeftArm
‪function GibLeftArm(entity)
Definition: gib.gsc:450
‪cqbAttributeCallback
‪function cqbAttributeCallback(entity, attribute, oldValue, value)
Definition: archetype_human.gsc:350
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪cointoss
‪function cointoss()
Definition: math_shared.csc:171
‪RegisterActorBlackBoardAttributes
‪function RegisterActorBlackBoardAttributes()
Definition: archetype_human_blackboard.gsc:30
‪ToggleSpawnGibs
‪function ToggleSpawnGibs(entity, shouldSpawnGibs)
Definition: destructible_character.gsc:19
‪COVER_MODE_NONE
‪#define COVER_MODE_NONE
Definition: blackboard.gsh:108
‪isAtCoverCondition
‪function isAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:371
‪forceTacticalWalkCallback
‪function forceTacticalWalkCallback(entity, attribute, oldValue, value)
Definition: archetype_human.gsc:365
‪SetBlackBoardAttribute
‪function SetBlackBoardAttribute(entity, attributeName, attributeValue)
Definition: blackboard.gsc:56
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪ArchetypeHumanOnAnimscriptedCallback
‪function private ArchetypeHumanOnAnimscriptedCallback(entity)
Definition: archetype_human.gsc:139
‪SQR
‪#define SQR(__var)
Definition: shared.gsh:293
‪RegisterUtilityBlackboardAttributes
‪function RegisterUtilityBlackboardAttributes()
Definition: archetype_utility.gsc:139
‪accuracy_buildup_before_fire
‪function accuracy_buildup_before_fire(ai)
Definition: gameskill_shared.gsc:2144
‪Annihilate
‪function Annihilate(entity)
Definition: gib.gsc:393
‪init
‪function autoexec init()
Definition: archetype_human.gsc:48
‪HUMAN_LOCOMOTION_VARIATION
‪#define HUMAN_LOCOMOTION_VARIATION
Definition: blackboard.gsh:129
‪GibRightLeg
‪function GibRightLeg(entity)
Definition: gib.gsc:496
‪GibLeftLeg
‪function GibLeftLeg(entity)
Definition: gib.gsc:485
‪damage
‪function damage(trap)
Definition: _zm_trap_electric.gsc:116
‪CLOSE_EXPLOSIVE
‪#define CLOSE_EXPLOSIVE
Definition: archetype_human.gsc:152
‪ENABLE_BLACKBOARD_DEBUG_TRACKING
‪#define ENABLE_BLACKBOARD_DEBUG_TRACKING(self)
Definition: blackboard.gsh:7
‪moveModeAttributeCallback
‪function moveModeAttributeCallback(entity, attribute, oldValue, value)
Definition: archetype_human.gsc:370
‪RegisterHumanInterfaceAttributes
‪function RegisterHumanInterfaceAttributes()
Definition: archetype_human_interface.gsc:8
‪TryGibbingLimb
‪function private TryGibbingLimb(entity, damage, hitLoc, isExplosive)
Definition: archetype_human.gsc:237
‪HUMAN_FACIAL_DIALOG_ACTIVE
‪#define HUMAN_FACIAL_DIALOG_ACTIVE
Definition: archetype_shared.gsh:56
‪MAX_GRENADE_ANIMSCRIPTED_TIME
‪#define MAX_GRENADE_ANIMSCRIPTED_TIME
Definition: behavior.gsh:44
‪AddBlackboardEvent
‪function AddBlackboardEvent(eventName, data, timeToLiveInMillis)
Definition: ai_blackboard.gsc:47
‪TryGibbingHead
‪function private TryGibbingHead(entity, damage, hitLoc, isExplosive)
Definition: archetype_human.gsc:225
‪array
‪function filter array
Definition: array_shared.csc:16
‪GetAiAttribute
‪function GetAiAttribute(entity, attribute)
Definition: ai_interface.gsc:118
‪add_archetype_spawn_function
‪function add_archetype_spawn_function(archetype, spawn_func)
Definition: ai_shared.csc:23
‪PREVIOUS_COVER_MODE
‪#define PREVIOUS_COVER_MODE
Definition: blackboard.gsh:42
‪TryGibbingLegs
‪function private TryGibbingLegs(entity, damage, hitLoc, isExplosive, attacker)
Definition: archetype_human.gsc:276
‪CreateBlackBoardForEntity
‪function CreateBlackBoardForEntity(entity)
Definition: blackboard.gsc:77
‪COVER_ALERT_MODE
‪#define COVER_ALERT_MODE
Definition: blackboard.gsh:113
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪GibLegs
‪function GibLegs(entity)
Definition: gib.gsc:507
‪ARCHETYPE_HUMAN
‪#define ARCHETYPE_HUMAN
Definition: archetype_shared.gsh:4
‪MIN_GRENADE_ANIMSCRIPTED_TIME
‪#define MIN_GRENADE_ANIMSCRIPTED_TIME
Definition: behavior.gsh:43
‪GibRightArm
‪function GibRightArm(entity)
Definition: gib.gsc:467
‪GibHead
‪function GibHead(entity)
Definition: gib.gsc:443
‪get_behavior_attribute
‪function get_behavior_attribute(attribute)
Definition: ai_shared.gsc:184
‪HandleDamage
‪function HandleDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex)
Definition: destructible_character.gsc:20
‪CreateInterfaceForEntity
‪function CreateInterfaceForEntity(entity)
Definition: ai_interface.gsc:110
‪postShootLaserAndGlintOff
‪function postShootLaserAndGlintOff(ai)
Definition: archetype_utility.gsc:3090