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

Function NPC_Howler_Move

code/game/AI_Howler.cpp:86–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86static qboolean NPC_Howler_Move( int randomJumpChance = 0 )
87{
88 if ( !TIMER_Done( NPC, "standing" ) )
89 {//standing around
90 return qfalse;
91 }
92 if ( NPC->client->ps.groundEntityNum == ENTITYNUM_NONE )
93 {//in air, don't do anything
94 return qfalse;
95 }
96 if ( (!NPC->enemy&&TIMER_Done( NPC, "running" )) || !TIMER_Done( NPC, "walking" ) )
97 {
98 ucmd.buttons |= BUTTON_WALKING;
99 }
100 if ( (!randomJumpChance||Q_irand( 0, randomJumpChance ))
101 && NPC_MoveToGoal( qtrue ) )
102 {
103 if ( VectorCompare( NPC->client->ps.moveDir, vec3_origin )
104 || !NPC->client->ps.speed )
105 {//uh.... wtf? Got there?
106 if ( NPCInfo->goalEntity )
107 {
108 NPC_FaceEntity( NPCInfo->goalEntity, qfalse );
109 }
110 else
111 {
112 NPC_UpdateAngles( qfalse, qtrue );
113 }
114 return qtrue;
115 }
116 //TEMP: don't want to strafe
117 VectorClear( NPC->client->ps.moveDir );
118 ucmd.rightmove = 0.0f;
119// Com_Printf( "Howler moving %d\n",ucmd.forwardmove );
120 //if backing up, go slow...
121 if ( ucmd.forwardmove < 0.0f )
122 {
123 ucmd.buttons |= BUTTON_WALKING;
124 //if ( NPC->client->ps.speed > NPCInfo->stats.walkSpeed )
125 {//don't walk faster than I'm allowed to
126 NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
127 }
128 }
129 else
130 {
131 if ( (ucmd.buttons&BUTTON_WALKING) )
132 {
133 NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
134 }
135 else
136 {
137 NPC->client->ps.speed = NPCInfo->stats.runSpeed;
138 }
139 }
140 NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw = NPCInfo->lastPathAngles[YAW];
141 NPC_UpdateAngles( qfalse, qtrue );
142 }
143 else if ( NPCInfo->goalEntity )

Callers 3

Howler_PatrolFunction · 0.85
Howler_MoveFunction · 0.85
Howler_CombatFunction · 0.85

Calls 8

Q_irandFunction · 0.85
VectorCompareFunction · 0.85
VectorClearFunction · 0.85
NPC_TryJumpFunction · 0.85
TIMER_DoneFunction · 0.70
NPC_MoveToGoalFunction · 0.70
NPC_FaceEntityFunction · 0.70
NPC_UpdateAnglesFunction · 0.70

Tested by

no test coverage detected