void Delete_Autosaves(gentity_t* ent) { int i, num; int touch[MAX_GENTITIES]; gentity_t *hit; vec3_t mins, maxs; VectorAdd( ent->r.currentOrigin, ent->r.mins, mins ); VectorAdd( ent->r.currentOrigin, ent->r.maxs, maxs ); num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); for (i=0 ; i<num ; i++) { hit = &g_entities[touch[i]]; if(Q_stricmp (hit->classname, "trigger_autosave") == 0) {//found a manually set autosave entity G_FreeEntity(hit); } } hit = NULL; while ( (hit = G_Find (hit, FOFS(classname), "info_player_deathmatch")) != NULL ) { if(hit->spawnflags & 1 && G_PointInBounds(hit->r.currentOrigin, mins, maxs)) {//found a manually set spawn point G_FreeEntity(hit); } } }
void space_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { if (!other || !other->inuse || !other->client ) //NOTE: we need vehicles to know this, too... //|| other->s.number >= MAX_CLIENTS) { return; } if (other->s.m_iVehicleNum && other->s.m_iVehicleNum <= MAX_CLIENTS ) {//a player client inside a vehicle gentity_t *veh = &g_entities[other->s.m_iVehicleNum]; if (veh->inuse && veh->client && veh->m_pVehicle && veh->m_pVehicle->m_pVehicleInfo->hideRider) { //if they are "inside" a vehicle, then let that protect them from THE HORRORS OF SPACE. return; } } if (!G_PointInBounds(other->client->ps.origin, self->absmin, self->absmax)) { //his origin must be inside the trigger return; } if (!other->client->inSpaceIndex || other->client->inSpaceIndex == ENTITYNUM_NONE) { //freshly entering space other->client->inSpaceSuffocation = level.time + INITIAL_SUFFOCATION_DELAY; } other->client->inSpaceIndex = self->s.number; }
void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) { if( !other->client ) { return; } if ( self->svFlags & SVF_INACTIVE ) {//set by target_deactivate return; } if( self->noDamageTeam ) { if ( other->client->playerTeam != self->noDamageTeam ) { return; } } // moved to just above multi_trigger because up here it just checks if the trigger is not being touched // we want it to check any conditions set on the trigger, if one of those isn't met, the trigger is considered to be "cleared" // if ( self->e_ThinkFunc == thinkF_trigger_cleared_fire ) // {//We're waiting to fire our target2 first // self->nextthink = level.time + self->speed; // return; // } if ( self->spawnflags & 1 ) { if ( other->s.number != 0 ) { return; } } else { if ( self->spawnflags & 16 ) {//NPCONLY if ( other->NPC == NULL ) { return; } } if ( self->NPC_targetname && self->NPC_targetname[0] ) { if ( other->script_targetname && other->script_targetname[0] ) { if ( Q_stricmp( self->NPC_targetname, other->script_targetname ) != 0 ) {//not the right guy to fire me off return; } } else { return; } } } if ( self->spawnflags & 2 ) {//FACING vec3_t forward; if ( other->client ) { AngleVectors( other->client->ps.viewangles, forward, NULL, NULL ); } else { AngleVectors( other->currentAngles, forward, NULL, NULL ); } if ( DotProduct( self->movedir, forward ) < 0.5 ) {//Not Within 45 degrees return; } } if ( self->spawnflags & 4 ) {//USE_BUTTON if ( !other->client ) { return; } if( !( other->client->usercmd.buttons & BUTTON_USE ) ) {//not pressing use button return; } } if ( self->spawnflags & 8 ) {//FIRE_BUTTON if ( !other->client ) { return; } if( !( other->client->ps.eFlags & EF_FIRING /*usercmd.buttons & BUTTON_ATTACK*/ ) && !( other->client->ps.eFlags & EF_ALT_FIRING/*usercmd.buttons & BUTTON_ALT_ATTACK*/ ) ) {//not pressing fire button or altfire button return; } //FIXME: do we care about the sniper rifle or not? if( other->s.number == 0 && ( other->client->ps.weapon > MAX_PLAYER_WEAPONS || other->client->ps.weapon <= WP_NONE ) ) {//don't care about non-player weapons if this is the player return; } } if ( other->client && self->radius ) { vec3_t eyeSpot; //Only works if your head is in it, but we allow leaning out //NOTE: We don't use CalcEntitySpot SPOT_HEAD because we don't want this //to be reliant on the physical model the player uses. VectorCopy(other->currentOrigin, eyeSpot); eyeSpot[2] += other->client->ps.viewheight; if ( G_PointInBounds( eyeSpot, self->absmin, self->absmax ) ) { if( !( other->client->ps.eFlags & EF_FIRING ) && !( other->client->ps.eFlags & EF_ALT_FIRING ) ) {//not attacking, so hiding bonus //FIXME: should really have sound events clear the hiddenDist other->client->hiddenDist = self->radius; //NOTE: movedir HAS to be normalized! if ( VectorLength( self->movedir ) ) {//They can only be hidden from enemies looking in this direction VectorCopy( self->movedir, other->client->hiddenDir ); } else { VectorClear( other->client->hiddenDir ); } } } } if ( self->spawnflags & 4 ) {//USE_BUTTON NPC_SetAnim( other, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); /* if ( !VectorLengthSquared( other->client->ps.velocity ) && !PM_CrouchAnim( other->client->ps.legsAnim ) ) { NPC_SetAnim( other, SETANIM_LEGS, BOTH_BUTTON_HOLD, SETANIM_FLAG_NORMAL|SETANIM_FLAG_HOLD ); } */ //other->client->ps.weaponTime = other->client->ps.torsoAnimTimer; } if ( self->e_ThinkFunc == thinkF_trigger_cleared_fire ) {//We're waiting to fire our target2 first self->nextthink = level.time + self->speed; return; } multi_trigger( self, other ); }
void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) { if( !other->client ) { return; } if ( self->flags & FL_INACTIVE ) {//set by target_deactivate return; } #ifdef _PHASE1 if (self->spawnflags & 32 && jkg_arearestrictions.integer) { return; // eezstreet: Pande's orders } #endif if( self->alliedTeam ) { if ( other->client->sess.sessionTeam != self->alliedTeam ) { return; } } // moved to just above multi_trigger because up here it just checks if the trigger is not being touched // we want it to check any conditions set on the trigger, if one of those isn't met, the trigger is considered to be "cleared" // if ( self->e_ThinkFunc == thinkF_trigger_cleared_fire ) // {//We're waiting to fire our target2 first // self->nextthink = level.time + self->speed; // return; // } if ( self->spawnflags & 1 ) { if ( other->s.eType == ET_NPC ) { return; } } else { if ( self->spawnflags & 16 ) {//NPCONLY if ( other->NPC == NULL ) { return; } } if ( self->NPC_targetname && self->NPC_targetname[0] ) { if ( other->script_targetname && other->script_targetname[0] ) { if ( Q_stricmp( self->NPC_targetname, other->script_targetname ) != 0 ) {//not the right guy to fire me off return; } } else { return; } } } if ( self->spawnflags & 2 ) {//FACING vec3_t forward; AngleVectors( other->client->ps.viewangles, forward, NULL, NULL ); if ( DotProduct( self->movedir, forward ) < 0.5 ) {//Not Within 45 degrees return; } } if ( self->spawnflags & 4 ) {//USE_BUTTON if( !( other->client->pers.cmd.buttons & BUTTON_USE ) ) {//not pressing use button return; } if ((other->client->ps.weaponTime > 0 && other->client->ps.torsoAnim != BOTH_BUTTON_HOLD && other->client->ps.torsoAnim != BOTH_CONSOLE1) || other->health < 1 || (other->client->ps.pm_flags & PMF_FOLLOW) || other->client->sess.sessionTeam == TEAM_SPECTATOR || other->client->ps.forceHandExtend != HANDEXTEND_NONE) { //player has to be free of other things to use. return; } if (self->genericValue7) { //we have to be holding the use key in this trigger for x milliseconds before firing if (!G_PointInBounds( other->client->ps.origin, self->r.absmin, self->r.absmax )) { return; } else if (other->client->isHacking != self->s.number && other->s.number < MAX_CLIENTS ) { //start the hack other->client->isHacking = self->s.number; VectorCopy(other->client->ps.viewangles, other->client->hackingAngles); other->client->ps.hackingTime = level.time + self->genericValue7; other->client->ps.hackingBaseTime = self->genericValue7; if (other->client->ps.hackingBaseTime > 60000) { //don't allow a bit overflow other->client->ps.hackingTime = level.time + 60000; other->client->ps.hackingBaseTime = 60000; } return; } else if (other->client->ps.hackingTime < level.time) { //finished with the hack, reset the hacking values and let it fall through other->client->isHacking = 0; //can't hack a client other->client->ps.hackingTime = 0; } else { //hack in progress // UQ1: Added this code from below... It would never have gotten there before... if (other->client->ps.torsoAnim != BOTH_BUTTON_HOLD && other->client->ps.torsoAnim != BOTH_CONSOLE1) { G_SetAnim( other, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); } else { other->client->ps.torsoTimer = 500; } other->client->ps.weaponTime = other->client->ps.torsoTimer; // UQ1: End added... return; } } } if ( self->spawnflags & 8 ) {//FIRE_BUTTON if( !( other->client->pers.cmd.buttons & BUTTON_ATTACK ) ) {//not pressing fire button or altfire button return; } } if ( self->radius ) { vec3_t eyeSpot; //Only works if your head is in it, but we allow leaning out //NOTE: We don't use CalcEntitySpot SPOT_HEAD because we don't want this //to be reliant on the physical model the player uses. VectorCopy(other->client->ps.origin, eyeSpot); eyeSpot[2] += other->client->ps.viewheight; if ( G_PointInBounds( eyeSpot, self->r.absmin, self->r.absmax ) ) { if( !( other->client->pers.cmd.buttons & BUTTON_ATTACK ) ) {//not attacking, so hiding bonus /* //FIXME: should really have sound events clear the hiddenDist other->client->hiddenDist = self->radius; //NOTE: movedir HAS to be normalized! if ( VectorLength( self->movedir ) ) {//They can only be hidden from enemies looking in this direction VectorCopy( self->movedir, other->client->hiddenDir ); } else { VectorClear( other->client->hiddenDir ); } */ //Not using this, at least not yet. } } } if ( self->spawnflags & 4 ) {//USE_BUTTON if (other->client->ps.torsoAnim != BOTH_BUTTON_HOLD && other->client->ps.torsoAnim != BOTH_CONSOLE1) { G_SetAnim( other, NULL, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); } else { other->client->ps.torsoTimer = 500; } other->client->ps.weaponTime = other->client->ps.torsoTimer; } if ( self->think == trigger_cleared_fire ) {//We're waiting to fire our target2 first self->nextthink = level.time + self->speed; return; } multi_trigger( self, other ); }