codemp/game/FighterNPC.c File Reference

#include "g_headers.h"
#include "g_local.h"
#include "g_functions.h"
#include "g_vehicles.h"

Go to the source code of this file.

Defines

#define QAGAME
#define bgEntity_t   gentity_t
#define FIGHTER_MIN_TAKEOFF_FRACTION   0.7f

Functions

float DotToSpot (vec3_t spot, vec3_t from, vec3_t fromAngles)
void ChangeWeapon (gentity_t *ent, int newWeapon)
void PM_SetAnim (pmove_t *pm, int setAnimParts, int anim, int setAnimFlags, int blendTime)
int PM_AnimLength (int index, animNumber_t anim)
void G_VehicleTrace (trace_t *results, const vec3_t start, const vec3_t tMins, const vec3_t tMaxs, const vec3_t end, int passEntityNum, int contentmask)
qboolean BG_UnrestrainedPitchRoll (playerState_t *ps, Vehicle_t *pVeh)
void BG_ExternThisSoICanRecompileInDebug (Vehicle_t *pVeh, playerState_t *riderPS)
bool BG_FighterUpdate (Vehicle_t *pVeh, const usercmd_t *pUcmd, vec3_t trMins, vec3_t trMaxs, float gravity, void(*traceFunc)(trace_t *results, const vec3_t start, const vec3_t lmins, const vec3_t lmaxs, const vec3_t end, int passEntityNum, int contentMask))
qboolean FighterIsInSpace (gentity_t *gParent)
qboolean FighterOverValidLandingSurface (Vehicle_t *pVeh)
qboolean FighterIsLanded (Vehicle_t *pVeh, playerState_t *parentPS)
qboolean FighterIsLanding (Vehicle_t *pVeh, playerState_t *parentPS)
qboolean FighterIsLaunching (Vehicle_t *pVeh, playerState_t *parentPS)
qboolean FighterSuspended (Vehicle_t *pVeh, playerState_t *parentPS)
void BG_VehicleTurnRateForSpeed (Vehicle_t *pVeh, float speed, float *mPitchOverride, float *mYawOverride)
void G_SetFighterVehicleFunctions (vehicleInfo_t *pVehInfo)
void G_AllocateVehicleObject (Vehicle_t **pVeh)
void G_CreateFighterNPC (Vehicle_t **pVeh, const char *strType)

Variables

vmCvar_t cg_thirdPersonAlpha
vec3_t playerMins
vec3_t playerMaxs
cvar_tg_speederControlScheme


Define Documentation

#define bgEntity_t   gentity_t
 

Definition at line 68 of file FighterNPC.c.

#define FIGHTER_MIN_TAKEOFF_FRACTION   0.7f
 

Definition at line 366 of file FighterNPC.c.

#define QAGAME
 

Definition at line 33 of file FighterNPC.c.


Function Documentation

void BG_ExternThisSoICanRecompileInDebug Vehicle_t pVeh,
playerState_t riderPS
 

Definition at line 641 of file bg_pmove.c.

References playerState_t, and Vehicle_t.

00642 {
00643 /*
00644         float pitchSubtract, pitchDelta, yawDelta;
00645         //Com_Printf( S_COLOR_RED"PITCH: %4.2f, YAW: %4.2f, ROLL: %4.2f\n", riderPS->viewangles[0],riderPS->viewangles[1],riderPS->viewangles[2]);
00646         yawDelta = AngleSubtract(riderPS->viewangles[YAW],pVeh->m_vPrevRiderViewAngles[YAW]);
00647 #ifndef QAGAME
00648         if ( !cg_paused.integer )
00649         {
00650                 //Com_Printf( "%d - yawDelta %4.2f\n", pm->cmd.serverTime, yawDelta );
00651         }
00652 #endif
00653         yawDelta *= (4.0f*pVeh->m_fTimeModifier);
00654         pVeh->m_vOrientation[ROLL] -= yawDelta;
00655 
00656         pitchDelta = AngleSubtract(riderPS->viewangles[PITCH],pVeh->m_vPrevRiderViewAngles[PITCH]);
00657         pitchDelta *= (2.0f*pVeh->m_fTimeModifier);
00658         pitchSubtract = pitchDelta * (fabs(pVeh->m_vOrientation[ROLL])/90.0f);
00659         pVeh->m_vOrientation[PITCH] += pitchDelta-pitchSubtract;
00660         if ( pVeh->m_vOrientation[ROLL] > 0 )
00661         {
00662                 pVeh->m_vOrientation[YAW] += pitchSubtract;
00663         }
00664         else
00665         {
00666                 pVeh->m_vOrientation[YAW] -= pitchSubtract;
00667         }
00668         pVeh->m_vOrientation[PITCH] = AngleNormalize180( pVeh->m_vOrientation[PITCH] );
00669         pVeh->m_vOrientation[YAW] = AngleNormalize360( pVeh->m_vOrientation[YAW] );
00670         pVeh->m_vOrientation[ROLL] = AngleNormalize180( pVeh->m_vOrientation[ROLL] );
00671 
00672         VectorCopy( riderPS->viewangles, pVeh->m_vPrevRiderViewAngles );
00673 */
00674 }

bool BG_FighterUpdate Vehicle_t pVeh,
const usercmd_t pUcmd,
vec3_t  trMins,
vec3_t  trMaxs,
float  gravity,
void(*  traceFunc)(trace_t *results, const vec3_t start, const vec3_t lmins, const vec3_t lmaxs, const vec3_t end, int passEntityNum, int contentMask)
 

Definition at line 96 of file FighterNPC.c.

References Com_Error(), CONTENTS_BODY, EF_DEAD, playerState_s::eFlags, ERR_DROP, vehicleInfo_t::Ghost, vehicleInfo_t::gravity, playerState_s::gravity, vehicleInfo_t::landingHeight, Vehicle_s::m_LandTrace, Vehicle_s::m_pParentEntity, Vehicle_s::m_pPilot, Vehicle_s::m_ppPassengers, Vehicle_s::m_pVehicleInfo, MASK_NPCSOLID, vehicleInfo_t::maxPassengers, vehicleInfo_t::name, entityState_s::number, playerState_s::origin, bgEntity_s::playerState, playerState_t, qboolean, qfalse, bgEntity_s::s, STAT_HEALTH, playerState_s::stats, usercmd_t, vec3_t, VectorCopy, and Vehicle_t.

Referenced by PmoveSingle().

00098 {
00099         vec3_t          bottom;
00100         playerState_t *parentPS;
00101         qboolean        isDead = qfalse;
00102 #ifdef QAGAME //don't do this on client
00103         int i;
00104 
00105         // Make sure the riders are not visible or collidable.
00106         pVeh->m_pVehicleInfo->Ghost( pVeh, pVeh->m_pPilot );
00107         for ( i = 0; i < pVeh->m_pVehicleInfo->maxPassengers; i++ )
00108         {
00109                 pVeh->m_pVehicleInfo->Ghost( pVeh, pVeh->m_ppPassengers[i] );
00110         }
00111 #endif
00112 
00113 
00114 #ifdef _JK2MP
00115         parentPS = pVeh->m_pParentEntity->playerState;
00116 #else
00117         parentPS = &pVeh->m_pParentEntity->client->ps;
00118 #endif
00119 
00120         if (!parentPS)
00121         {
00122                 Com_Error(ERR_DROP, "NULL PS in BG_FighterUpdate (%s)", pVeh->m_pVehicleInfo->name);
00123                 return false;
00124         }
00125 
00126         // If we have a pilot, take out gravity (it's a flying craft...).
00127         if ( pVeh->m_pPilot )
00128         {
00129                 parentPS->gravity = 0;
00130 #ifndef _JK2MP //don't need this flag in mp, I.. guess
00131                 pVeh->m_pParentEntity->svFlags |= SVF_CUSTOM_GRAVITY;
00132 #endif
00133         }
00134         else
00135         {
00136 #ifndef _JK2MP //don't need this flag in mp, I.. guess
00137                 pVeh->m_pParentEntity->svFlags &= ~SVF_CUSTOM_GRAVITY;
00138 #else //in MP set grav back to normal gravity
00139                 if (pVeh->m_pVehicleInfo->gravity)
00140                 {
00141                         parentPS->gravity = pVeh->m_pVehicleInfo->gravity;
00142                 }
00143                 else
00144                 { //it doesn't have gravity specified apparently
00145                         parentPS->gravity = gravity;
00146                 }
00147 #endif
00148         }
00149 
00150 #ifdef _JK2MP
00151         isDead = (qboolean)((parentPS->eFlags&EF_DEAD)!=0);
00152 #else
00153         isDead = (parentPS->stats[STAT_HEALTH] <= 0 );
00154 #endif
00155 
00156         /*
00157         if ( isDead || 
00158                 (pVeh->m_pVehicleInfo->surfDestruction &&
00159                         pVeh->m_iRemovedSurfaces ) )
00160         {//can't land if dead or spiralling out of control
00161                 pVeh->m_LandTrace.fraction = 1.0f;
00162                 pVeh->m_LandTrace.contents = pVeh->m_LandTrace.surfaceFlags = 0;
00163                 VectorClear( pVeh->m_LandTrace.plane.normal );
00164                 pVeh->m_LandTrace.allsolid = qfalse;
00165                 pVeh->m_LandTrace.startsolid = qfalse;
00166         }
00167         else
00168         {
00169         */
00170         //argh, no, I need to have a way to see when they impact the ground while damaged. -rww
00171 
00172                 // Check to see if the fighter has taken off yet (if it's a certain height above ground).
00173                 VectorCopy( parentPS->origin, bottom );
00174                 bottom[2] -= pVeh->m_pVehicleInfo->landingHeight;
00175 
00176                 traceFunc( &pVeh->m_LandTrace, parentPS->origin, trMins, trMaxs, bottom, pVeh->m_pParentEntity->s.number, (MASK_NPCSOLID&~CONTENTS_BODY) );
00177         //}
00178 
00179         return true;
00180 }

qboolean BG_UnrestrainedPitchRoll playerState_t ps,
Vehicle_t pVeh
 

Definition at line 7785 of file bg_pmove.c.

07786 {
07787         if ( bg_fighterAltControl.integer
07788                 && ps->clientNum < MAX_CLIENTS //real client
07789                 && ps->m_iVehicleNum//in a vehicle
07790                 && pVeh //valid vehicle data pointer
07791                 && pVeh->m_pVehicleInfo//valid vehicle info
07792                 && pVeh->m_pVehicleInfo->type == VH_FIGHTER )//fighter
07793                 //FIXME: specify per vehicle instead of assuming true for all fighters
07794                 //FIXME: map/server setting?
07795         {//can roll and pitch without limitation!
07796                 return qtrue;
07797         }
07798         return qfalse;
07799 }

void BG_VehicleTurnRateForSpeed Vehicle_t pVeh,
float  speed,
float *  mPitchOverride,
float *  mYawOverride
 

Definition at line 676 of file bg_pmove.c.

References trace_t::fraction, Vehicle_s::m_LandTrace, Vehicle_s::m_pVehicleInfo, MIN_LANDING_SLOPE, vehicleInfo_t::mousePitch, vehicleInfo_t::mouseYaw, cplane_s::normal, trace_t::plane, vehicleInfo_t::speedDependantTurning, vehicleInfo_t::speedMax, and Vehicle_t.

Referenced by CG_DrawActiveFrame().

00677 {
00678         if ( pVeh && pVeh->m_pVehicleInfo )
00679         {
00680                 float speedFrac = 1.0f;
00681                 if ( pVeh->m_pVehicleInfo->speedDependantTurning )
00682                 {
00683                         if ( pVeh->m_LandTrace.fraction >= 1.0f 
00684                                 || pVeh->m_LandTrace.plane.normal[2] < MIN_LANDING_SLOPE  )
00685                         {
00686                                 speedFrac = (speed/(pVeh->m_pVehicleInfo->speedMax*0.75f));
00687                                 if ( speedFrac < 0.25f )
00688                                 {
00689                                         speedFrac = 0.25f;
00690                                 }
00691                                 else if ( speedFrac > 1.0f )
00692                                 {
00693                                         speedFrac = 1.0f;
00694                                 }
00695                         }
00696                 }
00697                 if ( pVeh->m_pVehicleInfo->mousePitch )
00698                 {
00699                         *mPitchOverride = pVeh->m_pVehicleInfo->mousePitch*speedFrac;
00700                 }
00701                 if ( pVeh->m_pVehicleInfo->mouseYaw )
00702                 {
00703                         *mYawOverride = pVeh->m_pVehicleInfo->mouseYaw*speedFrac;
00704                 }
00705         }
00706 }

void ChangeWeapon gentity_t ent,
int  newWeapon
 

Definition at line 570 of file NPC_combat.c.

References gNPC_t::aiFlags, playerState_s::ammo, weaponData_s::ammoIndex, gNPC_t::attackHold, gNPC_t::burstCount, gNPC_t::burstMax, gNPC_t::burstMean, gNPC_t::burstMin, gNPC_t::burstSpacing, CLASS_REELO, gentity_s::client, clientPersistant_t::cmd, gNPC_t::currentAmmo, g_spskill, gentity_t, vmCvar_t::integer, gentity_s::NPC, gclient_s::NPC_class, NPCAI_BURST_WEAPON, gentity_s::parent, gclient_s::pers, gclient_s::ps, SCF_ALT_FIRE, gNPC_t::scriptFlags, gNPC_t::shotTime, gentity_s::wait, usercmd_s::weapon, playerState_s::weapon, weaponData, WP_BLASTER, WP_BOWCASTER, WP_BRYAR_PISTOL, WP_DEMP2, WP_DISRUPTOR, WP_EMPLACED_GUN, WP_FLECHETTE, WP_REPEATER, WP_ROCKET_LAUNCHER, WP_SABER, WP_STUN_BATON, and WP_THERMAL.

00571 {
00572         if ( !ent || !ent->client || !ent->NPC )
00573         {
00574                 return;
00575         }
00576 
00577         ent->client->ps.weapon = newWeapon;
00578         ent->client->pers.cmd.weapon = newWeapon;
00579         ent->NPC->shotTime = 0;
00580         ent->NPC->burstCount = 0;
00581         ent->NPC->attackHold = 0;
00582         ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[newWeapon].ammoIndex];
00583 
00584         switch ( newWeapon ) 
00585         {
00586         case WP_BRYAR_PISTOL://prifle
00587                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00588                 ent->NPC->burstSpacing = 1000;//attackdebounce
00589                 break;
00590 
00591                 /*
00592         case WP_BLASTER_PISTOL:
00593                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00594         //      ent->NPC->burstSpacing = 1000;//attackdebounce
00595                 if ( g_spskill.integer == 0 )
00596                         ent->NPC->burstSpacing = 1000;//attack debounce
00597                 else if ( g_spskill.integer == 1 )
00598                         ent->NPC->burstSpacing = 750;//attack debounce
00599                 else 
00600                         ent->NPC->burstSpacing = 500;//attack debounce
00601                 break;
00602                 */
00603                 //rwwFIXMEFIXME: support WP_BLASTER_PISTOL and WP_BOT_LASER
00604 
00605                 /*
00606         case WP_BOT_LASER://probe attack
00607                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00608         //      ent->NPC->burstSpacing = 600;//attackdebounce
00609                 if ( g_spskill.integer == 0 )
00610                         ent->NPC->burstSpacing = 600;//attack debounce
00611                 else if ( g_spskill.integer == 1 )
00612                         ent->NPC->burstSpacing = 400;//attack debounce
00613                 else 
00614                         ent->NPC->burstSpacing = 200;//attack debounce
00615                 break;
00616                 */
00617 
00618         case WP_SABER:
00619                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00620                 ent->NPC->burstSpacing = 0;//attackdebounce
00621                 break;
00622 
00623         case WP_DISRUPTOR:
00624                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00625                 if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
00626                 {
00627                         switch( g_spskill.integer )
00628                         {
00629                         case 0:
00630                                 ent->NPC->burstSpacing = 2500;//attackdebounce
00631                                 break;
00632                         case 1:
00633                                 ent->NPC->burstSpacing = 2000;//attackdebounce
00634                                 break;
00635                         case 2:
00636                                 ent->NPC->burstSpacing = 1500;//attackdebounce
00637                                 break;
00638                         }
00639                 }
00640                 else
00641                 {
00642                         ent->NPC->burstSpacing = 1000;//attackdebounce
00643                 }
00644                 break;
00645 
00646         case WP_BOWCASTER:
00647                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00648         //      ent->NPC->burstSpacing = 1000;//attackdebounce
00649                 if ( g_spskill.integer == 0 )
00650                         ent->NPC->burstSpacing = 1000;//attack debounce
00651                 else if ( g_spskill.integer == 1 )
00652                         ent->NPC->burstSpacing = 750;//attack debounce
00653                 else 
00654                         ent->NPC->burstSpacing = 500;//attack debounce
00655                 break;
00656 
00657         case WP_REPEATER:
00658                 if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
00659                 {
00660                         ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00661                         ent->NPC->burstSpacing = 2000;//attackdebounce
00662                 }
00663                 else
00664                 {
00665                         ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
00666                         ent->NPC->burstMin = 3;
00667                         ent->NPC->burstMean = 6;
00668                         ent->NPC->burstMax = 10;
00669                         if ( g_spskill.integer == 0 )
00670                                 ent->NPC->burstSpacing = 1500;//attack debounce
00671                         else if ( g_spskill.integer == 1 )
00672                                 ent->NPC->burstSpacing = 1000;//attack debounce
00673                         else 
00674                                 ent->NPC->burstSpacing = 500;//attack debounce
00675                 }
00676                 break;
00677 
00678         case WP_DEMP2:
00679                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00680                 ent->NPC->burstSpacing = 1000;//attackdebounce
00681                 break;
00682 
00683         case WP_FLECHETTE:
00684                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00685                 if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
00686                 {
00687                         ent->NPC->burstSpacing = 2000;//attackdebounce
00688                 }
00689                 else
00690                 {
00691                         ent->NPC->burstSpacing = 1000;//attackdebounce
00692                 }
00693                 break;
00694 
00695         case WP_ROCKET_LAUNCHER:
00696                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00697         //      ent->NPC->burstSpacing = 2500;//attackdebounce
00698                 if ( g_spskill.integer == 0 )
00699                         ent->NPC->burstSpacing = 2500;//attack debounce
00700                 else if ( g_spskill.integer == 1 )
00701                         ent->NPC->burstSpacing = 2000;//attack debounce
00702                 else 
00703                         ent->NPC->burstSpacing = 1500;//attack debounce
00704                 break;
00705 
00706         case WP_THERMAL:
00707                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00708         //      ent->NPC->burstSpacing = 3000;//attackdebounce
00709                 if ( g_spskill.integer == 0 )
00710                         ent->NPC->burstSpacing = 3000;//attack debounce
00711                 else if ( g_spskill.integer == 1 )
00712                         ent->NPC->burstSpacing = 2500;//attack debounce
00713                 else 
00714                         ent->NPC->burstSpacing = 2000;//attack debounce
00715                 break;
00716 
00717         /*
00718         case WP_SABER:
00719                 ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
00720                 ent->NPC->burstMin = 5;//0.5 sec
00721                 ent->NPC->burstMean = 10;//1 second
00722                 ent->NPC->burstMax = 20;//3 seconds
00723                 ent->NPC->burstSpacing = 2000;//2 seconds
00724                 ent->NPC->attackHold = 1000;//Hold attack button for a 1-second burst
00725                 break;
00726         
00727         case WP_TRICORDER:
00728                 ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
00729                 ent->NPC->burstMin = 5;
00730                 ent->NPC->burstMean = 10;
00731                 ent->NPC->burstMax = 30;
00732                 ent->NPC->burstSpacing = 1000;
00733                 break;
00734         */
00735 
00736         case WP_BLASTER:
00737                 if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
00738                 {
00739                         ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
00740                         ent->NPC->burstMin = 3;
00741                         ent->NPC->burstMean = 3;
00742                         ent->NPC->burstMax = 3;
00743                         if ( g_spskill.integer == 0 )
00744                                 ent->NPC->burstSpacing = 1500;//attack debounce
00745                         else if ( g_spskill.integer == 1 )
00746                                 ent->NPC->burstSpacing = 1000;//attack debounce
00747                         else 
00748                                 ent->NPC->burstSpacing = 500;//attack debounce
00749                 }
00750                 else
00751                 {
00752                         ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00753                         if ( g_spskill.integer == 0 )
00754                                 ent->NPC->burstSpacing = 1000;//attack debounce
00755                         else if ( g_spskill.integer == 1 )
00756                                 ent->NPC->burstSpacing = 750;//attack debounce
00757                         else 
00758                                 ent->NPC->burstSpacing = 500;//attack debounce
00759                 //      ent->NPC->burstSpacing = 1000;//attackdebounce
00760                 }
00761                 break;
00762 
00763         case WP_STUN_BATON:
00764                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00765                 ent->NPC->burstSpacing = 1000;//attackdebounce
00766                 break;
00767 
00768                 /*
00769         case WP_ATST_MAIN:
00770         case WP_ATST_SIDE:
00771                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00772         //      ent->NPC->burstSpacing = 1000;//attackdebounce
00773                         if ( g_spskill.integer == 0 )
00774                                 ent->NPC->burstSpacing = 1000;//attack debounce
00775                         else if ( g_spskill.integer == 1 )
00776                                 ent->NPC->burstSpacing = 750;//attack debounce
00777                         else 
00778                                 ent->NPC->burstSpacing = 500;//attack debounce
00779                 break;
00780                 */
00781                 //rwwFIXMEFIXME: support for atst weaps
00782 
00783         case WP_EMPLACED_GUN:
00784                 //FIXME: give some designer-control over this?
00785                 if ( ent->client && ent->client->NPC_class == CLASS_REELO )
00786                 {
00787                         ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00788                         ent->NPC->burstSpacing = 1000;//attack debounce
00789         //              if ( g_spskill.integer == 0 )
00790         //                      ent->NPC->burstSpacing = 300;//attack debounce
00791         //              else if ( g_spskill.integer == 1 )
00792         //                      ent->NPC->burstSpacing = 200;//attack debounce
00793         //              else 
00794         //                      ent->NPC->burstSpacing = 100;//attack debounce
00795                 }
00796                 else
00797                 {
00798                         ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
00799                         ent->NPC->burstMin = 2; // 3 shots, really
00800                         ent->NPC->burstMean = 2;
00801                         ent->NPC->burstMax = 2;
00802 
00803                         if ( ent->parent ) // if we have an owner, it should be the chair at this point...so query the chair for its shot debounce times, etc.
00804                         {
00805                                 if ( g_spskill.integer == 0 )
00806                                 {
00807                                         ent->NPC->burstSpacing = ent->parent->wait + 400;//attack debounce
00808                                         ent->NPC->burstMin = ent->NPC->burstMax = 1; // two shots
00809                                 }
00810                                 else if ( g_spskill.integer == 1 )
00811                                 {
00812                                         ent->NPC->burstSpacing = ent->parent->wait + 200;//attack debounce
00813                                 }
00814                                 else 
00815                                 {
00816                                         ent->NPC->burstSpacing = ent->parent->wait;//attack debounce
00817                                 }
00818                         }
00819                         else
00820                         {
00821                                 if ( g_spskill.integer == 0 )
00822                                 {
00823                                         ent->NPC->burstSpacing = 1200;//attack debounce
00824                                         ent->NPC->burstMin = ent->NPC->burstMax = 1; // two shots
00825                                 }
00826                                 else if ( g_spskill.integer == 1 )
00827                                 {
00828                                         ent->NPC->burstSpacing = 1000;//attack debounce
00829                                 }
00830                                 else 
00831                                 {
00832                                         ent->NPC->burstSpacing = 800;//attack debounce
00833                                 }
00834                         }
00835                 }
00836                 break;
00837 
00838         default:
00839                 ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
00840                 break;
00841         }
00842 }

float DotToSpot vec3_t  spot,
vec3_t  from,
vec3_t  fromAngles
 

qboolean FighterIsInSpace gentity_t gParent  ) 
 

Definition at line 273 of file FighterNPC.c.

References gentity_s::client, ENTITYNUM_WORLD, gentity_t, gclient_s::inSpaceIndex, qboolean, qfalse, and qtrue.

00274 {
00275         if ( gParent 
00276                 && gParent->client 
00277                 && gParent->client->inSpaceIndex
00278                 && gParent->client->inSpaceIndex < ENTITYNUM_WORLD )
00279         {
00280                 return qtrue;
00281         }
00282         return qfalse;
00283 }

qboolean FighterIsLanded Vehicle_t pVeh,
playerState_t parentPS
 

Definition at line 297 of file FighterNPC.c.

References FighterOverValidLandingSurface(), playerState_t, qboolean, qfalse, qtrue, playerState_s::speed, and Vehicle_t.

Referenced by G_MissileImpact(), and PM_VehicleImpact().

00298 {
00299         if ( FighterOverValidLandingSurface( pVeh )
00300                 && !parentPS->speed )//stopped
00301         {
00302                 return qtrue;
00303         }
00304         return qfalse;
00305 }

qboolean FighterIsLanding Vehicle_t pVeh,
playerState_t parentPS
 

Definition at line 307 of file FighterNPC.c.

References FighterOverValidLandingSurface(), usercmd_s::forwardmove, vehicleInfo_t::Inhabited, Vehicle_s::m_pVehicleInfo, Vehicle_s::m_ucmd, MIN_LANDING_SPEED, playerState_t, QAGAME, qboolean, qfalse, qtrue, playerState_s::speed, usercmd_s::upmove, and Vehicle_t.

00308 {
00309 
00310         if ( FighterOverValidLandingSurface( pVeh )
00311 #ifdef QAGAME//only do this check on GAME side, because if it's CGAME, it's being predicted, and it's only predicted if the local client is the driver
00312                 && pVeh->m_pVehicleInfo->Inhabited( pVeh )//has to have a driver in order to be capable of landing
00313 #endif
00314                 && (pVeh->m_ucmd.forwardmove < 0||pVeh->m_ucmd.upmove<0) //decelerating or holding crouch button
00315                 && parentPS->speed <= MIN_LANDING_SPEED )//going slow enough to start landing - was using pVeh->m_pVehicleInfo->speedIdle, but that's still too fast
00316         {
00317                 return qtrue;
00318         }
00319         return qfalse;
00320 }

qboolean FighterIsLaunching Vehicle_t pVeh,
playerState_t parentPS
 

Definition at line 322 of file FighterNPC.c.

References FighterOverValidLandingSurface(), vehicleInfo_t::Inhabited, Vehicle_s::m_pVehicleInfo, Vehicle_s::m_ucmd, playerState_t, QAGAME, qboolean, qfalse, qtrue, playerState_s::speed, usercmd_s::upmove, and Vehicle_t.

00323 {
00324 
00325         if ( FighterOverValidLandingSurface( pVeh )
00326 #ifdef QAGAME//only do this check on GAME side, because if it's CGAME, it's being predicted, and it's only predicted if the local client is the driver
00327                 && pVeh->m_pVehicleInfo->Inhabited( pVeh )//has to have a driver in order to be capable of landing
00328 #endif
00329                 && pVeh->m_ucmd.upmove > 0 //trying to take off
00330                 && parentPS->speed <= 200.0f )//going slow enough to start landing - was using pVeh->m_pVehicleInfo->speedIdle, but that's still too fast
00331         {
00332                 return qtrue;
00333         }
00334         return qfalse;
00335 }

qboolean FighterOverValidLandingSurface Vehicle_t pVeh  ) 
 

Definition at line 286 of file FighterNPC.c.

References trace_t::fraction, Vehicle_s::m_LandTrace, MIN_LANDING_SLOPE, cplane_s::normal, trace_t::plane, qboolean, qfalse, qtrue, and Vehicle_t.

Referenced by FighterIsLanded(), FighterIsLanding(), and FighterIsLaunching().

00287 {
00288         if ( pVeh->m_LandTrace.fraction < 1.0f //ground present
00289                 && pVeh->m_LandTrace.plane.normal[2] >= MIN_LANDING_SLOPE )//flat enough
00290                 //FIXME: also check for a certain surface flag ... "landing zones"?
00291         {
00292                 return qtrue;
00293         }
00294         return qfalse;
00295 }

qboolean FighterSuspended Vehicle_t pVeh,
playerState_t parentPS
 

Definition at line 337 of file FighterNPC.c.

References usercmd_s::forwardmove, gentity_t, Vehicle_s::m_pParentEntity, Vehicle_s::m_pPilot, Vehicle_s::m_ucmd, NULL, playerState_t, qboolean, qfalse, qtrue, playerState_s::speed, and Vehicle_t.

00338 {
00339 #ifdef QAGAME//only do this check on GAME side, because if it's CGAME, it's being predicted, and it's only predicted if the local client is the driver
00340         if (!pVeh->m_pPilot//empty
00341                 && !parentPS->speed//not moving
00342                 && pVeh->m_ucmd.forwardmove <= 0//not trying to go forward for whatever reason
00343                 && pVeh->m_pParentEntity != NULL
00344                 && (((gentity_t *)pVeh->m_pParentEntity)->spawnflags&2) )//SUSPENDED spawnflag is on
00345         {
00346                 return qtrue;
00347         }
00348         return qfalse;
00349 #elif CGAME
00350         return qfalse;
00351 #endif
00352 }

void G_AllocateVehicleObject Vehicle_t **  pVeh  ) 
 

Definition at line 388 of file g_utils.c.

00389 {
00390         int i = 0;
00391 
00392         if (!g_vehiclePoolInit)
00393         {
00394                 g_vehiclePoolInit = qtrue;
00395                 memset(g_vehiclePoolOccupied, 0, sizeof(g_vehiclePoolOccupied));
00396         }
00397 
00398         while (i < MAX_VEHICLES_AT_A_TIME)
00399         { //iterate through and try to find a free one
00400                 if (!g_vehiclePoolOccupied[i])
00401                 {
00402                         g_vehiclePoolOccupied[i] = qtrue;
00403                         memset(&g_vehiclePool[i], 0, sizeof(Vehicle_t));
00404                         *pVeh = &g_vehiclePool[i];
00405                         return;
00406                 }
00407                 i++;
00408         }
00409         Com_Error(ERR_DROP, "Ran out of vehicle pool slots.");
00410 }

void G_CreateFighterNPC Vehicle_t **  pVeh,
const char *  strType
 

Definition at line 1998 of file FighterNPC.c.

References BG_Alloc(), BG_VehicleGetIndex(), G_AllocateVehicleObject(), g_vehicleInfo, memset(), qtrue, and Vehicle_t.

Referenced by CG_G2AnimEntModelLoad(), and NPC_Spawn_Do().

01999 {
02000         // Allocate the Vehicle.
02001 #ifdef _JK2MP
02002 #ifdef QAGAME
02003         //these will remain on entities on the client once allocated because the pointer is
02004         //never stomped. on the server, however, when an ent is freed, the entity struct is
02005         //memset to 0, so this memory would be lost..
02006     G_AllocateVehicleObject(pVeh);
02007 #else
02008         if (!*pVeh)
02009         { //only allocate a new one if we really have to
02010                 (*pVeh) = (Vehicle_t *) BG_Alloc( sizeof(Vehicle_t) );
02011         }
02012 #endif
02013         memset(*pVeh, 0, sizeof(Vehicle_t));
02014 #else
02015         (*pVeh) = (Vehicle_t *) gi.Malloc( sizeof(Vehicle_t), TAG_G_ALLOC, qtrue );
02016 #endif
02017         (*pVeh)->m_pVehicleInfo = &g_vehicleInfo[BG_VehicleGetIndex( strType )];
02018 }

void G_SetFighterVehicleFunctions vehicleInfo_t pVehInfo  ) 
 

Definition at line 1952 of file FighterNPC.c.

References vehicleInfo_t::AnimateRiders, vehicleInfo_t::AnimateVehicle, vehicleInfo_t::AttachRiders, vehicleInfo_t::Board, vehicleInfo_t::Eject, vehicleInfo_t::ProcessMoveCommands, vehicleInfo_t::ProcessOrientCommands, and vehicleInfo_t::Update.

Referenced by BG_SetSharedVehicleFunctions().

01953 {
01954 #ifdef QAGAME //ONLY in SP or on server, not cgame
01955         pVehInfo->AnimateVehicle                        =               AnimateVehicle;
01956         pVehInfo->AnimateRiders                         =               AnimateRiders;
01957 //      pVehInfo->ValidateBoard                         =               ValidateBoard;
01958 //      pVehInfo->SetParent                                     =               SetParent;
01959 //      pVehInfo->SetPilot                                      =               SetPilot;
01960 //      pVehInfo->AddPassenger                          =               AddPassenger;
01961 //      pVehInfo->Animate                                       =               Animate;
01962         pVehInfo->Board                                         =               Board;
01963         pVehInfo->Eject                                         =               Eject;
01964 //      pVehInfo->EjectAll                                      =               EjectAll;
01965 //      pVehInfo->StartDeathDelay                       =               StartDeathDelay;
01966 //      pVehInfo->DeathUpdate                           =               DeathUpdate;
01967 //      pVehInfo->RegisterAssets                        =               RegisterAssets;
01968 //      pVehInfo->Initialize                            =               Initialize;
01969         pVehInfo->Update                                        =               Update;
01970 //      pVehInfo->UpdateRider                           =               UpdateRider;
01971 #endif //game-only
01972         pVehInfo->ProcessMoveCommands           =               ProcessMoveCommands;
01973         pVehInfo->ProcessOrientCommands         =               ProcessOrientCommands;
01974 
01975 #ifndef QAGAME //cgame prediction attachment func
01976         pVehInfo->AttachRiders                          =               AttachRidersGeneric;
01977 #endif
01978 //      pVehInfo->AttachRiders                          =               AttachRiders;
01979 //      pVehInfo->Ghost                                         =               Ghost;
01980 //      pVehInfo->UnGhost                                       =               UnGhost;
01981 //      pVehInfo->Inhabited                                     =               Inhabited;
01982 }

void G_VehicleTrace trace_t results,
const vec3_t  start,
const vec3_t  tMins,
const vec3_t  tMaxs,
const vec3_t  end,
int  passEntityNum,
int  contentmask
 

Definition at line 99 of file g_vehicles.c.

00100 {
00101 #ifdef _JK2MP
00102         trap_Trace(results, start, tMins, tMaxs, end, passEntityNum, contentmask);
00103 #else
00104         gi.trace( results, start, tMins, tMaxs, end, passEntityNum, contentmask );
00105 #endif
00106 }

int PM_AnimLength int  index,
animNumber_t  anim
 

Definition at line 1584 of file bg_panimate.c.

01585 {
01586         if (anim >= MAX_ANIMATIONS || !pm->animations)
01587         {
01588                 return -1;
01589         }
01590         if ( anim < 0 )
01591         {
01592                 Com_Error(ERR_DROP,"ERROR: anim %d < 0\n", anim );
01593         }
01594         return pm->animations[anim].numFrames * fabs((float)(pm->animations[anim].frameLerp));
01595 }

void PM_SetAnim pmove_t pm,
int  setAnimParts,
int  anim,
int  setAnimFlags,
int  blendTime
 


Variable Documentation

vmCvar_t cg_thirdPersonAlpha
 

Definition at line 73 of file FighterNPC.c.

cvar_t* g_speederControlScheme
 

Definition at line 76 of file FighterNPC.c.

vec3_t playerMaxs
 

Definition at line 75 of file FighterNPC.c.

vec3_t playerMins
 

Definition at line 74 of file FighterNPC.c.