codemp/game/NPC_AI_Droid.c File Reference

#include "b_local.h"

Go to the source code of this file.

Defines

#define TURN_OFF   0x00000100

Enumerations

enum  {
  LSTATE_NONE = 0, LSTATE_BACKINGUP, LSTATE_SPINNING, LSTATE_PAIN,
  LSTATE_DROP
}

Functions

float NPC_GetPainChance (gentity_t *self, int damage)
void G_SoundOnEnt (gentity_t *ent, soundChannel_t channel, const char *soundPath)
void R2D2_PartsMove (void)
void Droid_Idle (void)
void R2D2_TurnAnims (void)
void Droid_Patrol (void)
void Droid_Run (void)
void Droid_Spin (void)
void NPC_Droid_Pain (gentity_t *self, gentity_t *attacker, int damage)
void Droid_Pain (void)
void NPC_Mouse_Precache (void)
void NPC_R5D2_Precache (void)
void NPC_R2D2_Precache (void)
void NPC_Gonk_Precache (void)
void NPC_Protocol_Precache (void)
void NPC_BSDroid_Default (void)


Define Documentation

#define TURN_OFF   0x00000100
 

Definition at line 7 of file NPC_AI_Droid.c.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
LSTATE_NONE 
LSTATE_BACKINGUP 
LSTATE_SPINNING 
LSTATE_PAIN 
LSTATE_DROP 

Definition at line 10 of file NPC_AI_Droid.c.

00011 {
00012         LSTATE_NONE = 0,
00013         LSTATE_BACKINGUP,
00014         LSTATE_SPINNING,
00015         LSTATE_PAIN,
00016         LSTATE_DROP
00017 };


Function Documentation

void Droid_Idle void   ) 
 

Definition at line 53 of file NPC_AI_Droid.c.

00054 {
00055 //      VectorCopy( NPCInfo->investigateGoal, lookPos );
00056 
00057 //      NPC_FacePosition( lookPos );
00058 }

void Droid_Pain void   ) 
 

Definition at line 442 of file NPC_AI_Droid.c.

References gNPC_t::localState, LSTATE_NONE, NPC, NPCInfo, and TIMER_Done().

Referenced by NPC_BSDroid_Default().

00443 {
00444         if (TIMER_Done(NPC,"droidpain"))        //He's done jumping around
00445         {
00446                 NPCInfo->localState = LSTATE_NONE;
00447         }
00448 }

void Droid_Patrol void   ) 
 

Definition at line 102 of file NPC_AI_Droid.c.

References AngleNormalize360(), BUTTON_WALKING, usercmd_s::buttons, CHAN_AUTO, CLASS_GONK, CLASS_MOUSE, CLASS_R2D2, CLASS_R5D2, gentity_s::client, gNPC_t::desiredYaw, G_SoundOnEnt(), level, NPC, gclient_s::NPC_class, NPC_MoveToGoal(), NPC_UpdateAngles(), NPCInfo, gentity_s::pos1, Q_irand(), qtrue, R2D2_PartsMove(), R2D2_TurnAnims(), sin(), level_locals_t::time, TIMER_Done(), TIMER_Set(), ucmd, UpdateGoal(), and va().

Referenced by NPC_BSDroid_Default().

00103 {
00104 
00105         NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]);
00106 
00107         if ( NPC->client && NPC->client->NPC_class != CLASS_GONK )
00108         {
00109                 if (NPC->client->NPC_class != CLASS_R5D2)
00110                 { //he doesn't have an eye.
00111                         R2D2_PartsMove();               // Get his eye moving.
00112                 }
00113                 R2D2_TurnAnims();
00114         }
00115 
00116         //If we have somewhere to go, then do that
00117         if ( UpdateGoal() )
00118         {
00119                 ucmd.buttons |= BUTTON_WALKING;
00120                 NPC_MoveToGoal( qtrue );
00121 
00122                 if( NPC->client && NPC->client->NPC_class == CLASS_MOUSE )
00123                 {
00124                         NPCInfo->desiredYaw += sin(level.time*.5) * 25; // Weaves side to side a little
00125 
00126                         if (TIMER_Done(NPC,"patrolNoise"))
00127                         {
00128                                 G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/mouse/misc/mousego%d.wav", Q_irand(1, 3)) );
00129 
00130                                 TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
00131                         }
00132                 }
00133                 else if( NPC->client && NPC->client->NPC_class == CLASS_R2D2 )
00134                 {
00135                         if (TIMER_Done(NPC,"patrolNoise"))
00136                         {
00137                                 G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r2d2/misc/r2d2talk0%d.wav",       Q_irand(1, 3)) );
00138 
00139                                 TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
00140                         }
00141                 }
00142                 else if( NPC->client && NPC->client->NPC_class == CLASS_R5D2 )
00143                 {
00144                         if (TIMER_Done(NPC,"patrolNoise"))
00145                         {
00146                                 G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r5d2/misc/r5talk%d.wav", Q_irand(1, 4)) );
00147 
00148                                 TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
00149                         }
00150                 }
00151                 if( NPC->client && NPC->client->NPC_class == CLASS_GONK )
00152                 {
00153                         if (TIMER_Done(NPC,"patrolNoise"))
00154                         {
00155                                 G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/gonk/misc/gonktalk%d.wav", Q_irand(1, 2)) );
00156 
00157                                 TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
00158                         }
00159                 }
00160 //              else
00161 //              {
00162 //                      R5D2_LookAround();
00163 //              }
00164         }
00165 
00166         NPC_UpdateAngles( qtrue, qtrue );
00167 
00168 }

void Droid_Run void   ) 
 

Definition at line 175 of file NPC_AI_Droid.c.

References NPCInfo, and ucmd.

Referenced by NPC_BSDroid_Default().

00176 {
00177         R2D2_PartsMove();
00178 
00179         if ( NPCInfo->localState == LSTATE_BACKINGUP )
00180         {
00181                 ucmd.forwardmove = -127;
00182                 NPCInfo->desiredYaw += 5; 
00183 
00184                 NPCInfo->localState = LSTATE_NONE;      // So he doesn't constantly backup.
00185         }
00186         else 
00187         {
00188                 ucmd.forwardmove = 64;
00189                 //If we have somewhere to go, then do that
00190                 if ( UpdateGoal() )
00191                 {
00192                         if (NPC_MoveToGoal( qfalse ))
00193                         {
00194                                 NPCInfo->desiredYaw += sin(level.time*.5) * 5; // Weaves side to side a little
00195                         }
00196                 }
00197         }
00198 
00199         NPC_UpdateAngles( qtrue, qtrue );
00200 }

void Droid_Spin void   ) 
 

Definition at line 207 of file NPC_AI_Droid.c.

References AngleNormalize360(), CLASS_R2D2, CLASS_R5D2, gentity_s::client, entityShared_t::currentOrigin, gNPC_t::desiredYaw, usercmd_s::forwardmove, G_EffectIndex(), G_PlayEffectID(), gentity_s::ghoul2, gNPC_t::localState, LSTATE_NONE, NPC, gclient_s::NPC_class, NPC_UpdateAngles(), NPCInfo, Q_irand(), qtrue, gentity_s::r, R2D2_TurnAnims(), TIMER_Done(), TIMER_Set(), trap_G2API_GetSurfaceRenderStatus(), ucmd, and vec3_t.

Referenced by NPC_BSDroid_Default().

00208 {
00209         vec3_t dir = {0,0,1};
00210 
00211         R2D2_TurnAnims();
00212 
00213                                                 
00214         // Head is gone, spin and spark
00215         if ( NPC->client->NPC_class == CLASS_R5D2 
00216                 || NPC->client->NPC_class == CLASS_R2D2 )
00217         {
00218                 // No head?
00219                 if (trap_G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "head" )>0)
00220                 {
00221                         if (TIMER_Done(NPC,"smoke") && !TIMER_Done(NPC,"droidsmoketotal"))
00222                         {
00223                                 TIMER_Set( NPC, "smoke", 100);
00224                                 G_PlayEffectID( G_EffectIndex("volumetric/droid_smoke") , NPC->r.currentOrigin,dir);
00225                         }
00226 
00227                         if (TIMER_Done(NPC,"droidspark"))
00228                         {
00229                                 TIMER_Set( NPC, "droidspark", Q_irand(100,500));
00230                                 G_PlayEffectID( G_EffectIndex("sparks/spark"), NPC->r.currentOrigin,dir);
00231                         }
00232 
00233                         ucmd.forwardmove = Q_irand( -64, 64);
00234 
00235                         if (TIMER_Done(NPC,"roam"))
00236                         {       
00237                                 TIMER_Set( NPC, "roam", Q_irand( 250, 1000 ) );
00238                                 NPCInfo->desiredYaw = Q_irand( 0, 360 ); // Go in random directions
00239                         }
00240                 }
00241                 else
00242                 {
00243                         if (TIMER_Done(NPC,"roam"))
00244                         {
00245                                 NPCInfo->localState = LSTATE_NONE;
00246                         }
00247                         else
00248                         {
00249                                 NPCInfo->desiredYaw = AngleNormalize360(NPCInfo->desiredYaw + 40); // Spin around
00250                         }
00251                 }
00252         }
00253         else 
00254         {
00255                 if (TIMER_Done(NPC,"roam"))
00256                 {
00257                         NPCInfo->localState = LSTATE_NONE;
00258                 }
00259                 else
00260                 {
00261                         NPCInfo->desiredYaw = AngleNormalize360(NPCInfo->desiredYaw + 40); // Spin around
00262                 }
00263         }
00264 
00265         NPC_UpdateAngles( qtrue, qtrue );
00266 }

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

void NPC_BSDroid_Default void   ) 
 

Definition at line 597 of file NPC_AI_Droid.c.

References crandom, Droid_Pain(), Droid_Patrol(), Droid_Run(), Droid_Spin(), gNPC_t::localState, LSTATE_DROP, LSTATE_PAIN, LSTATE_SPINNING, NPC_UpdateAngles(), NPCInfo, qtrue, SCF_LOOK_FOR_ENEMIES, gNPC_t::scriptFlags, ucmd, and usercmd_s::upmove.

Referenced by NPC_BehaviorSet_Droid().

00598 {
00599 
00600         if ( NPCInfo->localState == LSTATE_SPINNING )
00601         {
00602                 Droid_Spin();
00603         }
00604         else if ( NPCInfo->localState == LSTATE_PAIN )
00605         {
00606                 Droid_Pain();
00607         }
00608         else if ( NPCInfo->localState == LSTATE_DROP )
00609         {
00610                 NPC_UpdateAngles( qtrue, qtrue );
00611                 ucmd.upmove = crandom() * 64;
00612         }
00613         else if ( NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES )
00614         {
00615                 Droid_Patrol();
00616         }
00617         else
00618         {
00619                 Droid_Run();
00620         }
00621 }

void NPC_Droid_Pain gentity_t self,
gentity_t attacker,
int  damage
 

Definition at line 273 of file NPC_AI_Droid.c.

References entityState_s::angles, AngleVectors(), BOTH_PAIN1, BOTH_PAIN2, BOTH_STAND2, CLASS_INTERROGATOR, CLASS_MOUSE, CLASS_R2D2, CLASS_R5D2, gentity_s::client, entityShared_t::currentAngles, entityShared_t::currentOrigin, playerState_s::electrifyTime, G_EffectIndex(), G_PlayEffectID(), gentity_t, gentity_s::ghoul2, gPainMOD, gentity_s::health, gNPC_t::lastPathAngles, playerState_s::legsAnim, level, gNPC_t::localState, LSTATE_BACKINGUP, LSTATE_SPINNING, entityState_s::m_iVehicleNum, playerState_s::m_iVehicleNum, MOD_DEMP2, MOD_DEMP2_ALT, gentity_s::NPC, gclient_s::NPC_class, NPC_GetPainChance(), NPC_Pain(), NPC_SetAnim(), NPC_SetSurfaceOnOff(), NULL, gclient_s::ps, Q_irand(), gentity_s::r, random, gentity_s::s, SCF_LOOK_FOR_ENEMIES, gNPC_t::scriptFlags, SETANIM_BOTH, SETANIM_FLAG_HOLD, SETANIM_FLAG_OVERRIDE, gentity_s::spawnflags, level_locals_t::time, TIMER_Set(), trap_G2API_GetSurfaceRenderStatus(), TURN_OFF, vec3_origin, vec3_t, VectorCopy, VectorMA, VectorNormalize(), VectorSubtract, and playerState_s::velocity.

Referenced by NPC_PainFunc().

00274 {
00275         gentity_t *other = attacker;
00276         int             anim;
00277         int             mod = gPainMOD;
00278         float   pain_chance;
00279 
00280         VectorCopy( self->NPC->lastPathAngles, self->s.angles );
00281 
00282         if ( self->client->NPC_class == CLASS_R5D2 )
00283         {
00284                 pain_chance = NPC_GetPainChance( self, damage );
00285 
00286                 // Put it in pain
00287                 if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT || random() < pain_chance )       // Spin around in pain? Demp2 always does this
00288                 {
00289                         // Health is between 0-30 or was hit by a DEMP2 so pop his head
00290                         if ( !self->s.m_iVehicleNum
00291                                 && ( self->health < 30 || mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) )
00292                         {
00293                                 if (!(self->spawnflags & 2))    // Doesn't have to ALWAYSDIE
00294                                 {
00295                                         if ((self->NPC->localState != LSTATE_SPINNING) && 
00296                                                 (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "head" )))
00297                                         {
00298                                                 NPC_SetSurfaceOnOff( self, "head", TURN_OFF );
00299 
00300                                                 if ( self->client->ps.m_iVehicleNum )
00301                                                 {
00302                                                         vec3_t  up;
00303                                                         AngleVectors( self->r.currentAngles, NULL, NULL, up );
00304                                                         G_PlayEffectID( G_EffectIndex("chunks/r5d2head_veh"), self->r.currentOrigin, up );
00305                                                 }
00306                                                 else
00307                                                 {
00308                                                         G_PlayEffectID( G_EffectIndex("small_chunks") , self->r.currentOrigin, vec3_origin );
00309                                                         G_PlayEffectID( G_EffectIndex("chunks/r5d2head"), self->r.currentOrigin, vec3_origin );
00310                                                 }
00311 
00312                                                 //self->s.powerups |= ( 1 << PW_SHOCKED );
00313                                                 //self->client->ps.powerups[PW_SHOCKED] = level.time + 3000;
00314                                                 self->client->ps.electrifyTime = level.time + 3000;
00315 
00316                                                 TIMER_Set( self, "droidsmoketotal", 5000);
00317                                                 TIMER_Set( self, "droidspark", 100);
00318                                                 self->NPC->localState = LSTATE_SPINNING;
00319                                         }
00320                                 }
00321                         }
00322                         // Just give him normal pain for a little while
00323                         else
00324                         {
00325                                 anim = self->client->ps.legsAnim;
00326 
00327                                 if ( anim == BOTH_STAND2 )      // On two legs?
00328                                 {
00329                                         anim = BOTH_PAIN1;
00330                                 }
00331                                 else                                            // On three legs
00332                                 {
00333                                         anim = BOTH_PAIN2;
00334                                 }
00335 
00336                                 NPC_SetAnim( self, SETANIM_BOTH, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
00337 
00338                                 // Spin around in pain
00339                                 self->NPC->localState = LSTATE_SPINNING;
00340                                 TIMER_Set( self, "roam", Q_irand(1000,2000));
00341                         } 
00342                 }
00343         }
00344         else if (self->client->NPC_class == CLASS_MOUSE)
00345         {
00346                 if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT )
00347                 {
00348                         self->NPC->localState = LSTATE_SPINNING;
00349                         //self->s.powerups |= ( 1 << PW_SHOCKED );
00350                         //self->client->ps.powerups[PW_SHOCKED] = level.time + 3000;
00351                         self->client->ps.electrifyTime = level.time + 3000;
00352                 }
00353                 else
00354                 {
00355                         self->NPC->localState = LSTATE_BACKINGUP;
00356                 }
00357 
00358                 self->NPC->scriptFlags &= ~SCF_LOOK_FOR_ENEMIES;
00359         }
00360         else if ((self->client->NPC_class == CLASS_R2D2))
00361         {
00362 
00363                 pain_chance = NPC_GetPainChance( self, damage );
00364 
00365                 if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT || random() < pain_chance )       // Spin around in pain? Demp2 always does this
00366                 {
00367                         // Health is between 0-30 or was hit by a DEMP2 so pop his head
00368                         if ( !self->s.m_iVehicleNum
00369                                 && ( self->health < 30 || mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) )
00370                         {
00371                                 if (!(self->spawnflags & 2))    // Doesn't have to ALWAYSDIE
00372                                 {
00373                                         if ((self->NPC->localState != LSTATE_SPINNING) && 
00374                                                 (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "head" )))
00375                                         {
00376                                                 NPC_SetSurfaceOnOff( self, "head", TURN_OFF );
00377 
00378                                                 if ( self->client->ps.m_iVehicleNum )
00379                                                 {
00380                                                         vec3_t  up;
00381                                                         AngleVectors( self->r.currentAngles, NULL, NULL, up );
00382                                                         G_PlayEffectID( G_EffectIndex("chunks/r2d2head_veh"), self->r.currentOrigin, up );
00383                                                 }
00384                                                 else
00385                                                 {
00386                                                         G_PlayEffectID( G_EffectIndex("small_chunks") , self->r.currentOrigin, vec3_origin );
00387                                                         G_PlayEffectID( G_EffectIndex("chunks/r2d2head"), self->r.currentOrigin, vec3_origin );
00388                                                 }
00389 
00390                                                 //self->s.powerups |= ( 1 << PW_SHOCKED );
00391                                                 //self->client->ps.powerups[PW_SHOCKED] = level.time + 3000;
00392                                                 self->client->ps.electrifyTime = level.time + 3000;
00393 
00394                                                 TIMER_Set( self, "droidsmoketotal", 5000);
00395                                                 TIMER_Set( self, "droidspark", 100);
00396                                                 self->NPC->localState = LSTATE_SPINNING;
00397                                         }
00398                                 }
00399                         }
00400                         // Just give him normal pain for a little while
00401                         else
00402                         {
00403                                 anim = self->client->ps.legsAnim;
00404 
00405                                 if ( anim == BOTH_STAND2 )      // On two legs?
00406                                 {
00407                                         anim = BOTH_PAIN1;
00408                                 }
00409                                 else                                            // On three legs
00410                                 {
00411                                         anim = BOTH_PAIN2;
00412                                 }
00413 
00414                                 NPC_SetAnim( self, SETANIM_BOTH, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
00415 
00416                                 // Spin around in pain
00417                                 self->NPC->localState = LSTATE_SPINNING;
00418                                 TIMER_Set( self, "roam", Q_irand(1000,2000));
00419                         }
00420                 } 
00421         }
00422         else if ( self->client->NPC_class == CLASS_INTERROGATOR && ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) && other )
00423         {
00424                 vec3_t dir;
00425 
00426                 VectorSubtract( self->r.currentOrigin, other->r.currentOrigin, dir );
00427                 VectorNormalize( dir );
00428 
00429                 VectorMA( self->client->ps.velocity, 550, dir, self->client->ps.velocity );
00430                 self->client->ps.velocity[2] -= 127;
00431         }
00432 
00433         NPC_Pain( self, attacker, damage);
00434 }

float NPC_GetPainChance gentity_t self,
int  damage
 

Definition at line 157 of file NPC_reactions.c.

References gentity_s::client, gentity_s::enemy, g_spskill, gentity_t, gentity_s::health, vmCvar_t::integer, gclient_s::ps, STAT_MAX_HEALTH, and playerState_s::stats.

Referenced by NPC_ChoosePainAnimation(), NPC_Droid_Pain(), and NPC_Probe_Pain().

00158 {
00159         float pain_chance;
00160         if ( !self->enemy )
00161         {//surprised, always take pain
00162                 return 1.0f;
00163         }
00164 
00165         if (!self->client)
00166         {
00167                 return 1.0f;
00168         }
00169 
00170         //if ( damage > self->max_health/2.0f )
00171         if (damage > self->client->ps.stats[STAT_MAX_HEALTH]/2.0f)
00172         {
00173                 return 1.0f;
00174         }
00175 
00176         pain_chance = (float)(self->client->ps.stats[STAT_MAX_HEALTH]-self->health)/(self->client->ps.stats[STAT_MAX_HEALTH]*2.0f) + (float)damage/(self->client->ps.stats[STAT_MAX_HEALTH]/2.0f);
00177         switch ( g_spskill.integer )
00178         {
00179         case 0: //easy
00180                 //return 0.75f;
00181                 break;
00182 
00183         case 1://med
00184                 pain_chance *= 0.5f;
00185                 //return 0.35f;
00186                 break;
00187 
00188         case 2://hard
00189         default:
00190                 pain_chance *= 0.1f;
00191                 //return 0.05f;
00192                 break;
00193         }
00194         //Com_Printf( "%s: %4.2f\n", self->NPC_type, pain_chance );
00195         return pain_chance;
00196 }

void NPC_Gonk_Precache void   ) 
 

Definition at line 520 of file NPC_AI_Droid.c.

References G_EffectIndex(), and G_SoundIndex().

Referenced by NPC_SpawnType(), and SP_NPC_Droid_Gonk().

00521 {
00522         G_SoundIndex("sound/chars/gonk/misc/gonktalk1.wav");
00523         G_SoundIndex("sound/chars/gonk/misc/gonktalk2.wav");
00524 
00525         G_SoundIndex("sound/chars/gonk/misc/death1.wav");
00526         G_SoundIndex("sound/chars/gonk/misc/death2.wav");
00527         G_SoundIndex("sound/chars/gonk/misc/death3.wav");
00528 
00529         G_EffectIndex( "env/med_explode");
00530 }

void NPC_Mouse_Precache void   ) 
 

Definition at line 455 of file NPC_AI_Droid.c.

References G_EffectIndex(), G_SoundIndex(), and va().

Referenced by NPC_SpawnType(), and SP_NPC_Droid_Mouse().

00456 {
00457         int     i;
00458 
00459         for (i = 1; i < 4; i++)
00460         {
00461                 G_SoundIndex( va( "sound/chars/mouse/misc/mousego%d.wav", i ) );
00462         }
00463 
00464         G_EffectIndex( "env/small_explode" );
00465         G_SoundIndex( "sound/chars/mouse/misc/death1" );
00466         G_SoundIndex( "sound/chars/mouse/misc/mouse_lp" );
00467 }

void NPC_Protocol_Precache void   ) 
 

Definition at line 537 of file NPC_AI_Droid.c.

References G_EffectIndex(), and G_SoundIndex().

Referenced by NPC_SpawnType(), and SP_NPC_Droid_Protocol().

00538 {
00539         G_SoundIndex( "sound/chars/mark2/misc/mark2_explo" );
00540         G_EffectIndex( "env/med_explode");
00541 }

void NPC_R2D2_Precache void   ) 
 

Definition at line 497 of file NPC_AI_Droid.c.

References G_EffectIndex(), G_SoundIndex(), and va().

Referenced by NPC_SpawnType(), and SP_NPC_Droid_R2D2().

00498 {
00499         int i;
00500 
00501         for ( i = 1; i < 4; i++)
00502         {
00503                 G_SoundIndex( va( "sound/chars/r2d2/misc/r2d2talk0%d.wav", i ) );
00504         }
00505         //G_SoundIndex( "sound/chars/r2d2/misc/falling1.wav" );
00506         G_SoundIndex( "sound/chars/mark2/misc/mark2_explo" ); // ??
00507         G_SoundIndex( "sound/chars/r2d2/misc/r2_move_lp.wav" );
00508         G_EffectIndex( "env/med_explode");
00509         G_EffectIndex( "volumetric/droid_smoke" );
00510         G_EffectIndex("sparks/spark");
00511         G_EffectIndex( "chunks/r2d2head");
00512         G_EffectIndex( "chunks/r2d2head_veh");
00513 }

void NPC_R5D2_Precache void   ) 
 

Definition at line 474 of file NPC_AI_Droid.c.

References G_EffectIndex(), G_SoundIndex(), and va().

Referenced by NPC_SpawnType(), and SP_NPC_Droid_R5D2().

00475 {
00476         int i;
00477 
00478         for ( i = 1; i < 5; i++)
00479         {
00480                 G_SoundIndex( va( "sound/chars/r5d2/misc/r5talk%d.wav", i ) );
00481         }
00482         //G_SoundIndex( "sound/chars/r5d2/misc/falling1.wav" );
00483         G_SoundIndex( "sound/chars/mark2/misc/mark2_explo" ); // ??
00484         G_SoundIndex( "sound/chars/r2d2/misc/r2_move_lp2.wav" );
00485         G_EffectIndex( "env/med_explode");
00486         G_EffectIndex( "volumetric/droid_smoke" );
00487         G_EffectIndex("sparks/spark");
00488         G_EffectIndex( "chunks/r5d2head");
00489         G_EffectIndex( "chunks/r5d2head_veh");
00490 }

void R2D2_PartsMove void   ) 
 

Definition at line 24 of file NPC_AI_Droid.c.

References AngleNormalize360(), NPC, NPC_SetBoneAngles(), gentity_s::pos1, Q_irand(), TIMER_Done(), and TIMER_Set().

Referenced by Droid_Patrol().

00025 {
00026         // Front 'eye' lense
00027         if ( TIMER_Done(NPC,"eyeDelay") )
00028         {
00029                 NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]);
00030 
00031                 NPC->pos1[0]+=Q_irand( -20, 20 );       // Roll 
00032                 NPC->pos1[1]=Q_irand( -20, 20 );        
00033                 NPC->pos1[2]=Q_irand( -20, 20 );        
00034 
00035                 /*
00036                 if (NPC->genericBone1)
00037                 {
00038                         gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL ); 
00039                 }
00040                 */
00041                 NPC_SetBoneAngles(NPC, "f_eye", NPC->pos1);
00042                 
00043 
00044                 TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) );
00045         }
00046 }

void R2D2_TurnAnims void   ) 
 

Definition at line 65 of file NPC_AI_Droid.c.

References AngleDelta(), BOTH_RUN1, BOTH_TURN_LEFT1, BOTH_TURN_RIGHT1, CLASS_R2D2, CLASS_R5D2, gentity_s::client, entityShared_t::currentAngles, gNPC_t::desiredYaw, fabs(), playerState_s::legsAnim, NPC, gclient_s::NPC_class, NPC_SetAnim(), NPCInfo, gclient_s::ps, gentity_s::r, SETANIM_BOTH, SETANIM_FLAG_HOLD, SETANIM_FLAG_OVERRIDE, and YAW.

Referenced by Droid_Patrol(), and Droid_Spin().

00066 {
00067         float turndelta;
00068         int             anim;
00069 
00070         turndelta = AngleDelta(NPC->r.currentAngles[YAW], NPCInfo->desiredYaw);
00071 
00072         if ((fabs(turndelta) > 20) && ((NPC->client->NPC_class == CLASS_R2D2) || (NPC->client->NPC_class == CLASS_R5D2)))
00073         {
00074                 anim = NPC->client->ps.legsAnim;
00075                 if (turndelta<0)
00076                 {
00077                         if (anim != BOTH_TURN_LEFT1)
00078                         {
00079                                 NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_TURN_LEFT1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
00080                         }
00081                 }
00082                 else
00083                 {
00084                         if (anim != BOTH_TURN_RIGHT1)
00085                         {
00086                                 NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_TURN_RIGHT1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
00087                         }
00088                 }
00089         }
00090         else
00091         {
00092                         NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
00093         }
00094 
00095 }