codemp/game/NPC.c File Reference

#include "b_local.h"
#include "anims.h"
#include "say.h"
#include "../icarus/Q3_Interface.h"

Go to the source code of this file.

Defines

#define REMOVE_DISTANCE   128
#define REMOVE_DISTANCE_SQR   (REMOVE_DISTANCE * REMOVE_DISTANCE)

Functions

void G_SoundOnEnt (gentity_t *ent, soundChannel_t channel, const char *soundPath)
void PM_SetTorsoAnimTimer (gentity_t *ent, int *torsoAnimTimer, int time)
void PM_SetLegsAnimTimer (gentity_t *ent, int *legsAnimTimer, int time)
void NPC_BSNoClip (void)
void G_AddVoiceEvent (gentity_t *self, int event, int speakDebounceTime)
void NPC_ApplyRoff (void)
void NPC_TempLookTarget (gentity_t *self, int lookEntNum, int minLookTime, int maxLookTime)
void NPC_CheckPlayerAim (void)
void NPC_CheckAllClear (void)
qboolean NPC_CheckLookTarget (gentity_t *self)
void NPC_SetLookTarget (gentity_t *self, int entNum, int clearTime)
void Mark1_dying (gentity_t *self)
void NPC_BSCinematic (void)
int GetTime (int lastTime)
void NPC_BSGM_Default (void)
void NPC_CheckCharmed (void)
qboolean Boba_Flying (gentity_t *self)
void NPC_SetAnim (gentity_t *ent, int type, int anim, int priority)
void pitch_roll_for_slope (gentity_t *forwhom, vec3_t pass_slope)
void GM_Dying (gentity_t *self)
void CorpsePhysics (gentity_t *self)
void NPC_RemoveBody (gentity_t *self)
int BodyRemovalPadTime (gentity_t *ent)
void SetNPCGlobals (gentity_t *ent)
void SaveNPCGlobals (void)
void RestoreNPCGlobals (void)
void ClearNPCGlobals (void)
void G_Cube (vec3_t mins, vec3_t maxs, vec3_t color, float alpha)
void G_Line (vec3_t start, vec3_t end, vec3_t color, float alpha)
void G_Cylinder (vec3_t start, vec3_t end, float radius, vec3_t color)
void NPC_ShowDebugInfo (void)
void NPC_ApplyScriptFlags (void)
void Q3_DebugPrint (int level, const char *format,...)
void NPC_HandleAIFlags (void)
void NPC_AvoidWallsAndCliffs (void)
void NPC_CheckAttackScript (void)
float NPC_MaxDistSquaredForWeapon (void)
void NPC_CheckAttackHold (void)
void NPC_KeepCurrentFacing (void)
void NPC_BehaviorSet_Charmed (int bState)
void NPC_BehaviorSet_Default (int bState)
void NPC_BehaviorSet_Interrogator (int bState)
void NPC_BSImperialProbe_Attack (void)
void NPC_BSImperialProbe_Patrol (void)
void NPC_BSImperialProbe_Wait (void)
void NPC_BehaviorSet_ImperialProbe (int bState)
void NPC_BSSeeker_Default (void)
void NPC_BehaviorSet_Seeker (int bState)
void NPC_BSRemote_Default (void)
void NPC_BehaviorSet_Remote (int bState)
void NPC_BSSentry_Default (void)
void NPC_BehaviorSet_Sentry (int bState)
void NPC_BehaviorSet_Grenadier (int bState)
void NPC_BehaviorSet_Sniper (int bState)
void NPC_BehaviorSet_Stormtrooper (int bState)
void NPC_BehaviorSet_Jedi (int bState)
void NPC_BehaviorSet_Droid (int bState)
void NPC_BehaviorSet_Mark1 (int bState)
void NPC_BehaviorSet_Mark2 (int bState)
void NPC_BehaviorSet_ATST (int bState)
void NPC_BehaviorSet_MineMonster (int bState)
void NPC_BehaviorSet_Howler (int bState)
void NPC_BehaviorSet_Rancor (int bState)
void NPC_BSEmplaced (void)
qboolean NPC_CheckSurrender (void)
void Boba_FlyStop (gentity_t *self)
void NPC_BSWampa_Default (void)
void NPC_RunBehavior (int team, int bState)
void NPC_ExecuteBState (gentity_t *self)
void NPC_CheckInSolid (void)
void G_DroidSounds (gentity_t *self)
void NPC_Think (gentity_t *self)
void NPC_InitAI (void)
void NPC_InitGame (void)

Variables

vec3_t playerMins
vec3_t playerMaxs
vmCvar_t g_saberRealisticCombat
gentity_tNPC
gNPC_tNPCInfo
gclient_tclient
usercmd_t ucmd
visibility_t enemyVisibility
int eventClearTime
gentity_t_saved_NPC
gNPC_t_saved_NPCInfo
gclient_t_saved_client
usercmd_t _saved_ucmd
qboolean showBBoxes
vec3_t NPCDEBUG_RED = {1.0, 0.0, 0.0}
vec3_t NPCDEBUG_GREEN = {0.0, 1.0, 0.0}
vec3_t NPCDEBUG_BLUE = {0.0, 0.0, 1.0}
vec3_t NPCDEBUG_LIGHT_BLUE = {0.3f, 0.7f, 1.0}


Define Documentation

#define REMOVE_DISTANCE   128
 

Definition at line 112 of file NPC.c.

#define REMOVE_DISTANCE_SQR   (REMOVE_DISTANCE * REMOVE_DISTANCE)
 

Definition at line 113 of file NPC.c.


Function Documentation

qboolean Boba_Flying gentity_t self  ) 
 

Definition at line 386 of file NPC_AI_Jedi.c.

References gentity_s::client, EF2_FLYING, playerState_s::eFlags2, gentity_t, gclient_s::ps, and qboolean.

Referenced by NPC_RunBehavior().

00387 {
00388         return ((qboolean)(self->client->ps.eFlags2&EF2_FLYING));//moveType==MT_FLYSWIM));
00389 }

void Boba_FlyStop gentity_t self  ) 
 

Definition at line 367 of file NPC_AI_Jedi.c.

References gNPC_t::aiFlags, gentity_s::client, gentity_s::count, EF2_FLYING, playerState_s::eFlags2, g_gravity, gentity_t, playerState_s::gravity, gclient_s::jetPackTime, entityState_s::loopSound, gentity_s::NPC, NPCAI_CUSTOM_GRAVITY, gclient_s::ps, Q_irand(), gentity_s::s, TIMER_Set(), and vmCvar_t::value.

Referenced by player_die().

00368 {
00369         self->client->ps.gravity = g_gravity.value;
00370         if ( self->NPC )
00371         {
00372                 self->NPC->aiFlags &= ~NPCAI_CUSTOM_GRAVITY;
00373         }
00374         self->client->ps.eFlags2 &= ~EF2_FLYING;
00375         self->client->jetPackTime = 0;
00376         //stop jet loop sound
00377         self->s.loopSound = 0;
00378         if ( self->NPC )
00379         {
00380                 self->count = 0; // SEEKER shot ammo count
00381                 TIMER_Set( self, "jetRecharge", Q_irand( 1000, 5000 ) );
00382                 TIMER_Set( self, "jumpChaseDebounce", Q_irand( 500, 2000 ) );
00383         }
00384 }

int BodyRemovalPadTime gentity_t ent  ) 
 

Definition at line 233 of file NPC.c.

References CLASS_GONK, CLASS_INTERROGATOR, CLASS_MARK1, CLASS_MARK2, CLASS_MOUSE, CLASS_PROBE, CLASS_R2D2, CLASS_R5D2, CLASS_REMOTE, CLASS_SEEKER, CLASS_SENTRY, gentity_s::client, gentity_t, and gclient_s::NPC_class.

00234 {
00235         int     time;
00236 
00237         if ( !ent || !ent->client )
00238                 return 0;
00239 /*
00240         switch ( ent->client->playerTeam )
00241         {
00242         case NPCTEAM_KLINGON:   // no effect, we just remove them when the player isn't looking
00243         case NPCTEAM_SCAVENGERS:
00244         case NPCTEAM_HIROGEN:
00245         case NPCTEAM_MALON:
00246         case NPCTEAM_IMPERIAL:
00247         case NPCTEAM_STARFLEET:
00248                 time = 10000; // 15 secs.
00249                 break;
00250 
00251         case NPCTEAM_BORG:
00252                 time = 2000;
00253                 break;
00254 
00255         case NPCTEAM_STASIS:
00256                 return qtrue;
00257                 break;
00258 
00259         case NPCTEAM_FORGE:
00260                 time = 1000;
00261                 break;
00262 
00263         case NPCTEAM_BOTS:
00264 //              if (!Q_stricmp( ent->NPC_type, "mouse" ))
00265 //              {
00266                         time = 0;
00267 //              }
00268 //              else
00269 //              {
00270 //                      time = 10000;
00271 //              }
00272                 break;
00273 
00274         case NPCTEAM_8472:
00275                 time = 2000;
00276                 break;
00277 
00278         default:
00279                 // never go away
00280                 time = Q3_INFINITE;
00281                 break;
00282         }
00283 */
00284         // team no longer indicates species/race, so in this case we'd use NPC_class, but
00285         switch( ent->client->NPC_class )
00286         {
00287         case CLASS_MOUSE:
00288         case CLASS_GONK:
00289         case CLASS_R2D2:
00290         case CLASS_R5D2:
00291         //case CLASS_PROTOCOL:
00292         case CLASS_MARK1:
00293         case CLASS_MARK2:
00294         case CLASS_PROBE:
00295         case CLASS_SEEKER:
00296         case CLASS_REMOTE:
00297         case CLASS_SENTRY:
00298         case CLASS_INTERROGATOR:
00299                 time = 0;
00300                 break;
00301         default:
00302                 // never go away
00303         //      time = Q3_INFINITE;
00304                 // for now I'm making default 10000
00305                 time = 10000;
00306                 break;
00307 
00308         }
00309         
00310 
00311         return time;
00312 }

void ClearNPCGlobals void   ) 
 

Definition at line 647 of file NPC.c.

References client, NPC, NPCInfo, and NULL.

Referenced by G_RunFrame().

00648 {
00649         NPC = NULL;
00650         NPCInfo = NULL;
00651         client = NULL;
00652 }

void CorpsePhysics gentity_t self  ) 
 

Definition at line 46 of file NPC.c.

References AddSightEvent(), AEL_DISCOVERED, ALERT_CLEAR_TIME, CLASS_GALAKMECH, CLASS_INTERROGATOR, CLASS_MARK1, CLASS_PROTOCOL, gentity_s::client, ClientThink(), entityShared_t::contents, CONTENTS_CORPSE, CONTENTS_TRIGGER, entityShared_t::currentOrigin, EF_DISINTEGRATION, EF_NODRAW, playerState_s::eFlags, entityState_s::eFlags, gentity_s::enemy, ENTITYNUM_NONE, eventClearTime, g_dismember, g_saberRealisticCombat, gentity_t, GM_Dying(), playerState_s::groundEntityNum, vmCvar_t::integer, level, memset(), gentity_s::message, gclient_s::NPC_class, NULL, entityState_s::number, pitch_roll_for_slope(), gclient_s::ps, gentity_s::r, gclient_s::respawnTime, gentity_s::s, entityState_s::time, level_locals_t::time, and ucmd.

Referenced by NPC_RemoveBody().

00047 {
00048         // run the bot through the server like it was a real client
00049         memset( &ucmd, 0, sizeof( ucmd ) );
00050         ClientThink( self->s.number, &ucmd );
00051         //VectorCopy( self->s.origin, self->s.origin2 );
00052         //rww - don't get why this is happening.
00053         
00054         if ( self->client->NPC_class == CLASS_GALAKMECH )
00055         {
00056                 GM_Dying( self );
00057         }
00058         //FIXME: match my pitch and roll for the slope of my groundPlane
00059         if ( self->client->ps.groundEntityNum != ENTITYNUM_NONE && !(self->s.eFlags&EF_DISINTEGRATION) )
00060         {//on the ground
00061                 //FIXME: check 4 corners
00062                 pitch_roll_for_slope( self, NULL );
00063         }
00064 
00065         if ( eventClearTime == level.time + ALERT_CLEAR_TIME )
00066         {//events were just cleared out so add me again
00067                 if ( !(self->client->ps.eFlags&EF_NODRAW) )
00068                 {
00069                         AddSightEvent( self->enemy, self->r.currentOrigin, 384, AEL_DISCOVERED, 0.0f );
00070                 }
00071         }
00072 
00073         if ( level.time - self->s.time > 3000 )
00074         {//been dead for 3 seconds
00075                 if ( g_dismember.integer < 11381138 && !g_saberRealisticCombat.integer )
00076                 {//can't be dismembered once dead
00077                         if ( self->client->NPC_class != CLASS_PROTOCOL )
00078                         {
00079                         //      self->client->dismembered = qtrue;
00080                         }
00081                 }
00082         }
00083 
00084         //if ( level.time - self->s.time > 500 )
00085         if (self->client->respawnTime < (level.time+500))
00086         {//don't turn "nonsolid" until about 1 second after actual death
00087 
00088                 if (self->client->ps.eFlags & EF_DISINTEGRATION)
00089                 {
00090                         self->r.contents = 0;
00091                 }
00092                 else if ((self->client->NPC_class != CLASS_MARK1) && (self->client->NPC_class != CLASS_INTERROGATOR))   // The Mark1 & Interrogator stays solid.
00093                 {
00094                         self->r.contents = CONTENTS_CORPSE;
00095                         //self->r.maxs[2] = -8;
00096                 }
00097 
00098                 if ( self->message )
00099                 {
00100                         self->r.contents |= CONTENTS_TRIGGER;
00101                 }
00102         }
00103 }

void G_AddVoiceEvent gentity_t self,
int  event,
int  speakDebounceTime
 

Definition at line 23 of file NPC_sounds.c.

00024 {
00025         if ( !self->NPC )
00026         {
00027                 return;
00028         }
00029 
00030         if ( !self->client || self->client->ps.pm_type >= PM_DEAD )
00031         {
00032                 return;
00033         }
00034 
00035         if ( self->NPC->blockedSpeechDebounceTime > level.time )
00036         {
00037                 return;
00038         }
00039 
00040         if ( trap_ICARUS_TaskIDPending( self, TID_CHAN_VOICE ) )
00041         {
00042                 return;
00043         }
00044 
00045         
00046         if ( (self->NPC->scriptFlags&SCF_NO_COMBAT_TALK) && ( (event >= EV_ANGER1 && event <= EV_VICTORY3) || (event >= EV_CHASE1 && event <= EV_SUSPICIOUS5) ) )//(event < EV_FF_1A || event > EV_FF_3C) && (event < EV_RESPOND1 || event > EV_MISSION3) )
00047         {
00048                 return;
00049         }
00050         
00051         if ( (self->NPC->scriptFlags&SCF_NO_ALERT_TALK) && (event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5) )
00052         {
00053                 return;
00054         }
00055         //FIXME: Also needs to check for teammates. Don't want
00056         //              everyone babbling at once
00057 
00058         //NOTE: was losing too many speech events, so we do it directly now, screw networking!
00059         //G_AddEvent( self, event, 0 );
00060         G_SpeechEvent( self, event );
00061 
00062         //won't speak again for 5 seconds (unless otherwise specified)
00063         self->NPC->blockedSpeechDebounceTime = level.time + ((speakDebounceTime==0) ? 5000 : speakDebounceTime);
00064 }

void G_Cube vec3_t  mins,
vec3_t  maxs,
vec3_t  color,
float  alpha
 

Definition at line 16 of file g_nav.c.

00017 {
00018 
00019 }

void G_Cylinder vec3_t  start,
vec3_t  end,
float  radius,
vec3_t  color
 

void G_DroidSounds gentity_t self  ) 
 

Definition at line 1787 of file NPC.c.

References CHAN_AUTO, CLASS_GONK, CLASS_MOUSE, CLASS_PROBE, CLASS_R2D2, CLASS_R5D2, gentity_s::client, G_SoundOnEnt(), gentity_t, gclient_s::NPC_class, Q_irand(), TIMER_Done(), TIMER_Set(), and va().

Referenced by NPC_Think().

01788 {
01789         if ( self->client )
01790         {//make the noises
01791                 if ( TIMER_Done( self, "patrolNoise" ) && !Q_irand( 0, 20 ) )
01792                 {
01793                         switch( self->client->NPC_class )
01794                         {
01795                         case CLASS_R2D2:                                // droid
01796                                 G_SoundOnEnt(self, CHAN_AUTO, va("sound/chars/r2d2/misc/r2d2talk0%d.wav",Q_irand(1, 3)) );
01797                                 break;
01798                         case CLASS_R5D2:                                // droid
01799                                 G_SoundOnEnt(self, CHAN_AUTO, va("sound/chars/r5d2/misc/r5talk%d.wav",Q_irand(1, 4)) );
01800                                 break;
01801                         case CLASS_PROBE:                               // droid
01802                                 G_SoundOnEnt(self, CHAN_AUTO, va("sound/chars/probe/misc/probetalk%d.wav",Q_irand(1, 3)) );
01803                                 break;
01804                         case CLASS_MOUSE:                               // droid
01805                                 G_SoundOnEnt(self, CHAN_AUTO, va("sound/chars/mouse/misc/mousego%d.wav",Q_irand(1, 3)) );
01806                                 break;
01807                         case CLASS_GONK:                                // droid
01808                                 G_SoundOnEnt(self, CHAN_AUTO, va("sound/chars/gonk/misc/gonktalk%d.wav",Q_irand(1, 2)) );
01809                                 break;
01810                         }
01811                         TIMER_Set( self, "patrolNoise", Q_irand( 2000, 4000 ) );
01812                 }
01813         }
01814 }

void G_Line vec3_t  start,
vec3_t  end,
vec3_t  color,
float  alpha
 

Definition at line 11 of file g_nav.c.

References vec3_t.

00012 {
00013 
00014 }

void G_SoundOnEnt gentity_t ent,
soundChannel_t  channel,
const char *  soundPath
 

int GetTime int  lastTime  ) 
 

void GM_Dying gentity_t self  ) 
 

Definition at line 133 of file NPC_AI_GalakMech.c.

References gentity_s::client, entityShared_t::currentOrigin, playerState_s::electrifyTime, FRAMETIME, G_EffectIndex(), G_FreeEntity(), G_PlayEffectID(), gentity_t, gentity_s::ghoul2, renderInfo_s::headBolt, level, gentity_s::nextthink, NPC_SetSurfaceOnOff(), gclient_s::ps, Q_irand(), qfalse, qtrue, gentity_s::r, gclient_s::renderInfo, gentity_s::s, gentity_s::think, level_locals_t::time, entityState_s::time, TIMER_Done(), TIMER_Set(), trap_G2API_AddBolt(), trap_G2API_GetSurfaceRenderStatus(), TURN_OFF, and vec3_origin.

Referenced by CorpsePhysics().

00134 {
00135         if ( level.time - self->s.time < 4000 )
00136         {//FIXME: need a real effect
00137                 //self->s.powerups |= ( 1 << PW_SHOCKED );
00138                 //self->client->ps.powerups[PW_SHOCKED] = level.time + 1000;
00139                 self->client->ps.electrifyTime = level.time + 1000;
00140                 if ( TIMER_Done( self, "dyingExplosion" ) )
00141                 {
00142                         int     newBolt;
00143                         switch ( Q_irand( 1, 14 ) )
00144                         {
00145                         // Find place to generate explosion
00146                         case 1:
00147                                 if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "r_hand" ))
00148                                 {//r_hand still there
00149                                         GM_CreateExplosion( self, trap_G2API_AddBolt(self->ghoul2, 0, "*flasha"), qtrue );
00150                                         NPC_SetSurfaceOnOff( self, "r_hand", TURN_OFF );
00151                                 }
00152                                 else if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "r_arm_middle" ))
00153                                 {//r_arm_middle still there
00154                                         newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*r_arm_elbow" );
00155                                         NPC_SetSurfaceOnOff( self, "r_arm_middle", TURN_OFF );
00156                                 }
00157                                 break;
00158                         case 2:
00159                                 //FIXME: do only once?
00160                                 if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_hand" ))
00161                                 {//l_hand still there
00162                                         GM_CreateExplosion( self, trap_G2API_AddBolt(self->ghoul2, 0, "*flashc"), qfalse );
00163                                         NPC_SetSurfaceOnOff( self, "l_hand", TURN_OFF );
00164                                 }
00165                                 else if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_arm_wrist" ))
00166                                 {//l_arm_wrist still there
00167                                         newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*l_arm_cap_l_hand" );
00168                                         NPC_SetSurfaceOnOff( self, "l_arm_wrist", TURN_OFF );
00169                                 }
00170                                 else if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_arm_middle" ))
00171                                 {//l_arm_middle still there
00172                                         newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*l_arm_cap_l_hand" );
00173                                         NPC_SetSurfaceOnOff( self, "l_arm_middle", TURN_OFF );
00174                                 }
00175                                 else if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_arm_augment" ))
00176                                 {//l_arm_augment still there
00177                                         newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*l_arm_elbow" );
00178                                         NPC_SetSurfaceOnOff( self, "l_arm_augment", TURN_OFF );
00179                                 }
00180                                 break;
00181                         case 3:
00182                         case 4:
00183                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*hip_fr" );
00184                                 GM_CreateExplosion( self, newBolt, qfalse );
00185                                 break;
00186                         case 5:
00187                         case 6:
00188                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*shldr_l" );
00189                                 GM_CreateExplosion( self, newBolt, qfalse );
00190                                 break;
00191                         case 7:
00192                         case 8:
00193                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*uchest_r" );
00194                                 GM_CreateExplosion( self, newBolt, qfalse );
00195                                 break;
00196                         case 9:
00197                         case 10:
00198                                 GM_CreateExplosion( self, self->client->renderInfo.headBolt, qfalse );
00199                                 break;
00200                         case 11:
00201                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*l_leg_knee" );
00202                                 GM_CreateExplosion( self, newBolt, qtrue );
00203                                 break;
00204                         case 12:
00205                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*r_leg_knee" );
00206                                 GM_CreateExplosion( self, newBolt, qtrue );
00207                                 break;
00208                         case 13:
00209                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*l_leg_foot" );
00210                                 GM_CreateExplosion( self, newBolt, qtrue );
00211                                 break;
00212                         case 14:
00213                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, "*r_leg_foot" );
00214                                 GM_CreateExplosion( self, newBolt, qtrue );
00215                                 break;
00216                         }
00217 
00218                         TIMER_Set( self, "dyingExplosion", Q_irand( 300, 1100 ) );
00219                 }
00220         }
00221         else
00222         {//one final, huge explosion
00223                 G_PlayEffectID( G_EffectIndex("galak/explode"), self->r.currentOrigin, vec3_origin );
00224 //              G_PlayEffect( "small_chunks", self->r.currentOrigin );
00225 //              G_PlayEffect( "env/exp_trail_comp", self->r.currentOrigin, self->currentAngles );
00226                 self->nextthink = level.time + FRAMETIME;
00227                 self->think = G_FreeEntity;
00228         }
00229 }

void Mark1_dying gentity_t self  ) 
 

Definition at line 250 of file NPC_AI_Mark1.c.

References gentity_s::client, gentity_t, gentity_s::ghoul2, Mark1Dead_FireBlaster(), Mark1Dead_FireRocket(), NPC_Mark1_Part_Explode(), NPC_SetSurfaceOnOff(), gclient_s::ps, Q_irand(), RestoreNPCGlobals(), SaveNPCGlobals(), SetNPCGlobals(), TIMER_Done(), TIMER_Set(), playerState_s::torsoTimer, trap_G2API_AddBolt(), trap_G2API_GetSurfaceRenderStatus(), TURN_OFF, and va().

Referenced by NPC_RemoveBody().

00251 {
00252         int     num,newBolt;
00253 
00254         if (self->client->ps.torsoTimer>0)
00255         {
00256                 if (TIMER_Done(self,"dyingExplosion"))
00257                 {
00258                         num = Q_irand( 1, 3);
00259 
00260                         // Find place to generate explosion
00261                         if (num == 1)
00262                         {
00263                                 num = Q_irand( 8, 10);
00264                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, va("*flash%d",num) );
00265                                 NPC_Mark1_Part_Explode(self,newBolt);
00266                         }
00267                         else
00268                         {
00269                                 num = Q_irand( 1, 6);
00270                                 newBolt = trap_G2API_AddBolt( self->ghoul2, 0, va("*torso_tube%d",num) );
00271                                 NPC_Mark1_Part_Explode(self,newBolt);
00272                                 NPC_SetSurfaceOnOff( self, va("torso_tube%d",num), TURN_OFF );
00273                         }
00274 
00275                         TIMER_Set( self, "dyingExplosion", Q_irand( 300, 1000 ) );
00276                 }
00277 
00278 
00279 //              int             dir;
00280 //              vec3_t  right;
00281 
00282                 // Shove to the side
00283 //              AngleVectors( self->client->renderInfo.eyeAngles, NULL, right, NULL );
00284 //              VectorMA( self->client->ps.velocity, -80, right, self->client->ps.velocity );
00285 
00286                 // See which weapons are there
00287                 // Randomly fire blaster
00288                 if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_arm" ))     // Is the blaster still on the model?
00289                 {
00290                         if (Q_irand( 1, 5) == 1)
00291                         {
00292                                 SaveNPCGlobals();
00293                                 SetNPCGlobals( self );
00294                                 Mark1Dead_FireBlaster();
00295                                 RestoreNPCGlobals();
00296                         }
00297                 }
00298 
00299                 // Randomly fire rocket
00300                 if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "r_arm" ))     // Is the rocket still on the model?
00301                 {
00302                         if (Q_irand( 1, 10) == 1)
00303                         {
00304                                 SaveNPCGlobals();
00305                                 SetNPCGlobals( self );
00306                                 Mark1Dead_FireRocket();
00307                                 RestoreNPCGlobals();
00308                         }
00309                 }
00310         }
00311 
00312 }

void NPC_ApplyRoff void   ) 
 

Definition at line 497 of file NPC_move.c.

References BG_PlayerStateToEntityState(), gentity_s::client, NPC, gclient_s::ps, qfalse, gentity_s::s, and trap_LinkEntity().

Referenced by NPC_ExecuteBState(), and NPC_Think().

00498 {
00499         BG_PlayerStateToEntityState( &NPC->client->ps, &NPC->s, qfalse );
00500         //VectorCopy ( NPC->r.currentOrigin, NPC->lastOrigin );
00501         //rwwFIXMEFIXME: Any significance to this?
00502 
00503         // use the precise origin for linking
00504         trap_LinkEntity(NPC);
00505 }

void NPC_ApplyScriptFlags void   ) 
 

Definition at line 683 of file NPC.c.

References BUTTON_ALT_ATTACK, BUTTON_ATTACK, BUTTON_USE, BUTTON_WALKING, usercmd_s::buttons, gNPC_t::charmedTime, usercmd_s::forwardmove, level, NPCInfo, usercmd_s::rightmove, SCF_ALT_FIRE, SCF_CROUCHED, SCF_LEAN_LEFT, SCF_LEAN_RIGHT, SCF_RUNNING, SCF_WALKING, gNPC_t::scriptFlags, level_locals_t::time, ucmd, and usercmd_s::upmove.

Referenced by NPC_ExecuteBState().

00684 {
00685         if ( NPCInfo->scriptFlags & SCF_CROUCHED )
00686         {
00687                 if ( NPCInfo->charmedTime > level.time && (ucmd.forwardmove || ucmd.rightmove) )
00688                 {//ugh, if charmed and moving, ignore the crouched command
00689                 }
00690                 else
00691                 {
00692                         ucmd.upmove = -127;
00693                 }
00694         }
00695 
00696         if(NPCInfo->scriptFlags & SCF_RUNNING)
00697         {
00698                 ucmd.buttons &= ~BUTTON_WALKING;
00699         }
00700         else if(NPCInfo->scriptFlags & SCF_WALKING)
00701         {
00702                 if ( NPCInfo->charmedTime > level.time && (ucmd.forwardmove || ucmd.rightmove) )
00703                 {//ugh, if charmed and moving, ignore the walking command
00704                 }
00705                 else
00706                 {
00707                         ucmd.buttons |= BUTTON_WALKING;
00708                 }
00709         }
00710 /*
00711         if(NPCInfo->scriptFlags & SCF_CAREFUL)
00712         {
00713                 ucmd.buttons |= BUTTON_CAREFUL;
00714         }
00715 */
00716         if(NPCInfo->scriptFlags & SCF_LEAN_RIGHT)
00717         {
00718                 ucmd.buttons |= BUTTON_USE;
00719                 ucmd.rightmove = 127;
00720                 ucmd.forwardmove = 0;
00721                 ucmd.upmove = 0;
00722         }
00723         else if(NPCInfo->scriptFlags & SCF_LEAN_LEFT)
00724         {
00725                 ucmd.buttons |= BUTTON_USE;
00726                 ucmd.rightmove = -127;
00727                 ucmd.forwardmove = 0;
00728                 ucmd.upmove = 0;
00729         }
00730 
00731         if ( (NPCInfo->scriptFlags & SCF_ALT_FIRE) && (ucmd.buttons & BUTTON_ATTACK) )
00732         {//Use altfire instead
00733                 ucmd.buttons |= BUTTON_ALT_ATTACK;
00734         }
00735 }

void NPC_AvoidWallsAndCliffs void   ) 
 

Definition at line 835 of file NPC.c.

Referenced by NPC_ExecuteBState().

00836 {
00837         //...
00838 }

void NPC_BehaviorSet_ATST int  bState  ) 
 

Definition at line 1293 of file NPC.c.

References BS_DEFAULT, BS_HUNT_AND_KILL, BS_PATROL, BS_STAND_AND_SHOOT, NPC_BehaviorSet_Default(), and NPC_BSATST_Default().

Referenced by NPC_RunBehavior().

01294 {
01295         switch( bState )
01296         {
01297         case BS_DEFAULT:
01298         case BS_PATROL:
01299         case BS_STAND_AND_SHOOT:
01300         case BS_HUNT_AND_KILL:
01301                 NPC_BSATST_Default();
01302                 break;
01303         default:
01304                 NPC_BehaviorSet_Default( bState );
01305                 break;
01306         }
01307 }

void NPC_BehaviorSet_Charmed int  bState  ) 
 

Definition at line 939 of file NPC.c.

References BS_DEFAULT, BS_FLEE, BS_FOLLOW_LEADER, BS_REMOVE, BS_SEARCH, BS_WANDER, NPC_BSDefault(), NPC_BSFlee(), NPC_BSFollowLeader(), NPC_BSRemove(), NPC_BSSearch(), and NPC_BSWander().

Referenced by NPC_RunBehavior().

00940 {
00941         switch( bState )
00942         {
00943         case BS_FOLLOW_LEADER://# 40: Follow your leader and shoot any enemies you come across
00944                 NPC_BSFollowLeader();
00945                 break;
00946         case BS_REMOVE:
00947                 NPC_BSRemove();
00948                 break;
00949         case BS_SEARCH:                 //# 43: Using current waypoint as a base, search the immediate branches of waypoints for enemies
00950                 NPC_BSSearch();
00951                 break;
00952         case BS_WANDER:                 //# 46: Wander down random waypoint paths
00953                 NPC_BSWander();
00954                 break;
00955         case BS_FLEE:
00956                 NPC_BSFlee();
00957                 break;
00958         default:
00959         case BS_DEFAULT://whatever
00960                 NPC_BSDefault();
00961                 break;
00962         }
00963 }

void NPC_BehaviorSet_Default int  bState  ) 
 

Definition at line 970 of file NPC.c.

References BS_ADVANCE_FIGHT, BS_CINEMATIC, BS_DEFAULT, BS_FLEE, BS_FOLLOW_LEADER, BS_JUMP, BS_NOCLIP, BS_REMOVE, BS_SEARCH, BS_SLEEP, BS_WAIT, BS_WANDER, NPC_BSAdvanceFight(), NPC_BSCinematic(), NPC_BSDefault(), NPC_BSFlee(), NPC_BSFollowLeader(), NPC_BSJump(), NPC_BSNoClip(), NPC_BSRemove(), NPC_BSSearch(), NPC_BSSleep(), NPC_BSWait(), and NPC_BSWander().

Referenced by NPC_BehaviorSet_ATST(), NPC_BehaviorSet_Droid(), NPC_BehaviorSet_Grenadier(), NPC_BehaviorSet_Howler(), NPC_BehaviorSet_ImperialProbe(), NPC_BehaviorSet_Interrogator(), NPC_BehaviorSet_Jedi(), NPC_BehaviorSet_Mark1(), NPC_BehaviorSet_Mark2(), NPC_BehaviorSet_MineMonster(), NPC_BehaviorSet_Rancor(), NPC_BehaviorSet_Seeker(), NPC_BehaviorSet_Sentry(), NPC_BehaviorSet_Sniper(), NPC_BehaviorSet_Stormtrooper(), and NPC_RunBehavior().

00971 {
00972         switch( bState )
00973         {
00974         case BS_ADVANCE_FIGHT://head toward captureGoal, shoot anything that gets in the way
00975                 NPC_BSAdvanceFight ();
00976                 break;
00977         case BS_SLEEP://Follow a path, looking for enemies
00978                 NPC_BSSleep ();
00979                 break;
00980         case BS_FOLLOW_LEADER://# 40: Follow your leader and shoot any enemies you come across
00981                 NPC_BSFollowLeader();
00982                 break;
00983         case BS_JUMP:                   //41: Face navgoal and jump to it.
00984                 NPC_BSJump();
00985                 break;
00986         case BS_REMOVE:
00987                 NPC_BSRemove();
00988                 break;
00989         case BS_SEARCH:                 //# 43: Using current waypoint as a base, search the immediate branches of waypoints for enemies
00990                 NPC_BSSearch();
00991                 break;
00992         case BS_NOCLIP:
00993                 NPC_BSNoClip();
00994                 break;
00995         case BS_WANDER:                 //# 46: Wander down random waypoint paths
00996                 NPC_BSWander();
00997                 break;
00998         case BS_FLEE:
00999                 NPC_BSFlee();
01000                 break;
01001         case BS_WAIT:
01002                 NPC_BSWait();
01003                 break;
01004         case BS_CINEMATIC:
01005                 NPC_BSCinematic();
01006                 break;
01007         default:
01008         case BS_DEFAULT://whatever
01009                 NPC_BSDefault();
01010                 break;
01011         }
01012 }

void NPC_BehaviorSet_Droid int  bState  ) 
 

Definition at line 1232 of file NPC.c.

References BS_DEFAULT, BS_PATROL, BS_STAND_GUARD, NPC_BehaviorSet_Default(), and NPC_BSDroid_Default().

Referenced by NPC_RunBehavior().

01233 {
01234         switch( bState )
01235         {
01236         case BS_DEFAULT:
01237         case BS_STAND_GUARD:
01238         case BS_PATROL:
01239                 NPC_BSDroid_Default();
01240                 break;
01241         default:
01242                 NPC_BehaviorSet_Default( bState );
01243                 break;
01244         }
01245 }

void NPC_BehaviorSet_Grenadier int  bState  ) 
 

Definition at line 1128 of file NPC.c.

References BS_DEFAULT, BS_HUNT_AND_KILL, BS_PATROL, BS_STAND_AND_SHOOT, BS_STAND_GUARD, NPC_BehaviorSet_Default(), and NPC_BSGrenadier_Default().

Referenced by NPC_RunBehavior().

01129 {
01130         switch( bState )
01131         {
01132         case BS_STAND_GUARD:
01133         case BS_PATROL:
01134         case BS_STAND_AND_SHOOT:
01135         case BS_HUNT_AND_KILL:
01136         case BS_DEFAULT:
01137                 NPC_BSGrenadier_Default();
01138                 break;
01139 
01140         default:
01141                 NPC_BehaviorSet_Default( bState );
01142                 break;
01143         }
01144 }

void NPC_BehaviorSet_Howler int  bState  ) 
 

Definition at line 1336 of file NPC.c.

References BS_DEFAULT, BS_HUNT_AND_KILL, BS_PATROL, BS_STAND_AND_SHOOT, BS_STAND_GUARD, NPC_BehaviorSet_Default(), and NPC_BSHowler_Default().

Referenced by NPC_RunBehavior().

01337 {
01338         switch( bState )
01339         {
01340         case BS_STAND_GUARD:
01341         case BS_PATROL:
01342         case BS_STAND_AND_SHOOT:
01343         case BS_HUNT_AND_KILL:
01344         case BS_DEFAULT:
01345                 NPC_BSHowler_Default();
01346                 break;
01347         default:
01348                 NPC_BehaviorSet_Default( bState );
01349                 break;
01350         }
01351 }

void NPC_BehaviorSet_ImperialProbe int  bState  ) 
 

Definition at line 1045 of file NPC.c.

References BS_DEFAULT, BS_HUNT_AND_KILL, BS_PATROL, BS_STAND_AND_SHOOT, BS_STAND_GUARD, NPC_BehaviorSet_Default(), and NPC_BSImperialProbe_Default().

Referenced by NPC_RunBehavior().

01046 {
01047         switch( bState )
01048         {
01049         case BS_STAND_GUARD:
01050         case BS_PATROL:
01051         case BS_STAND_AND_SHOOT:
01052         case BS_HUNT_AND_KILL:
01053         case BS_DEFAULT:
01054                 NPC_BSImperialProbe_Default();
01055                 break;
01056         default:
01057                 NPC_BehaviorSet_Default( bState );
01058                 break;
01059         }
01060 }

void NPC_BehaviorSet_Interrogator int  bState  ) 
 

Definition at line 1019 of file NPC.c.

References BS_DEFAULT, BS_HUNT_AND_KILL, BS_PATROL, BS_STAND_AND_SHOOT, BS_STAND_GUARD, NPC_BehaviorSet_Default(), and NPC_BSInterrogator_Default().

Referenced by NPC_RunBehavior().

01020 {
01021         switch( bState )
01022         {
01023         case BS_STAND_GUARD:
01024         case BS_PATROL