Example #1
0
/*
================
SpawnBlood
================
*/
void SpawnBlood( vec3_t org, float damage )
{
	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, TE_BLOOD );
	trap_WriteByte( MSG_MULTICAST, 1 );
	trap_WriteCoord( MSG_MULTICAST, org[0] );
	trap_WriteCoord( MSG_MULTICAST, org[1] );
	trap_WriteCoord( MSG_MULTICAST, org[2] );
	trap_multicast( PASSVEC3( org ), MULTICAST_PVS );
}
Example #2
0
void LightningHit( gedict_t * from, float damage )
{
	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, TE_LIGHTNINGBLOOD );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] );
	trap_multicast( PASSVEC3( g_globalvars.trace_endpos ), MULTICAST_PVS );

	T_Damage( PROG_TO_EDICT( g_globalvars.trace_ent ), from, from, damage );
}
Example #3
0
//=========================================================================
// Ammo/Weapon exploded by the EMP grenade
void EMPExplode(  )
{
    float expsize;

    expsize = 10;
    if ( self->s.v.touch == ( func_t ) weapon_touch )
	expsize = 60;
    else
    {
	if ( streq( self->s.v.classname, "item_shells" ) )
	    expsize = 50 + self->aflag;
	else
	{
	    if ( streq( self->s.v.classname, "item_spikes" ) )
		expsize = 40;
	    else
	    {
		if ( streq( self->s.v.classname, "item_rockets" ) )
		    expsize = 100 + self->aflag * 4;
		else
		{
		    if ( streq( self->s.v.classname, "item_cells" ) )
			expsize = 100 + self->aflag * 3;
		    else
		    {
			if ( streq( self->s.v.classname, "item_weapon" ) )
			    expsize = 60;
			else
			{
			    G_dprintf( "EMPExplode: Attempting to explode a %s\n", self->s.v.classname );
			    return;
			}
		    }
		}
	    }
	}
    }
    tf_data.deathmsg = DMSG_GREN_EMP_AMMO;
    T_RadiusDamage( self, PROG_TO_EDICT( self->s.v.enemy ), expsize, world );
    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 ), 1 );

    // Respawn
    Respawn_Item( self, PROG_TO_EDICT( self->s.v.enemy ) );
}
Example #4
0
void spawn_tfog( vec3_t org )
{
	s = spawn();
	VectorCopy( org, s->s.v.origin );
// s->s.v.origin = org;
	s->s.v.nextthink = g_globalvars.time + 0.2;
	s->s.v.think = ( func_t ) play_teleport;

	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, TE_TELEPORT );
	trap_WriteCoord( MSG_MULTICAST, org[0] );
	trap_WriteCoord( MSG_MULTICAST, org[1] );
	trap_WriteCoord( MSG_MULTICAST, org[2] );
	trap_multicast( PASSVEC3( org ), MULTICAST_PHS );
}
Example #5
0
void W_FireSpikes( float ox )
{
	vec3_t          dir, tmp;

// gedict_t*    old;

	makevectors( self->s.v.v_angle );

	if ( self->s.v.ammo_nails >= 2 && self->s.v.weapon == IT_SUPER_NAILGUN )
	{
		W_FireSuperSpikes();
		return;
	}

	if ( self->s.v.ammo_nails < 1 )
	{
		self->s.v.weapon = W_BestWeapon();
		W_SetCurrentAmmo();
		return;
	}

	sound( self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM );
	self->attack_finished = g_globalvars.time + 0.2;
	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_nails = self->s.v.ammo_nails - 1;
	aim( dir );		// dir = aim (self, 1000);
	VectorScale( g_globalvars.v_right, ox, tmp );
	VectorAdd( tmp, self->s.v.origin, tmp );
	tmp[2] += 16;
	launch_spike( tmp, dir );

	g_globalvars.msg_entity = EDICT_TO_PROG( self );
	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );
}
Example #6
0
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 );

}
Example #7
0
/*
================
W_FireAxe
================
*/
void W_FireAxe()
{
	vec3_t          source, dest;
	vec3_t          org;

	makevectors( self->s.v.v_angle );

	VectorCopy( self->s.v.origin, source );
	source[2] += 16;
	VectorScale( g_globalvars.v_forward, 64, dest );
	VectorAdd( dest, source, dest )
	//source = self->s.v.origin + '0 0 16';
	
	traceline( PASSVEC3( source ), PASSVEC3( dest ), false, self );
	if ( g_globalvars.trace_fraction == 1.0 )
		return;

	VectorScale( g_globalvars.v_forward, 4, org );
	VectorSubtract( g_globalvars.trace_endpos, org, org );
// org = trace_endpos - v_forward*4;

	if ( PROG_TO_EDICT( g_globalvars.trace_ent )->s.v.takedamage )
	{
		PROG_TO_EDICT( g_globalvars.trace_ent )->axhitme = 1;
		SpawnBlood( org, 20 );
		if ( deathmatch > 3 )
			T_Damage( PROG_TO_EDICT( g_globalvars.trace_ent ), self, self,
				  75 );
		else
			T_Damage( PROG_TO_EDICT( g_globalvars.trace_ent ), self, self,
				  20 );
	} else
	{			// hit wall
		sound( self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM );

		trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_MULTICAST, TE_GUNSHOT );
		trap_WriteByte( MSG_MULTICAST, 3 );
		trap_WriteCoord( MSG_MULTICAST, org[0] );
		trap_WriteCoord( MSG_MULTICAST, org[1] );
		trap_WriteCoord( MSG_MULTICAST, org[2] );
		trap_multicast( PASSVEC3( org ), MULTICAST_PVS );
	}
}
Example #8
0
void GrenadeExplode()
{
	if ( self->voided )
	{
		return;
	}
	self->voided = 1;

	T_RadiusDamage( self, PROG_TO_EDICT( self->s.v.owner ), 120, world, "grenade" );

	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 );
}
Example #9
0
//=========================================================================
// 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 );
}
Example #10
0
////////////////////////////////////////
///		 Hologram
void HoloHumm ( )
{
	gedict_t *owner = PROG_TO_EDICT( self->s.v.owner );

	self->playerclass = self->playerclass + 1;
	self->s.v.nextthink = g_globalvars.time + 1;
	sound( self, 0, "ambient/100hzhum.wav", 1, 1 );
	if ( self->playerclass > 4 ) {
		trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_MULTICAST, 11 );
		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 );
		if ( self->playerclass > 4 ) {
			owner->has_holo = 1;
			self->s.v.think = ( func_t ) SUB_Remove;
		}
	}
}
Example #11
0
// 20mm cannon
// self->nojumptime < - fixes the bh w/ 20mm bug
void BigAssBullet ( vec3_t direction, float damage )
{
	vec3_t org, src, vtemp;

	makevectors( self->s.v.v_angle );
	src[0] = self->s.v.origin[0] + ( g_globalvars.v_forward[0] * 10 );
	src[1] = self->s.v.origin[1] + ( g_globalvars.v_forward[0] * 10 );
	src[2] = self->s.v.absmin[2] + ( self->s.v.size[2] * 0.7 );
	ClearMultiDamage ( );
	VectorScale( direction, 1500, vtemp );
	VectorAdd( vtemp, src, vtemp );
	traceline( PASSVEC3( src ), PASSVEC3( vtemp ), 0, self );
	//traceline( src, (src + (direction * 1500)), 0, self );
	if ( g_globalvars.trace_fraction != 1 )
		TraceAttack ( damage, direction );

	if ( PROG_TO_EDICT( g_globalvars.trace_ent )->s.v.takedamage ) {
		org[0] = g_globalvars.trace_endpos[0] - ( g_globalvars.v_forward[0] * 4 );
		org[1] = g_globalvars.trace_endpos[1] - ( g_globalvars.v_forward[1] * 4 );
		org[2] = g_globalvars.trace_endpos[2] - ( g_globalvars.v_forward[2] * 4 );
		//org = (trace_endpos - (v_forward * 4));
		SpawnBlood ( org, 9 );
	}
	else {
		//org = (trace_endpos - (v_forward * 4));
		org[0] = g_globalvars.trace_endpos[0] - ( g_globalvars.v_forward[0] * 4 );
		org[1] = g_globalvars.trace_endpos[1] - ( g_globalvars.v_forward[1] * 4 );
		org[2] = g_globalvars.trace_endpos[2] - ( g_globalvars.v_forward[0] * 4 );
		trap_WriteByte( MSG_BROADCAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_BROADCAST, TE_SPIKE );
		trap_WriteCoord( MSG_BROADCAST, org[0] );
		trap_WriteCoord( MSG_BROADCAST, org[1] );
		trap_WriteCoord( MSG_BROADCAST, org[2] );
		trap_multicast( PASSVEC3( g_globalvars.trace_endpos ), MULTICAST_PHS );
	}

	ApplyMultiDamage ( );
}
Example #12
0
void Dispenser_Explode(  )
{
    float sdmg;

    if ( self->real_owner->has_disconnected != 1 )
    {
	tf_data.deathmsg = DMSG_DISP_EXPLODION;
	sdmg = 25 + self->s.v.ammo_rockets * 1.5 + self->s.v.ammo_cells;
	if ( sdmg > 250 )
	    sdmg = 250;
	T_RadiusDamage( self, self->real_owner, sdmg, self );
    }
    ThrowGib( "progs/dgib1.mdl", -30 );
    ThrowGib( "progs/dgib2.mdl", -50 );
    ThrowGib( "progs/dgib3.mdl", -50 );
    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 ), 1 );
    BecomeExplosion(  );
}
Example #13
0
// spawn the actual holo
void HoloDood ( )
{
	gedict_t *holo;
	vec3_t vtemp;

	sound( self, 1, "weapons/railgr1a.wav", 0.6, 1 );
	holo = spawn(  );
	holo->s.v.owner = EDICT_TO_PROG( self );
	vtemp[0] =
		self->s.v.origin[0];
	vtemp[1] =
		self->s.v.origin[1];
	vtemp[2] =
		self->s.v.origin[2] + 24;
	setorigin( holo, PASSVEC3( vtemp ) );
	holo->s.v.angles[1] = self->s.v.angles[1];
	holo->s.v.angles[0] = self->s.v.angles[0];
	holo->s.v.skin = self->s.v.skin;
	holo->s.v.frame = self->s.v.frame;
	holo->s.v.colormap = self->s.v.colormap;
	holo->s.v.flags = 256;
	holo->s.v.solid = SOLID_TRIGGER;
	holo->s.v.effects = EF_DIMLIGHT;
	holo->s.v.movetype = MOVETYPE_TOSS;
	setmodel( holo, "progs/player.mdl" );
	setsize( holo, -16, -16, -24, 16, 16, 32 );
	holo->s.v.classname = "holo";
	holo->playerclass = 0;
	holo->s.v.nextthink = g_globalvars.time + 1;
	holo->s.v.think = ( func_t ) HoloHumm;
	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, 11 );
	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 );
}
Example #14
0
/*
================
W_FireShotgun
================
*/
void W_FireShotgun()
{
	vec3_t          dir;

	sound( self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM );

	g_globalvars.msg_entity = EDICT_TO_PROG( self );

	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );

	if ( deathmatch != 4 )
		self->s.v.currentammo = --( self->s.v.ammo_shells );

	//dir = aim (self, 100000);
	aim( dir );
	FireBullets( 6, dir, 0.04, 0.04, 0 );
}
Example #15
0
/*
================
W_FireSuperShotgun
================
*/
void W_FireSuperShotgun()
{
	vec3_t          dir;

	if ( self->s.v.currentammo == 1 )
	{
		W_FireShotgun();
		return;
	}
	sound( self, CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM );
	g_globalvars.msg_entity = EDICT_TO_PROG( self );

	trap_WriteByte( MSG_ONE, SVC_BIGKICK );

	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_shells = self->s.v.ammo_shells - 2;
	//dir = aim (self, 100000);
	aim( dir );
	FireBullets( 14, dir, 0.14, 0.08, 0 );
}
Example #16
0
void W_FireRocket()
{
	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_rockets =
		    self->s.v.ammo_rockets - 1;

	sound( self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM );

	g_globalvars.msg_entity = EDICT_TO_PROG( self );
	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );

	newmis = spawn();
	g_globalvars.newmis = EDICT_TO_PROG( newmis );
	newmis->s.v.owner = EDICT_TO_PROG( self );
	newmis->s.v.movetype = MOVETYPE_FLYMISSILE;
	newmis->s.v.solid = SOLID_BBOX;

// set newmis speed     
	makevectors( self->s.v.v_angle );
	aim( newmis->s.v.velocity );	// = aim(self, 1000);
	VectorScale( newmis->s.v.velocity, 1000, newmis->s.v.velocity );
// newmis->s.v.velocity = newmis->s.v.velocity * 1000;

	vectoangles( newmis->s.v.velocity, newmis->s.v.angles );
	
	newmis->s.v.touch = ( func_t ) T_MissileTouch;
	newmis->voided = 0;

// set newmis duration
	newmis->s.v.nextthink = g_globalvars.time + 5;
	newmis->s.v.think = ( func_t ) SUB_Remove;
	newmis->s.v.classname = "rocket";

	setmodel( newmis, "progs/missile.mdl" );
	setsize( newmis, 0, 0, 0, 0, 0, 0 );

// setorigin (newmis, self->s.v.origin + v_forward*8 + '0 0 16');
	setorigin( newmis, self->s.v.origin[0] + g_globalvars.v_forward[0] * 8,
			self->s.v.origin[1] + g_globalvars.v_forward[1] * 8,
			self->s.v.origin[2] + g_globalvars.v_forward[2] * 8 + 16 );
}
Example #17
0
void W_FireSuperSpikes()
{
	vec3_t          dir, tmp;

// gedict_t*    old;

	sound( self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM );
	self->attack_finished = g_globalvars.time + 0.2;
	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_nails = self->s.v.ammo_nails - 2;
	aim( dir );		//dir = aim (self, 1000);

	VectorCopy( self->s.v.origin, tmp );
	tmp[2] += 16;
	launch_spike( tmp, dir );
	newmis->s.v.touch = ( func_t ) superspike_touch;
	setmodel( newmis, "progs/s_spike.mdl" );
	setsize( newmis, 0, 0, 0, 0, 0, 0 );
	g_globalvars.msg_entity = EDICT_TO_PROG( self );
	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );
}
Example #18
0
// the trigger was just touched/killed/used
// self->s.v.enemy should be set to the activator so it can be held through a delay
// so wait for the delay g_globalvars.time before firing
void multi_trigger()
{
	if ( self->s.v.nextthink > g_globalvars.time )
	{
		return;		// allready been triggered
	}

	if ( streq( self->s.v.classname, "trigger_secret" ) )
	{
		if ( strneq( PROG_TO_EDICT( self->s.v.enemy )->s.v.classname, "player" ) )
			return;
		g_globalvars.found_secrets = g_globalvars.found_secrets + 1;
		trap_WriteByte( MSG_ALL, SVC_FOUNDSECRET );
	}

	if ( self->s.v.noise )
		sound( self, CHAN_VOICE, self->s.v.noise, 1, ATTN_NORM );

// don't trigger again until reset
	self->s.v.takedamage = DAMAGE_NO;

	activator = PROG_TO_EDICT( self->s.v.enemy );

	SUB_UseTargets();

	if ( self->wait > 0 )
	{
		self->s.v.think = ( func_t ) multi_wait;
		self->s.v.nextthink = g_globalvars.time + self->wait;
	} else
	{			// we can't just ent_remove(self) here, because this is a touch function
		// called wheil C code is looping through area links...
		self->s.v.touch = ( func_t ) SUB_Null;
		self->s.v.nextthink = g_globalvars.time + 0.1;
		self->s.v.think = ( func_t ) SUB_Remove;
	}
}
Example #19
0
void Multi_Finish()
{
	if ( puff_count )
	{
		trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_MULTICAST, TE_GUNSHOT );
		trap_WriteByte( MSG_MULTICAST, puff_count );
		trap_WriteCoord( MSG_MULTICAST, puff_org[0] );
		trap_WriteCoord( MSG_MULTICAST, puff_org[1] );
		trap_WriteCoord( MSG_MULTICAST, puff_org[2] );
		trap_multicast( PASSVEC3( puff_org ), MULTICAST_PVS );
	}

	if ( blood_count )
	{
		trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_MULTICAST, TE_BLOOD );
		trap_WriteByte( MSG_MULTICAST, blood_count );
		trap_WriteCoord( MSG_MULTICAST, blood_org[0] );
		trap_WriteCoord( MSG_MULTICAST, blood_org[1] );
		trap_WriteCoord( MSG_MULTICAST, blood_org[2] );
		trap_multicast( PASSVEC3( puff_org ), MULTICAST_PVS );
	}
}
Example #20
0
//=========================================================================
// EMP Grenade explode function, for when the PRIMETIME runs out
void EMPGrenadeExplode(  )
{
    float expsize;
    gedict_t *te;
    gedict_t *oldself;

    trap_WriteByte( MSG_BROADCAST, SVC_TEMPENTITY );
    trap_WriteByte( MSG_BROADCAST, TE_TAREXPLOSION );
    trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[0] );
    trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[1] );
    trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[2] );
    trap_multicast( PASSVEC3( self->s.v.origin ), 1 );
    for ( te = world; (te = findradius( te, self->s.v.origin, 240 )); )
    {
	if ( te->s.v.touch == ( func_t ) ammo_touch || te->s.v.touch == ( func_t ) weapon_touch )
	{
	    if ( strneq( te->s.v.classname, "item_spikes" ) )
	    {
		te->s.v.solid = SOLID_NOT;
		te->s.v.enemy = self->s.v.owner;
		te->s.v.nextthink = g_globalvars.time + 1 + g_random(  ) * 2;
		te->s.v.think = ( func_t ) EMPExplode;
	    }
	    continue;
	}

	if ( te->s.v.think == ( func_t ) TeamFortress_DetpackExplode )
	{
	    te->s.v.solid = SOLID_NOT;
	    te->s.v.nextthink = g_globalvars.time + 1 + g_random(  ) * 2;
	    dremove( te->oldenemy );
	    continue;
	}
	if ( streq( te->s.v.classname, "pipebomb" ) )
	{
	    te->s.v.nextthink = g_globalvars.time + 0.1;
	    continue;
	}
	// No sentrygun damage in mtf vanilla :(
	// Clan Edition should have tho..
	//				- XavioR
	if ( streq( te->s.v.classname, "building_dispenser" ) /*|| streq( te->s.v.classname, "building_sentrygun" )*/ )
	{
	    if ( !
		 ( ( teamplay & TEAMPLAY_NOEXPLOSIVE ) && te->team_no > 0
		   && te->team_no == PROG_TO_EDICT( self->s.v.owner )->team_no ) )
		TF_T_Damage( te, self, PROG_TO_EDICT( self->s.v.owner ), 200, 0, 4 );
	    continue;
	}
	if ( streq( te->s.v.classname, "ammobox" ) )
	{
	    expsize = 0;
	    expsize = expsize + te->s.v.ammo_shells * 0.75;
	    expsize = expsize + te->s.v.ammo_rockets * 0.75 * 2;
	    expsize = expsize + te->s.v.ammo_cells * 0.75 * 2;
	    if ( expsize > 0 )
	    {
		te->s.v.solid = SOLID_NOT;
		tf_data.deathmsg = DMSG_GREN_EMP;
		T_RadiusDamage( te, PROG_TO_EDICT( self->s.v.owner ), expsize, te );
		te->s.v.think = ( func_t ) TeamFortress_AmmoboxRemove;//SUB_Remove;
		te->s.v.nextthink = g_globalvars.time + 0.1;
		trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		trap_WriteByte( MSG_MULTICAST, TE_EXPLOSION );
		trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[0] );
		trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[1] );
		trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[2] );
		trap_multicast( PASSVEC3( te->s.v.origin ), 1 );
	    }
	    continue;
	}
	if ( streq( te->s.v.classname, "player" ) || te->s.v.touch == ( func_t ) BackpackTouch )
	{
//	    if ( !( ( teamplay & 16 ) && te->team_no > 0 && te->team_no == PROG_TO_EDICT( self->s.v.owner )->team_no ) )
//	    {
		// ^ yeah it's also kinda dumb that in mtf you can emp teammates but wtva..
		expsize = 0;
		expsize = expsize + te->s.v.ammo_shells * 0.75;
		expsize = expsize + te->s.v.ammo_rockets * 0.75 * 2;
		if ( te->playerclass != PC_ENGINEER )
		    expsize = expsize + te->s.v.ammo_cells * 0.75;
		if ( expsize > 0 )
		{
		    tf_data.deathmsg = DMSG_GREN_EMP;
		    T_RadiusDamage( te, PROG_TO_EDICT( self->s.v.owner ), expsize, te );
		    if ( te->s.v.touch != ( func_t ) BackpackTouch )
		    {
			TF_T_Damage( te, self, PROG_TO_EDICT( self->s.v.owner ), expsize, 2, 4 );
			te->s.v.ammo_shells = ceil( te->s.v.ammo_shells * 0.25 );
			te->s.v.ammo_rockets = ceil( te->s.v.ammo_rockets * 0.25 );
			if ( te->playerclass != 9 )
			    te->s.v.ammo_cells = ceil( te->s.v.ammo_cells * 0.25 );
			oldself = self;
			self = te;
			W_SetCurrentAmmo(  );
			self = oldself;
		    } else
		    {
			te->s.v.think = ( func_t ) SUB_Remove;
			te->s.v.nextthink = g_globalvars.time + 0.1;
		    }
		    trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		    trap_WriteByte( MSG_MULTICAST, TE_EXPLOSION );
		    trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[0] );
		    trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[1] );
		    trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[2] );
		    trap_multicast( PASSVEC3( te->s.v.origin ), 1 );
		}
//	    }
	    continue;
	}
    }
    dremove( self );
}
Example #21
0
///////////////////////////////////////
///	Night Vision
void TeamFortress_NightVision (  )
{
	gedict_t *te, *tl;
	te=world;

	sound( self, 0, "items/nightvis.wav", 0.5, 1 );
	// find enemies and put lightning effects around them
	te = trap_find( te, FOFS( s.v.classname ), "player" );
	while( te )
	{
		if ( self != te )
		{
			if ( te->team_no != 0 )
			{
				if ( te->s.v.health > 1 )
				{
					if ( visible( te ) )
					{
						g_globalvars.msg_entity = EDICT_TO_PROG( self );
						tl = spawn(  );
						tl->s.v.owner = EDICT_TO_PROG( self );
						VectorCopy( te->s.v.origin, tl->s.v.origin );
						tl->s.v.origin[2] = tl->s.v.origin[2] + 32;
						trap_WriteByte( MSG_ONE, 23 );
						trap_WriteByte( MSG_ONE, 9 );
						WriteEntity( MSG_ONE, tl );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 );
						dremove( tl );
					}
				}
			}
		}
		te = trap_find( te, FOFS( s.v.classname ), "player" );
	}
	te=world;
	te = trap_find( te, FOFS( s.v.classname ), "building_sentrygun" );
	while ( te )
	{
		if ( self != te )
		{
			if ( te->team_no != 0 )
			{
				if ( te->s.v.health > 1 )
				{
					if ( visible( te ) )
					{
						g_globalvars.msg_entity = EDICT_TO_PROG( self );
						tl = spawn(  );
						tl->s.v.owner = EDICT_TO_PROG( self );
						VectorCopy( te->s.v.origin, tl->s.v.origin );
						tl->s.v.origin[2] = tl->s.v.origin[2] + 32;
						trap_WriteByte( MSG_ONE, 23 );
						trap_WriteByte( MSG_ONE, 9 );
						WriteEntity( MSG_ONE, tl );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 );
						dremove( tl );
					}
				}
			}
		}
		te = trap_find( te, FOFS( s.v.classname ), "building_sentrygun" );
	}
	te=world;
	te = trap_find( te, FOFS( s.v.classname ), "bot" );
	while ( te )
	{
		if ( self != te )
		{
			if ( te->team_no != 0 )
			{
				if ( te->s.v.health > 1 )
				{
					if ( visible( te ) )
					{
						g_globalvars.msg_entity = EDICT_TO_PROG( self );
						tl = spawn(  );
						tl->s.v.owner = EDICT_TO_PROG( self );
						VectorCopy( te->s.v.origin, tl->s.v.origin );
						tl->s.v.origin[2] = tl->s.v.origin[2] + 32;
						trap_WriteByte( MSG_ONE, 23 );
						trap_WriteByte( MSG_ONE, 9 );
						WriteEntity( MSG_ONE, tl );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[0] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[1] );
						trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 );
						dremove( tl );
					}
				}
			}
		}
		te = trap_find( te, FOFS( s.v.classname ), "bot" );
	}
}
Example #22
0
/*
================
W_FireGrenade
================
*/
void W_FireGrenade()
{
	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_rockets =
		    self->s.v.ammo_rockets - 1;

	sound( self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM );

	g_globalvars.msg_entity = EDICT_TO_PROG( self );

	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );

	newmis = spawn();
	g_globalvars.newmis = EDICT_TO_PROG( newmis );
	newmis->voided = 0;
	newmis->s.v.owner = EDICT_TO_PROG( self );
	newmis->s.v.movetype = MOVETYPE_BOUNCE;
	newmis->s.v.solid = SOLID_BBOX;
	newmis->s.v.classname = "grenade";

// set newmis speed     

	makevectors( self->s.v.v_angle );

	if ( self->s.v.v_angle[0] )
	{
		newmis->s.v.velocity[0] =
		    g_globalvars.v_forward[0] * 600 + g_globalvars.v_up[0] * 200 +
		    crandom() * g_globalvars.v_right[0] * 10 +
		    crandom() * g_globalvars.v_up[0] * 10;
		newmis->s.v.velocity[1] =
		    g_globalvars.v_forward[1] * 600 + g_globalvars.v_up[1] * 200 +
		    crandom() * g_globalvars.v_right[1] * 10 +
		    crandom() * g_globalvars.v_up[1] * 10;
		newmis->s.v.velocity[2] =
		    g_globalvars.v_forward[2] * 600 + g_globalvars.v_up[2] * 200 +
		    crandom() * g_globalvars.v_right[2] * 10 +
		    crandom() * g_globalvars.v_up[0] * 10;
	} else
	{
		aim( newmis->s.v.velocity );	// = aim(self, 10000);
		VectorScale( newmis->s.v.velocity, 600, newmis->s.v.velocity );	// * 600;
		newmis->s.v.velocity[2] = 200;
	}
	SetVector( newmis->s.v.avelocity, 300, 300, 300 );
// newmis.avelocity = '300 300 300';

	vectoangles( newmis->s.v.velocity, newmis->s.v.angles );

	newmis->s.v.touch = ( func_t ) GrenadeTouch;

// set newmis duration
	if ( deathmatch == 4 )
	{
		newmis->s.v.nextthink = g_globalvars.time + 2.5;
		self->attack_finished = g_globalvars.time + 1.1;
//  self->s.v.health = self->s.v.health - 1;
		T_Damage( self, self, PROG_TO_EDICT( self->s.v.owner ), 10 );
	} else
		newmis->s.v.nextthink = g_globalvars.time + 2.5;

	newmis->s.v.think = ( func_t ) GrenadeExplode;

	setmodel( newmis, "progs/grenade.mdl" );
	setsize( newmis, 0, 0, 0, 0, 0, 0 );
	setorigin( newmis, PASSVEC3( self->s.v.origin ) );
}
Example #23
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 );
}
Example #24
0
void    FireSentryLighting( gedict_t * targ )  
{
    vec3_t  src;
    vec3_t  dst;
    vec3_t  dir, end, norm_dir;
    gedict_t*trace_ent;

    switch( tfset_sg_sfire )
    {
        case SG_SFIRE_NEW:
            VectorCopy( self->s.v.angles, self->s.v.v_angle );
            sgAimNew( self, targ, src, dst, norm_dir );

            VectorCopy(dst,end);
            break;
        case SG_SFIRE_MTFL2:
            VectorCopy( self->s.v.angles, self->s.v.v_angle );
            sgAimMTFL2( self, targ, src, dir );

            VectorNormalize( dir );
            VectorScale( dir, 2048, end );
            VectorAdd( end, src, end );
            break;

        case SG_SFIRE_MTFL1:
            VectorCopy( self->s.v.angles, self->s.v.v_angle );
        case SG_SFIRE_281:
            trap_makevectors( self->s.v.v_angle );
            VectorScale( g_globalvars.v_forward, 10, src );
            VectorAdd( self->s.v.origin, src, src );
            src[2] = self->s.v.absmin[2] + self->s.v.size[2] * 0.7;
            VectorSubtract( targ->s.v.origin, self->s.v.origin, dir );
            VectorScale( dir, 2048, end );
            VectorAdd( end, src, end );
            break;
        default:
            return;
    }
    g_globalvars.trace_ent = 0;

    traceline( PASSVEC3( src ), PASSVEC3( end ), 0, self );


    trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
    trap_WriteByte( MSG_MULTICAST, TE_LIGHTNING2 );
    WriteEntity( MSG_MULTICAST, self );
    trap_WriteCoord( MSG_MULTICAST, src[0] );
    trap_WriteCoord( MSG_MULTICAST, src[1] );
    trap_WriteCoord( MSG_MULTICAST, src[2] );
    trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] );
    trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] );
    trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] );
    trap_multicast( PASSVEC3( src ), 1 );
    if ( g_globalvars.trace_ent )
    {
        trace_ent = PROG_TO_EDICT(g_globalvars.trace_ent);
        if ( streq( trace_ent->s.v.classname, "player" ) )
        {
            switch((int)( g_random(  ) * 30) )  
            {
                case 0:
                    sound( trace_ent, 2, "player/pain1.wav" , 1, 1 );
                    break;
                case 1:
                    sound( trace_ent, 2, "player/pain1.wav" , 1, 1 );
                    break;
                case 2:
                    sound( trace_ent, 2, "player/pain2.wav" , 1, 1 );
                    break;
                case 3:
                    sound( trace_ent, 2, "player/pain3.wav" , 1, 1 );
                    break;
                case 4:
                    sound( trace_ent, 2, "player/pain4.wav" , 1, 1 );
                    break;
                case 5:
                    sound( trace_ent, 2, "player/pain5.wav" , 1, 1 );
                    break;
                case 6:
                    sound( trace_ent, 2, "player/pain6.wav" , 1, 1 );
                    break;
                default:break;
            }
        }
    }
}
Example #25
0
void W_FireLightning()
{
	vec3_t          org;
	float           cells;
	vec3_t          tmp;

	if ( self->s.v.ammo_cells < 1 )
	{
		self->s.v.weapon = W_BestWeapon();
		W_SetCurrentAmmo();
		return;
	}
// explode if under water
	if ( self->s.v.waterlevel > 1 )
	{
		if ( deathmatch > 3 )
		{
			if ( g_random() <= 0.5 )
			{
				self->deathtype = "selfwater";
				T_Damage( self, self, PROG_TO_EDICT( self->s.v.owner ),
					  4000 );
			} else
			{
				cells = self->s.v.ammo_cells;
				self->s.v.ammo_cells = 0;
				W_SetCurrentAmmo();
				T_RadiusDamage( self, self, 35 * cells, world, "" );
				return;
			}
		} else
		{
			cells = self->s.v.ammo_cells;
			self->s.v.ammo_cells = 0;
			W_SetCurrentAmmo();
			T_RadiusDamage( self, self, 35 * cells, world, "" );
			return;
		}
	}

	if ( self->t_width < g_globalvars.time )
	{
		sound( self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM );
		self->t_width = g_globalvars.time + 0.6;
	}
	g_globalvars.msg_entity = EDICT_TO_PROG( self );
	trap_WriteByte( MSG_ONE, SVC_SMALLKICK );

	if ( deathmatch != 4 )
		self->s.v.currentammo = self->s.v.ammo_cells = self->s.v.ammo_cells - 1;

	VectorCopy( self->s.v.origin, org );	//org = self->s.v.origin + '0 0 16';
	org[2] += 16;


	traceline( PASSVEC3( org ), org[0] + g_globalvars.v_forward[0] * 600,
			org[1] + g_globalvars.v_forward[1] * 600,
			org[2] + g_globalvars.v_forward[2] * 600, true, self );

	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, TE_LIGHTNING2 );
	WriteEntity( MSG_MULTICAST, self );
	trap_WriteCoord( MSG_MULTICAST, org[0] );
	trap_WriteCoord( MSG_MULTICAST, org[1] );
	trap_WriteCoord( MSG_MULTICAST, org[2] );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] );
	trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] );

	trap_multicast( PASSVEC3( org ), MULTICAST_PHS );

	VectorScale( g_globalvars.v_forward, 4, tmp );
	VectorAdd( g_globalvars.trace_endpos, tmp, tmp );
	LightningDamage( self->s.v.origin, tmp, self, 30 );
}