#include "q_shared.h"
#include "bg_public.h"
Include dependency graph for bg_misc.c:

Go to the source code of this file.
|
||||||||||||||||
|
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:

|
||||||||||||||||
|
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:

|
||||||||||||||||
|
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:

|
||||||||||||||||
|
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:

|
|
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:

|
|
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:

|
|
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 }
|
|
|
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:

|
||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||
|
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:

|
||||||||||||
|
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:

|
||||||||||||||||
|
Definition at line 69 of file cg_syscalls.c. 00069 {
00070 syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
00071 }
|
|
|
|
Definition at line 923 of file bg_misc.c. Referenced by CG_RegisterItemVisuals(). |
|
|
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(). |
1.3.9.1