‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
archetype_cover_utility.gsc
Go to the documentation of this file.
1 #using scripts\shared\ai_shared;
2 #using scripts\shared\math_shared;
3 #using scripts\shared\ai\archetype_utility;
4 #using scripts\shared\ai\systems\animation_state_machine_utility;
5 #using scripts\shared\ai\systems\behavior_tree_utility;
6 #using scripts\shared\ai\systems\blackboard;
7 
8 #insert scripts\shared\ai\systems\animation_state_machine.gsh;
9 #insert scripts\shared\ai\systems\behavior.gsh;
10 #insert scripts\shared\ai\systems\behavior_tree.gsh;
11 #insert scripts\shared\ai\systems\blackboard.gsh;
12 #insert scripts\shared\ai\utility.gsh;
13 #insert scripts\shared\shared.gsh;
14 
15 #namespace AiUtility;
16 // Use this utility if AI takes cover, behavior here should not be archetype dependent at all
17 
18 #define COVER_AIM_ANGLE_EPSILON 10 // 10 degree allowable threshold for aims against the aimtables
19 
21 {
22  ‪BT_REGISTER_API( "isAtCrouchNode", &‪isAtCrouchNode );
23  ‪BT_REGISTER_API( "isAtCoverCondition", &‪isAtCoverCondition );
24  ‪BT_REGISTER_API( "isAtCoverStrictCondition", &‪isAtCoverStrictCondition );
25  ‪BT_REGISTER_API( "isAtCoverModeOver", &‪isAtCoverModeOver );
26  ‪BT_REGISTER_API( "isAtCoverModeNone", &‪isAtCoverModeNone );
27  ‪BT_REGISTER_API( "isExposedAtCoverCondition", &‪isExposedAtCoverCondition );
28  ‪BT_REGISTER_API( "keepClaimedNodeAndChooseCoverDirection", &‪keepClaimedNodeAndChooseCoverDirection);
29  ‪BT_REGISTER_API( "resetCoverParameters", &‪resetCoverParameters );
30  ‪BT_REGISTER_API( "cleanupCoverMode", &‪cleanupCoverMode );
31  ‪BT_REGISTER_API( "canBeFlankedService", &‪canBeFlankedService );
32  ‪BT_REGISTER_API( "shouldCoverIdleOnly", &‪shouldCoverIdleOnly );
33  ‪BT_REGISTER_API( "isSuppressedAtCoverCondition", &‪isSuppressedAtCoverCondition );
34 
35  // ------- COVER - IDLE BEHAVIOR -----------//
36  ‪BT_REGISTER_API( "coverIdleInitialize", &‪coverIdleInitialize );
37  ‪BT_REGISTER_API( "coverIdleUpdate", &‪coverIdleUpdate );
38  ‪BT_REGISTER_API( "coverIdleTerminate", &‪coverIdleTerminate );
39 
40  // ------- COVER - FLANKED BEHAVIOR -----------//
41  ‪BT_REGISTER_API( "isFlankedByEnemyAtCover", &‪isFlankedByEnemyAtCover );
42  ‪BT_REGISTER_API( "coverFlankedActionStart", &‪coverFlankedInitialize );
43  ‪BT_REGISTER_API( "coverFlankedActionTerminate", &‪coverFlankedActionTerminate );
44 
45  // ------- COVER - OVER SHOOT BEHAVIOR -----------//
46  ‪BT_REGISTER_API( "supportsOverCoverCondition", &‪supportsOverCoverCondition );
47  ‪BT_REGISTER_API( "shouldOverAtCoverCondition", &‪shouldOverAtCoverCondition );
48  ‪BT_REGISTER_API( "coverOverInitialize", &‪coverOverInitialize );
49  ‪BT_REGISTER_API( "coverOverTerminate", &‪coverOverTerminate );
50 
51  // ------- COVER - LEAN SHOOT BEHAVIOR -----------//
52  ‪BT_REGISTER_API( "supportsLeanCoverCondition", &‪supportsLeanCoverCondition );
53  ‪BT_REGISTER_API( "shouldLeanAtCoverCondition", &‪shouldLeanAtCoverCondition );
54  ‪BT_REGISTER_API( "continueLeaningAtCoverCondition", &‪continueLeaningAtCoverCondition );
55  ‪BT_REGISTER_API( "coverLeanInitialize", &‪coverLeanInitialize );
56  ‪BT_REGISTER_API( "coverLeanTerminate", &‪coverLeanTerminate );
57 
58  // ------- COVER - PEEK SHOOT BEHAVIOR -----------//
59  ‪BT_REGISTER_API( "supportsPeekCoverCondition", &‪supportsPeekCoverCondition );
60  ‪BT_REGISTER_API( "coverPeekInitialize", &‪coverPeekInitialize );
61  ‪BT_REGISTER_API( "coverPeekTerminate", &‪coverPeekTerminate );
62 
63  // ------- COVER - RELOAD BEHAVIOR -----------//
64  ‪BT_REGISTER_API( "coverReloadInitialize", &‪coverReloadInitialize );
65  ‪BT_REGISTER_API( "refillAmmoAndCleanupCoverMode", &‪refillAmmoAndCleanupCoverMode );
66 }
67 
68 // ------- COVER - RELOAD BEHAVIOR -----------//
69 function private ‪coverReloadInitialize( behaviorTreeEntity )
70 {
72  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
73 }
74 
75 function ‪refillAmmoAndCleanupCoverMode( behaviorTreeEntity )
76 {
77  if( IsAlive( behaviorTreeEntity ) )
78  {
79  ‪AiUtility::refillAmmo( behaviorTreeEntity );
80  }
81 
82  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
83 }
84 
85 // ------- COVER - PEEK BEHAVIOR -----------//
86 function private ‪supportsPeekCoverCondition( behaviorTreeEntity )
87 {
88  return IsDefined( behaviorTreeEntity.node );
89 }
90 
91 function private ‪coverPeekInitialize( behaviorTreeEntity )
92 {
94  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
95  ‪chooseCoverDirection( behaviorTreeEntity );
96 }
97 
98 function private ‪coverPeekTerminate( behaviorTreeEntity )
99 {
100  ‪AiUtility::chooseFrontCoverDirection( behaviorTreeEntity );
101  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
102 }
103 // ------- COVER - PEEK BEHAVIOR -----------//
104 
105 
106 // ------- COVER - LEAN SHOOT BEHAVIOR -----------//
107 function private ‪supportsLeanCoverCondition( behaviorTreeEntity )
108 {
109  if ( IsDefined( behaviorTreeEntity.node ) )
110  {
111  if( ‪NODE_COVER_LEFT( behaviorTreeEntity.node ) || ‪NODE_COVER_RIGHT( behaviorTreeEntity.node ) )
112  {
113  return true;
114  }
115  else if ( ‪NODE_COVER_PILLAR( behaviorTreeEntity.node ) )
116  {
117  if ( !‪ISNODEDONTLEFT( behaviorTreeEntity.node ) || !‪ISNODEDONTRIGHT( behaviorTreeEntity.node ) )
118  {
119  return true;
120  }
121  }
122  }
123 
124  return false;
125 }
126 
127 function private ‪shouldLeanAtCoverCondition( behaviorTreeEntity )
128 {
129  if( !IsDefined( behaviorTreeEntity.node ) ||
130  !IsDefined( behaviorTreeEntity.node.type ) ||
131  !IsDefined( behaviorTreeEntity.enemy) ||
132  !IsDefined( behaviorTreeEntity.enemy.origin ) )
133  {
134  return false;
135  }
136 
137  yawToEnemyPosition = AiUtility::GetAimYawToEnemyFromNode( behaviorTreeEntity, behaviorTreeEntity.node, behaviorTreeEntity.enemy );
138 
139  legalAimYaw = false;
140 
141  if( ‪NODE_COVER_LEFT(behaviorTreeEntity.node) )
142  {
143  aimLimitsForCover = behaviortreeentity GetAimLimitsFromEntry(‪AIM_LIMIT_TABLE_ENTRY_COVER_LEFT_LEAN);
144  legalAimYaw = yawToEnemyPosition <= ( aimLimitsForCover[‪AIM_LEFT] + ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition >= -‪COVER_AIM_ANGLE_EPSILON;
145  }
146  else if( ‪NODE_COVER_RIGHT(behaviorTreeEntity.node) )
147  {
148  aimLimitsForCover = behaviortreeentity GetAimLimitsFromEntry(‪AIM_LIMIT_TABLE_ENTRY_COVER_RIGHT_LEAN);
149  legalAimYaw = yawToEnemyPosition >= ( aimLimitsForCover[‪AIM_RIGHT] - ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition <= ‪COVER_AIM_ANGLE_EPSILON;
150  }
151  else if( ‪NODE_COVER_PILLAR(behaviorTreeEntity.node) )
152  {
153  aimLimitsForCover = behaviortreeentity GetAimLimitsFromEntry(‪AIM_LIMIT_TABLE_ENTRY_COVER);
154  supportsLeft = !‪ISNODEDONTLEFT( behaviorTreeEntity.node );
155  supportsRight = !‪ISNODEDONTRIGHT( behaviorTreeEntity.node );
156 
157  // If both left and right are supported, then split the 180 coverage along the center, otherwise pad the leeway to force the AI to lean more often.
158  angleLeeway = ‪COVER_AIM_ANGLE_EPSILON;
159 
160  if ( supportsRight && supportsLeft )
161  {
162  angleLeeway = 0;
163  }
164 
165  if ( supportsLeft )
166  {
167  legalAimYaw = yawToEnemyPosition <= ( aimLimitsForCover[‪AIM_LEFT] + ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition >= -angleLeeway;
168  }
169 
170  if ( !legalAimYaw && supportsRight )
171  {
172  legalAimYaw = yawToEnemyPosition >= ( aimLimitsForCover[‪AIM_RIGHT] - ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition <= angleLeeway;
173  }
174  }
175 
176  return legalAimYaw;
177 }
178 
179 
180 function private ‪continueLeaningAtCoverCondition( behaviorTreeEntity )
181 {
182  if ( behaviorTreeEntity ASMIsTransitionRunning() )
183  {
184  return true;
185  }
186 
187  return ‪AiUtility::shouldLeanAtCoverCondition( behaviorTreeEntity );
188 }
189 
190 
191 function private ‪coverLeanInitialize( behaviorTreeEntity )
192 {
193  ‪AiUtility::setCoverShootStartTime( behaviorTreeEntity );
194  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
196  ‪AiUtility::chooseCoverDirection( behaviorTreeEntity );
197 }
198 
199 function private ‪coverLeanTerminate( behaviorTreeEntity )
200 {
201  ‪AiUtility::chooseFrontCoverDirection( behaviorTreeEntity );
202  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
203  ‪AiUtility::clearCoverShootStartTime( behaviorTreeEntity );
204 }
205 // ------- COVER - LEAN SHOOT BEHAVIOR -----------//
206 
207 // ------- COVER - OVER SHOOT BEHAVIOR -----------//
208 function private ‪supportsOverCoverCondition( behaviorTreeEntity )
209 {
210  stance = ‪Blackboard::GetBlackBoardAttribute( behaviorTreeEntity, ‪STANCE );
211 
212  if ( IsDefined( behaviorTreeEntity.node ) )
213  {
214  if ( !IsInArray( GetValidCoverPeekOuts( behaviorTreeEntity.node ), ‪COVER_MODE_OVER ) )
215  {
216  return false;
217  }
218 
219  if( ‪NODE_COVER_LEFT(behaviorTreeEntity.node)
220  || ‪NODE_COVER_RIGHT(behaviorTreeEntity.node)
221  || ‪NODE_COVER_CROUCH(behaviorTreeEntity.node) )
222  {
223  if( stance == ‪STANCE_CROUCH )
224  {
225  return true;
226  }
227  }
228  else if( ‪NODE_COVER_STAND(behaviorTreeEntity.node) )
229  {
230  if( stance == ‪STANCE_STAND )
231  return true;
232  }
233  }
234 
235  return false;
236 }
237 
238 function private ‪shouldOverAtCoverCondition( entity )
239 {
240  if ( !IsDefined( entity.node ) ||
241  !IsDefined( entity.node.type ) ||
242  !IsDefined( entity.enemy) ||
243  !IsDefined( entity.enemy.origin ) )
244  {
245  return false;
246  }
247 
248  aimTable = ( ‪AiUtility::isCoverConcealed( entity.node ) ?
250 
251  aimLimitsForCover = entity GetAimLimitsFromEntry( aimTable );
252 
253  yawToEnemyPosition = AiUtility::GetAimYawToEnemyFromNode( entity, entity.node, entity.enemy );
254 
255  legalAimYaw = ( yawToEnemyPosition >= ( aimLimitsForCover[‪AIM_RIGHT] - ‪COVER_AIM_ANGLE_EPSILON ) ) &&
256  ( yawToEnemyPosition <= ( aimLimitsForCover[‪AIM_LEFT] + ‪COVER_AIM_ANGLE_EPSILON ) );
257 
258  if ( !legalAimYaw )
259  {
260  return false;
261  }
262 
263  pitchToEnemyPosition = AiUtility::GetAimPitchToEnemyFromNode( entity, entity.node, entity.enemy );
264 
265  legalAimPitch = ( pitchToEnemyPosition >= ( aimLimitsForCover[‪AIM_UP] + ‪COVER_AIM_ANGLE_EPSILON ) ) &&
266  ( pitchToEnemyPosition <= ( aimLimitsForCover[‪AIM_DOWN] + ‪COVER_AIM_ANGLE_EPSILON ) );
267 
268  if ( !legalAimPitch )
269  {
270  return false;
271  }
272 
273  return true;
274 }
275 
276 function private ‪coverOverInitialize( behaviorTreeEntity )
277 {
278  ‪AiUtility::setCoverShootStartTime( behaviorTreeEntity );
279  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
281 }
282 
283 function private ‪coverOverTerminate( behaviorTreeEntity )
284 {
285  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
286  ‪AiUtility::clearCoverShootStartTime( behaviorTreeEntity );
287 }
288 // ------- COVER - OVER SHOOT BEHAVIOR -----------//
289 
290 
291 // ------- COVER - IDLE BEHAVIOR -----------//
292 function private ‪coverIdleInitialize( behaviorTreeEntity )
293 {
294  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
296 }
297 
298 function private ‪coverIdleUpdate( behaviorTreeEntity )
299 {
300  if( !behaviorTreeEntity ASMIsTransitionRunning() )
301  {
302  ‪AiUtility::releaseClaimNode( behaviorTreeEntity );
303  }
304 }
305 
306 function private ‪coverIdleTerminate( behaviorTreeEntity )
307 {
308  ‪AiUtility::releaseClaimNode( behaviorTreeEntity );
309  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
310 }
311 // ------- COVER - IDLE BEHAVIOR -----------//
312 
313 
314 // ------- COVER - FLANKED BEHAVIOR ---------//
315 function private ‪isFlankedByEnemyAtCover( behaviorTreeEntity )
316 {
317  return ‪canBeFlanked( behaviorTreeEntity ) &&
318  behaviorTreeEntity IsAtCoverNodeStrict() &&
319  behaviorTreeEntity IsFlankedAtCoverNode() &&
320  !behaviorTreeEntity HasPath();
321 }
322 
323 function private ‪canBeFlankedService( behaviorTreeEntity )
324 {
325  ‪AiUtility::setCanBeFlanked( behaviorTreeEntity, true );
326 }
327 
328 function private ‪coverFlankedInitialize( behaviorTreeEntity )
329 {
330  if( IsDefined( behaviorTreeEntity.enemy ) )
331  {
332  // cheat and give perfect info about the close enemy, makes it feel like AI is smart :)
333  behaviorTreeEntity GetPerfectInfo( behaviorTreeEntity.enemy );
334 
335  // Dont move for a few sec, this may trigger AI to charge melee attack
336  behaviorTreeEntity PathMode( "move delayed", false, 2 );
337  }
338 
339  ‪setCanBeFlanked( behaviorTreeEntity, false );
340 
341  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
342  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
344 }
345 
346 function private ‪coverFlankedActionTerminate( behaviorTreeEntity )
347 {
348  behaviorTreeEntity.newEnemyReaction = false;
349  ‪AiUtility::releaseClaimNode( behaviorTreeEntity );
350 }
351 // ------- COVER - FLANKED BEHAVIOR ---------//
352 
353 
354 // ------- COVER - COMMON CONDITIONS ---------//
355 #define NEAR_NODE_DIST_SQR SQR(24)
356 function ‪isAtCrouchNode( behaviorTreeEntity )
357 {
358  if ( IsDefined( behaviorTreeEntity.node ) &&
359  ( ‪NODE_EXPOSED( behaviorTreeEntity.node ) || ‪NODE_GUARD( behaviorTreeEntity.node ) || ‪NODE_PATH( behaviorTreeEntity.node ) ) )
360  {
361  if ( DistanceSquared( behaviorTreeEntity.origin, behaviorTreeEntity.node.origin ) <= ‪NEAR_NODE_DIST_SQR )
362  {
363  return !‪AiUtility::isStanceAllowedAtNode( ‪STANCE_STAND, behaviorTreeEntity.node ) &&
364  ‪AiUtility::isStanceAllowedAtNode( ‪STANCE_CROUCH, behaviorTreeEntity.node );
365  }
366  }
367 
368  return false;
369 }
370 
371 function ‪isAtCoverCondition( behaviorTreeEntity )
372 {
373  return behaviorTreeEntity IsAtCoverNodeStrict() &&
374  behaviorTreeEntity ShouldUseCoverNode() &&
375  !behaviorTreeEntity HasPath();
376 }
377 
378 function ‪isAtCoverStrictCondition( behaviorTreeEntity )
379 {
380  return behaviorTreeEntity IsAtCoverNodeStrict() &&
381  !behaviorTreeEntity HasPath();
382 }
383 
384 function ‪isAtCoverModeOver( behaviorTreeEntity )
385 {
386  coverMode = ‪Blackboard::GetBlackBoardAttribute( behaviorTreeEntity, ‪COVER_MODE );
387 
388  return coverMode == ‪COVER_OVER_MODE;
389 }
390 
391 function ‪isAtCoverModeNone( behaviorTreeEntity )
392 {
393  coverMode = ‪Blackboard::GetBlackBoardAttribute( behaviorTreeEntity, ‪COVER_MODE );
394 
395  return coverMode == ‪COVER_MODE_NONE;
396 }
397 
398 function ‪isExposedAtCoverCondition( behaviorTreeEntity )
399 {
400  return behaviorTreeEntity IsAtCoverNodeStrict() && !behaviorTreeEntity ShouldUseCoverNode();
401 }
402 
403 function ‪shouldCoverIdleOnly( behaviorTreeEntity )
404 {
405  if( behaviorTreeEntity ‪ai::get_behavior_attribute( "coverIdleOnly" ) )
406  {
407  return true;
408  }
409 
410  if( ‪IS_TRUE( behaviorTreeEntity.node.script_onlyidle ) )
411  {
412  return true;
413  }
414 
415  return false;
416 }
417 
418 function ‪isSuppressedAtCoverCondition( behaviorTreeEntity )
419 {
420  // TODO(David Young 9-6-13): Move this to code.
421  return behaviorTreeEntity.suppressionMeter > behaviorTreeEntity.suppressionThreshold;
422 }
423 
424 function ‪keepClaimedNodeAndChooseCoverDirection( behaviorTreeEntity )
425 {
426  ‪AiUtility::keepClaimNode( behaviorTreeEntity );
427  ‪chooseCoverDirection( behaviorTreeEntity );
428 }
429 
430 function ‪resetCoverParameters( behaviorTreeEntity )
431 {
432  ‪AiUtility::chooseFrontCoverDirection( behaviorTreeEntity );
433  ‪AiUtility::cleanupCoverMode( behaviorTreeEntity );
434 
435  ‪AiUtility::clearCoverShootStartTime( behaviorTreeEntity );
436 }
437 
438 function ‪chooseCoverDirection( behaviorTreeEntity, stepOut )
439 {
440  if ( !IsDefined( behaviorTreeEntity.node ) )
441  {
442  return;
443  }
444 
445  coverDirection = ‪Blackboard::GetBlackBoardAttribute( behaviorTreeEntity, ‪COVER_DIRECTION );
446 
447  ‪Blackboard::SetBlackBoardAttribute( behaviorTreeEntity, ‪PREVIOUS_COVER_DIRECTION, coverDirection );
448  ‪Blackboard::SetBlackBoardAttribute( behaviorTreeEntity, ‪COVER_DIRECTION, ‪calculateCoverDirection( behaviorTreeEntity, stepOut ) );
449 }
450 
451 function ‪calculateCoverDirection( behaviorTreeEntity, stepOut )
452 {
453  if( IsDefined( behaviorTreeEntity.treatAllCoversAsGeneric ) )
454  {
455  if ( !IsDefined( stepOut ) )
456  {
457  stepOut = false;
458  }
459 
460  coverDirection = ‪COVER_FRONT_DIRECTION;
461 
462  if ( ‪NODE_COVER_LEFT( behaviorTreeEntity.node ) )
463  {
464  if ( ‪NODE_SUPPORTS_STANCE_STAND( behaviorTreeEntity.node ) || ‪math::cointoss() || stepOut )
465  {
466  coverDirection = ‪COVER_LEFT_DIRECTION;
467  }
468  }
469  else if ( ‪NODE_COVER_RIGHT( behaviorTreeEntity.node ) )
470  {
471  if ( ‪NODE_SUPPORTS_STANCE_STAND( behaviorTreeEntity.node ) || ‪math::cointoss() || stepOut )
472  {
473  coverDirection = ‪COVER_RIGHT_DIRECTION;
474  }
475  }
476  else if ( ‪NODE_COVER_PILLAR( behaviorTreeEntity.node ) )
477  {
478  // must choose either left or right
479  if( ‪ISNODEDONTLEFT( behaviorTreeEntity.node ) )
480  {
482  }
483 
484  if( ‪ISNODEDONTRIGHT( behaviorTreeEntity.node ) )
485  {
487  }
488 
489  coverDirection = ‪COVER_LEFT_DIRECTION;
490 
491  if ( IsDefined( behaviorTreeEntity.enemy ) )
492  {
493  yawToEnemyPosition = AiUtility::GetAimYawToEnemyFromNode( behaviorTreeEntity, behaviorTreeEntity.node, behaviorTreeEntity.enemy );
494  aimLimitsForDirectionRight = behaviorTreeEntity GetAimLimitsFromEntry(‪AIM_LIMIT_TABLE_ENTRY_PILLAR_RIGHT_LEAN);
495 
496  legalRightDirectionYaw = yawToEnemyPosition >= ( aimLimitsForDirectionRight[‪AIM_RIGHT] - ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition <= 0;
497 
498  if ( legalRightDirectionYaw )
499  {
500  coverDirection = ‪COVER_RIGHT_DIRECTION;
501  }
502  }
503  }
504 
505  return coverDirection;
506  }
507  else
508  {
509  coverDirection = ‪COVER_FRONT_DIRECTION;
510 
511  if ( ‪NODE_COVER_PILLAR(behaviorTreeEntity.node) )
512  {
513  // must choose either left or right
514  if( ‪ISNODEDONTLEFT( behaviorTreeEntity.node ) )
515  {
517  }
518 
519  if( ‪ISNODEDONTRIGHT( behaviorTreeEntity.node ) )
520  {
522  }
523 
524  coverDirection = ‪COVER_LEFT_DIRECTION;
525 
526  if ( IsDefined( behaviorTreeEntity.enemy ) )
527  {
528  yawToEnemyPosition = AiUtility::GetAimYawToEnemyFromNode( behaviorTreeEntity, behaviorTreeEntity.node, behaviorTreeEntity.enemy );
529  aimLimitsForDirectionRight = behaviorTreeEntity GetAimLimitsFromEntry(‪AIM_LIMIT_TABLE_ENTRY_PILLAR_RIGHT_LEAN);
530 
531  legalRightDirectionYaw = yawToEnemyPosition >= ( aimLimitsForDirectionRight[‪AIM_RIGHT] - ‪COVER_AIM_ANGLE_EPSILON ) && yawToEnemyPosition <= 0;
532 
533  if ( legalRightDirectionYaw )
534  {
535  coverDirection = ‪COVER_RIGHT_DIRECTION;
536  }
537  }
538  }
539  }
540 
541  return coverDirection;
542 }
543 
544 function ‪clearCoverShootStartTime( behaviorTreeEntity )
545 {
546  behaviorTreeEntity.coverShootStartTime = undefined;
547 }
548 
549 function ‪setCoverShootStartTime( behaviorTreeEntity )
550 {
551  behaviorTreeEntity.coverShootStartTime = GetTime();
552 }
553 
554 function ‪canBeFlanked( behaviorTreeEntity )
555 {
556  return IsDefined( behaviorTreeEntity.canBeFlanked ) && behaviorTreeEntity.canBeFlanked;
557 }
558 
559 function ‪setCanBeFlanked( behaviorTreeEntity, ‪canBeFlanked )
560 {
561  behaviorTreeEntity.canBeFlanked = ‪canBeFlanked;
562 }
563 
564 function ‪cleanupCoverMode( behaviorTreeEntity )
565 {
566  if( ‪isAtCoverCondition( behaviorTreeEntity ) )
567  {
568  coverMode = ‪Blackboard::GetBlackBoardAttribute( behaviorTreeEntity, ‪COVER_MODE );
569 
570  ‪Blackboard::SetBlackBoardAttribute( behaviorTreeEntity, ‪PREVIOUS_COVER_MODE, coverMode );
572  }
573  else
574  {
577  }
578 }
579 
580 // ------- COVER - COMMON CONDITIONS ---------//
‪COVER_MODE
‪#define COVER_MODE
Definition: blackboard.gsh:41
‪isAtCrouchNode
‪function isAtCrouchNode(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:356
‪chooseFrontCoverDirection
‪function chooseFrontCoverDirection(behaviorTreeEntity)
‪Sets the cover direction blackboard to the front direction.
Definition: archetype_utility.gsc:2215
‪AIM_LIMIT_TABLE_ENTRY_COVER_RIGHT_LEAN
‪#define AIM_LIMIT_TABLE_ENTRY_COVER_RIGHT_LEAN
Definition: blackboard.gsh:265
‪NODE_PATH
‪#define NODE_PATH(_node)
Definition: utility.gsh:13
‪cleanupCoverMode
‪function cleanupCoverMode(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:564
‪refillAmmo
‪function refillAmmo(behaviorTreeEntity)
Definition: archetype_utility.gsc:1759
‪BT_REGISTER_API
‪#define BT_REGISTER_API(name, function)
Definition: behavior.gsh:1
‪NODE_COVER_STAND
‪#define NODE_COVER_STAND(_node)
Definition: utility.gsh:9
‪shouldOverAtCoverCondition
‪function private shouldOverAtCoverCondition(entity)
Definition: archetype_cover_utility.gsc:238
‪coverFlankedActionTerminate
‪function private coverFlankedActionTerminate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:346
‪supportsLeanCoverCondition
‪function private supportsLeanCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:107
‪AIM_LIMIT_TABLE_ENTRY_COVER_CONCEALED_OVER
‪#define AIM_LIMIT_TABLE_ENTRY_COVER_CONCEALED_OVER
Definition: blackboard.gsh:267
‪canBeFlankedService
‪function private canBeFlankedService(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:323
‪AIM_LIMIT_TABLE_ENTRY_COVER_LEFT_LEAN
‪#define AIM_LIMIT_TABLE_ENTRY_COVER_LEFT_LEAN
Definition: blackboard.gsh:264
‪NODE_COVER_PILLAR
‪#define NODE_COVER_PILLAR(_node)
Definition: utility.gsh:8
‪NODE_COVER_LEFT
‪#define NODE_COVER_LEFT(_node)
Definition: utility.gsh:6
‪cointoss
‪function cointoss()
Definition: math_shared.csc:171
‪isAtCoverStrictCondition
‪function isAtCoverStrictCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:378
‪coverFlankedInitialize
‪function private coverFlankedInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:328
‪isStanceAllowedAtNode
‪function isStanceAllowedAtNode(stance, node)
Definition: archetype_utility.gsc:2094
‪resetCoverParameters
‪function resetCoverParameters(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:430
‪coverOverInitialize
‪function private coverOverInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:276
‪COVER_MODE_NONE
‪#define COVER_MODE_NONE
Definition: blackboard.gsh:108
‪clearCoverShootStartTime
‪function clearCoverShootStartTime(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:544
‪coverPeekInitialize
‪function private coverPeekInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:91
‪isAtCoverCondition
‪function isAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:371
‪SetBlackBoardAttribute
‪function SetBlackBoardAttribute(entity, attributeName, attributeValue)
Definition: blackboard.gsc:56
‪coverLeanInitialize
‪function private coverLeanInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:191
‪calculateCoverDirection
‪function calculateCoverDirection(behaviorTreeEntity, stepOut)
Definition: archetype_cover_utility.gsc:451
‪setCanBeFlanked
‪function setCanBeFlanked(behaviorTreeEntity, canBeFlanked)
Definition: archetype_cover_utility.gsc:559
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪GetBlackBoardAttribute
‪function GetBlackBoardAttribute(entity, attributeName)
Definition: blackboard.gsc:32
‪keepClaimedNodeAndChooseCoverDirection
‪function keepClaimedNodeAndChooseCoverDirection(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:424
‪canBeFlanked
‪function canBeFlanked(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:554
‪COVER_AIM_ANGLE_EPSILON
‪#define COVER_AIM_ANGLE_EPSILON
Definition: archetype_cover_utility.gsc:18
‪STANCE
‪#define STANCE
Definition: blackboard.gsh:36
‪isAtCoverModeOver
‪function isAtCoverModeOver(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:384
‪STANCE_STAND
‪#define STANCE_STAND
Definition: blackboard.gsh:273
‪DESIRED_STANCE
‪#define DESIRED_STANCE
Definition: blackboard.gsh:18
‪COVER_MODE_OVER
‪#define COVER_MODE_OVER
Definition: behavior.gsh:74
‪coverReloadInitialize
‪function private coverReloadInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:69
‪NODE_EXPOSED
‪#define NODE_EXPOSED(_node)
Definition: utility.gsh:11
‪NODE_COVER_RIGHT
‪#define NODE_COVER_RIGHT(_node)
Definition: utility.gsh:7
‪AIM_LEFT
‪#define AIM_LEFT
Definition: blackboard.gsh:257
‪ISNODEDONTRIGHT
‪#define ISNODEDONTRIGHT(__node)
Definition: utility.gsh:2
‪COVER_LEAN_MODE
‪#define COVER_LEAN_MODE
Definition: blackboard.gsh:109
‪isExposedAtCoverCondition
‪function isExposedAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:398
‪PREVIOUS_COVER_DIRECTION
‪#define PREVIOUS_COVER_DIRECTION
Definition: blackboard.gsh:47
‪shouldLeanAtCoverCondition
‪function private shouldLeanAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:127
‪AIM_LIMIT_TABLE_ENTRY_PILLAR_RIGHT_LEAN
‪#define AIM_LIMIT_TABLE_ENTRY_PILLAR_RIGHT_LEAN
Definition: blackboard.gsh:270
‪coverIdleUpdate
‪function private coverIdleUpdate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:298
‪COVER_FRONT_DIRECTION
‪#define COVER_FRONT_DIRECTION
Definition: blackboard.gsh:50
‪ISNODEDONTLEFT
‪#define ISNODEDONTLEFT(__node)
Definition: utility.gsh:3
‪releaseClaimNode
‪function releaseClaimNode(behaviorTreeEntity)
Definition: archetype_utility.gsc:2188
‪supportsPeekCoverCondition
‪function private supportsPeekCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:86
‪AIM_DOWN
‪#define AIM_DOWN
Definition: blackboard.gsh:259
‪coverOverTerminate
‪function private coverOverTerminate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:283
‪continueLeaningAtCoverCondition
‪function private continueLeaningAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:180
‪setCoverShootStartTime
‪function setCoverShootStartTime(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:549
‪keepClaimNode
‪function keepClaimNode(behaviorTreeEntity)
Definition: archetype_utility.gsc:2181
‪isSuppressedAtCoverCondition
‪function isSuppressedAtCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:418
‪NODE_SUPPORTS_STANCE_STAND
‪#define NODE_SUPPORTS_STANCE_STAND(__node)
Definition: utility.gsh:20
‪AIM_UP
‪#define AIM_UP
Definition: blackboard.gsh:258
‪chooseCoverDirection
‪function chooseCoverDirection(behaviorTreeEntity, stepOut)
Definition: archetype_cover_utility.gsc:438
‪COVER_RIGHT_DIRECTION
‪#define COVER_RIGHT_DIRECTION
Definition: blackboard.gsh:52
‪AIM_LIMIT_TABLE_ENTRY_COVER_OVER
‪#define AIM_LIMIT_TABLE_ENTRY_COVER_OVER
Definition: blackboard.gsh:266
‪PREVIOUS_COVER_MODE
‪#define PREVIOUS_COVER_MODE
Definition: blackboard.gsh:42
‪COVER_DIRECTION
‪#define COVER_DIRECTION
Definition: blackboard.gsh:46
‪NODE_GUARD
‪#define NODE_GUARD(_node)
Definition: utility.gsh:12
‪coverPeekTerminate
‪function private coverPeekTerminate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:98
‪coverIdleInitialize
‪function private coverIdleInitialize(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:292
‪isFlankedByEnemyAtCover
‪function private isFlankedByEnemyAtCover(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:315
‪COVER_ALERT_MODE
‪#define COVER_ALERT_MODE
Definition: blackboard.gsh:113
‪isCoverConcealed
‪function isCoverConcealed(node)
Definition: archetype_utility.gsc:1928
‪AIM_LIMIT_TABLE_ENTRY_COVER
‪#define AIM_LIMIT_TABLE_ENTRY_COVER
Definition: blackboard.gsh:262
‪COVER_OVER_MODE
‪#define COVER_OVER_MODE
Definition: blackboard.gsh:111
‪STANCE_CROUCH
‪#define STANCE_CROUCH
Definition: blackboard.gsh:274
‪AIM_RIGHT
‪#define AIM_RIGHT
Definition: blackboard.gsh:256
‪shouldCoverIdleOnly
‪function shouldCoverIdleOnly(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:403
‪refillAmmoAndCleanupCoverMode
‪function refillAmmoAndCleanupCoverMode(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:75
‪get_behavior_attribute
‪function get_behavior_attribute(attribute)
Definition: ai_shared.gsc:184
‪isAtCoverModeNone
‪function isAtCoverModeNone(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:391
‪RegisterBehaviorScriptFunctions
‪function autoexec RegisterBehaviorScriptFunctions()
Definition: archetype_cover_utility.gsc:20
‪COVER_LEFT_DIRECTION
‪#define COVER_LEFT_DIRECTION
Definition: blackboard.gsh:51
‪coverIdleTerminate
‪function private coverIdleTerminate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:306
‪supportsOverCoverCondition
‪function private supportsOverCoverCondition(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:208
‪coverLeanTerminate
‪function private coverLeanTerminate(behaviorTreeEntity)
Definition: archetype_cover_utility.gsc:199
‪NODE_COVER_CROUCH
‪#define NODE_COVER_CROUCH(_node)
Definition: utility.gsh:10
‪NEAR_NODE_DIST_SQR
‪#define NEAR_NODE_DIST_SQR
Definition: archetype_cover_utility.gsc:355