#include "g_local.h"#include "bg_saga.h"#include "q_shared.h"#include "../namespace_begin.h"#include "../namespace_end.h"Go to the source code of this file.
Data Structures | |
| struct | shaderRemap_t |
Defines | |
| #define | MAX_SHADER_REMAPS 128 |
| #define | MAX_VEHICLES_AT_A_TIME 128 |
| #define | MAXCHOICES 32 |
| #define | MAX_G2_KILL_QUEUE 256 |
| #define | USE_DISTANCE 64.0f |
Functions | |
| void | AddRemap (const char *oldShader, const char *newShader, float timeOffset) |
| const char * | BuildShaderStateConfig (void) |
| int | G_BoneIndex (const char *name) |
| int | G_ModelIndex (const char *name) |
| int | G_IconIndex (const char *name) |
| int | G_SoundIndex (const char *name) |
| int | G_SoundSetIndex (const char *name) |
| int | G_EffectIndex (const char *name) |
| int | G_BSPIndex (const char *name) |
| qboolean | G_PlayerHasCustomSkeleton (gentity_t *ent) |
| void | G_TeamCommand (team_t team, char *cmd) |
| gentity_t * | G_Find (gentity_t *from, int fieldofs, const char *match) |
| int | G_RadiusList (vec3_t origin, float radius, gentity_t *ignore, qboolean takeDamage, gentity_t *ent_list[MAX_GENTITIES]) |
| void | G_Throw (gentity_t *targ, vec3_t newDir, float push) |
| void | G_FreeFakeClient (gclient_t **cl) |
| void | G_AllocateVehicleObject (Vehicle_t **pVeh) |
| void | G_FreeVehicleObject (Vehicle_t *pVeh) |
| void | G_CreateFakeClient (int entNum, gclient_t **cl) |
| void | G_CleanAllFakeClients (void) |
| void | BG_SetAnim (playerState_t *ps, animation_t *animations, int setAnimParts, int anim, int setAnimFlags, int blendTime) |
| void | G_SetAnim (gentity_t *ent, usercmd_t *ucmd, int setAnimParts, int anim, int setAnimFlags, int blendTime) |
| gentity_t * | G_PickTarget (char *targetname) |
| void | GlobalUse (gentity_t *self, gentity_t *other, gentity_t *activator) |
| void | G_UseTargets2 (gentity_t *ent, gentity_t *activator, const char *string) |
| void | G_UseTargets (gentity_t *ent, gentity_t *activator) |
| float * | tv (float x, float y, float z) |
| char * | vtos (const vec3_t v) |
| void | G_SetMovedir (vec3_t angles, vec3_t movedir) |
| void | G_InitGentity (gentity_t *e) |
| gentity_t * | G_Spawn (void) |
| qboolean | G_EntitiesFree (void) |
| void | G_SendG2KillQueue (void) |
| void | G_KillG2Queue (int entNum) |
| void | G_FreeEntity (gentity_t *ed) |
| gentity_t * | G_TempEntity (vec3_t origin, int event) |
| gentity_t * | G_SoundTempEntity (vec3_t origin, int event, int channel) |
| void | G_ScaleNetHealth (gentity_t *self) |
| void | G_KillBox (gentity_t *ent) |
| void | G_AddPredictableEvent (gentity_t *ent, int event, int eventParm) |
| void | G_AddEvent (gentity_t *ent, int event, int eventParm) |
| gentity_t * | G_PlayEffect (int fxID, vec3_t org, vec3_t ang) |
| gentity_t * | G_PlayEffectID (const int fxID, vec3_t org, vec3_t ang) |
| gentity_t * | G_ScreenShake (vec3_t org, gentity_t *target, float intensity, int duration, qboolean global) |
| void | G_MuteSound (int entnum, int channel) |
| void | G_Sound (gentity_t *ent, int channel, int soundIndex) |
| void | G_SoundAtLoc (vec3_t loc, int channel, int soundIndex) |
| void | G_EntitySound (gentity_t *ent, int channel, int soundIndex) |
| void | G_SoundOnEnt (gentity_t *ent, int channel, const char *soundPath) |
| qboolean | ValidUseTarget (gentity_t *ent) |
| void | G_UseDispenserOn (gentity_t *ent, int dispType, gentity_t *target) |
| int | G_CanUseDispOn (gentity_t *ent, int dispType) |
| qboolean | TryHeal (gentity_t *ent, gentity_t *target) |
| void | Touch_Button (gentity_t *ent, gentity_t *other, trace_t *trace) |
| void | TryUse (gentity_t *ent) |
| qboolean | G_PointInBounds (vec3_t point, vec3_t mins, vec3_t maxs) |
| qboolean | G_BoxInBounds (vec3_t point, vec3_t mins, vec3_t maxs, vec3_t boundsMins, vec3_t boundsMaxs) |
| void | G_SetAngles (gentity_t *ent, vec3_t angles) |
| qboolean | G_ClearTrace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int ignore, int clipmask) |
| void | G_SetOrigin (gentity_t *ent, vec3_t origin) |
| qboolean | G_CheckInSolid (gentity_t *self, qboolean fix) |
| int | DebugLine (vec3_t start, vec3_t end, int color) |
| void | G_ROFF_NotetrackCallback (gentity_t *cent, const char *notetrack) |
| void | G_SpeechEvent (gentity_t *self, int event) |
| qboolean | G_ExpandPointToBBox (vec3_t point, const vec3_t mins, const vec3_t maxs, int ignore, int clipmask) |
| qboolean | G_FindClosestPointOnLineSegment (const vec3_t start, const vec3_t end, const vec3_t from, vec3_t result) |
| float | ShortestLineSegBewteen2LineSegs (vec3_t start1, vec3_t end1, vec3_t start2, vec3_t end2, vec3_t close_pnt1, vec3_t close_pnt2) |
| void | GetAnglesForDirection (const vec3_t p1, const vec3_t p2, vec3_t out) |
Variables | |
| int | remapCount = 0 |
| shaderRemap_t | remappedShaders [MAX_SHADER_REMAPS] |
| gclient_t * | gClPtrs [MAX_GENTITIES] |
| int | gG2KillIndex [MAX_G2_KILL_QUEUE] |
| int | gG2KillNum = 0 |
| qboolean | gSiegeRoundBegun |
|
|
Definition at line 875 of file g_utils.c. Referenced by G_KillG2Queue(). |
|
|
Definition at line 15 of file g_utils.c. Referenced by AddRemap(). |
|
|
Definition at line 384 of file g_utils.c. Referenced by G_AllocateVehicleObject(), and G_FreeVehicleObject(). |
|
|
Definition at line 519 of file g_utils.c. Referenced by G_PickTarget(). |
|
|
Definition at line 1612 of file g_utils.c. Referenced by TryUse(). |
|
||||||||||||||||
|
Definition at line 20 of file g_utils.c. References MAX_SHADER_REMAPS, Q_stricmp(), remapCount, remappedShaders, strcpy(), and shaderRemap_t::timeOffset. Referenced by G_RemapTeamShaders(), and G_UseTargets2().
00020 {
00021 int i;
00022
00023 for (i = 0; i < remapCount; i++) {
00024 if (Q_stricmp(oldShader, remappedShaders[i].oldShader) == 0) {
00025 // found it, just update this one
00026 strcpy(remappedShaders[i].newShader,newShader);
00027 remappedShaders[i].timeOffset = timeOffset;
00028 return;
00029 }
00030 }
00031 if (remapCount < MAX_SHADER_REMAPS) {
00032 strcpy(remappedShaders[remapCount].newShader,newShader);
00033 strcpy(remappedShaders[remapCount].oldShader,oldShader);
00034 remappedShaders[remapCount].timeOffset = timeOffset;
00035 remapCount++;
00036 }
00037 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 2976 of file bg_panimate.c. References animation_t, bgLoadedAnim_t::anims, BG_SetAnimFinal(), BG_SetLegsAnimTimer(), BG_SetTorsoAnimTimer(), bgAllAnims, BOTH_RUN1, BOTH_RUNBACK1, BOTH_WALK2, BOTH_WALKBACK1, animation_s::firstFrame, playerState_s::legsAnim, animation_s::numFrames, playerState_t, SETANIM_FLAG_OVERRIDE, SETANIM_FLAG_RESTART, SETANIM_LEGS, SETANIM_TORSO, and playerState_s::torsoAnim. Referenced by AnimateRiders(), G_SetAnim(), Initialize(), PM_SetAnim(), and Vehicle_SetAnim().
02977 {
02978 if (!animations)
02979 {
02980 animations = bgAllAnims[0].anims;
02981 }
02982
02983 if (animations[anim].firstFrame == 0 && animations[anim].numFrames == 0)
02984 {
02985 if (anim == BOTH_RUNBACK1 ||
02986 anim == BOTH_WALKBACK1 ||
02987 anim == BOTH_RUN1)
02988 { //hack for droids
02989 anim = BOTH_WALK2;
02990 }
02991
02992 if (animations[anim].firstFrame == 0 && animations[anim].numFrames == 0)
02993 { //still? Just return then I guess.
02994 return;
02995 }
02996 }
02997
02998 /*
02999 if (BG_InSpecialJump(anim))
03000 {
03001 setAnimFlags |= SETANIM_FLAG_RESTART;
03002 }
03003 */
03004 //Don't know why I put this here originally but it's messing stuff up now and it isn't needed.
03005
03006 // if (BG_InRoll(ps, ps->legsAnim))
03007 // { //never interrupt a roll
03008 // return;
03009 // }
03010
03011 if (setAnimFlags&SETANIM_FLAG_OVERRIDE)
03012 {
03013 if (setAnimParts & SETANIM_TORSO)
03014 {
03015 if( (setAnimFlags & SETANIM_FLAG_RESTART) || (ps->torsoAnim) != anim )
03016 {
03017 BG_SetTorsoAnimTimer(ps, 0);
03018 }
03019 }
03020 if (setAnimParts & SETANIM_LEGS)
03021 {
03022 if( (setAnimFlags & SETANIM_FLAG_RESTART) || (ps->legsAnim) != anim )
03023 {
03024 BG_SetLegsAnimTimer(ps, 0);
03025 }
03026 }
03027 }
03028
03029 BG_SetAnimFinal(ps, animations, setAnimParts, anim, setAnimFlags, blendTime);
03030 }
|
|
|
Definition at line 39 of file g_utils.c. References Com_sprintf(), MAX_QPATH, MAX_STRING_CHARS, memset(), Q_strcat(), remapCount, and remappedShaders. Referenced by G_RemapTeamShaders(), and G_UseTargets2().
00039 {
00040 static char buff[MAX_STRING_CHARS*4];
00041 char out[(MAX_QPATH * 2) + 5];
00042 int i;
00043
00044 memset(buff, 0, MAX_STRING_CHARS);
00045 for (i = 0; i < remapCount; i++) {
00046 Com_sprintf(out, (MAX_QPATH * 2) + 5, "%s=%s:%5.2f@", remappedShaders[i].oldShader, remappedShaders[i].newShader, remappedShaders[i].timeOffset);
00047 Q_strcat( buff, sizeof( buff ), out);
00048 }
00049 return buff;
00050 }
|
|
||||||||||||||||
|
Definition at line 2011 of file g_utils.c. References DotProduct, trap_DebugPolygonCreate(), vec3_t, VectorCopy, VectorMA, VectorNormalize(), VectorSet, and VectorSubtract.
02011 {
02012 vec3_t points[4], dir, cross, up = {0, 0, 1};
02013 float dot;
02014
02015 VectorCopy(start, points[0]);
02016 VectorCopy(start, points[1]);
02017 //points[1][2] -= 2;
02018 VectorCopy(end, points[2]);
02019 //points[2][2] -= 2;
02020 VectorCopy(end, points[3]);
02021
02022
02023 VectorSubtract(end, start, dir);
02024 VectorNormalize(dir);
02025 dot = DotProduct(dir, up);
02026 if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
02027 else CrossProduct(dir, up, cross);
02028
02029 VectorNormalize(cross);
02030
02031 VectorMA(points[0], 2, cross, points[0]);
02032 VectorMA(points[1], -2, cross, points[1]);
02033 VectorMA(points[2], -2, cross, points[2]);
02034 VectorMA(points[3], 2, cross, points[3]);
02035
02036 return trap_DebugPolygonCreate(color, 4, points);
02037 }
|
|
||||||||||||||||
|
||||||||||||||||
|
Definition at line 1206 of file g_utils.c. References BG_AddPredictableEventToPlayerstate(), gentity_s::client, gentity_t, and gclient_s::ps. Referenced by Touch_Item().
01206 {
01207 if ( !ent->client ) {
01208 return;
01209 }
01210 BG_AddPredictableEventToPlayerstate( event, eventParm, &ent->client->ps );
01211 }
|
|
|
Definition at line 388 of file g_utils.c. References Com_Error(), ERR_DROP, MAX_VEHICLES_AT_A_TIME, memset(), qtrue, and Vehicle_t. Referenced by G_CreateAnimalNPC(), G_CreateFighterNPC(), G_CreateSpeederNPC(), and G_CreateWalkerNPC().
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 }
|
|
|
Definition at line 101 of file g_utils.c. References CS_G2BONES, MAX_G2BONES, name, and qtrue. Referenced by EWeb_SetBoneAngles(), G2Tur_SetBoneAngles(), and NPC_SetBoneAngles().
00101 {
00102 return G_FindConfigstringIndex (name, CS_G2BONES, MAX_G2BONES, qtrue);
00103 }
|
|
||||||||||||||||||||||||
|
Definition at line 1896 of file g_utils.c. References qboolean, qfalse, qtrue, vec3_t, and VectorAdd. Referenced by W_TraceSetStart().
01897 {
01898 vec3_t boxMins;
01899 vec3_t boxMaxs;
01900
01901 VectorAdd( point, mins, boxMins );
01902 VectorAdd( point, maxs, boxMaxs );
01903
01904 if(boxMaxs[0]>boundsMaxs[0])
01905 return qfalse;
01906
01907 if(boxMaxs[1]>boundsMaxs[1])
01908 return qfalse;
01909
01910 if(boxMaxs[2]>boundsMaxs[2])
01911 return qfalse;
01912
01913 if(boxMins[0]<boundsMins[0])
01914 return qfalse;
01915
01916 if(boxMins[1]<boundsMins[1])
01917 return qfalse;
01918
01919 if(boxMins[2]<boundsMins[2])
01920 return qfalse;
01921
01922 //box is completely contained within bounds
01923 return qtrue;
01924 }
|
|
|
Definition at line 153 of file g_utils.c. References CS_BSP_MODELS, MAX_SUB_BSP, name, and qtrue. Referenced by SP_misc_bsp().
00154 {
00155 return G_FindConfigstringIndex (name, CS_BSP_MODELS, MAX_SUB_BSP, qtrue);
00156 }
|
|
||||||||||||
|
Definition at line 1508 of file g_utils.c. References playerState_s::ammo, ammoData, gentity_s::client, gentity_t, gentity_s::health, HI_AMMODISP, HI_HEALTHDISP, gentity_s::inuse, LAST_USEABLE_WEAPON, gclient_s::ps, STAT_HEALTH, STAT_MAX_HEALTH, playerState_s::stats, playerState_s::weapon, weaponData, and WP_NONE. Referenced by TryUse().
01509 {
01510 if (!ent->client || !ent->inuse || ent->health < 1 ||
01511 ent->client->ps.stats[STAT_HEALTH] < 1)
01512 { //dead or invalid
01513 return 0;
01514 }
01515
01516 if (dispType == HI_HEALTHDISP)
01517 {
01518 if (ent->client->ps.stats[STAT_HEALTH] < ent->client->ps.stats[STAT_MAX_HEALTH])
01519 { //he's hurt
01520 return 1;
01521 }
01522
01523 //otherwise no
01524 return 0;
01525 }
01526 else if (dispType == HI_AMMODISP)
01527 {
01528 if (ent->client->ps.weapon <= WP_NONE || ent->client->ps.weapon > LAST_USEABLE_WEAPON)
01529 { //not a player-useable weapon
01530 return 0;
01531 }
01532
01533 if (ent->client->ps.ammo[weaponData[ent->client->ps.weapon].ammoIndex] < ammoData[weaponData[ent->client->ps.weapon].ammoIndex].max)
01534 { //needs more ammo for current weapon
01535 return 1;
01536 }
01537
01538 //needs none
01539 return 0;
01540 }
01541
01542 //invalid type?
01543 return 0;
01544 }
|
|
||||||||||||
|
Definition at line 1965 of file g_utils.c. References trace_t::allsolid, gentity_s::clipmask, entityShared_t::currentOrigin, trace_t::endpos, trace_t::fraction, G_SetOrigin(), gentity_t, entityShared_t::maxs, entityShared_t::mins, entityState_s::number, qboolean, qfalse, qtrue, gentity_s::r, gentity_s::s, trace_t::startsolid, trap_LinkEntity(), trap_Trace(), vec3_t, and VectorCopy. Referenced by NPC_Begin(), SP_point_combat(), SP_waypoint(), SP_waypoint_navgoal(), SP_waypoint_navgoal_1(), SP_waypoint_navgoal_2(), SP_waypoint_navgoal_4(), SP_waypoint_navgoal_8(), and SP_waypoint_small().
01966 {
01967 trace_t trace;
01968 vec3_t end, mins;
01969
01970 VectorCopy(self->r.currentOrigin, end);
01971 end[2] += self->r.mins[2];
01972 VectorCopy(self->r.mins, mins);
01973 mins[2] = 0;
01974
01975 trap_Trace(&trace, self->r.currentOrigin, mins, self->r.maxs, end, self->s.number, self->clipmask);
01976 if(trace.allsolid || trace.startsolid)
01977 {
01978 return qtrue;
01979 }
01980
01981 if(trace.fraction < 1.0)
01982 {
01983 if(fix)
01984 {//Put them at end of trace and check again
01985 vec3_t neworg;
01986
01987 VectorCopy(trace.endpos, neworg);
01988 neworg[2] -= self->r.mins[2];
01989 G_SetOrigin(self, neworg);
01990 trap_LinkEntity(self);
01991
01992 return G_CheckInSolid(self, qfalse);
01993 }
01994 else
01995 {
01996 return qtrue;
01997 }
01998 }
01999
02000 return qfalse;
02001 }
|
|
|
Definition at line 450 of file g_utils.c. References gentity_s::client, ET_NPC, entityState_s::eType, g_entities, G_FreeFakeClient(), gentity_t, gentity_s::inuse, MAX_CLIENTS, MAX_GENTITIES, and gentity_s::s. Referenced by G_ShutdownGame().
00451 {
00452 int i = MAX_CLIENTS; //start off here since all ents below have real client structs.
00453 gentity_t *ent;
00454
00455 while (i < MAX_GENTITIES)
00456 {
00457 ent = &g_entities[i];
00458
00459 if (ent->inuse && ent->s.eType == ET_NPC && ent->client)
00460 {
00461 G_FreeFakeClient(&ent->client);
00462 }
00463 i++;
00464 }
00465 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1934 of file g_utils.c. References trace_t::allsolid, trace_t::fraction, qboolean, qfalse, qtrue, trace_t::startsolid, trap_Trace(), and vec3_t.
01935 {
01936 static trace_t tr;
01937
01938 trap_Trace( &tr, start, mins, maxs, end, ignore, clipmask );
01939
01940 if ( tr.allsolid || tr.startsolid || tr.fraction < 1.0 )
01941 {
01942 return qfalse;
01943 }
01944
01945 return qtrue;
01946 }
|
|
||||||||||||
|
Definition at line 430 of file g_utils.c. References BG_Alloc(), gclient_t, and gClPtrs. Referenced by NPC_Spawn_Do().
|
|
|
|
Definition at line 860 of file g_utils.c. References g_entities, gentity_t, gentity_s::inuse, level, MAX_CLIENTS, level_locals_t::num_entities, qboolean, qfalse, and qtrue.
00860 {
00861 int i;
00862 gentity_t *e;
00863
00864 e = &g_entities[MAX_CLIENTS];
00865 for ( i = MAX_CLIENTS; i < level.num_entities; i++, e++) {
00866 if ( e->inuse ) {
00867 continue;
00868 }
00869 // slot available
00870 return qtrue;
00871 }
00872 return qfalse;
00873 }
|
|
||||||||||||||||
|
Definition at line 1392 of file g_utils.c. References entityState_s::clientNum, entityShared_t::currentOrigin, EV_ENTITY_SOUND, entityState_s::eventParm, G_TempEntity(), gentity_t, entityState_s::number, gentity_s::r, gentity_s::s, and entityState_s::trickedentindex. Referenced by ClientCommand(), ClientThink_real(), DoGripAction(), faller_think(), faller_touch(), G_BreakArm(), G_RunFrame(), G_SpecialRollGetup(), hurt_touch(), WP_ForcePowerStop(), WP_ForcePowersUpdate(), and WP_SaberPositionUpdate().
01392 {
01393 gentity_t *te;
01394
01395 te = G_TempEntity( ent->r.currentOrigin, EV_ENTITY_SOUND );
01396 te->s.eventParm = soundIndex;
01397 te->s.clientNum = ent->s.number;
01398 te->s.trickedentindex = channel;
01399 }
|
|
||||||||||||||||||||||||
|
Definition at line 2087 of file g_utils.c. References trace_t::allsolid, trace_t::fraction, qboolean, qfalse, qtrue, trace_t::startsolid, trap_Trace(), vec3_origin, vec3_t, and VectorCopy.
02088 {
02089 trace_t tr;
02090 vec3_t start, end;
02091 int i;
02092
02093 VectorCopy( point, start );
02094
02095 for ( i = 0; i < 3; i++ )
02096 {
02097 VectorCopy( start, end );
02098 end[i] += mins[i];
02099 trap_Trace( &tr, start, vec3_origin, vec3_origin, end, ignore, clipmask );
02100 if ( tr.allsolid || tr.startsolid )
02101 {
02102 return qfalse;
02103 }
02104 if ( tr.fraction < 1.0 )
02105 {
02106 VectorCopy( start, end );
02107 end[i] += maxs[i]-(mins[i]*tr.fraction);
02108 trap_Trace( &tr, start, vec3_origin, vec3_origin, end, ignore, clipmask );
02109 if ( tr.allsolid || tr.startsolid )
02110 {
02111 return qfalse;
02112 }
02113 if ( tr.fraction < 1.0 )
02114 {
02115 return qfalse;
02116 }
02117 VectorCopy( end, start );
02118 }
02119 }
02120 //expanded it, now see if it's all clear
02121 trap_Trace( &tr, start, mins, maxs, start, ignore, clipmask );
02122 if ( tr.allsolid || tr.startsolid )
02123 {
02124 return qfalse;
02125 }
02126 VectorCopy( start, point );
02127 return qtrue;
02128 }
|
|
||||||||||||||||
|
||||||||||||||||||||
|
Definition at line 1524 of file q_math.c.
01525 {
01526 vec3_t vecStart2From, vecStart2End, vecEnd2Start, vecEnd2From;
01527 float distEnd2From, distEnd2Result, theta, cos_theta, dot;
01528
01529 //Find the perpendicular vector to vec from start to end
01530 VectorSubtract( from, start, vecStart2From);
01531 VectorSubtract( end, start, vecStart2End);
01532
01533 dot = DotProductNormalize( vecStart2From, vecStart2End );
01534
01535 if ( dot <= 0 )
01536 {
01537 //The perpendicular would be beyond or through the start point
01538 VectorCopy( start, result );
01539 return qfalse;
01540 }
01541
01542 if ( dot == 1 )
01543 {
01544 //parallel, closer of 2 points will be the target
01545 if( (VectorLengthSquared( vecStart2From )) < (VectorLengthSquared( vecStart2End )) )
01546 {
01547 VectorCopy( from, result );
01548 }
01549 else
01550 {
01551 VectorCopy( end, result );
01552 }
01553 return qfalse;
01554 }
01555
01556 //Try other end
01557 VectorSubtract( from, end, vecEnd2From);
01558 VectorSubtract( start, end, vecEnd2Start);
01559
01560 dot = DotProductNormalize( vecEnd2From, vecEnd2Start );
01561
01562 if ( dot <= 0 )
01563 {//The perpendicular would be beyond or through the start point
01564 VectorCopy( end, result );
01565 return qfalse;
01566 }
01567
01568 if ( dot == 1 )
01569 {//parallel, closer of 2 points will be the target
01570 if( (VectorLengthSquared( vecEnd2From )) < (VectorLengthSquared( vecEnd2Start )))
01571 {
01572 VectorCopy( from, result );
01573 }
01574 else
01575 {
01576 VectorCopy( end, result );
01577 }
01578 return qfalse;
01579 }
01580
01581 // /|
01582 // c / |
01583 // / |a
01584 // theta /)__|
01585 // b
01586 //cos(theta) = b / c
01587 //solve for b
01588 //b = cos(theta) * c
01589
01590 //angle between vecs end2from and end2start, should be between 0 and 90
01591 theta = 90 * (1 - dot);//theta
01592
01593 //Get length of side from End2Result using sine of theta
01594 distEnd2From = VectorLength( vecEnd2From );//c
01595 cos_theta = cos(DEG2RAD(theta));//cos(theta)
01596 distEnd2Result = cos_theta * distEnd2From;//b
01597
01598 //Extrapolate to find result
01599 VectorNormalize( vecEnd2Start );
01600 VectorMA( end, distEnd2Result, vecEnd2Start, result );
01601
01602 //perpendicular intersection is between the 2 endpoints
01603 return qtrue;
01604 }
|
|
|
|
Definition at line 376 of file g_utils.c. References gclient_t. Referenced by G_CleanAllFakeClients(), and G_FreeEntity().
00377 { //or not, the dynamic stuff is busted somehow at the moment. Yet it still works in the test.
00378 //I think something is messed up in being able to cast the memory to stuff to modify it,
00379 //while modifying it directly seems to work fine.
00380 //trap_TrueFree((void **)cl);
00381 }
|
|
|
Definition at line 413 of file g_utils.c. References MAX_VEHICLES_AT_A_TIME, qfalse, and Vehicle_t. Referenced by G_FreeEntity().
00414 {
00415 int i = 0;
00416 while (i < MAX_VEHICLES_AT_A_TIME)
00417 {
00418 if (g_vehiclePoolOccupied[i] &&
00419 &g_vehiclePool[i] == pVeh)
00420 { //guess this is it
00421 g_vehiclePoolOccupied[i] = qfalse;
00422 break;
00423 }
00424 i++;
00425 }
00426 }
|
|
|
Definition at line 132 of file g_utils.c. References CS_ICONS, MAX_ICONS, name, and qtrue. Referenced by SP_info_siege_objective(), SP_info_siege_radaricon(), SP_misc_ammo_floor_unit(), SP_misc_model_health_power_converter(), SP_misc_shield_floor_unit(), SP_misc_siege_item(), SP_misc_turret(), and SP_misc_turretG2().
00133 {
00134 assert(name && name[0]);
00135 return G_FindConfigstringIndex (name, CS_ICONS, MAX_ICONS, qtrue);
00136 }
|
|
|
Definition at line 694 of file g_utils.c. References gentity_s::classname, ENTITYNUM_NONE, g_entities, gentity_t, gentity_s::inuse, entityState_s::modelGhoul2, entityState_s::number, entityShared_t::ownerNum, qtrue, gentity_s::r, gentity_s::s, and trap_ICARUS_FreeEnt(). Referenced by ClientBegin(), G_Spawn(), and WP_SaberInitBladeData().
00694 {
00695 e->inuse = qtrue;
00696 e->classname = "noclass";
00697 e->s.number = e - g_entities;
00698 e->r.ownerNum = ENTITYNUM_NONE;
00699 e->s.modelGhoul2 = 0; //assume not
00700
00701 trap_ICARUS_FreeEnt( e ); //ICARUS information must be added after this point
00702 }
|
|
|
Definition at line 1162 of file g_utils.c. References gentity_s::client, DAMAGE_NO_PROTECTION, G_Damage(), g_entities, gentity_t, MAX_GENTITIES, entityShared_t::maxs, entityShared_t::mins, MOD_TELEFRAG, NULL, entityState_s::number, playerState_s::origin, entityShared_t::ownerNum, gclient_s::ps, gentity_s::r, gentity_s::s, trap_EntitiesInBox(), vec3_t, and VectorAdd. Referenced by ClientSpawn(), NPC_Begin(), and TeleportPlayer().
01162 {
01163 int i, num;
01164 int touch[MAX_GENTITIES];
01165 gentity_t *hit;
01166 vec3_t mins, maxs;
01167
01168 VectorAdd( ent->client->ps.origin, ent->r.mins, mins );
01169 VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );
01170 num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
01171
01172 for (i=0 ; i<num ; i++) {
01173 hit = &g_entities[touch[i]];
01174 if ( !hit->client ) {
01175 continue;
01176 }
01177
01178 if (hit->s.number == ent->s.number)
01179 { //don't telefrag yourself!
01180 continue;
01181 }
01182
01183 if (ent->r.ownerNum == hit->s.number)
01184 { //don't telefrag your vehicle!
01185 continue;
01186 }
01187
01188 // nail it
01189 G_Damage ( hit, ent, ent, NULL, NULL,
01190 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
01191 }
01192
01193 }
|
|
|
Definition at line 909 of file g_utils.c. References Com_Printf(), gG2KillIndex, gG2KillNum, MAX_G2_KILL_QUEUE, trap_SendServerCommand(), and va(). Referenced by G_FreeEntity(), JMSaberTouch(), and turretG2_set_models().
00910 {
00911 if (gG2KillNum >= MAX_G2_KILL_QUEUE)
00912 { //This would be considered a Bad Thing.
00913 #ifdef _DEBUG
00914 Com_Printf("WARNING: Exceeded the MAX_G2_KILL_QUEUE count for this frame!\n");
00915 #endif
00916 //Since we're out of queue slots, just send it now as a seperate command (eats more bandwidth, but we have no choice)
00917 trap_SendServerCommand(-1, va("kg2 %i", entNum));
00918 return;
00919 }
00920
00921 gG2KillIndex[gG2KillNum] = entNum;
00922 gG2KillNum++;
00923 }
|
|
|
||||||||||||
|
Definition at line 1322 of file g_utils.c. References EF_SOUNDTRACKER, entityState_s::eFlags, EV_MUTE_SOUND, g_entities, G_FreeEntity(), G_TempEntity(), gentity_t, gentity_s::r, gentity_s::s, SVF_BROADCAST, entityShared_t::svFlags, entityState_s::trickedentindex, entityState_s::trickedentindex2, and vec3_origin. Referenced by ClientBegin(), ClientDisconnect(), ClientThink_real(), EjectAll(), ForceJumpCharge(), G_EjectDroidUnit(), G_Sound(), player_die(), WP_DoSpecificPower(), WP_ForcePowerStop(), WP_ForcePowersUpdate(), and WP_GetVelocityForForceJump().
01323 {
01324 gentity_t *te, *e;
01325
01326 te = G_TempEntity( vec3_origin, EV_MUTE_SOUND );
01327 te->r.svFlags = SVF_BROADCAST;
01328 te->s.trickedentindex2 = entnum;
01329 te->s.trickedentindex = channel;
01330
01331 e = &g_entities[entnum];
01332
01333 if (e && (e->s.eFlags & EF_SOUNDTRACKER))
01334 {
01335 G_FreeEntity(e);
01336 e->s.eFlags = 0;
01337 }
01338 }
|
|
|
Definition at line 521 of file g_utils.c. References FOFS, G_Find(), G_Printf(), gentity_t, MAXCHOICES, NULL, and rand(). Referenced by AimAtTarget(), FindIntermissionPoint(), locateCamera(), target_relay_use(), target_teleporter_use(), and trigger_teleporter_touch().
00522 {
00523 gentity_t *ent = NULL;
00524 int num_choices = 0;
00525 gentity_t *choice[MAXCHOICES];
00526
00527 if (!targetname)
00528 {
00529 G_Printf("G_PickTarget called with NULL targetname\n");
00530 return NULL;
00531 }
00532
00533 while(1)
00534 {
00535 ent = G_Find (ent, FOFS(targetname), targetname);
00536 if (!ent)
00537 break;
00538 choice[num_choices++] = ent;
00539 if (num_choices == MAXCHOICES)
00540 break;
00541 }
00542
00543 if (!num_choices)
00544 {
00545 G_Printf("G_PickTarget: target %s not found\n", targetname);
00546 return NULL;
00547 }
00548
00549 return choice[rand() % num_choices];
00550 }
|
|
||||||||||||||||
|
Definition at line 1250 of file g_utils.c. References entityState_s::angles, EV_PLAY_EFFECT, entityState_s::eventParm, G_TempEntity(), gentity_t, entityState_s::origin, gentity_s::s, vec3_t, and VectorCopy. Referenced by auto_turret_die(), CG_PlayerAnimEventDo(), charge_stick(), DEMP2_AltDetonate(), DetPackBlow(), emplaced_gun_update(), EWebDie(), laserTrapExplode(), SeekerDroneUpdate(), turret_die(), turret_head_think(), turretG2_die(), Update(), and WP_FireStunBaton().
01251 {
01252 gentity_t *te;
01253
01254 te = G_TempEntity( org, EV_PLAY_EFFECT );
01255 VectorCopy(ang, te->s.angles);
01256 VectorCopy(org, te->s.origin);
01257 te->s.eventParm = fxID;
01258
01259 return te;
01260 }
|
|
||||||||||||||||
|
|
Definition at line 162 of file g_utils.c. References gentity_t, qboolean, and qfalse. Referenced by ClientUserinfoChanged(), and SetupGameGhoul2Model().
00163 {
00164 /*
00165 siegeClass_t *scl;
00166
00167 if (g_gametype.integer != GT_SIEGE)
00168 { //only in siege
00169 return qfalse;
00170 }
00171
00172 if (ent->s.number >= MAX_CLIENTS ||
00173 !ent->client ||
00174 ent->client->siegeClass == -1)
00175 { //invalid class
00176 return qfalse;
00177 }
00178
00179 scl = &bgSiegeClasses[ent->client->siegeClass];
00180 if (!(scl->classflags & (1<<CFL_CUSTOMSKEL)))
00181 { //class is not flagged for this
00182 return qfalse;
00183 }
00184
00185 return qtrue;
00186 */
00187 return qfalse;
00188 }
|
|
||||||||||||||||
|
Definition at line 1877 of file g_utils.c. References qboolean, qfalse, qtrue, and vec3_t. Referenced by G_RunFrame(), space_touch(), and Touch_Multi().
|
|
||||||||||||||||||||||||
|
Definition at line 252 of file g_utils.c. References entityShared_t::absmax, entityShared_t::absmin, g_entities, gentity_t, gentity_s::inuse, MAX_GENTITIES, gentity_s::r, gentity_s::takedamage, trap_EntitiesInBox(), and vec3_t. Referenced by prox_mine_think().
00253 {
00254 float dist;
00255 gentity_t *ent;
00256 int entityList[MAX_GENTITIES];
00257 int numListedEntities;
00258 vec3_t mins, maxs;
00259 vec3_t v;
00260 int i, e;
00261 int ent_count = 0;
00262
00263 if ( radius < 1 )
00264 {
00265 radius = 1;
00266 }
00267
00268 for ( i = 0 ; i < 3 ; i++ )
00269 {
00270 mins[i] = origin[i] - radius;
00271 maxs[i] = origin[i] + radius;
00272 }
00273
00274 numListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
00275
00276 for ( e = 0 ; e < numListedEntities ; e++ )
00277 {
00278 ent = &g_entities[entityList[ e ]];
00279
00280 if ((ent == ignore) || !(ent->inuse) || ent->takedamage != takeDamage)
00281 continue;
00282
00283 // find the distance from the edge of the bounding box
00284 for ( i = 0 ; i < 3 ; i++ )
00285 {
00286 if ( origin[i] < ent->r.absmin[i] )
00287 {
00288 v[i] = ent->r.absmin[i] - origin[i];
00289 } else if ( origin[i] > ent->r.absmax[i] )
00290 {
00291 v[i] = origin[i] - ent->r.absmax[i];
00292 } else
00293 {
00294 v[i] = 0;
00295 }
00296 }
00297
00298 dist = VectorLength( v );
00299 if ( dist >= radius )
00300 {
00301 continue;
00302 }
00303
00304 // ok, we are within the radius, add us to the incoming list
00305 ent_list[ent_count] = ent;
00306 ent_count++;
00307
00308 }
00309 // we are done, return how many we found
00310 return(ent_count);
00311 }
|
|
||||||||||||
|
Definition at line 2039 of file g_utils.c. References entityState_s::angles2, entityState_s::apos, entityShared_t::currentAngles, entityShared_t::currentOrigin, gentity_t, entityState_s::number, entityState_s::origin2, entityState_s::pos, qfalse, gentity_s::r, gentity_s::roffid, gentity_s::s, strcmp(), trap_ROFF_Play(), trajectory_t::trBase, and VectorCopy. Referenced by vmMain().
02040 {
02041 char type[256];
02042 int i = 0;
02043 int addlArg = 0;
02044
02045 if (!cent || !notetrack)
02046 {
02047 return;
02048 }
02049
02050 while (notetrack[i] && notetrack[i] != ' ')
02051 {
02052 type[i] = notetrack[i];
02053 i++;
02054 }
02055
02056 type[i] = '\0';
02057
02058 if (!i || !type[0])
02059 {
02060 return;
02061 }
02062
02063 if (notetrack[i] == ' ')
02064 {
02065 addlArg = 1;
02066 }
02067
02068 if (strcmp(type, "loop") == 0)
02069 {
02070 if (addlArg) //including an additional argument means reset to original position before loop
02071 {
02072 VectorCopy(cent->s.origin2, cent->s.pos.trBase);
02073 VectorCopy(cent->s.origin2, cent->r.currentOrigin);
02074 VectorCopy(cent->s.angles2, cent->s.apos.trBase);
02075 VectorCopy(cent->s.angles2, cent->r.currentAngles);
02076 }
02077
02078 trap_ROFF_Play(cent->s.number, cent->roffid, qfalse);
02079 }
02080 }
|
|
|
Definition at line 1112 of file g_utils.c. References gentity_t, gentity_s::health, entityState_s::health, entityState_s::maxhealth, gentity_s::maxHealth, and gentity_s::s. Referenced by asteroid_field_think(), bottom_die(), EWeb_Create(), finish_spawning_turretG2(), G_Damage(), NPC_Begin(), SP_emplaced_gun(), SP_func_breakable(), SP_misc_siege_item(), Touch_Item(), TryHeal(), turret_base_spawn_top(), TurretBasePain(), turretG2_respawn(), and TurretPain().
01113 {
01114 int maxHealth = self->maxHealth;
01115
01116 if (maxHealth < 1000)
01117 { //it's good then
01118 self->s.maxhealth = maxHealth;
01119 self->s.health = self->health;
01120
01121 if (self->s.health < 0)
01122 { //don't let it wrap around
01123 self->s.health = 0;
01124 }
01125 return;
01126 }
01127
01128 //otherwise, scale it down
01129 self->s.maxhealth = (maxHealth/100);
01130 self->s.health = (self->health/100);
01131
01132 if (self->s.health < 0)
01133 { //don't let it wrap around
01134 self->s.health = 0;
01135 }
01136
01137 if (self->health > 0 &&
01138 self->s.health <= 0)
01139 { //don't let it scale to 0 if the thing is still not "dead"
01140 self->s.health = 1;
01141 }
01142 }
|
|
||||||||||||||||||||||||
|
Definition at line 1291 of file g_utils.c. References entityState_s::angles, EV_SCREENSHAKE, G_TempEntity(), gentity_t, entityState_s::modelindex, entityState_s::number, entityState_s::origin, gentity_s::r, gentity_s::s, SVF_BROADCAST, entityShared_t::svFlags, entityState_s::time, vec3_t, and VectorCopy. Referenced by Rancor_Attack(), and Use_Target_Screenshake().
01292 {
01293 gentity_t *te;
01294
01295 te = G_TempEntity( org, EV_SCREENSHAKE );
01296 VectorCopy(org, te->s.origin);
01297 te->s.angles[0] = intensity;
01298 te->s.time = duration;
01299
01300 if (target)
01301 {
01302 te->s.modelindex = target->s.number+1;
01303 }
01304 else
01305 {
01306 te->s.modelindex = 0;
01307 }
01308
01309 if (global)
01310 {
01311 te->r.svFlags |= SVF_BROADCAST;
01312 }
01313
01314 return te;
01315 }
|
|
|
Definition at line 880 of file g_utils.c. References Com_sprintf(), gG2KillIndex, gG2KillNum, Q_strcat(), trap_SendServerCommand(), and va(). Referenced by G_RunFrame().
00881 {
00882 char g2KillString[1024];
00883 int i = 0;
00884
00885 if (!gG2KillNum)
00886 {
00887 return;
00888 }
00889
00890 Com_sprintf(g2KillString, 1024, "kg2");
00891
00892 while (i < gG2KillNum && i < 64)
00893 { //send 64 at once, max...
00894 Q_strcat(g2KillString, 1024, va(" %i", gG2KillIndex[i]));
00895 i++;
00896 }
00897
00898 trap_SendServerCommand(-1, g2KillString);
00899
00900 //Clear the count because we just sent off the whole queue
00901 gG2KillNum -= i;
00902 if (gG2KillNum < 0)
00903 { //hmm, should be impossible, but I'm paranoid as we're far past beta.
00904 assert(0);
00905 gG2KillNum = 0;
00906 }
00907 }
|
|
||||||||||||
|
Definition at line 1927 of file g_utils.c. References entityState_s::angles, entityState_s::apos, entityShared_t::currentAngles, gentity_t, gentity_s::r, gentity_s::s, trajectory_t::trBase, vec3_t, and VectorCopy. Referenced by asteroid_field_think(), finish_spawning_turretG2(), fx_runner_link(), G_HeldByMonster(), maglock_link(), NPC_Begin(), NPC_Spawn_Do(), Rancor_DropVictim(), SP_func_static(), SP_misc_turret(), SP_NPC_Vehicle(), and turret_base_spawn_top().
01928 {
01929 VectorCopy( angles, ent->r.currentAngles );
01930 VectorCopy( angles, ent->s.angles );
01931 VectorCopy( angles, ent->s.apos.trBase );
01932 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 479 of file g_utils.c. References pmove_t::animations, BG_SetAnim(), bgAllAnims, gentity_s::client, clientPersistant_t::cmd, pmove_t::cmd, g_gametype, pmove_t::gametype, gentity_t, vmCvar_t::integer, gentity_s::inuse, gentity_s::localAnimIndex, memset(), gclient_s::pers, pm, PM_SetAnim(), pmove_t::pointcontents, gclient_s::ps, pmove_t::ps, pmove_t::trace, trap_PointContents(), trap_Trace(), ucmd, and usercmd_t. Referenced by ClientSpawn(), Cmd_DebugSetBodyAnim_f(), EWebPositionUser(), G_BreakArm(), G_CheckClientIdle(), G_RunFrame(), G_SpecialRollGetup(), NPC_SetAnim(), player_die(), StandardSetBodyAnim(), Touch_Multi(), TryGrapple(), TryHeal(), TryUse(), and WP_SaberPositionUpdate().
00480 {
00481 #if 0 //old hackish way
00482 pmove_t pmv;
00483
00484 assert(ent && ent->inuse && ent->client);
00485
00486 memset (&pmv, 0, sizeof(pmv));
00487 pmv.ps = &ent->client->ps;
00488 pmv.animations = bgAllAnims[ent->localAnimIndex].anims;
00489 if (!ucmd)
00490 {
00491 pmv.cmd = ent->client->pers.cmd;
00492 }
00493 else
00494 {
00495 pmv.cmd = *ucmd;
00496 }
00497 pmv.trace = trap_Trace;
00498 pmv.pointcontents = trap_PointContents;
00499 pmv.gametype = g_gametype.integer;
00500
00501 //don't need to bother with ghoul2 stuff, it's not even used in PM_SetAnim.
00502 pm = &pmv;
00503 PM_SetAnim(setAnimParts, anim, setAnimFlags, blendTime);
00504 #else //new clean and shining way!
00505 assert(ent->client);
00506 BG_SetAnim(&ent->client->ps, bgAllAnims[ent->localAnimIndex].anims, setAnimParts,
00507 anim, setAnimFlags, blendTime);
00508 #endif
00509 }
|
|
||||||||||||
|
Definition at line 678 of file g_utils.c. References AngleVectors(), NULL, vec3_t, VectorClear, and VectorCopy. Referenced by InitShooter(), InitTrigger(), locateCamera(), SP_func_button(), SP_func_door(), SP_target_push(), and target_laser_start().
00678 {
00679 static vec3_t VEC_UP = {0, -1, 0};
00680 static vec3_t MOVEDIR_UP = {0, 0, 1};
00681 static vec3_t VEC_DOWN = {0, -2, 0};
00682 static vec3_t MOVEDIR_DOWN = {0, 0, -1};
00683
00684 if ( VectorCompare (angles, VEC_UP) ) {
00685 VectorCopy (MOVEDIR_UP, movedir);
00686 } else if ( VectorCompare (angles, VEC_DOWN) ) {
00687 VectorCopy (MOVEDIR_DOWN, movedir);
00688 } else {
00689 AngleVectors (angles, movedir, NULL, NULL);
00690 }
00691 VectorClear( angles );
00692 }
|
|
||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
Definition at line 1379 of file g_utils.c. References EV_GENERAL_SOUND, entityState_s::eventParm, G_TempEntity(), gentity_t, gentity_s::s, entityState_s::saberEntityNum, and vec3_t. Referenced by NPC_BSGM_Attack(), and SeekerDroneUpdate().
01379 {
01380 gentity_t *te;
01381
01382 te = G_TempEntity( loc, EV_GENERAL_SOUND );
01383 te->s.eventParm = soundIndex;
01384 te->s.saberEntityNum = channel;
01385 }
|
|
|
||||||||||||||||
|
Definition at line 1402 of file g_utils.c. References entityState_s::clientNum, entityShared_t::currentOrigin, EV_ENTITY_SOUND, entityState_s::eventParm, G_SoundIndex(), G_TempEntity(), gentity_t, entityState_s::number, gentity_s::r, gentity_s::s, and entityState_s::trickedentindex.
01403 {
01404 gentity_t *te;
01405
01406 te = G_TempEntity( ent->r.currentOrigin, EV_ENTITY_SOUND );
01407 te->s.eventParm = G_SoundIndex((char *)soundPath);
01408 te->s.clientNum = ent->s.number;
01409 te->s.trickedentindex = channel;
01410
01411 }
|
|
|
Definition at line 143 of file g_utils.c. References CS_AMBIENT_SET, MAX_AMBIENT_SETS, name, and qtrue. Referenced by func_rotating_use(), fx_runner_link(), fx_runner_think(), fx_runner_use(), G_PlayDoorLoopSound(), G_PlayDoorSound(), G_PrecacheSoundsets(), and SP_target_speaker().
00144 {
00145 return G_FindConfigstringIndex (name, CS_AMBIENT_SET, MAX_AMBIENT_SETS, qtrue);
00146 }
|
|
||||||||||||||||
|
Definition at line 1087 of file g_utils.c. References gentity_s::classname, ET_EVENTS, entityState_s::eType, gentity_s::eventTime, gentity_s::freeAfterEvent, G_SetOrigin(), G_Spawn(), gentity_t, gentity_s::inuse, level, qtrue, gentity_s::s, level_locals_t::time, trap_LinkEntity(), vec3_t, and VectorCopy. Referenced by G_Sound().
01087 {
01088 gentity_t *e;
01089 vec3_t snapped;
01090
01091 e = G_Spawn();
01092
01093 e->s.eType = ET_EVENTS + event;
01094 e->inuse = qtrue;
01095
01096 e->classname = "tempEntity";
01097 e->eventTime = level.time;
01098 e->freeAfterEvent = qtrue;
01099
01100 VectorCopy( origin, snapped );
01101 SnapVector( snapped ); // save network bandwidth
01102 G_SetOrigin( e, snapped );
01103
01104 // find cluster for PVS
01105 trap_LinkEntity( e );
01106
01107 return e;
01108 }
|
|
|
Definition at line 804 of file g_utils.c. References level_locals_t::clients, ENTITYNUM_MAX_NORMAL, gentity_s::freetime, g_entities, G_Error(), G_InitGentity(), level_locals_t::gentities, gentity_t, gentity_s::inuse, level, MAX_CLIENTS, MAX_GENTITIES, NULL, level_locals_t::num_entities, gclient_s::ps, level_locals_t::startTime, level_locals_t::time, and trap_LocateGameData(). Referenced by asteroid_field_think(), Cmd_Give_f(), CreateMissile(), drop_charge(), EWeb_Create(), G_Dismember(), G_SoundTempEntity(), G_SpawnEntitiesFromString(), G_SpawnGEntityFromSpawnVars(), G_TempEntity(), InitBodyQue(), ItemUse_Sentry(), ItemUse_UseDisp(), LaunchItem(), MakeDeadSaber(), misc_faller_create(), NAV_FindClosestWaypointForPoint(), NAV_FindClosestWaypointForPoint2(), NPC_BSGM_Attack(), NPC_BSJedi_FollowLeader(), NPC_PrecacheType(), NPC_Spawn_Do(), NPC_SpawnType(), PlaceShield(), SpawnPlatTrigger(), Think_SpawnNewDoorTrigger(), turret_base_spawn_top(), WP_FireThermalDetonator(), WP_PlaceLaserTrap(), and WP_SaberInitBladeData().
00804 {
00805 int i, force;
00806 gentity_t *e;
00807
00808 e = NULL; // shut up warning
00809 i = 0; // shut up warning
00810 for ( force = 0 ; force < 2 ; force++ ) {
00811 // if we go through all entities and can't find one to free,
00812 // override the normal minimum times before use
00813 e = &g_entities[MAX_CLIENTS];
00814 for ( i = MAX_CLIENTS ; i<level.num_entities ; i++, e++) {
00815 if ( e->inuse ) {
00816 continue;
00817 }
00818
00819 // the first couple seconds of server time can involve a lot of
00820 // freeing and allocating, so relax the replacement policy
00821 if ( !force && e->freetime > level.startTime + 2000 && level.time - e->freetime < 1000 )
00822 {
00823 continue;
00824 }
00825
00826 // reuse this slot
00827 G_InitGentity( e );
00828 return e;
00829 }
00830 if ( i != MAX_GENTITIES ) {
00831 break;
00832 }
00833 }
00834 if ( i == ENTITYNUM_MAX_NORMAL ) {
00835 /*
00836 for (i = 0; i < MAX_GENTITIES; i++) {
00837 G_Printf("%4i: %s\n", i, g_entities[i].classname);
00838 }
00839 */
00840 G_SpewEntList();
00841 G_Error( "G_Spawn: no free entities" );
00842 }
00843
00844 // open up a new slot
00845 level.num_entities++;
00846
00847 // let the server system know that there are more entities
00848 trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
00849 &level.clients[0].ps, sizeof( level.clients[0] ) );
00850
00851 G_InitGentity( e );
00852 return e;
00853 }
|
|
||||||||||||
|
Definition at line 2082 of file g_utils.c. References G_AddEvent(), and gentity_t. Referenced by G_AddVoiceEvent().
02083 {
02084 G_AddEvent(self, event, 0);
02085 }
|
|
||||||||||||
|
Definition at line 197 of file g_utils.c. References level_locals_t::clients, CON_CONNECTED, clientPersistant_t::connected, level, level_locals_t::maxclients, gclient_s::pers, gclient_s::sess, clientSession_t::sessionTeam, team_t, trap_SendServerCommand(), and va(). Referenced by Use_Target_Print().
00197 {
00198 int i;
00199
00200 for ( i = 0 ; i < level.maxclients ; i++ ) {
00201 if ( level.clients[i].pers.connected == CON_CONNECTED ) {
00202 if ( level.clients[i].sess.sessionTeam == team ) {
00203 trap_SendServerCommand( i, va("%s", cmd ));
00204 }
00205 }
00206 }
00207 }
|
|
||||||||||||
|
||||||||||||||||
|
Definition at line 315 of file g_utils.c. References gentity_s::client, entityShared_t::currentOrigin, g_gravity, g_knockback, gentity_t, level, gentity_s::physicsBounce, playerState_s::pm_flags, playerState_s::pm_time, PMF_TIME_KNOCKBACK, entityState_s::pos, gclient_s::ps, gentity_s::r, gentity_s::s, level_locals_t::time, TR_LINEAR_STOP, TR_NONLINEAR_STOP, TR_STATIONARY, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, vmCvar_t::value, vec3_t, VectorAdd, VectorCopy, VectorScale, and playerState_s::velocity. Referenced by AnimateRiders(), NPC_BSGM_Attack(), Rancor_Swing(), Wampa_Slash(), and WP_SaberRadiusDamage().
00317 {
00318 vec3_t kvel;
00319 float mass;
00320
00321 if ( targ->physicsBounce > 0 ) //overide the mass
00322 {
00323 mass = targ->physicsBounce;
00324 }
00325 else
00326 {
00327 mass = 200;
00328 }
00329
00330 if ( g_gravity.value > 0 )
00331 {
00332 VectorScale( newDir, g_knockback.value * (float)push / mass * 0.8, kvel );
00333 kvel[2] = newDir[2] * g_knockback.value * (float)push / mass * 1.5;
00334 }
00335 else
00336 {
00337 VectorScale( newDir, g_knockback.value * (float)push / mass, kvel );
00338 }
00339
00340 if ( targ->client )
00341 {
00342 VectorAdd( targ->client->ps.velocity, kvel, targ->client->ps.velocity );
00343 }
00344 else if ( targ->s.pos.trType != TR_STATIONARY && targ->s.pos.trType != TR_LINEAR_STOP && targ->s.pos.trType != TR_NONLINEAR_STOP )
00345 {
00346 VectorAdd( targ->s.pos.trDelta, kvel, targ->s.pos.trDelta );
00347 VectorCopy( targ->r.currentOrigin, targ->s.pos.trBase );
00348 targ->s.pos.trTime = level.time;
00349 }
00350
00351 // set the timer so that the other client can't cancel
00352 // out the movement immediately
00353 if ( targ->client && !targ->client->ps.pm_time )
00354 {
00355 int t;
00356
00357 t = push * 2;
00358
00359 if ( t < 50 )
00360 {
00361 t = 50;
00362 }
00363 if ( t > 200 )
00364 {
00365 t = 200;
00366 }
00367 targ->client->ps.pm_time = t;
00368 targ->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
00369 }
00370 }
|
|
||||||||||||||||
|
Definition at line 1474 of file g_utils.c. References playerState_s::ammo, ammoData, gentity_s::client, gentity_t, gentity_s::health, HI_AMMODISP, HI_HEALTHDISP, gclient_s::isMedHealed, gclient_s::isMedSupplied, level, gclient_s::medSupplyDebounce, gclient_s::ps, STAT_HEALTH, STAT_MAX_HEALTH, playerState_s::stats, level_locals_t::time, playerState_s::weapon, and weaponData. Referenced by TryUse().
01475 {
01476 if (dispType == HI_HEALTHDISP)
01477 {
01478 target->client->ps.stats[STAT_HEALTH] += 4;
01479
01480 if (target->client->ps.stats[STAT_HEALTH] > target->client->ps.stats[STAT_MAX_HEALTH])
01481 {
01482 target->client->ps.stats[STAT_HEALTH] = target->client->ps.stats[STAT_MAX_HEALTH];
01483 }
01484
01485 target->client->isMedHealed = level.time + 500;
01486 target->health = target->client->ps.stats[STAT_HEALTH];
01487 }
01488 else if (dispType == HI_AMMODISP)
01489 {
01490 if (ent->client->medSupplyDebounce < level.time)
01491 { //do the next increment
01492 //increment based on the amount of ammo used per normal shot.
01493 target->client->ps.ammo[weaponData[target->client->ps.weapon].ammoIndex] += weaponData[target->client->ps.weapon].energyPerShot;
01494
01495 if (target->client->ps.ammo[weaponData[target->client->ps.weapon].ammoIndex] > ammoData[weaponData[target->client->ps.weapon].ammoIndex].max)
01496 { //cap it off
01497 target->client->ps.ammo[weaponData[target->client->ps.weapon].ammoIndex] = ammoData[weaponData[target->client->ps.weapon].ammoIndex].max;
01498 }
01499
01500 //base the next supply time on how long the weapon takes to fire. Seems fair enough.
01501 ent->client->medSupplyDebounce = level.time + weaponData[target->client->ps.weapon].fireTime;
01502 }
01503 target->client->isMedSupplied = level.time + 500;
01504 }
01505 }
|
|
||||||||||||
|
Definition at line 609 of file g_utils.c. References G_UseTargets2(), gentity_t, and gentity_s::target. Referenced by auto_turret_die(), ClientSpawn(), func_static_use(), func_timer_think(), func_usable_use(), funcBBrushDieGo(), funcBBrushUse(), GlassDie(), GlassDie_Old(), maglock_die(), multi_trigger_run(), NPC_Begin(), NPC_Spawn_Do(), ObjectDie(), player_die(), Reached_Train(), target_counter_use(), target_random_use(), target_relay_use(), Think_Target_Delay(), Touch_Item(), trigger_always_think(), turret_die(), turretG2_die(), and Use_BinaryMover_Go().
00610 {
00611 if (!ent)
00612 {
00613 return;
00614 }
00615 G_UseTargets2(ent, activator, ent->target);
00616 }
|
|
||||||||||||||||
|
||||||||||||||||
|
Definition at line 2309 of file g_utils.c. References vec3_t, vectoangles(), and VectorSubtract. Referenced by NPC_FacePosition(), and Sniper_FaceEnemy().
02310 {
02311 vec3_t v;
02312
02313 VectorSubtract( p2, p1, v );
02314 vectoangles( v, out );
02315 }
|
|
||||||||||||||||
|
Definition at line 552 of file g_utils.c. References FL_INACTIVE, gentity_s::flags, gentity_t, and gentity_s::use. Referenced by func_usable_die(), func_usable_pain(), G_Damage(), G_UseTargets2(), GEntity_UseFunc(), target_random_use(), target_relay_use(), TryUse(), and UseSiegeTarget().
00553 {
00554 if (!self || (self->flags & FL_INACTIVE))
00555 {
00556 return;
00557 }
00558
00559 if (!self->use)
00560 {
00561 return;
00562 }
00563 self->use(self, other, activator);
00564 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 2131 of file g_utils.c. References DotProduct, fabs(), G_FindClosestPointOnLineSegment(), Q3_INFINITE, qboolean, qfalse, qtrue, vec3_t, VectorCopy, VectorMA, and VectorSubtract.
02132 {
02133 float current_dist, new_dist;
02134 vec3_t new_pnt;
02135 //start1, end1 : the first segment
02136 //start2, end2 : the second segment
02137
02138 //output, one point on each segment, the closest two points on the segments.
02139
02140 //compute some temporaries:
02141 //vec start_dif = start2 - start1
02142 vec3_t start_dif;
02143 vec3_t v1;
02144 vec3_t v2;
02145 float v1v1, v2v2, v1v2;
02146 float denom;
02147
02148 VectorSubtract( start2, start1, start_dif );
02149 //vec v1 = end1 - start1
02150 VectorSubtract( end1, start1, v1 );
02151 //vec v2 = end2 - start2
02152 VectorSubtract( end2, start2, v2 );
02153 //
02154 v1v1 = DotProduct( v1, v1 );
02155 v2v2 = DotProduct( v2, v2 );
02156 v1v2 = DotProduct( v1, v2 );
02157
02158 //the main computation
02159
02160 denom = (v1v2 * v1v2) - (v1v1 * v2v2);
02161
02162 //if denom is small, then skip all this and jump to the section marked below
02163 if ( fabs(denom) > 0.001f )
02164 {
02165 float s = -( (v2v2*DotProduct( v1, start_dif )) - (v1v2*DotProduct( v2, start_dif )) ) / denom;
02166 float t = ( (v1v1*DotProduct( v2, start_dif )) - (v1v2*DotProduct( v1, start_dif )) ) / denom;
02167 qboolean done = qtrue;
02168
02169 if ( s < 0 )
02170 {
02171 done = qfalse;
02172 s = 0;// and see note below
02173 }
02174
02175 if ( s > 1 )
02176 {
02177 done = qfalse;
02178 s = 1;// and see note below
02179 }
02180
02181 if ( t < 0 )
02182 {
02183 done = qfalse;
02184 t = 0;// and see note below
02185 }
02186
02187 if ( t > 1 )
02188 {
02189 done = qfalse;
02190 t = 1;// and see note below
02191 }
02192
02193 //vec close_pnt1 = start1 + s * v1
02194 VectorMA( start1, s, v1, close_pnt1 );
02195 //vec close_pnt2 = start2 + t * v2
02196 VectorMA( start2, t, v2, close_pnt2 );
02197
02198 current_dist = Distance( close_pnt1, close_pnt2 );
02199 //now, if none of those if's fired, you are done.
02200 if ( done )
02201 {
02202 return current_dist;
02203 }
02204 //If they did fire, then we need to do some additional tests.
02205
02206 //What we are gonna do is see if we can find a shorter distance than the above
02207 //involving the endpoints.
02208 }
02209 else
02210 {
02211 //******start here for paralell lines with current_dist = infinity****
02212 current_dist = Q3_INFINITE;
02213 }
02214
02215 //test 2 close_pnts first
02216 /*
02217 G_FindClosestPointOnLineSegment( start1, end1, close_pnt2, new_pnt );
02218 new_dist = Distance( close_pnt2, new_pnt );
02219 if ( new_dist < current_dist )
02220 {//then update close_pnt1 close_pnt2 and current_dist
02221 VectorCopy( new_pnt, close_pnt1 );
02222 VectorCopy( close_pnt2, close_pnt2 );
02223 current_dist = new_dist;
02224 }
02225
02226 G_FindClosestPointOnLineSegment( start2, end2, close_pnt1, new_pnt );
02227 new_dist = Distance( close_pnt1, new_pnt );
02228 if ( new_dist < current_dist )
02229 {//then update close_pnt1 close_pnt2 and current_dist
02230 VectorCopy( close_pnt1, close_pnt1 );
02231 VectorCopy( new_pnt, close_pnt2 );
02232 current_dist = new_dist;
02233 }
02234 */
02235 //test all the endpoints
02236 new_dist = Distance( start1, start2 );
02237 if ( new_dist < current_dist )
02238 {//then update close_pnt1 close_pnt2 and current_dist
02239 VectorCopy( start1, close_pnt1 );
02240 VectorCopy( start2, close_pnt2 );
02241 current_dist = new_dist;
02242 }
02243
02244 new_dist = Distance( start1, end2 );
02245 if ( new_dist < current_dist )
02246 {//then update close_pnt1 close_pnt2 and current_dist
02247 VectorCopy( start1, close_pnt1 );
02248 VectorCopy( end2, close_pnt2 );
02249 current_dist = new_dist;
02250 }
02251
02252 new_dist = Distance( end1, start2 );
02253 if ( new_dist < current_dist )
02254 {//then update close_pnt1 close_pnt2 and current_dist
02255 VectorCopy( end1, close_pnt1 );
02256 VectorCopy( start2, close_pnt2 );
02257 current_dist = new_dist;
02258 }
02259
02260 new_dist = Distance( end1, end2 );
02261 if ( new_dist < current_dist )
02262 {//then update close_pnt1 close_pnt2 and current_dist
02263 VectorCopy( end1, close_pnt1 );
02264 VectorCopy( end2, close_pnt2 );
02265 current_dist = new_dist;
02266 }
02267
02268 //Then we have 4 more point / segment tests
02269
02270 G_FindClosestPointOnLineSegment( start2, end2, start1, new_pnt );
02271 new_dist = Distance( start1, new_pnt );
02272 if ( new_dist < current_dist )
02273 {//then update close_pnt1 close_pnt2 and current_dist
02274 VectorCopy( start1, close_pnt1 );
02275 VectorCopy( new_pnt, close_pnt2 );
02276 current_dist = new_dist;
02277 }
02278
02279 G_FindClosestPointOnLineSegment( start2, end2, end1, new_pnt );
02280 new_dist = Distance( end1, new_pnt );
02281 if ( new_dist < current_dist )
02282 {//then update close_pnt1 close_pnt2 and current_dist
02283 VectorCopy( end1, close_pnt1 );
02284 VectorCopy( new_pnt, close_pnt2 );
02285 current_dist = new_dist;
02286 }
02287
02288 G_FindClosestPointOnLineSegment( start1, end1, start2, new_pnt );
02289 new_dist = Distance( start2, new_pnt );
02290 if ( new_dist < current_dist )
02291 {//then update close_pnt1 close_pnt2 and current_dist
02292 VectorCopy( new_pnt, close_pnt1 );
02293 VectorCopy( start2, close_pnt2 );
02294 current_dist = new_dist;
02295 }
02296
02297 G_FindClosestPointOnLineSegment( start1, end1, end2, new_pnt );
02298 new_dist = Distance( end2, new_pnt );
02299 if ( new_dist < current_dist )
02300 {//then update close_pnt1 close_pnt2 and current_dist
02301 VectorCopy( new_pnt, close_pnt1 );
02302 VectorCopy( end2, close_pnt2 );
02303 current_dist = new_dist;
02304 }
02305
02306 return current_dist;
02307 }
|
|
||||||||||||||||
|
Definition at line 1623 of file g_mover.c.
01623 {
01624 if ( !other->client ) {
01625 return;
01626 }
01627
01628 if ( ent->moverState == MOVER_POS1 ) {
01629 Use_BinaryMover( ent, other, other );
01630 }
01631 }
|
|
||||||||||||
|
Definition at line 1546 of file g_utils.c. References bgSiegeClasses, BOTH_BUTTON_HOLD, BOTH_CONSOLE1, CHAN_AUTO, gentity_s::client, g_gametype, G_ScaleNetHealth(), G_SetAnim(), G_Sound(), G_SoundIndex(), gentity_t, GT_SIEGE, gentity_s::healingclass, gentity_s::healingDebounce, gentity_s::healingrate, gentity_s::healingsound, gentity_s::health, vmCvar_t::integer, gentity_s::inuse, level, gentity_s::maxHealth, siegeClass_t::name, NULL, gclient_s::ps, Q_stricmp(), qboolean, qfalse, qtrue, gentity_s::s, SETANIM_FLAG_HOLD, SETANIM_FLAG_OVERRIDE, SETANIM_TORSO, gclient_s::siegeClass, entityState_s::solid, SOLID_BMODEL, gentity_s::target_ent, level_locals_t::time, playerState_s::torsoAnim, and playerState_s::torsoTimer. Referenced by emplaced_gun_use(), and TryUse().
01547 {
01548 if (g_gametype.integer == GT_SIEGE && ent->client->siegeClass != -1 &&
01549 target && target->inuse && target->maxHealth && target->healingclass &&
01550 target->healingclass[0] && target->health > 0 && target->health < target->maxHealth)
01551 { //it's not dead yet...
01552 siegeClass_t *scl = &bgSiegeClasses[ent->client->siegeClass];
01553
01554 if (!Q_stricmp(scl->name, target->healingclass))
01555 { //this thing can be healed by the class this player is using
01556 if (target->healingDebounce < level.time)
01557 { //do the actual heal
01558 target->health += 10;
01559 if (target->health > target->maxHealth)
01560 { //don't go too high
01561 target->health = target->maxHealth;
01562 }
01563 target->healingDebounce = level.time + target->healingrate;
01564 if (target->healingsound && target->healingsound[0])
01565 { //play it
01566 if (target->s.solid == SOLID_BMODEL)
01567 { //ok, well, just play it on the client then.
01568 G_Sound(ent, CHAN_AUTO, G_SoundIndex(target->healingsound));
01569 }
01570 else
01571 {
01572 G_Sound(target, CHAN_AUTO, G_SoundIndex(target->healingsound));
01573 }
01574 }
01575
01576 //update net health for bar
01577 G_ScaleNetHealth(target);
01578 if (target->target_ent &&
01579 target->target_ent->maxHealth)
01580 {
01581 target->target_ent->health = target->health;
01582 G_ScaleNetHealth(target->target_ent);
01583 }
01584 }
01585
01586 //keep them in the healing anim even when the healing debounce is not yet expired
01587 if (ent->client->ps.torsoAnim == BOTH_BUTTON_HOLD ||
01588 ent->client->ps.torsoAnim == BOTH_CONSOLE1)
01589 { //extend the time
01590 ent->client->ps.torsoTimer = 500;
01591 }
01592 else
01593 {
01594 G_SetAnim( ent, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD, 0 );
01595 }
01596
01597 return qtrue;
01598 }
01599 }
01600
01601 return qfalse;
01602 }
|
|
|
Definition at line 1618 of file g_utils.c. References gentity_s::alliedTeam, trace_t::allsolid, AngleVectors(), bg_itemlist, bgEntity_t, vehicleInfo_t::Board, gclient_s::bodyGrabIndex, gclient_s::bodyGrabTime, BOTH_BUTTON_HOLD, BOTH_CONSOLE1, BUTTON_USE, usercmd_s::buttons, CLASS_VEHICLE, gentity_s::client, gentity_s::clipmask, clientPersistant_t::cmd, CONTENTS_BODY, CONTENTS_CORPSE, CONTENTS_ITEM, CONTENTS_SOLID, EF_RAG, entityState_s::eFlags, vehicleInfo_t::Eject, playerState_s::emplacedIndex, trace_t::entityNum, ENTITYNUM_NONE, ET_BODY, entityState_s::eType, EV_USE_ITEM0, playerState_s::forceHandExtend, trace_t::fraction, G_AddEvent(), G_CanUseDispOn(), g_entities, g_ff_objectives, g_gametype, G_SetAnim(), G_UseDispenserOn(), gentity_t, GlobalUse(), playerState_s::groundEntityNum, gSiegeRoundBegun, GT_SIEGE, GT_TEAM, HANDEXTEND_DRAGGING, HANDEXTEND_NONE, gentity_s::health, HI_AMMODISP, HI_HEALTHDISP, HI_JETPACK, vmCvar_t::integer, gentity_s::inuse, IT_HOLDABLE, ItemUse_Jetpack(), ItemUse_UseDisp(), gclient_s::jetPackOn, level, Vehicle_s::m_iBoarding, playerState_s::m_iVehicleNum, gentity_s::m_pVehicle, Vehicle_s::m_pVehicleInfo, MASK_OPAQUE, MAX_CLIENTS, entityState_s::NPC_class, NULL, entityState_s::number, OnSameTeam(), playerState_s::origin, entityShared_t::ownerNum, gclient_s::pers, playerMaxs, playerMins, playerState_s::pm_flags, PMF_FOLLOW, gclient_s::ps, qfalse, gentity_s::r, entityState_s::ragAttach, playerState_s::ragAttach, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, SETANIM_FLAG_HOLD, SETANIM_FLAG_OVERRIDE, SETANIM_TORSO, trace_t::startsolid, STAT_HOLDABLE_ITEM, STAT_HOLDABLE_ITEMS, playerState_s::stats, TEAM_SPECTATOR, level_locals_t::time, playerState_s::torsoAnim, playerState_s::torsoTimer, gentity_s::touch, Touch_Button(), trap_Trace(), TryHeal(), USE_DISTANCE, ValidUseTarget(), vec3_origin, vec3_t, VectorCopy, VectorMA, VectorSet, Vehicle_t, playerState_s::viewangles, playerState_s::viewheight, playerState_s::weaponTime, YAW, and playerState_s::zoomMode. Referenced by ClientThink_real().
01619 {
01620 gentity_t *target;
01621 trace_t trace;
01622 vec3_t src, dest, vf;
01623 vec3_t viewspot;
01624
01625 if (g_gametype.integer == GT_SIEGE &&
01626 !gSiegeRoundBegun)
01627 { //nothing can be used til the round starts.
01628 return;
01629 }
01630
01631 if (!ent || !ent->client || (ent->client->ps.weaponTime > 0 && ent->client->ps.torsoAnim != BOTH_BUTTON_HOLD && ent->client->ps.torsoAnim != BOTH_CONSOLE1) || ent->health < 1 ||
01632 (ent->client->ps.pm_flags & PMF_FOLLOW) || ent->client->sess.sessionTeam == TEAM_SPECTATOR ||
01633 (ent->client->ps.forceHandExtend != HANDEXTEND_NONE && ent->client->ps.forceHandExtend != HANDEXTEND_DRAGGING))
01634 {
01635 return;
01636 }
01637
01638 if (ent->client->ps.emplacedIndex)
01639 { //on an emplaced gun or using a vehicle, don't do anything when hitting use key
01640 return;
01641 }
01642
01643 if (ent->s.number < MAX_CLIENTS && ent->client && ent->client->ps.m_iVehicleNum)
01644 {
01645 gentity_t *currentVeh = &g_entities[ent->client->ps.m_iVehicleNum];
01646 if (currentVeh->inuse && currentVeh->m_pVehicle)
01647 {
01648 Vehicle_t *pVeh = currentVeh->m_pVehicle;
01649 if (!pVeh->m_iBoarding)
01650 {
01651 pVeh->m_pVehicleInfo->Eject( pVeh, (bgEntity_t *)ent, qfalse );
01652 }
01653 return;
01654 }
01655 }
01656
01657 if (ent->client->jetPackOn)
01658 { //can't use anything else to jp is off
01659 goto tryJetPack;
01660 }
01661
01662 if (ent->client->bodyGrabIndex != ENTITYNUM_NONE)
01663 { //then hitting the use key just means let go
01664 if (ent->client->bodyGrabTime < level.time)
01665 {
01666 gentity_t *grabbed = &g_entities[ent->client->bodyGrabIndex];
01667
01668 if (grabbed->inuse)
01669 {
01670 if (grabbed->client)
01671 {
01672 grabbed->client->ps.ragAttach = 0;
01673 }
01674 else
01675 {
01676 grabbed->s.ragAttach = 0;
01677 }
01678 }
01679 ent->client->bodyGrabIndex = ENTITYNUM_NONE;
01680 ent->client->bodyGrabTime = level.time + 1000;
01681 }
01682 return;
01683 }
01684
01685 VectorCopy(ent->client->ps.origin, viewspot);
01686 viewspot[2] += ent->client->ps.viewheight;
01687
01688 VectorCopy( viewspot, src );
01689 AngleVectors( ent->client->ps.viewangles, vf, NULL, NULL );
01690
01691 VectorMA( src, USE_DISTANCE, vf, dest );
01692
01693 //Trace ahead to find a valid target
01694 trap_Trace( &trace, src, vec3_origin, vec3_origin, dest, ent->s.number, MASK_OPAQUE|CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_ITEM|CONTENTS_CORPSE );
01695
01696 if ( trace.fraction == 1.0f || trace.entityNum < 1 )
01697 {
01698 goto tryJetPack;
01699 }
01700
01701 target = &g_entities[trace.entityNum];
01702
01703 //Enable for corpse dragging
01704 #if 0
01705 if (target->inuse && target->s.eType == ET_BODY &&
01706 ent->client->bodyGrabTime < level.time)
01707 { //then grab the body
01708 target->s.eFlags |= EF_RAG; //make sure it's in rag state
01709 if (!ent->s.number)
01710 { //switch cl 0 and entitynum_none, so we can operate on the "if non-0" concept
01711 target->s.ragAttach = ENTITYNUM_NONE;
01712 }
01713 else
01714 {
01715 target->s.ragAttach = ent->s.number;
01716 }
01717 ent->client->bodyGrabTime = level.time + 1000;
01718 ent->client->bodyGrabIndex = target->s.number;
01719 return;
01720 }
01721 #endif
01722
01723 if (target && target->m_pVehicle && target->client &&
01724 target->s.NPC_class == CLASS_VEHICLE &&
01725 !ent->client->ps.zoomMode)
01726 { //if target is a vehicle then perform appropriate checks
01727 Vehicle_t *pVeh = target->m_pVehicle;
01728
01729 if (pVeh->m_pVehicleInfo)
01730 {
01731 if ( ent->r.ownerNum == target->s.number )
01732 { //user is already on this vehicle so eject him
01733 pVeh->m_pVehicleInfo->Eject( pVeh, (bgEntity_t *)ent, qfalse );
01734 }
01735 else
01736 { // Otherwise board this vehicle.
01737 if (g_gametype.integer < GT_TEAM ||
01738 !target->alliedTeam ||
01739 (target->alliedTeam == ent->client->sess.sessionTeam))
01740 { //not belonging to a team, or client is on same team
01741 pVeh->m_pVehicleInfo->Board( pVeh, (bgEntity_t *)ent );
01742 }
01743 }
01744 //clear the damn button!
01745 ent->client->pers.cmd.buttons &= ~BUTTON_USE;
01746 return;
01747 }
01748 }
01749
01750 #if 0 //ye olde method
01751 if (ent->client->ps.stats[STAT_HOLDABLE_ITEM] > 0 &&
01752 bg_itemlist[ent->client->ps.stats[STAT_HOLDABLE_ITEM]].giType == IT_HOLDABLE)
01753 {
01754 if (bg_itemlist[ent->client->ps.stats[STAT_HOLDABLE_ITEM]].giTag == HI_HEALTHDISP ||
01755 bg_itemlist[ent->client->ps.stats[STAT_HOLDABLE_ITEM]].giTag == HI_AMMODISP)
01756 { //has a dispenser item selected
01757 if (target && target->client && target->health > 0 && OnSameTeam(ent, target) &&
01758 G_CanUseDispOn(target, bg_itemlist[ent->client->ps.stats[STAT_HOLDABLE_ITEM]].giTag))
01759 { //a live target that's on my team, we can use him
01760 G_UseDispenserOn(ent, bg_itemlist[ent->client->ps.stats[STAT_HOLDABLE_ITEM]].giTag, target);
01761
01762 //for now, we will use the standard use anim
01763 if (ent->client->ps.torsoAnim == BOTH_BUTTON_HOLD)
01764 { //extend the time
01765 ent->client->ps.torsoTimer = 500;
01766 }
01767 else
01768 {
01769 G_SetAnim( ent, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD, 0 );
01770 }
01771 ent->client->ps.weaponTime = ent->client->ps.torsoTimer;
01772 return;
01773 }
01774 }
01775 }
01776 #else
01777 if ( ((ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_HEALTHDISP)) || (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_AMMODISP))) &&
01778 target && target->inuse && target->client && target->health > 0 && OnSameTeam(ent, target) &&
01779 (G_CanUseDispOn(target, HI_HEALTHDISP) || G_CanUseDispOn(target, HI_AMMODISP)) )
01780 { //a live target that's on my team, we can use him
01781 if (G_CanUseDispOn(target, HI_HEALTHDISP))
01782 {
01783 G_UseDispenserOn(ent, HI_HEALTHDISP, target);
01784 }
01785 if (G_CanUseDispOn(target, HI_AMMODISP))
01786 {
01787 G_UseDispenserOn(ent, HI_AMMODISP, target);
01788 }
01789
01790 //for now, we will use the standard use anim
01791 if (ent->client->ps.torsoAnim == BOTH_BUTTON_HOLD)
01792 { //extend the time
01793 ent->client->ps.torsoTimer = 500;
01794 }
01795 else
01796 {
01797 G_SetAnim( ent, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD, 0 );
01798 }
01799 ent->client->ps.weaponTime = ent->client->ps.torsoTimer;
01800 return;
01801 }
01802
01803 #endif
01804
01805 //Check for a use command
01806 if ( ValidUseTarget( target )
01807 && (g_gametype.integer != GT_SIEGE
01808 || !target->alliedTeam
01809 || target->alliedTeam != ent->client->sess.sessionTeam
01810 || g_ff_objectives.integer) )
01811 {
01812 if (ent->client->ps.torsoAnim == BOTH_BUTTON_HOLD ||
01813 ent->client->ps.torsoAnim == BOTH_CONSOLE1)
01814 { //extend the time
01815 ent->client->ps.torsoTimer = 500;
01816 }
01817 else
01818 {
01819 G_SetAnim( ent, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD, 0 );
01820 }
01821 ent->client->ps.weaponTime = ent->client->ps.torsoTimer;
01822 /*
01823 NPC_SetAnim( ent, SETANIM_TORSO, BOTH_FORCEPUSH, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
01824 if ( !VectorLengthSquared( ent->client->ps.velocity ) )
01825 {
01826 NPC_SetAnim( ent, SETANIM_LEGS, BOTH_FORCEPUSH, SETANIM_FLAG_NORMAL|SETANIM_FLAG_HOLD );
01827 }
01828 */
01829 if ( target->touch == Touch_Button )
01830 {//pretend we touched it
01831 target->touch(target, ent, NULL);
01832 }
01833 else
01834 {
01835 GlobalUse(target, ent, ent);
01836 }
01837 return;
01838 }
01839
01840 if (TryHeal(ent, target))
01841 {
01842 return;
01843 }
01844
01845 tryJetPack:
01846 //if we got here, we didn't actually use anything else, so try to toggle jetpack if we are in the air, or if it is already on
01847 if (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_JETPACK))
01848 {
01849 if (ent->client->jetPackOn || ent->client->ps.groundEntityNum == ENTITYNUM_NONE)
01850 {
01851 ItemUse_Jetpack(ent);
01852 return;
01853 }
01854 }
01855
01856 if ( (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_AMMODISP)) /*&&
01857 G_ItemUsable(&ent->client->ps, HI_AMMODISP)*/ )
01858 { //if you used nothing, then try spewing out some ammo
01859 trace_t trToss;
01860 vec3_t fAng;
01861 vec3_t fwd;
01862
01863 VectorSet(fAng, 0.0f, ent->client->ps.viewangles[YAW], 0.0f);
01864 AngleVectors(fAng, fwd, 0, 0);
01865
01866 VectorMA(ent->client->ps.origin, 64.0f, fwd, fwd);
01867 trap_Trace(&trToss, ent->client->ps.origin, playerMins, playerMaxs, fwd, ent->s.number, ent->clipmask);
01868 if (trToss.fraction == 1.0f && !trToss.allsolid && !trToss.startsolid)
01869 {
01870 ItemUse_UseDisp(ent, HI_AMMODISP);
01871 G_AddEvent(ent, EV_USE_ITEM0+HI_AMMODISP, 0);
01872 return;
01873 }
01874 }
01875 }
|
|
||||||||||||||||
|
Definition at line 627 of file g_utils.c. References vec3_t.
00627 {
00628 static int index;
00629 static vec3_t vecs[8];
00630 float *v;
00631
00632 // use an array so that multiple tempvectors won't collide
00633 // for a while
00634 v = vecs[index];
00635 index = (index + 1)&7;
00636
00637 v[0] = x;
00638 v[1] = y;
00639 v[2] = z;
00640
00641 return v;
00642 }
|
|
|
Definition at line 1453 of file g_utils.c. References FL_INACTIVE, gentity_s::flags, gentity_t, qboolean, qfalse, qtrue, gentity_s::r, SVF_PLAYER_USABLE, entityShared_t::svFlags, and gentity_s::use. Referenced by TryUse().
01454 {
01455 if ( !ent->use )
01456 {
01457 return qfalse;
01458 }
01459
01460 if ( ent->flags & FL_INACTIVE )
01461 {//set by target_deactivate
01462 return qfalse;
01463 }
01464
01465 if ( !(ent->r.svFlags & SVF_PLAYER_USABLE) )
01466 {//Check for flag that denotes BUTTON_USE useability
01467 return qfalse;
01468 }
01469
01470 return qtrue;
01471 }
|
|
|
Definition at line 653 of file g_utils.c. References Com_sprintf(), and vec3_t. Referenced by Cmd_Where_f(), CP_FindCombatPointWaypoints(), FinishSpawningItem(), maglock_link(), NAV_WaypointsTooFar(), NPC_PickEnemy(), NPC_Think(), SP_func_timer(), SP_func_train(), SP_fx_runner(), SP_misc_ammo_floor_unit(), SP_misc_holocron(), SP_misc_shield_floor_unit(), SP_path_corner(), SP_point_combat(), SP_target_play_music(), SP_target_speaker(), SP_target_teleporter(), SP_waypoint(), SP_waypoint_navgoal(), SP_waypoint_navgoal_1(), SP_waypoint_navgoal_2(), SP_waypoint_navgoal_4(), SP_waypoint_navgoal_8(), SP_waypoint_small(), target_laser_start(), and Think_SetupTrainTargets().
00653 {
00654 static int index;
00655 static char str[8][32];
00656 char *s;
00657
00658 // use an array so that multiple vtos won't collide
00659 s = str[index];
00660 index = (index + 1)&7;
00661
00662 Com_sprintf (s, 32, "(%i %i %i)", (int)v[0], (int)v[1], (int)v[2]);
00663
00664 return s;
00665 }
|
|
|
Definition at line 428 of file g_utils.c. Referenced by G_CreateFakeClient(). |
|
|
Definition at line 877 of file g_utils.c. Referenced by G_KillG2Queue(), and G_SendG2KillQueue(). |
|
|
Definition at line 878 of file g_utils.c. Referenced by G_KillG2Queue(), and G_SendG2KillQueue(). |
|
|
|
|
|
Definition at line 17 of file g_utils.c. Referenced by AddRemap(), and BuildShaderStateConfig(). |
|
|
Definition at line 18 of file g_utils.c. Referenced by AddRemap(), and BuildShaderStateConfig(). |