Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

bg_misc.c File Reference

#include "q_shared.h"
#include "bg_public.h"

Include dependency graph for bg_misc.c:

Include dependency graph

Go to the source code of this file.

Functions

void BG_AddPredictableEventToPlayerstate (int newEvent, int eventParm, playerState_t *ps)
qboolean BG_CanItemBeGrabbed (int gametype, const entityState_t *ent, const playerState_t *ps)
void BG_EvaluateTrajectory (const trajectory_t *tr, int atTime, vec3_t result)
void BG_EvaluateTrajectoryDelta (const trajectory_t *tr, int atTime, vec3_t result)
gitem_tBG_FindItem (const char *pickupName)
gitem_tBG_FindItemForHoldable (holdable_t pw)
gitem_tBG_FindItemForPowerup (powerup_t pw)
gitem_tBG_FindItemForWeapon (weapon_t weapon)
void BG_PlayerStateToEntityState (playerState_t *ps, entityState_t *s, qboolean snap)
void BG_PlayerStateToEntityStateExtraPolate (playerState_t *ps, entityState_t *s, int time, qboolean snap)
qboolean BG_PlayerTouchesItem (playerState_t *ps, entityState_t *item, int atTime)
void BG_TouchJumpPad (playerState_t *ps, entityState_t *jumppad)
void trap_Cvar_VariableStringBuffer (const char *var_name, char *buffer, int bufsize)

Variables

gitem_t bg_itemlist []
int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1
char * eventnames []


Function Documentation

void BG_AddPredictableEventToPlayerstate int  newEvent,
int  eventParm,
playerState_t ps
 

Definition at line 1390 of file bg_misc.c.

References atof(), Com_Printf(), eventnames, playerState_s::eventParms, playerState_s::events, playerState_s::eventSequence, MAX_PS_EVENTS, playerState_t, playerState_s::pmove_framecount, and trap_Cvar_VariableStringBuffer().

Referenced by BG_TouchJumpPad(), CG_TouchItem(), G_AddPredictableEvent(), and PM_AddEvent().

01390                                                                                            {
01391 
01392 #ifdef _DEBUG
01393     {
01394         char buf[256];
01395         trap_Cvar_VariableStringBuffer("showevents", buf, sizeof(buf));
01396         if ( atof(buf) != 0 ) {
01397 #ifdef QAGAME
01398             Com_Printf(" game event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
01399 #else
01400             Com_Printf("Cgame event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
01401 #endif
01402         }
01403     }
01404 #endif
01405     ps->events[ps->eventSequence & (MAX_PS_EVENTS-1)] = newEvent;
01406     ps->eventParms[ps->eventSequence & (MAX_PS_EVENTS-1)] = eventParm;
01407     ps->eventSequence++;
01408 }

Here is the call graph for this function:

qboolean BG_CanItemBeGrabbed int  gametype,
const entityState_t ent,
const playerState_t ps
 

Definition at line 1039 of file bg_misc.c.

References playerState_s::ammo, bg_itemlist, Com_Error(), Com_Printf(), entityState_t, ERR_DROP, gametype, entityState_s::generic1, gitem_s::giTag, gitem_t, gitem_s::giType, IT_AMMO, IT_ARMOR, IT_BAD, IT_HEALTH, IT_HOLDABLE, IT_PERSISTANT_POWERUP, IT_POWERUP, IT_TEAM, IT_WEAPON, entityState_s::modelindex, entityState_s::modelindex2, playerState_s::persistant, playerState_t, playerState_s::powerups, PW_BLUEFLAG, PW_REDFLAG, qboolean, gitem_s::quantity, and playerState_s::stats.

Referenced by CG_TouchItem(), and Touch_Item().

01039                                                                                                 {
01040     gitem_t *item;
01041 #ifdef MISSIONPACK
01042     int     upperBound;
01043 #endif
01044 
01045     if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) {
01046         Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" );
01047     }
01048 
01049     item = &bg_itemlist[ent->modelindex];
01050 
01051     switch( item->giType ) {
01052     case IT_WEAPON:
01053         return qtrue;   // weapons are always picked up
01054 
01055     case IT_AMMO:
01056         if ( ps->ammo[ item->giTag ] >= 200 ) {
01057             return qfalse;      // can't hold any more
01058         }
01059         return qtrue;
01060 
01061     case IT_ARMOR:
01062 #ifdef MISSIONPACK
01063         if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {
01064             return qfalse;
01065         }
01066 
01067         // we also clamp armor to the maxhealth for handicapping
01068         if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
01069             upperBound = ps->stats[STAT_MAX_HEALTH];
01070         }
01071         else {
01072             upperBound = ps->stats[STAT_MAX_HEALTH] * 2;
01073         }
01074 
01075         if ( ps->stats[STAT_ARMOR] >= upperBound ) {
01076             return qfalse;
01077         }
01078 #else
01079         if ( ps->stats[STAT_ARMOR] >= ps->stats[STAT_MAX_HEALTH] * 2 ) {
01080             return qfalse;
01081         }
01082 #endif
01083         return qtrue;
01084 
01085     case IT_HEALTH:
01086         // small and mega healths will go over the max, otherwise
01087         // don't pick up if already at max
01088 #ifdef MISSIONPACK
01089         if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
01090             upperBound = ps->stats[STAT_MAX_HEALTH];
01091         }
01092         else
01093 #endif
01094         if ( item->quantity == 5 || item->quantity == 100 ) {
01095             if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] * 2 ) {
01096                 return qfalse;
01097             }
01098             return qtrue;
01099         }
01100 
01101         if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] ) {
01102             return qfalse;
01103         }
01104         return qtrue;
01105 
01106     case IT_POWERUP:
01107         return qtrue;   // powerups are always picked up
01108 
01109 #ifdef MISSIONPACK
01110     case IT_PERSISTANT_POWERUP:
01111         // can only hold one item at a time
01112         if ( ps->stats[STAT_PERSISTANT_POWERUP] ) {
01113             return qfalse;
01114         }
01115 
01116         // check team only
01117         if( ( ent->generic1 & 2 ) && ( ps->persistant[PERS_TEAM] != TEAM_RED ) ) {
01118             return qfalse;
01119         }
01120         if( ( ent->generic1 & 4 ) && ( ps->persistant[PERS_TEAM] != TEAM_BLUE ) ) {
01121             return qfalse;
01122         }
01123 
01124         return qtrue;
01125 #endif
01126 
01127     case IT_TEAM: // team items, such as flags
01128 #ifdef MISSIONPACK      
01129         if( gametype == GT_1FCTF ) {
01130             // neutral flag can always be picked up
01131             if( item->giTag == PW_NEUTRALFLAG ) {
01132                 return qtrue;
01133             }
01134             if (ps->persistant[PERS_TEAM] == TEAM_RED) {
01135                 if (item->giTag == PW_BLUEFLAG  && ps->powerups[PW_NEUTRALFLAG] ) {
01136                     return qtrue;
01137                 }
01138             } else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) {
01139                 if (item->giTag == PW_REDFLAG  && ps->powerups[PW_NEUTRALFLAG] ) {
01140                     return qtrue;
01141                 }
01142             }
01143         }
01144 #endif
01145         if( gametype == GT_CTF ) {
01146             // ent->modelindex2 is non-zero on items if they are dropped
01147             // we need to know this because we can pick up our dropped flag (and return it)
01148             // but we can't pick up our flag at base
01149             if (ps->persistant[PERS_TEAM] == TEAM_RED) {
01150                 if (item->giTag == PW_BLUEFLAG ||
01151                     (item->giTag == PW_REDFLAG && ent->modelindex2) ||
01152                     (item->giTag == PW_REDFLAG && ps->powerups[PW_BLUEFLAG]) )
01153                     return qtrue;
01154             } else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) {
01155                 if (item->giTag == PW_REDFLAG ||
01156                     (item->giTag == PW_BLUEFLAG && ent->modelindex2) ||
01157                     (item->giTag == PW_BLUEFLAG && ps->powerups[PW_REDFLAG]) )
01158                     return qtrue;
01159             }
01160         }
01161 
01162 #ifdef MISSIONPACK
01163         if( gametype == GT_HARVESTER ) {
01164             return qtrue;
01165         }
01166 #endif
01167         return qfalse;
01168 
01169     case IT_HOLDABLE:
01170         // can only hold one item at a time
01171         if ( ps->stats[STAT_HOLDABLE_ITEM] ) {
01172             return qfalse;
01173         }
01174         return qtrue;
01175 
01176         case IT_BAD:
01177             Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: IT_BAD" );
01178         default:
01179 #ifndef Q3_VM
01180 #ifndef NDEBUG // bk0001204
01181           Com_Printf("BG_CanItemBeGrabbed: unknown enum %d\n", item->giType );
01182 #endif
01183 #endif
01184          break;
01185     }
01186 
01187     return qfalse;
01188 }

Here is the call graph for this function:

void BG_EvaluateTrajectory const trajectory_t tr,
int  atTime,
vec3_t  result
 

Definition at line 1198 of file bg_misc.c.

References Com_Error(), DEFAULT_GRAVITY, ERR_DROP, M_PI, sin(), tr, TR_GRAVITY, TR_INTERPOLATE, TR_LINEAR, TR_LINEAR_STOP, TR_SINE, TR_STATIONARY, VectorCopy, and VectorMA.

Referenced by BG_PlayerTouchesItem(), CG_AddFragment(), CG_AddMoveScaleFade(), CG_AdjustPositionForMover(), CG_BloodTrail(), CG_CalcEntityLerpPositions(), CG_CheckEvents(), CG_ClipMoveToEntities(), CG_GrappleTrail(), CG_InterpolateEntityPosition(), CG_PlasmaTrail(), CG_ResetPlayerEntity(), CG_RocketTrail(), G_ExplodeMissile(), G_MoverTeam(), G_RunItem(), G_RunMissile(), and SetMoverState().

01198                                                                                 {
01199     float       deltaTime;
01200     float       phase;
01201 
01202     switch( tr->trType ) {
01203     case TR_STATIONARY:
01204     case TR_INTERPOLATE:
01205         VectorCopy( tr->trBase, result );
01206         break;
01207     case TR_LINEAR:
01208         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
01209         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
01210         break;
01211     case TR_SINE:
01212         deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
01213         phase = sin( deltaTime * M_PI * 2 );
01214         VectorMA( tr->trBase, phase, tr->trDelta, result );
01215         break;
01216     case TR_LINEAR_STOP:
01217         if ( atTime > tr->trTime + tr->trDuration ) {
01218             atTime = tr->trTime + tr->trDuration;
01219         }
01220         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
01221         if ( deltaTime < 0 ) {
01222             deltaTime = 0;
01223         }
01224         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
01225         break;
01226     case TR_GRAVITY:
01227         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
01228         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
01229         result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime;     // FIXME: local gravity...
01230         break;
01231     default:
01232         Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime );
01233         break;
01234     }
01235 }

Here is the call graph for this function:

void BG_EvaluateTrajectoryDelta const trajectory_t tr,
int  atTime,
vec3_t  result
 

Definition at line 1244 of file bg_misc.c.

References Com_Error(), cos(), DEFAULT_GRAVITY, ERR_DROP, M_PI, tr, TR_GRAVITY, TR_INTERPOLATE, TR_LINEAR, TR_LINEAR_STOP, TR_SINE, TR_STATIONARY, VectorClear, VectorCopy, and VectorScale.

Referenced by CG_Missile(), CG_ReflectVelocity(), G_BounceItem(), G_BounceMissile(), and G_MissileImpact().

01244                                                                                      {
01245     float   deltaTime;
01246     float   phase;
01247 
01248     switch( tr->trType ) {
01249     case TR_STATIONARY:
01250     case TR_INTERPOLATE:
01251         VectorClear( result );
01252         break;
01253     case TR_LINEAR:
01254         VectorCopy( tr->trDelta, result );
01255         break;
01256     case TR_SINE:
01257         deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
01258         phase = cos( deltaTime * M_PI * 2 );    // derivative of sin = cos
01259         phase *= 0.5;
01260         VectorScale( tr->trDelta, phase, result );
01261         break;
01262     case TR_LINEAR_STOP:
01263         if ( atTime > tr->trTime + tr->trDuration ) {
01264             VectorClear( result );
01265             return;
01266         }
01267         VectorCopy( tr->trDelta, result );
01268         break;
01269     case TR_GRAVITY:
01270         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
01271         VectorCopy( tr->trDelta, result );
01272         result[2] -= DEFAULT_GRAVITY * deltaTime;       // FIXME: local gravity...
01273         break;
01274     default:
01275         Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
01276         break;
01277     }
01278 }

Here is the call graph for this function:

gitem_t* BG_FindItem const char *  pickupName  ) 
 

Definition at line 992 of file bg_misc.c.

References bg_itemlist, gitem_s::classname, gitem_t, gitem_s::pickup_name, and Q_stricmp().

Referenced by ClearRegisteredItems(), ClientEvents(), Cmd_Give_f(), and G_CheckTeamItems().

00992                                                {
00993     gitem_t *it;
00994     
00995     for ( it = bg_itemlist + 1 ; it->classname ; it++ ) {
00996         if ( !Q_stricmp( it->pickup_name, pickupName ) )
00997             return it;
00998     }
00999 
01000     return NULL;
01001 }

Here is the call graph for this function:

gitem_t* BG_FindItemForHoldable holdable_t  pw  ) 
 

Definition at line 952 of file bg_misc.c.

References bg_itemlist, Com_Error(), ERR_DROP, gitem_s::giTag, gitem_t, gitem_s::giType, i, and IT_HOLDABLE.

Referenced by CG_UseItem().

00952                                                  {
00953     int     i;
00954 
00955     for ( i = 0 ; i < bg_numItems ; i++ ) {
00956         if ( bg_itemlist[i].giType == IT_HOLDABLE && bg_itemlist[i].giTag == pw ) {
00957             return &bg_itemlist[i];
00958         }
00959     }
00960 
00961     Com_Error( ERR_DROP, "HoldableItem not found" );
00962 
00963     return NULL;
00964 }

Here is the call graph for this function:

gitem_t* BG_FindItemForPowerup powerup_t  pw  ) 
 

Definition at line 931 of file bg_misc.c.

References bg_itemlist, gitem_s::giTag, gitem_t, gitem_s::giType, i, IT_POWERUP, and IT_TEAM.

Referenced by CG_DrawAreaPowerUp(), CG_DrawBlueFlagStatus(), CG_DrawFlagModel(), CG_DrawNewTeamInfo(), CG_DrawPowerups(), CG_DrawRedFlagStatus(), CG_DrawScores(), CG_DrawSelectedPlayerPowerup(), CG_DrawTeamOverlay(), CG_OneFlagStatus(), ClientEvents(), and TossClientItems().

00931                                                {
00932     int     i;
00933 
00934     for ( i = 0 ; i < bg_numItems ; i++ ) {
00935         if ( (bg_itemlist[i].giType == IT_POWERUP || 
00936                     bg_itemlist[i].giType == IT_TEAM ||
00937                     bg_itemlist[i].giType == IT_PERSISTANT_POWERUP) && 
00938             bg_itemlist[i].giTag == pw ) {
00939             return &bg_itemlist[i];
00940         }
00941     }
00942 
00943     return NULL;
00944 }

gitem_t* BG_FindItemForWeapon weapon_t  weapon  ) 
 

Definition at line 973 of file bg_misc.c.

References bg_itemlist, gitem_s::classname, Com_Error(), ERR_DROP, gitem_s::giTag, gitem_t, gitem_s::giType, and IT_WEAPON.

Referenced by ClearRegisteredItems(), InitShooter(), and TossClientItems().

00973                                                  {
00974     gitem_t *it;
00975     
00976     for ( it = bg_itemlist + 1 ; it->classname ; it++) {
00977         if ( it->giType == IT_WEAPON && it->giTag == weapon ) {
00978             return it;
00979         }
00980     }
00981 
00982     Com_Error( ERR_DROP, "Couldn't find item for weapon %i", weapon);
00983     return NULL;
00984 }

Here is the call graph for this function:

void BG_PlayerStateToEntityState playerState_t ps,
entityState_t s,
qboolean  snap
 

Definition at line 1458 of file bg_misc.c.

References entityState_s::angles2, entityState_s::apos, playerState_s::clientNum, entityState_s::clientNum, entityState_s::eFlags, playerState_s::eFlags, playerState_s::entityEventSequence, entityState_t, entityState_s::eType, entityState_s::event, entityState_s::eventParm, playerState_s::eventParms, playerState_s::events, playerState_s::eventSequence, playerState_s::externalEvent, playerState_s::externalEventParm, entityState_s::generic1, playerState_s::generic1, entityState_s::groundEntityNum, playerState_s::groundEntityNum, i, entityState_s::legsAnim, playerState_s::legsAnim, entityState_s::loopSound, playerState_s::loopSound, MAX_PS_EVENTS, playerState_s::movementDir, entityState_s::number, playerState_s::origin, playerState_t, PM_INTERMISSION, playerState_s::pm_type, entityState_s::pos, entityState_s::powerups, playerState_s::powerups, s, SnapVector, playerState_s::stats, entityState_s::torsoAnim, playerState_s::torsoAnim, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trType, VectorCopy, playerState_s::velocity, playerState_s::viewangles, entityState_s::weapon, and playerState_s::weapon.

Referenced by CG_AddPacketEntities(), CG_SetInitialSnapshot(), CG_SetNextSnap(), CG_TransitionSnapshot(), ClientEndFrame(), ClientSpawn(), ClientThink_real(), SendPendingPredictableEvents(), and TeleportPlayer().

01458                                                                                        {
01459     int     i;
01460 
01461     if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) {
01462         s->eType = ET_INVISIBLE;
01463     } else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {
01464         s->eType = ET_INVISIBLE;
01465     } else {
01466         s->eType = ET_PLAYER;
01467     }
01468 
01469     s->number = ps->clientNum;
01470 
01471     s->pos.trType = TR_INTERPOLATE;
01472     VectorCopy( ps->origin, s->pos.trBase );
01473     if ( snap ) {
01474         SnapVector( s->pos.trBase );
01475     }
01476     // set the trDelta for flag direction
01477     VectorCopy( ps->velocity, s->pos.trDelta );
01478 
01479     s->apos.trType = TR_INTERPOLATE;
01480     VectorCopy( ps->viewangles, s->apos.trBase );
01481     if ( snap ) {
01482         SnapVector( s->apos.trBase );
01483     }
01484 
01485     s->angles2[YAW] = ps->movementDir;
01486     s->legsAnim = ps->legsAnim;
01487     s->torsoAnim = ps->torsoAnim;
01488     s->clientNum = ps->clientNum;       // ET_PLAYER looks here instead of at number
01489                                         // so corpses can also reference the proper config
01490     s->eFlags = ps->eFlags;
01491     if ( ps->stats[STAT_HEALTH] <= 0 ) {
01492         s->eFlags |= EF_DEAD;
01493     } else {
01494         s->eFlags &= ~EF_DEAD;
01495     }
01496 
01497     if ( ps->externalEvent ) {
01498         s->event = ps->externalEvent;
01499         s->eventParm = ps->externalEventParm;
01500     } else if ( ps->entityEventSequence < ps->eventSequence ) {
01501         int     seq;
01502 
01503         if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {
01504             ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
01505         }
01506         seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
01507         s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
01508         s->eventParm = ps->eventParms[ seq ];
01509         ps->entityEventSequence++;
01510     }
01511 
01512     s->weapon = ps->weapon;
01513     s->groundEntityNum = ps->groundEntityNum;
01514 
01515     s->powerups = 0;
01516     for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
01517         if ( ps->powerups[ i ] ) {
01518             s->powerups |= 1 << i;
01519         }
01520     }
01521 
01522     s->loopSound = ps->loopSound;
01523     s->generic1 = ps->generic1;
01524 }

void BG_PlayerStateToEntityStateExtraPolate playerState_t ps,
entityState_t s,
int  time,
qboolean  snap
 

Definition at line 1534 of file bg_misc.c.

References entityState_s::angles2, entityState_s::apos, playerState_s::clientNum, entityState_s::clientNum, entityState_s::eFlags, playerState_s::eFlags, playerState_s::entityEventSequence, entityState_t, entityState_s::eType, entityState_s::event, entityState_s::eventParm, playerState_s::eventParms, playerState_s::events, playerState_s::eventSequence, playerState_s::externalEvent, playerState_s::externalEventParm, entityState_s::generic1, playerState_s::generic1, entityState_s::groundEntityNum, playerState_s::groundEntityNum, i, entityState_s::legsAnim, playerState_s::legsAnim, entityState_s::loopSound, playerState_s::loopSound, MAX_PS_EVENTS, playerState_s::movementDir, entityState_s::number, playerState_s::origin, playerState_t, PM_INTERMISSION, playerState_s::pm_type, entityState_s::pos, entityState_s::powerups, playerState_s::powerups, s, SnapVector, playerState_s::stats, entityState_s::torsoAnim, playerState_s::torsoAnim, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trDuration, trajectory_t::trTime, trajectory_t::trType, VectorCopy, playerState_s::velocity, playerState_s::viewangles, entityState_s::weapon, and playerState_s::weapon.

Referenced by ClientEndFrame(), and ClientThink_real().

01534                                                                                                             {
01535     int     i;
01536 
01537     if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) {
01538         s->eType = ET_INVISIBLE;
01539     } else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {
01540         s->eType = ET_INVISIBLE;
01541     } else {
01542         s->eType = ET_PLAYER;
01543     }
01544 
01545     s->number = ps->clientNum;
01546 
01547     s->pos.trType = TR_LINEAR_STOP;
01548     VectorCopy( ps->origin, s->pos.trBase );
01549     if ( snap ) {
01550         SnapVector( s->pos.trBase );
01551     }
01552     // set the trDelta for flag direction and linear prediction
01553     VectorCopy( ps->velocity, s->pos.trDelta );
01554     // set the time for linear prediction
01555     s->pos.trTime = time;
01556     // set maximum extra polation time
01557     s->pos.trDuration = 50; // 1000 / sv_fps (default = 20)
01558 
01559     s->apos.trType = TR_INTERPOLATE;
01560     VectorCopy( ps->viewangles, s->apos.trBase );
01561     if ( snap ) {
01562         SnapVector( s->apos.trBase );
01563     }
01564 
01565     s->angles2[YAW] = ps->movementDir;
01566     s->legsAnim = ps->legsAnim;
01567     s->torsoAnim = ps->torsoAnim;
01568     s->clientNum = ps->clientNum;       // ET_PLAYER looks here instead of at number
01569                                         // so corpses can also reference the proper config
01570     s->eFlags = ps->eFlags;
01571     if ( ps->stats[STAT_HEALTH] <= 0 ) {
01572         s->eFlags |= EF_DEAD;
01573     } else {
01574         s->eFlags &= ~EF_DEAD;
01575     }
01576 
01577     if ( ps->externalEvent ) {
01578         s->event = ps->externalEvent;
01579         s->eventParm = ps->externalEventParm;
01580     } else if ( ps->entityEventSequence < ps->eventSequence ) {
01581         int     seq;
01582 
01583         if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {
01584             ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
01585         }
01586         seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
01587         s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
01588         s->eventParm = ps->eventParms[ seq ];
01589         ps->entityEventSequence++;
01590     }
01591 
01592     s->weapon = ps->weapon;
01593     s->groundEntityNum = ps->groundEntityNum;
01594 
01595     s->powerups = 0;
01596     for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
01597         if ( ps->powerups[ i ] ) {
01598             s->powerups |= 1 << i;
01599         }
01600     }
01601 
01602     s->loopSound = ps->loopSound;
01603     s->generic1 = ps->generic1;
01604 }

qboolean BG_PlayerTouchesItem playerState_t ps,
entityState_t item,
int  atTime
 

Definition at line 1011 of file bg_misc.c.

References BG_EvaluateTrajectory(), entityState_t, playerState_s::origin, playerState_t, entityState_s::pos, qboolean, and vec3_t.

Referenced by CG_TouchItem(), and G_TouchTriggers().

01011                                                                                        {
01012     vec3_t      origin;
01013 
01014     BG_EvaluateTrajectory( &item->pos, atTime, origin );
01015 
01016     // we are ignoring ducked differences here
01017     if ( ps->origin[0] - origin[0] > 44
01018         || ps->origin[0] - origin[0] < -50
01019         || ps->origin[1] - origin[1] > 36
01020         || ps->origin[1] - origin[1] < -36
01021         || ps->origin[2] - origin[2] > 36
01022         || ps->origin[2] - origin[2] < -36 ) {
01023         return qfalse;
01024     }
01025 
01026     return qtrue;
01027 }

Here is the call graph for this function:

void BG_TouchJumpPad playerState_t ps,
entityState_t jumppad
 

Definition at line 1415 of file bg_misc.c.

References AngleNormalize180(), BG_AddPredictableEventToPlayerstate(), entityState_t, EV_JUMP_PAD, fabs(), playerState_s::jumppad_ent, playerState_s::jumppad_frame, entityState_s::number, entityState_s::origin2, p, PITCH, playerState_t, playerState_s::pm_type, playerState_s::pmove_framecount, playerState_s::powerups, vec3_t, vectoangles(), VectorCopy, and playerState_s::velocity.

Referenced by CG_TouchTriggerPrediction(), and trigger_push_touch().

01415                                                                   {
01416     vec3_t  angles;
01417     float p;
01418     int effectNum;
01419 
01420     // spectators don't use jump pads
01421     if ( ps->pm_type != PM_NORMAL ) {
01422         return;
01423     }
01424 
01425     // flying characters don't hit bounce pads
01426     if ( ps->powerups[PW_FLIGHT] ) {
01427         return;
01428     }
01429 
01430     // if we didn't hit this same jumppad the previous frame
01431     // then don't play the event sound again if we are in a fat trigger
01432     if ( ps->jumppad_ent != jumppad->number ) {
01433 
01434         vectoangles( jumppad->origin2, angles);
01435         p = fabs( AngleNormalize180( angles[PITCH] ) );
01436         if( p < 45 ) {
01437             effectNum = 0;
01438         } else {
01439             effectNum = 1;
01440         }
01441         BG_AddPredictableEventToPlayerstate( EV_JUMP_PAD, effectNum, ps );
01442     }
01443     // remember hitting this jumppad this frame
01444     ps->jumppad_ent = jumppad->number;
01445     ps->jumppad_frame = ps->pmove_framecount;
01446     // give the player the velocity from the jumppad
01447     VectorCopy( jumppad->origin2, ps->velocity );
01448 }

Here is the call graph for this function:

void trap_Cvar_VariableStringBuffer const char *  var_name,
char *  buffer,
int  bufsize
 

Definition at line 69 of file cg_syscalls.c.

00069                                                                                        {
00070     syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
00071 }


Variable Documentation

gitem_t bg_itemlist[]
 

Definition at line 44 of file bg_misc.c.

Referenced by BG_CanItemBeGrabbed(), BG_FindItem(), BG_FindItemForHoldable(), BG_FindItemForPowerup(), BG_FindItemForWeapon(), CG_DrawPickupItem(), CG_EntityEvent(), CG_Item(), CG_ItemPickup(), CG_LoadingItem(), CG_RegisterItemSounds(), CG_RegisterItemVisuals(), CG_RegisterWeapon(), CG_TouchItem(), ClientEndFrame(), ClientThink_real(), ClientTimerActions(), Controls_InitWeapons(), G_CallSpawn(), G_Damage(), Pickup_Armor(), Pickup_Health(), PM_Weapon(), and UI_PlayerInfo_SetWeapon().

int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1
 

Definition at line 923 of file bg_misc.c.

Referenced by CG_RegisterItemVisuals().

char* eventnames[]
 

Initial value:

 {
    "EV_NONE",

    "EV_FOOTSTEP",
    "EV_FOOTSTEP_METAL",
    "EV_FOOTSPLASH",
    "EV_FOOTWADE",
    "EV_SWIM",

    "EV_STEP_4",
    "EV_STEP_8",
    "EV_STEP_12",
    "EV_STEP_16",

    "EV_FALL_SHORT",
    "EV_FALL_MEDIUM",
    "EV_FALL_FAR",

    "EV_JUMP_PAD",          

    "EV_JUMP",
    "EV_WATER_TOUCH",   
    "EV_WATER_LEAVE",   
    "EV_WATER_UNDER",   
    "EV_WATER_CLEAR",   

    "EV_ITEM_PICKUP",           
    "EV_GLOBAL_ITEM_PICKUP",    

    "EV_NOAMMO",
    "EV_CHANGE_WEAPON",
    "EV_FIRE_WEAPON",

    "EV_USE_ITEM0",
    "EV_USE_ITEM1",
    "EV_USE_ITEM2",
    "EV_USE_ITEM3",
    "EV_USE_ITEM4",
    "EV_USE_ITEM5",
    "EV_USE_ITEM6",
    "EV_USE_ITEM7",
    "EV_USE_ITEM8",
    "EV_USE_ITEM9",
    "EV_USE_ITEM10",
    "EV_USE_ITEM11",
    "EV_USE_ITEM12",
    "EV_USE_ITEM13",
    "EV_USE_ITEM14",
    "EV_USE_ITEM15",

    "EV_ITEM_RESPAWN",
    "EV_ITEM_POP",
    "EV_PLAYER_TELEPORT_IN",
    "EV_PLAYER_TELEPORT_OUT",

    "EV_GRENADE_BOUNCE",        

    "EV_GENERAL_SOUND",
    "EV_GLOBAL_SOUND",      
    "EV_GLOBAL_TEAM_SOUND",

    "EV_BULLET_HIT_FLESH",
    "EV_BULLET_HIT_WALL",

    "EV_MISSILE_HIT",
    "EV_MISSILE_MISS",
    "EV_MISSILE_MISS_METAL",
    "EV_RAILTRAIL",
    "EV_SHOTGUN",
    "EV_BULLET",                

    "EV_PAIN",
    "EV_DEATH1",
    "EV_DEATH2",
    "EV_DEATH3",
    "EV_OBITUARY",

    "EV_POWERUP_QUAD",
    "EV_POWERUP_BATTLESUIT",
    "EV_POWERUP_REGEN",

    "EV_GIB_PLAYER",            
    "EV_SCOREPLUM",         


    "EV_PROXIMITY_MINE_STICK",
    "EV_PROXIMITY_MINE_TRIGGER",
    "EV_KAMIKAZE",          
    "EV_OBELISKEXPLODE",        
    "EV_INVUL_IMPACT",      
    "EV_JUICED",                
    "EV_LIGHTNINGBOLT",     


    "EV_DEBUG_LINE",
    "EV_STOPLOOPINGSOUND",
    "EV_TAUNT"

}

Definition at line 1280 of file bg_misc.c.

Referenced by BG_AddPredictableEventToPlayerstate().


Generated on Thu Aug 25 13:46:31 2005 for Quake III Arena by  doxygen 1.3.9.1