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

Function NPC_CheckAttackHold

code/game/NPC.cpp:1228–1257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226
1227float NPC_MaxDistSquaredForWeapon (void);
1228void NPC_CheckAttackHold(void)
1229{
1230 vec3_t vec;
1231
1232 // If they don't have an enemy they shouldn't hold their attack anim.
1233 if ( !NPC->enemy )
1234 {
1235 NPCInfo->attackHoldTime = 0;
1236 return;
1237 }
1238
1239 //FIXME: need to tie this into AI somehow?
1240 VectorSubtract(NPC->enemy->currentOrigin, NPC->currentOrigin, vec);
1241 if( VectorLengthSquared(vec) > NPC_MaxDistSquaredForWeapon() )
1242 {
1243 NPCInfo->attackHoldTime = 0;
1244 }
1245 else if( NPCInfo->attackHoldTime && NPCInfo->attackHoldTime > level.time )
1246 {
1247 ucmd.buttons |= BUTTON_ATTACK;
1248 }
1249 else if ( ( NPCInfo->attackHold ) && ( ucmd.buttons & BUTTON_ATTACK ) )
1250 {
1251 NPCInfo->attackHoldTime = level.time + NPCInfo->attackHold;
1252 }
1253 else
1254 {
1255 NPCInfo->attackHoldTime = 0;
1256 }
1257}
1258
1259/*
1260void NPC_KeepCurrentFacing(void)

Callers 1

NPC_ExecuteBStateFunction · 0.70

Calls 3

VectorSubtractFunction · 0.85
VectorLengthSquaredFunction · 0.85

Tested by

no test coverage detected