int CheckArea( gedict_t * obj, gedict_t * builder ) { vec3_t src; vec3_t end; int pos; gedict_t *te; pos = CheckAreaNew( obj, builder ); if ( pos == 0 ) return 0; pos = trap_pointcontents( PASSVEC3( obj->s.v.origin ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) return 0; src[0] = obj->s.v.origin[0] + 24; src[1] = obj->s.v.origin[1] + 24; src[2] = obj->s.v.origin[2] + 16; pos = trap_pointcontents( PASSVEC3( src ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) return 0; end[0] = obj->s.v.origin[0] - 16; end[1] = obj->s.v.origin[1] - 16; end[2] = obj->s.v.origin[2] - 16; traceline( PASSVEC3( src ), PASSVEC3( end ), 1, obj ); if ( g_globalvars.trace_fraction != 1 ) return 0; pos = trap_pointcontents( PASSVEC3( end ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) return 0; src[0] = obj->s.v.origin[0] - 16; src[1] = obj->s.v.origin[1] + 16; src[2] = obj->s.v.origin[2] + 16; pos = trap_pointcontents( PASSVEC3( src ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) return 0; end[0] = obj->s.v.origin[0] + 16; end[1] = obj->s.v.origin[1] - 16; end[2] = obj->s.v.origin[2] - 16; traceline( PASSVEC3( src ), PASSVEC3( end ), 1, obj ); if ( g_globalvars.trace_fraction != 1 ) return 0; pos = trap_pointcontents( PASSVEC3( end ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) return 0; traceline( PASSVEC3( builder->s.v.origin ), PASSVEC3( obj->s.v.origin ), 1, builder ); if ( g_globalvars.trace_fraction != 1 ) return 0; te = findradius( world, obj->s.v.origin, 64 ); if ( te ) return 0; return 1; }
void Laser_Touch( ) { vec3_t org; if ( other == PROG_TO_EDICT( self->s.v.owner ) ) return; // don't explode on owner if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY ) { ent_remove( self ); return; } sound( self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC ); normalize( self->s.v.velocity, org ); VectorScale( org, 8, org ); VectorSubtract( self->s.v.origin, org, org ); //org = self->s.v.origin - 8*normalize(self->s.v.velocity); if ( other->s.v.health ) { SpawnBlood( org, 15 ); TF_T_Damage( other, self, PROG_TO_EDICT( self->s.v.owner ), 15, 0, TF_TD_ELECTRICITY ); } else { TempEffectCount( org, TE_GUNSHOT, 5); } dremove( self ); }
void BotDetectTrapped(gedict_t* self) { // This tries to detect stuck bots, and fixes the situation by either jumping or committing suicide vec3_t point; int content1; VectorSet(point, self->s.v.origin[0], self->s.v.origin[1], self->s.v.origin[2] - 24); content1 = trap_pointcontents(PASSVEC3(point)); if (content1 == CONTENT_EMPTY) { self->fb.oldwaterlevel = 0; self->fb.oldwatertype = CONTENT_EMPTY; } else if (content1 == CONTENT_SOLID) { unstick_time = unstick_time + g_globalvars.frametime; if (unstick_time <= NumberOfClients()) { no_bots_stuck = false; SetJumpFlag (self, true, "Trapped1"); } else { self->fb.botchose = true; self->fb.next_impulse = CLIENTKILL; } } else { int content2 = trap_pointcontents(self->s.v.origin[0], self->s.v.origin[1], self->s.v.origin[2] + 4); if (content2 == CONTENT_EMPTY) { self->fb.oldwaterlevel = 1; self->fb.oldwatertype = content1; } else { int content3 = trap_pointcontents(self->s.v.origin[0], self->s.v.origin[1], self->s.v.origin[2] + 22); if (content3 == CONTENT_EMPTY) { self->fb.oldwaterlevel = 2; self->fb.oldwatertype = content2; } else { self->fb.oldwaterlevel = 3; self->fb.oldwatertype = content3; } } } }
void spike_touch() { //float rand; if ( other == PROG_TO_EDICT( self->s.v.owner ) ) return; if ( self->voided ) { return; } self->voided = 1; if ( other->s.v.solid == SOLID_TRIGGER ) return; // trigger field, do nothing if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY ) { ent_remove( self ); return; } // hit something that bleeds if ( other->s.v.takedamage ) { spawn_touchblood( 9 ); other->deathtype = "nail"; T_Damage( other, self, PROG_TO_EDICT( self->s.v.owner ), 9 ); } else { trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); if ( !strcmp( self->s.v.classname, "wizspike" ) ) trap_WriteByte( MSG_MULTICAST, TE_WIZSPIKE ); else if ( !strcmp( self->s.v.classname, "knightspike" ) ) trap_WriteByte( MSG_MULTICAST, TE_KNIGHTSPIKE ); else trap_WriteByte( MSG_MULTICAST, TE_SPIKE ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[0] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[1] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[2] ); trap_multicast( PASSVEC3( self->s.v.origin ), MULTICAST_PHS ); } ent_remove( self ); }
//========================================================================= // Laserbolt touch function. Just moves through the player and comes out // the other side. void LaserBolt_Touch( ) { vec3_t org; if ( other == PROG_TO_EDICT( self->s.v.owner ) ) return; // don't explode on same person twice if ( other == PROG_TO_EDICT( self->s.v.enemy ) && self->s.v.enemy ) return; if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY ) { dremove( self ); return; } normalize( self->s.v.velocity, org ); VectorScale( org, 8, org ); VectorSubtract( self->s.v.origin, org, org ); if ( other->s.v.health ) { SpawnBlood( org, 15 ); tf_data.deathmsg = DMSG_LASERBOLT; TF_T_Damage( other, self, PROG_TO_EDICT( self->s.v.enemy ), 30, 2, TF_TD_ELECTRICITY ); VectorCopy( self->s.v.oldorigin, self->s.v.velocity ); self->s.v.owner = EDICT_TO_PROG( other ); setmodel( self, "" ); self->s.v.touch = ( func_t ) SUB_Null; self->s.v.nextthink = g_globalvars.time + 0.1; self->s.v.think = ( func_t ) LaserBolt_Think; return; } else { sound( self, 1, "enforcer/enfstop.wav", 1, 1 ); trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, 11/*TE_SPIKE*/ ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[0] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[1] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[2] ); trap_multicast( PASSVEC3( self->s.v.origin ), 1 ); } dremove( self ); }
void Laser_Touch() { vec3_t org; if ( other == PROG_TO_EDICT( self->s.v.owner ) ) return; // don't explode on owner if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY ) { ent_remove( self ); return; } sound( self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC ); normalize( self->s.v.velocity, org ); VectorScale( org, 8, org ); VectorSubtract( self->s.v.origin, org, org ); //org = self->s.v.origin - 8*normalize(self->s.v.velocity); if ( ISLIVE( other ) ) { SpawnBlood( org, 15 ); other->deathtype = dtLASER; T_Damage( other, self, PROG_TO_EDICT( self->s.v.owner ), 15 ); } else { WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); WriteByte( MSG_MULTICAST, TE_GUNSHOT ); WriteByte( MSG_MULTICAST, 5 ); WriteCoord( MSG_MULTICAST, org[0] ); WriteCoord( MSG_MULTICAST, org[1] ); WriteCoord( MSG_MULTICAST, org[2] ); trap_multicast( PASSVEC3( org ), MULTICAST_PVS ); } ent_remove( self ); }
void DestroyBuilding( gedict_t * eng, char *bld ) { gedict_t *te; gedict_t *oldself; float pos; for ( te = world; (te = trap_find( te, FOFS( s.v.classname ), bld )); ) { if ( te->real_owner == eng ) { pos = trap_pointcontents( PASSVEC3( te->s.v.origin ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) { oldself = self; self = eng; self->s.v.ammo_cells = self->s.v.ammo_cells + 100; bound_other_ammo( self ); W_SetCurrentAmmo( ); self = oldself; } if ( te->real_owner->building == te ) { if ( !te->real_owner->StatusBarSize ) CenterPrint( te->real_owner, "\n" ); else te->real_owner->StatusRefreshTime = g_globalvars.time + 0.1; te->real_owner->menu_count = MENU_REFRESH_RATE; te->real_owner->current_menu = MENU_DEFAULT; te->real_owner->building = world; } if( tg_data.tg_enabled ) te->has_sentry = 0; TF_T_Damage( te, world, world, 500, 0, 0 ); } } }
/* ============================================================================== ROCKETS ============================================================================== */ void T_MissileTouch() { float damg; vec3_t tmp; // if (deathmatch == 4) // { // if ( ((other.weapon == 32) || (other.weapon == 16))) // { // if (g_random() < 0.1) // { // if (other != world) // { // // bprint (PRINT_HIGH, "Got here\n"); // other->deathtype = "blaze"; // T_Damage (other, self, self->s.v.owner, 1000 ); // T_RadiusDamage (self, self->s.v.owner, 1000, other); // } // } // } // } if ( other == PROG_TO_EDICT( self->s.v.owner ) ) return; // don't explode on owner if ( self->voided ) { return; } self->voided = 1; if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY ) { ent_remove( self ); return; } damg = 100 + g_random() * 20; if ( other->s.v.health ) { other->deathtype = "rocket"; T_Damage( other, self, PROG_TO_EDICT( self->s.v.owner ), damg ); } // don't do radius damage to the other, because all the damage // was done in the impact T_RadiusDamage( self, PROG_TO_EDICT( self->s.v.owner ), 120, other, "rocket" ); // sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM); normalize( self->s.v.velocity, tmp ); VectorScale( tmp, -8, tmp ); VectorAdd( self->s.v.origin, tmp, self->s.v.origin ) // self->s.v.origin = self->s.v.origin - 8 * normalize(self->s.v.velocity); trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_EXPLOSION ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[0] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[1] ); trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[2] ); trap_multicast( PASSVEC3( self->s.v.origin ), MULTICAST_PHS ); ent_remove( self ); }