本文整理汇总了C++中G_IsDead函数的典型用法代码示例。如果您正苦于以下问题:C++ G_IsDead函数的具体用法?C++ G_IsDead怎么用?C++ G_IsDead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_IsDead函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Touch_TouchTrigger
/**
* @brief Touch trigger
* @sa SP_trigger_touch
*/
static bool Touch_TouchTrigger (Edict* self, Edict* activator)
{
/* these actors should really not be able to trigger this - they don't move anymore */
assert(!G_IsDead(activator));
self->_owner = G_EdictsFindTargetEntity(self->target);
if (!self->owner()) {
gi.DPrintf("Target '%s' wasn't found for %s\n", self->target, self->classname);
G_FreeEdict(self);
return false;
}
if (self->owner()->flags & FL_CLIENTACTION) {
G_ActorSetClientAction(activator, self->owner());
} else if (!(self->spawnflags & TRIGGER_TOUCH_ONCE) || self->touchedNext == nullptr) {
if (!self->owner()->use) {
gi.DPrintf("Owner of %s doesn't have a use function\n", self->classname);
G_FreeEdict(self);
return false;
}
G_UseEdict(self->owner(), activator);
}
return false;
}
示例2: G_ClientEndSnapFrame
/*
* G_ClientEndSnapFrame
*
* Called for each player at the end of the server frame
* and right after spawning
*/
void G_ClientEndSnapFrame( edict_t *ent )
{
gclient_t *client;
int i;
if( trap_GetClientState( PLAYERNUM( ent ) ) < CS_SPAWNED )
return;
client = ent->r.client;
// set fov
if( !client->ps.pmove.stats[PM_STAT_ZOOMTIME] )
client->ps.fov = ent->r.client->fov;
else
{
float frac = (float)client->ps.pmove.stats[PM_STAT_ZOOMTIME] / (float)ZOOMTIME;
client->ps.fov = client->fov - ( (float)( client->fov - client->zoomfov ) * frac );
}
// If the end of unit layout is displayed, don't give
// the player any normal movement attributes
if( GS_MatchState() >= MATCH_STATE_POSTMATCH )
{
G_SetClientStats( ent );
}
else
{
if( G_IsDead( ent ) && !level.gametype.customDeadBodyCam )
{
G_Client_DeadView( ent );
}
G_PlayerWorldEffects( ent ); // burn from lava, etc
G_ClientDamageFeedback( ent ); // show damage taken along the snap
G_SetClientStats( ent );
G_SetClientEffects( ent );
G_SetClientSound( ent );
G_SetClientFrame( ent );
client->ps.plrkeys = client->resp.snap.plrkeys;
}
G_ReleaseClientPSEvent( client );
// set the delta angle
for( i = 0; i < 3; i++ )
client->ps.pmove.delta_angles[i] = ANGLE2SHORT( client->ps.viewangles[i] ) - client->ucmd.angles[i];
// this is pretty hackish. We exploit the fact that servers *do not* transmit
// origin2/old_origin for ET_PLAYER/ET_CORPSE entities, and we use it for sending the player velocity
if( !G_ISGHOSTING( ent ) )
{
ent->r.svflags |= SVF_TRANSMITORIGIN2;
VectorCopy( ent->velocity, ent->s.origin2 );
}
else
ent->r.svflags &= ~SVF_TRANSMITORIGIN2;
}
示例3: G_ReactionFireIsPossible
/**
* @brief Check whether ent can reaction fire at target, i.e. that it can see it and neither is dead etc.
* @param[in] ent The entity that might be firing
* @param[in] target The entity that might be fired at
* @return @c true if 'ent' can actually fire at 'target', @c false otherwise
*/
static bool G_ReactionFireIsPossible (const edict_t *ent, const edict_t *target)
{
float actorVis;
bool frustum;
/* an entity can't reaction fire at itself */
if (ent == target)
return false;
/* Don't react in your own turn */
if (ent->team == level.activeTeam)
return false;
/* ent can't use RF if is in STATE_DAZED (flashbang impact) */
if (G_IsDazed(ent))
return false;
if (G_IsDead(target))
return false;
/* check ent has reaction fire enabled */
if (!G_IsShaken(ent) && !G_IsReaction(ent))
return false;
/* check ent has weapon in RF hand */
/* @todo Should this situation even happen when G_IsReaction(ent) is true? */
if (!ACTOR_GET_INV(ent, ent->chr.RFmode.hand)) {
/* print character info if this happens, for now */
gi.DPrintf("Reaction fire enabled but no weapon for hand (name=%s,hand=%i,fmIdx=%i)\n",
ent->chr.name, ent->chr.RFmode.hand, ent->chr.RFmode.fmIdx);
return false;
}
if (!G_IsVisibleForTeam(target, ent->team))
return false;
/* If reaction fire is triggered by a friendly unit
* and the shooter is still sane, don't shoot;
* well, if the shooter isn't sane anymore... */
if (G_IsCivilian(target) || target->team == ent->team)
if (!G_IsShaken(ent) || (float) ent->morale / mor_shaken->value > frand())
return false;
/* check in range and visible */
if (VectorDistSqr(ent->origin, target->origin) > MAX_SPOT_DIST * MAX_SPOT_DIST)
return false;
frustum = G_FrustumVis(ent, target->origin);
if (!frustum)
return false;
actorVis = G_ActorVis(ent->origin, ent, target, true);
if (actorVis <= 0.2)
return false;
/* okay do it then */
return true;
}
示例4: G_MoraleBehaviour
/**
* @brief Applies morale behaviour on actors
* @note only called when mor_panic is not zero
* @sa G_MoralePanic
* @sa G_MoraleRage
* @sa G_MoraleStopRage
* @sa G_MoraleStopPanic
*/
void G_MoraleBehaviour (int team)
{
edict_t *ent = NULL;
int newMorale;
while ((ent = G_EdictsGetNextInUse(ent))) {
/* this only applies to ET_ACTOR but not to ET_ACTOR2x2 */
if (ent->type == ET_ACTOR && ent->team == team && !G_IsDead(ent)) {
/* civilians have a 1:1 chance to randomly run away in multiplayer */
if (sv_maxclients->integer >= 2 && level.activeTeam == TEAM_CIVILIAN && 0.5 > frand())
G_MoralePanic(ent, qfalse);
/* multiplayer needs enabled sv_enablemorale */
/* singleplayer has this in every case */
if (G_IsMoraleEnabled()) {
/* if panic, determine what kind of panic happens: */
if (ent->morale <= mor_panic->value && !G_IsPaniced(ent) && !G_IsRaged(ent)) {
qboolean sanity;
if ((float) ent->morale / mor_panic->value > (m_sanity->value * frand()))
sanity = qtrue;
else
sanity = qfalse;
if ((float) ent->morale / mor_panic->value > (m_rage->value * frand()))
G_MoralePanic(ent, sanity);
else
G_MoraleRage(ent, sanity);
/* if shaken, well .. be shaken; */
} else if (ent->morale <= mor_shaken->value && !G_IsPaniced(ent)
&& !G_IsRaged(ent)) {
/* shaken is later reset along with reaction fire */
G_SetShaken(ent);
G_SetState(ent, STATE_REACTION);
G_EventSendState(G_VisToPM(ent->visflags), ent);
G_ClientPrintf(G_PLAYER_FROM_ENT(ent), PRINT_HUD, _("%s is currently shaken.\n"),
ent->chr.name);
} else {
if (G_IsPaniced(ent))
G_MoraleStopPanic(ent);
else if (G_IsRaged(ent))
G_MoraleStopRage(ent);
}
}
G_ActorSetMaxs(ent);
/* morale-regeneration, capped at max: */
newMorale = ent->morale + MORALE_RANDOM(mor_regeneration->value);
if (newMorale > GET_MORALE(ent->chr.score.skills[ABILITY_MIND]))
ent->morale = GET_MORALE(ent->chr.score.skills[ABILITY_MIND]);
else
ent->morale = newMorale;
/* send phys data and state: */
G_SendStats(ent);
gi.EndEvents();
}
}
}
示例5: G_Vis
/**
* @brief test if check is visible by from
* @param[in] team Living team members are always visible. If this is a negative
* number we inverse the team rules (see comments included). In combination with VT_NOFRUSTUM
* we can check whether there is any edict (that is no in our team) that can see @c check
* @param[in] from is from team @c team and must be a living actor
* @param[in] check The edict we want to get the visibility for
* @param[in] flags @c VT_NOFRUSTUM, ...
*/
bool G_Vis (const int team, const Edict* from, const Edict* check, const vischeckflags_t flags)
{
vec3_t eye;
/* if any of them isn't in use, then they're not visible */
if (!from->inuse || !check->inuse)
return false;
/* only actors and 2x2 units can see anything */
if (!G_IsLivingActor(from) && !G_IsActiveCamera(from))
return false;
/* living team members are always visible */
if (team >= 0 && check->getTeam() == team && !G_IsDead(check))
return true;
/* standard team rules */
if (team >= 0 && from->getTeam() != team)
return false;
/* inverse team rules */
if (team < 0 && check->getTeam() == -team)
return false;
/* check for same pos */
if (VectorCompare(from->pos, check->pos))
return true;
if (!G_IsVisibleOnBattlefield(check))
return false;
/* view distance check */
const int spotDist = G_VisCheckDist(from);
if (VectorDistSqr(from->origin, check->origin) > spotDist * spotDist)
return false;
/* view frustum check */
if (!(flags & VT_NOFRUSTUM) && !G_FrustumVis(from, check->origin))
return false;
/* get viewers eye height */
G_ActorGetEyeVector(from, eye);
/* line trace check */
switch (check->type) {
case ET_ACTOR:
case ET_ACTOR2x2:
return G_ActorVis(eye, from, check, false) > ACTOR_VIS_0;
case ET_ITEM:
case ET_CAMERA:
case ET_PARTICLE:
return !G_LineVis(eye, check->origin);
default:
return false;
}
}
示例6: Touch_RescueTrigger
/**
* @brief Rescue trigger
* @sa SP_trigger_resuce
*/
static bool Touch_RescueTrigger (Edict* self, Edict* activator)
{
/* these actors should really not be able to trigger this - they don't move anymore */
assert(!G_IsDead(activator));
if (self->team == activator->team)
G_ActorSetInRescueZone(activator, true);
return false;
}
示例7: G_MissionIsTouched
static bool G_MissionIsTouched (Edict* self) {
linkedList_t* touched = self->touchedList;
while (touched) {
const Edict* const ent = static_cast<const Edict* const>(touched->data);
if (self->isSameTeamAs(ent) && !G_IsDead(ent))
return true;
touched = touched->next;
}
return false;
}
示例8: G_AwardResetPlayerComboStats
void G_AwardResetPlayerComboStats( edict_t *ent )
{
int i;
int resetvalue;
// combo from LB can be cancelled only if player's dead, if he missed or if he hasnt shot with LB for too long
resetvalue = ( G_IsDead( ent ) ? 0 : COMBO_FLAG( WEAP_LASERGUN ) );
for( i = 0; i < gs.maxclients; i++ )
game.clients[i].resp.awardInfo.combo[PLAYERNUM( ent )] &= resetvalue;
}
示例9: G_FindPointedPlayer
static unsigned int G_FindPointedPlayer( edict_t *self ) {
trace_t trace;
int i, j, bestNum = 0;
vec3_t boxpoints[8];
float value, dist, value_best = 0.90f; // if nothing better is found, print nothing
edict_t *other;
vec3_t vieworg, dir, viewforward;
if( G_IsDead( self ) ) {
return 0;
}
// we can't handle the thirdperson modifications in server side :/
VectorSet( vieworg, self->r.client->ps.pmove.origin[0], self->r.client->ps.pmove.origin[1], self->r.client->ps.pmove.origin[2] + self->r.client->ps.viewheight );
AngleVectors( self->r.client->ps.viewangles, viewforward, NULL, NULL );
for( i = 0; i < gs.maxclients; i++ ) {
other = PLAYERENT( i );
if( !other->r.inuse ) {
continue;
}
if( !other->r.client ) {
continue;
}
if( other == self ) {
continue;
}
if( !other->r.solid || ( other->r.svflags & SVF_NOCLIENT ) ) {
continue;
}
VectorSubtract( other->s.origin, self->s.origin, dir );
dist = VectorNormalize2( dir, dir );
if( dist > 1000 ) {
continue;
}
value = DotProduct( dir, viewforward );
if( value > value_best ) {
BuildBoxPoints( boxpoints, other->s.origin, tv( 4, 4, 4 ), tv( 4, 4, 4 ) );
for( j = 0; j < 8; j++ ) {
G_Trace( &trace, vieworg, vec3_origin, vec3_origin, boxpoints[j], self, MASK_SHOT | MASK_OPAQUE );
if( trace.ent && trace.ent == ENTNUM( other ) ) {
value_best = value;
bestNum = ENTNUM( other );
}
}
}
}
return bestNum;
}
示例10: G_ActorSetMaxs
/**
* @brief Sets correct bounding box for actor (state dependent).
* @param[in] ent Pointer to entity for which bounding box is being set.
* @note Also re-links the actor edict - because the server must know about the
* changed bounding box for tracing to work.
*/
void G_ActorSetMaxs (Edict* ent)
{
if (G_IsCrouched(ent))
VectorSet(ent->entBox.maxs, PLAYER_WIDTH, PLAYER_WIDTH, PLAYER_CROUCH);
else if (G_IsDead(ent) && !CHRSH_IsTeamDefRobot(ent->chr.teamDef))
VectorSet(ent->entBox.maxs, PLAYER_WIDTH, PLAYER_WIDTH, PLAYER_DEAD);
else
VectorSet(ent->entBox.maxs, PLAYER_WIDTH, PLAYER_WIDTH, PLAYER_STAND);
/* Link it. */
gi.LinkEdict(ent);
}
示例11: Touch_RescueTrigger
/**
* @brief Rescue trigger
* @sa SP_trigger_resuce
*/
static bool Touch_RescueTrigger (Edict* self, Edict* activator)
{
/* these actors should really not be able to trigger this - they don't move anymore */
assert(!G_IsDead(activator));
if (G_IsActor(activator)) {
Actor* actor = makeActor(activator);
if (self->isSameTeamAs(actor))
actor->setInRescueZone(true);
}
return false;
}
示例12: G_ReactionFireIsPossible
/**
* @brief Check whether ent can reaction fire at target, i.e. that it can see it and neither is dead etc.
* @param[in] ent The entity that might be firing
* @param[in] target The entity that might be fired at
* @return @c true if 'ent' can actually fire at 'target', @c false otherwise
*/
static qboolean G_ReactionFireIsPossible (const edict_t *ent, const edict_t *target)
{
float actorVis;
qboolean frustum;
/* an entity can't reaction fire at itself */
if (ent == target)
return qfalse;
/* Don't react in your own turn */
if (ent->team == level.activeTeam)
return qfalse;
/* ent can't use RF if is in STATE_DAZED (flashbang impact) */
if (G_IsDazed(ent))
return qfalse;
if (G_IsDead(target))
return qfalse;
/* check ent has reaction fire enabled */
if (!G_IsShaken(ent) && !G_IsReaction(ent))
return qfalse;
if (!G_IsVisibleForTeam(target, ent->team))
return qfalse;
/* If reaction fire is triggered by a friendly unit
* and the shooter is still sane, don't shoot;
* well, if the shooter isn't sane anymore... */
if (G_IsCivilian(target) || target->team == ent->team)
if (!G_IsShaken(ent) || (float) ent->morale / mor_shaken->value > frand())
return qfalse;
/* check in range and visible */
if (VectorDistSqr(ent->origin, target->origin) > MAX_SPOT_DIST * MAX_SPOT_DIST)
return qfalse;
frustum = G_FrustumVis(ent, target->origin);
if (!frustum)
return qfalse;
actorVis = G_ActorVis(ent->origin, target, qtrue);
if (actorVis <= 0.2)
return qfalse;
/* okay do it then */
return qtrue;
}
示例13: G_ActorStun
static bool G_ActorStun (Edict* ent, const Edict* attacker)
{
/* already dead or stunned? */
if (G_IsDead(ent))
return false;
/* no other state should be set here */
ent->state = STATE_STUN;
G_ActorSetMaxs(ent);
ent->link = attacker;
G_ActorModifyCounters(attacker, ent, -1, 0, 1);
return true;
}
示例14: G_SetClientEffects
/*
* G_SetClientEffects
*/
static void G_SetClientEffects( edict_t *ent )
{
gclient_t *client = ent->r.client;
if( G_IsDead( ent ) || GS_MatchState() >= MATCH_STATE_POSTMATCH )
return;
if( client->ps.inventory[POWERUP_QUAD] > 0 )
{
ent->s.effects |= EF_QUAD;
if( client->ps.inventory[POWERUP_QUAD] < 6 )
ent->s.effects |= EF_EXPIRING_QUAD;
}
if( client->ps.inventory[POWERUP_SHELL] > 0 )
{
ent->s.effects |= EF_SHELL;
if( client->ps.inventory[POWERUP_SHELL] < 6 )
ent->s.effects |= EF_EXPIRING_SHELL;
}
if( client->ps.inventory[POWERUP_REGEN] > 0 )
{
ent->s.effects |= EF_REGEN;
if( client->ps.inventory[POWERUP_REGEN] < 6 )
ent->s.effects |= EF_EXPIRING_REGEN;
}
if( ent->s.weapon )
{
firedef_t *firedef = GS_FiredefForPlayerState( &client->ps, ent->s.weapon );
if( firedef && firedef->fire_mode == FIRE_MODE_STRONG )
ent->s.effects |= EF_STRONG_WEAPON;
}
if( client->ps.pmove.stats[PM_STAT_STUN] )
ent->s.effects |= EF_PLAYER_STUNNED;
else
ent->s.effects &= ~EF_PLAYER_STUNNED;
// show cheaters!!!
if( ent->flags & FL_GODMODE )
ent->s.effects |= EF_GODMODE;
// add chatting icon effect
if( ent->r.client->resp.snap.buttons & BUTTON_BUSYICON )
ent->s.effects |= EF_BUSYICON;
}
示例15: G_UpdateCharacterBodycount
/**
* @brief Update character stats for this mission after successful shoot.
* @note Mind you that this code is always from the view of PHALANX soldiers right now, not anybody else!
* @param[in,out] attacker Pointer to attacker.
* @param[in] fd Pointer to fireDef_t used in shoot.
* @param[in] target Pointer to target.
* @sa G_UpdateCharacterSkills
*/
static void G_UpdateCharacterBodycount (edict_t *attacker, const fireDef_t *fd, const edict_t *target)
{
chrScoreMission_t *scoreMission;
chrScoreGlobal_t *scoreGlobal;
killtypes_t type;
if (!attacker || !target)
return;
scoreGlobal = &attacker->chr.score;
scoreMission = attacker->chr.scoreMission;
/* only phalanx soldiers have this */
if (!scoreMission)
return;
switch (target->team) {
case TEAM_ALIEN:
type = KILLED_ENEMIES;
if (fd) {
assert(fd->weaponSkill >= 0);
assert(fd->weaponSkill < lengthof(scoreMission->skillKills));
scoreMission->skillKills[fd->weaponSkill]++;
}
break;
case TEAM_CIVILIAN:
type = KILLED_CIVILIANS;
break;
case TEAM_PHALANX:
type = KILLED_TEAM;
break;
default:
return;
}
if (G_IsStunned(target)) {
scoreMission->stuns[type]++;
scoreGlobal->stuns[type]++;
} else if (G_IsDead(target)) {
scoreMission->kills[type]++;
scoreGlobal->kills[type]++;
}
}