MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Howler_Combat

Function Howler_Combat

code/game/AI_Howler.cpp:447–522  ·  view source on GitHub ↗

----------------------------------

Source from the content-addressed store, hash-verified

445
446//----------------------------------
447static void Howler_Combat( void )
448{
449 qboolean faced = qfalse;
450 float distance;
451 qboolean advance = qfalse;
452 if ( NPC->client->ps.groundEntityNum == ENTITYNUM_NONE )
453 {//not on the ground
454 if ( NPC->client->ps.legsAnim == BOTH_JUMP1
455 || NPC->client->ps.legsAnim == BOTH_INAIR1 )
456 {//flying through the air with the greatest of ease, etc
457 Howler_TryDamage( 10, qfalse, qfalse );
458 }
459 }
460 else
461 {//not in air, see if we should attack or advance
462 // If we cannot see our target or we have somewhere to go, then do that
463 if ( !NPC_ClearLOS( NPC->enemy ) )//|| UpdateGoal( ))
464 {
465 NPCInfo->goalEntity = NPC->enemy;
466 NPCInfo->goalRadius = MAX_DISTANCE; // just get us within combat range
467
468 if ( NPCInfo->localState == LSTATE_BERZERK )
469 {
470 NPC_Howler_Move( 3 );
471 }
472 else
473 {
474 NPC_Howler_Move( 10 );
475 }
476 NPC_UpdateAngles( qfalse, qtrue );
477 return;
478 }
479
480 distance = DistanceHorizontal( NPC->currentOrigin, NPC->enemy->currentOrigin );
481
482 if ( NPC->enemy && NPC->enemy->client && PM_InKnockDown( &NPC->enemy->client->ps ) )
483 {//get really close to knocked down enemies
484 advance = (qboolean)( distance > MIN_DISTANCE ? qtrue : qfalse );
485 }
486 else
487 {
488 advance = (qboolean)( distance > MAX_DISTANCE ? qtrue : qfalse );//MIN_DISTANCE
489 }
490
491 if (( advance || NPCInfo->localState == LSTATE_WAITING ) && TIMER_Done( NPC, "attacking" )) // waiting monsters can't attack
492 {
493 if ( TIMER_Done2( NPC, "takingPain", qtrue ))
494 {
495 NPCInfo->localState = LSTATE_CLEAR;
496 }
497 else if ( TIMER_Done( NPC, "standing" ) )
498 {
499 faced = Howler_Move( qtrue );
500 }
501 }
502 else
503 {
504 Howler_Attack( distance );

Callers 1

NPC_BSHowler_DefaultFunction · 0.70

Calls 11

NPC_Howler_MoveFunction · 0.85
DistanceHorizontalFunction · 0.85
Howler_TryDamageFunction · 0.70
NPC_ClearLOSFunction · 0.70
NPC_UpdateAnglesFunction · 0.70
PM_InKnockDownFunction · 0.70
TIMER_DoneFunction · 0.70
TIMER_Done2Function · 0.70
Howler_MoveFunction · 0.70
Howler_AttackFunction · 0.70
NPC_FaceEnemyFunction · 0.70

Tested by

no test coverage detected