| 1226 | |
| 1227 | float NPC_MaxDistSquaredForWeapon (void); |
| 1228 | void 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 | /* |
| 1260 | void NPC_KeepCurrentFacing(void) |
no test coverage detected