AI_Civilian.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // leave this line at the top of all AI_xxxx.cpp files for PCH reasons...
  2. #include "g_headers.h"
  3. #include "Q3_Interface.h"
  4. extern qboolean NPC_CheckSurrender( void );
  5. extern void NPC_BehaviorSet_Default( int bState );
  6. void NPC_BSCivilian_Default( int bState )
  7. {
  8. if ( NPC->enemy
  9. && NPC->s.weapon == WP_NONE
  10. && NPC_CheckSurrender() )
  11. {//surrendering, do nothing
  12. }
  13. else if ( NPC->enemy
  14. && NPC->s.weapon == WP_NONE
  15. && bState != BS_HUNT_AND_KILL
  16. && !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) )
  17. {//if in battle and have no weapon, run away, fixme: when in BS_HUNT_AND_KILL, they just stand there
  18. if ( !NPCInfo->goalEntity
  19. || bState != BS_FLEE //not fleeing
  20. || ( NPC_BSFlee()//have reached our flee goal
  21. && NPC->enemy//still have enemy (NPC_BSFlee checks enemy and can clear it)
  22. && DistanceSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ) < 16384 )//enemy within 128
  23. )
  24. {//run away!
  25. NPC_StartFlee( NPC->enemy, NPC->enemy->currentOrigin, AEL_DANGER_GREAT, 5000, 10000 );
  26. }
  27. }
  28. else
  29. {//not surrendering
  30. //FIXME: if unarmed and a jawa/ugnuaght, constantly look for enemies/players to run away from?
  31. //FIXME: if we have a weapon and an enemy, set out playerTeam to the opposite of our enemy..???
  32. NPC_BehaviorSet_Default(bState);
  33. }
  34. if ( !VectorCompare( NPC->client->ps.moveDir, vec3_origin ) )
  35. {//moving
  36. if ( NPC->client->ps.legsAnim == BOTH_COWER1 )
  37. {//stop cowering anim on legs
  38. NPC->client->ps.legsAnimTimer = 0;
  39. }
  40. }
  41. }