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

Function RT_CheckJump

code/game/AI_Jedi.cpp:5682–5794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5680
5681extern void RT_JetPackEffect( int duration );
5682void RT_CheckJump( void )
5683{
5684 int jumpEntNum = ENTITYNUM_NONE;
5685 vec3_t jumpPos = {0,0,0};
5686
5687 if ( !NPCInfo->goalEntity )
5688 {
5689 if ( NPC->enemy )
5690 {
5691 //FIXME: debounce this?
5692 if ( TIMER_Done( NPC, "roamTime" )
5693 && Q_irand( 0, 9 ) )
5694 {//okay to try to find another spot to be
5695 int cpFlags = (CP_CLEAR|CP_HAS_ROUTE);//must have a clear shot at enemy
5696 float enemyDistSq = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin );
5697 //FIXME: base these ranges on weapon
5698 if ( enemyDistSq > (2048*2048) )
5699 {//hmm, close in?
5700 cpFlags |= CP_APPROACH_ENEMY;
5701 }
5702 else if ( enemyDistSq < (256*256) )
5703 {//back off!
5704 cpFlags |= CP_RETREAT;
5705 }
5706 int sendFlags = cpFlags;
5707 int cp = NPC_FindCombatPointRetry( NPC->currentOrigin,
5708 NPC->currentOrigin,
5709 NPC->currentOrigin,
5710 &sendFlags,
5711 256,
5712 NPCInfo->lastFailedCombatPoint );
5713 if ( cp == -1 )
5714 {//try again, no route needed since we can rocket-jump to it!
5715 cpFlags &= ~CP_HAS_ROUTE;
5716 cp = NPC_FindCombatPointRetry( NPC->currentOrigin,
5717 NPC->currentOrigin,
5718 NPC->currentOrigin,
5719 &cpFlags,
5720 256,
5721 NPCInfo->lastFailedCombatPoint );
5722 }
5723 if ( cp != -1 )
5724 {
5725 NPC_SetMoveGoal( NPC, level.combatPoints[cp].origin, 8, qtrue, cp );
5726 }
5727 else
5728 {//FIXME: okay to do this if have good close-range weapon...
5729 //FIXME: should we really try to go right for him?!
5730 //NPCInfo->goalEntity = NPC->enemy;
5731 jumpEntNum = NPC->enemy->s.number;
5732 VectorCopy( NPC->enemy->currentOrigin, jumpPos );
5733 //return;
5734 }
5735 TIMER_Set( NPC, "roamTime", Q_irand( 3000, 12000 ) );
5736 }
5737 else
5738 {//FIXME: okay to do this if have good close-range weapon...
5739 //FIXME: should we really try to go right for him?!

Callers 1

NPC_BSRT_DefaultFunction · 0.85

Calls 15

Q_irandFunction · 0.85
NPC_FindCombatPointRetryFunction · 0.85
VectorCopyFunction · 0.85
VectorSubtractFunction · 0.85
VectorLengthSquaredFunction · 0.85
NPC_TryJumpFunction · 0.85
RT_JetPackEffectFunction · 0.85
TIMER_DoneFunction · 0.70
NPC_SetMoveGoalFunction · 0.70
TIMER_SetFunction · 0.70
Jedi_ClearPathToSpotFunction · 0.70

Tested by

no test coverage detected