2006-01-01 00:37:52 +00:00
/*
*/
void ( entity targ , entity inflictor , entity attacker , float damage ) T_Damage ;
void ( ) player_run ;
void ( entity bomb , entity attacker , float rad , entity ignore , string dtype ) T_RadiusDamage ;
void ( vector org , float damage ) SpawnBlood ;
void ( ) SuperDamageSound ;
2006-01-01 21:33:21 +00:00
void ( float rec , float number , float dam , float var , float ran , float auto ) W_FireShotgun ;
2006-01-01 00:37:52 +00:00
void ( float dam , float rec , string snd , float rng , float rate ) FireAssaultRifle ;
void ( float dam , float rec , string snd , float rng , float rate ) FirePistol ;
void ( float dam , float rec , string snd , float rng , float rate ) FireSMG ;
void ( ) W_PlayerMenu ;
2006-01-02 22:04:05 +00:00
//void () UseChem;
2006-01-01 21:33:21 +00:00
void ( ) Special ;
void ( ) BuyMenu ;
2006-01-01 00:37:52 +00:00
void ( ) Sneak ;
2006-01-02 22:04:05 +00:00
//void() Bandage;
2006-01-01 00:37:52 +00:00
void ( ) Shield ;
2006-01-02 03:58:02 +00:00
void ( ) player_throw1 ;
2006-01-01 21:33:21 +00:00
void ( ) player_knife1 ;
void ( ) player_knifea ;
void ( ) ExitScreen ;
void ( ) CharacterSheet ;
void ( ) UseEquipment ;
2006-01-02 03:58:02 +00:00
void ( float slot , float snd , float drop ) DropFromSlot ;
2006-01-02 00:14:21 +00:00
void ( ) PositionControl ;
2006-01-02 05:40:11 +00:00
void ( ) autofire ;
void ( ) autofire_s ;
2006-01-02 22:04:05 +00:00
float ( float iid ) UseBoostingChem ;
float ( float iid ) UseHealingChem ;
float ( float slotno ) DecreaseDestroySlot ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
# define weightx() (self.weight)
2006-01-01 00:37:52 +00:00
// called by worldspawn
void ( ) W_Precache =
{
precache_sound ( " weapons/r_exp3.wav " ) ; // new rocket explosion
precache_sound ( " weapons/rocket1i.wav " ) ; // spike gun
precache_sound ( " weapons/sgun1.wav " ) ;
precache_sound ( " weapons/guncock.wav " ) ; // player shotgun
precache_sound ( " weapons/ric1.wav " ) ; // ricochet (used in c code)
precache_sound ( " weapons/ric2.wav " ) ; // ricochet (used in c code)
precache_sound ( " weapons/ric3.wav " ) ; // ricochet (used in c code)
precache_sound ( " weapons/ric4.wav " ) ; // ricochet (used in c code)
precache_sound ( " weapons/ric5.wav " ) ; // ricochet (used in c code)
precache_sound ( " weapons/spike2.wav " ) ; // super spikes
precache_sound ( " weapons/tink1.wav " ) ; // spikes tink (used in c code)
precache_sound ( " weapons/grenade.wav " ) ; // grenade launcher
precache_sound ( " weapons/bounce.wav " ) ; // grenade bounce
precache_sound ( " weapons/shotgn2.wav " ) ; // super shotgun
} ;
float ( ) crandom =
{
return 2 * ( random ( ) - 0.5 ) ;
} ;
/*
= = = = = = = = = = = = = = = =
W_FireMelee
= = = = = = = = = = = = = = = =
*/
void ( float damage , float dist , float rate ) FireMelee =
{
local vector source ;
local vector org ;
makevectors ( self . v_angle ) ;
source = self . origin + ' 0 0 16 ' ;
traceline ( source , source + v_forward * dist , FALSE , self ) ;
if ( trace_fraction = = 1.0 )
return ;
org = trace_endpos - v_forward * 4 ;
if ( trace_ent . takedamage )
{
trace_ent . axhitme = 1 ;
SpawnBlood ( org , 20 ) ;
T_Damage ( trace_ent , self , self , damage + random ( ) * damage ) ;
}
else
{ // hit wall
sound ( self , CHAN_WEAPON , " player/axhit2.wav " , 1 , ATTN_NORM ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_SPIKE ) ;
WriteCoord ( MSG_MULTICAST , org_x ) ;
WriteCoord ( MSG_MULTICAST , org_y ) ;
WriteCoord ( MSG_MULTICAST , org_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
}
} ;
2006-01-02 22:04:05 +00:00
void ( ) W_FireMelee =
{
local float iid ;
iid = ToIID ( self . ( SlotField ( self . current_slot ) ) ) ;
if ( iid = = IID_WP_KNIFE )
FireMelee ( 5 , 32 , 0.2 ) ;
else if ( iid = = IID_WP_AXE )
FireMelee ( 10 , 64 , 0.2 ) ;
else if ( iid = = IID_WP_VIBROBLADE )
FireMelee ( 25 , 64 , 0.2 ) ;
else if ( iid = = IID_WP_POWERAXE )
FireMelee ( 50 , 96 , 0.2 ) ;
else if ( iid = = IID_CHEM_STIMPACK | |
iid = = IID_CHEM_MEDICALBAG | |
iid = = IID_CHEM_SUPERSTIM )
{
if ( UseHealingChem ( iid ) )
DecreaseDestroySlot ( self . current_slot ) ;
}
else if ( iid = = IID_CHEM_ADRENALINE | |
iid = = IID_CHEM_PSYCHO | |
iid = = IID_CHEM_BESERK )
{
if ( UseBoostingChem ( iid ) )
DecreaseDestroySlot ( self . current_slot ) ;
}
else
dprint ( strcat ( " W_FireMelee - " , ftos ( iid ) , " not implemented \n " ) ) ;
} ;
2006-01-01 00:37:52 +00:00
//============================================================================
vector ( ) wall_velocity =
{
local vector vel ;
vel = normalize ( self . velocity ) ;
vel = normalize ( vel + v_up * ( random ( ) - 0.5 ) + v_right * ( random ( ) - 0.5 ) ) ;
vel = vel + 2 * trace_plane_normal ;
vel = vel * 200 ;
return vel ;
} ;
/*
= = = = = = = = = = = = = = = =
SpawnMeatSpray
= = = = = = = = = = = = = = = =
*/
void ( vector org , vector vel ) SpawnMeatSpray =
{
local entity missile ;
missile = spawn ( ) ;
missile . owner = self ;
missile . movetype = MOVETYPE_BOUNCE ;
missile . solid = SOLID_NOT ;
makevectors ( self . angles ) ;
missile . velocity = vel ;
missile . velocity_z = missile . velocity_z + 250 + 50 * random ( ) ;
missile . avelocity = ' 3000 1000 2000 ' ;
// set missile duration
missile . nextthink = time + 1 ;
missile . think = SUB_Remove ;
setmodel ( missile , " progs/zom_gib.mdl " ) ;
setsize ( missile , ' 0 0 0 ' , ' 0 0 0 ' ) ;
setorigin ( missile , org ) ;
} ;
/*
= = = = = = = = = = = = = = = =
SpawnBlood
= = = = = = = = = = = = = = = =
*/
void ( vector org , float damage ) SpawnBlood =
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_BLOOD ) ;
WriteByte ( MSG_MULTICAST , 1 ) ;
WriteCoord ( MSG_MULTICAST , org_x ) ;
WriteCoord ( MSG_MULTICAST , org_y ) ;
WriteCoord ( MSG_MULTICAST , org_z ) ;
multicast ( org , MULTICAST_PVS ) ;
} ;
/*
= = = = = = = = = = = = = = = =
spawn_touchblood
= = = = = = = = = = = = = = = =
*/
void ( float damage ) spawn_touchblood =
{
local vector vel ;
vel = wall_velocity ( ) * 0.2 ;
SpawnBlood ( self . origin + vel * 0.01 , damage ) ;
} ;
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
MULTI - DAMAGE
Collects multiple small damages into a single damage
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
entity multi_ent ;
float multi_damage ;
vector blood_org ;
float blood_count ;
vector puff_org ;
float puff_count ;
void ( ) ClearMultiDamage =
{
multi_ent = world ;
multi_damage = 0 ;
blood_count = 0 ;
puff_count = 0 ;
} ;
void ( ) ApplyMultiDamage =
{
if ( ! multi_ent )
return ;
T_Damage ( multi_ent , self , self , multi_damage ) ;
} ;
void ( entity hit , float damage ) AddMultiDamage =
{
if ( ! hit )
return ;
if ( hit ! = multi_ent )
{
ApplyMultiDamage ( ) ;
multi_damage = damage ;
multi_ent = hit ;
}
else
multi_damage = multi_damage + damage ;
} ;
void ( ) Multi_Finish =
{
if ( puff_count )
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_GUNSHOT ) ;
WriteByte ( MSG_MULTICAST , puff_count ) ;
WriteCoord ( MSG_MULTICAST , puff_org_x ) ;
WriteCoord ( MSG_MULTICAST , puff_org_y ) ;
WriteCoord ( MSG_MULTICAST , puff_org_z ) ;
multicast ( puff_org , MULTICAST_PVS ) ;
}
if ( blood_count )
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_BLOOD ) ;
WriteByte ( MSG_MULTICAST , blood_count ) ;
WriteCoord ( MSG_MULTICAST , blood_org_x ) ;
WriteCoord ( MSG_MULTICAST , blood_org_y ) ;
WriteCoord ( MSG_MULTICAST , blood_org_z ) ;
multicast ( puff_org , MULTICAST_PVS ) ;
}
} ;
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
BULLETS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = =
TraceAttack
= = = = = = = = = = = = = = = =
*/
void ( float damage , vector dir ) TraceAttack =
{
local vector vel , org ;
vel = normalize ( dir + v_up * crandom ( ) + v_right * crandom ( ) ) ;
vel = vel + 2 * trace_plane_normal ;
vel = vel * 200 ;
org = trace_endpos - dir * 4 ;
if ( trace_ent . takedamage )
{
blood_count = blood_count + 1 ;
blood_org = org ;
AddMultiDamage ( trace_ent , damage ) ;
}
else
{
puff_count = puff_count + 1 ;
}
} ;
/*
= = = = = = = = = = = = = = = =
FireBullets
Used by shotgun , super shotgun , and enemy soldier firing
Go to the trouble of combining multiple pellets into a single damage call .
= = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
ROCKETS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
void ( ) T_MissileTouch =
{
local float damg ;
// if (deathmatch == 4)
// {
// if ( ((other.weapon == 32) || (other.weapon == 16)))
// {
// if (random() < 0.1)
// {
// if (other != world)
// {
// // bprint (PRINT_HIGH, "Got here\n");
// other.deathtype = "blaze";
// T_Damage (other, self, self.owner, 1000 );
// T_RadiusDamage (self, self.owner, 1000, other);
// }
// }
// }
// }
if ( other = = self . owner )
return ; // don't explode on owner
if ( self . voided ) {
return ;
}
self . voided = 1 ;
if ( pointcontents ( self . origin ) = = CONTENT_SKY )
{
remove ( self ) ;
return ;
}
damg = 100 + random ( ) * 20 ;
if ( other . health )
{
other . deathtype = " rocket " ;
T_Damage ( other , self , self . owner , damg ) ;
}
// don't do radius damage to the other, because all the damage
// was done in the impact
T_RadiusDamage ( self , self . owner , 120 , other , " rocket " ) ;
// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
self . origin = self . origin - 8 * normalize ( self . velocity ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_EXPLOSION ) ;
WriteCoord ( MSG_MULTICAST , self . origin_x ) ;
WriteCoord ( MSG_MULTICAST , self . origin_y ) ;
WriteCoord ( MSG_MULTICAST , self . origin_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
remove ( self ) ;
} ;
/*
= = = = = = = = = = = = = = = =
W_FireRocket
= = = = = = = = = = = = = = = =
*/
void ( ) W_FireRocket =
{
if ( deathmatch ! = 4 )
self . currentammo = self . ammo_rockets = self . ammo_rockets - 1 ;
sound ( self , CHAN_WEAPON , " weapons/sgun1.wav " , 1 , ATTN_NORM ) ;
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
newmis = spawn ( ) ;
newmis . owner = self ;
newmis . movetype = MOVETYPE_FLYMISSILE ;
newmis . solid = SOLID_BBOX ;
// set newmis speed
makevectors ( self . v_angle ) ;
newmis . velocity = aim ( self , 1000 ) ;
newmis . velocity = newmis . velocity * 1000 ;
newmis . angles = vectoangles ( newmis . velocity ) ;
newmis . touch = T_MissileTouch ;
newmis . voided = 0 ;
// set newmis duration
newmis . nextthink = time + 5 ;
newmis . think = SUB_Remove ;
newmis . classname = " rocket " ;
setmodel ( newmis , " progs/missile.mdl " ) ;
setsize ( newmis , ' 0 0 0 ' , ' 0 0 0 ' ) ;
setorigin ( newmis , self . origin + v_forward * 8 + ' 0 0 16 ' ) ;
} ;
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
LIGHTNING
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
void ( entity from , float damage ) LightningHit =
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_LIGHTNINGBLOOD ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_x ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_y ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_z ) ;
multicast ( trace_endpos , MULTICAST_PVS ) ;
T_Damage ( trace_ent , from , from , damage ) ;
} ;
/*
= = = = = = = = = = = = = = = = =
LightningDamage
= = = = = = = = = = = = = = = = =
*/
void ( vector p1 , vector p2 , entity from , float damage ) LightningDamage =
{
local entity e1 , e2 ;
local vector f ;
f = p2 - p1 ;
normalize ( f ) ;
f_x = 0 - f_y ;
f_y = f_x ;
f_z = 0 ;
f = f * 16 ;
e1 = e2 = world ;
traceline ( p1 , p2 , FALSE , self ) ;
if ( trace_ent . takedamage )
{
LightningHit ( from , damage ) ;
if ( self . classname = = " player " )
{
if ( other . classname = = " player " )
trace_ent . velocity_z = trace_ent . velocity_z + 400 ;
}
}
e1 = trace_ent ;
traceline ( p1 + f , p2 + f , FALSE , self ) ;
if ( trace_ent ! = e1 & & trace_ent . takedamage )
{
LightningHit ( from , damage ) ;
}
e2 = trace_ent ;
traceline ( p1 - f , p2 - f , FALSE , self ) ;
if ( trace_ent ! = e1 & & trace_ent ! = e2 & & trace_ent . takedamage )
{
LightningHit ( from , damage ) ;
}
} ;
void ( ) W_FireLightning =
{
local vector org ;
local float cells ;
if ( self . ammo_cells < 1 )
{
self . weapon = W_BestWeapon ( ) ;
W_SetCurrentAmmo ( ) ;
return ;
}
// explode if under water
if ( self . waterlevel > 1 )
{
if ( deathmatch > 3 )
{
if ( random ( ) < = 0.5 )
{
self . deathtype = " selfwater " ;
T_Damage ( self , self , self . owner , 4000 ) ;
}
else
{
cells = self . ammo_cells ;
self . ammo_cells = 0 ;
W_SetCurrentAmmo ( ) ;
T_RadiusDamage ( self , self , 35 * cells , world , " " ) ;
return ;
}
}
else
{
cells = self . ammo_cells ;
self . ammo_cells = 0 ;
W_SetCurrentAmmo ( ) ;
T_RadiusDamage ( self , self , 35 * cells , world , " " ) ;
return ;
}
}
if ( self . t_width < time )
{
sound ( self , CHAN_WEAPON , " weapons/lhit.wav " , 1 , ATTN_NORM ) ;
self . t_width = time + 0.6 ;
}
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
if ( deathmatch ! = 4 )
self . currentammo = self . ammo_cells = self . ammo_cells - 1 ;
org = self . origin + ' 0 0 16 ' ;
traceline ( org , org + v_forward * 600 , TRUE , self ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_LIGHTNING2 ) ;
WriteEntity ( MSG_MULTICAST , self ) ;
WriteCoord ( MSG_MULTICAST , org_x ) ;
WriteCoord ( MSG_MULTICAST , org_y ) ;
WriteCoord ( MSG_MULTICAST , org_z ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_x ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_y ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_z ) ;
multicast ( org , MULTICAST_PHS ) ;
LightningDamage ( self . origin , trace_endpos + v_forward * 4 , self , 30 ) ;
} ;
//=============================================================================
void ( ) GrenadeExplode =
{
if ( self . voided ) {
return ;
}
self . voided = 1 ;
T_RadiusDamage ( self , self . owner , 120 , world , " grenade " ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_EXPLOSION ) ;
WriteCoord ( MSG_MULTICAST , self . origin_x ) ;
WriteCoord ( MSG_MULTICAST , self . origin_y ) ;
WriteCoord ( MSG_MULTICAST , self . origin_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
remove ( self ) ;
} ;
void ( ) GrenadeTouch =
{
if ( other = = self . owner )
return ; // don't explode on owner
if ( other . takedamage = = DAMAGE_AIM )
{
GrenadeExplode ( ) ;
return ;
}
sound ( self , CHAN_WEAPON , " weapons/bounce.wav " , 1 , ATTN_NORM ) ; // bounce sound
if ( self . velocity = = ' 0 0 0 ' )
self . avelocity = ' 0 0 0 ' ;
} ;
/*
= = = = = = = = = = = = = = = =
W_FireGrenade
= = = = = = = = = = = = = = = =
*/
void ( ) W_FireGrenade =
{
if ( deathmatch ! = 4 )
self . currentammo = self . ammo_rockets = self . ammo_rockets - 1 ;
sound ( self , CHAN_WEAPON , " weapons/grenade.wav " , 1 , ATTN_NORM ) ;
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
newmis = spawn ( ) ;
newmis . voided = 0 ;
newmis . owner = self ;
newmis . movetype = MOVETYPE_BOUNCE ;
newmis . solid = SOLID_BBOX ;
newmis . classname = " grenade " ;
// set newmis speed
makevectors ( self . v_angle ) ;
if ( self . v_angle_x )
newmis . velocity = v_forward * 600 + v_up * 200 + crandom ( ) * v_right * 10 + crandom ( ) * v_up * 10 ;
else
{
newmis . velocity = aim ( self , 10000 ) ;
newmis . velocity = newmis . velocity * 600 ;
newmis . velocity_z = 200 ;
}
newmis . avelocity = ' 300 300 300 ' ;
newmis . angles = vectoangles ( newmis . velocity ) ;
newmis . touch = GrenadeTouch ;
// set newmis duration
if ( deathmatch = = 4 )
{
newmis . nextthink = time + 2.5 ;
self . attack_finished = time + 1.1 ;
// self.health = self.health - 1;
T_Damage ( self , self , self . owner , 10 ) ;
}
else
newmis . nextthink = time + 2.5 ;
newmis . think = GrenadeExplode ;
setmodel ( newmis , " progs/grenade.mdl " ) ;
setsize ( newmis , ' 0 0 0 ' , ' 0 0 0 ' ) ;
setorigin ( newmis , self . origin ) ;
} ;
//=============================================================================
void ( ) spike_touch ;
void ( ) superspike_touch ;
/*
= = = = = = = = = = = = = = =
launch_spike
Used for both the player and the ogre
= = = = = = = = = = = = = = =
*/
void ( vector org , vector dir ) launch_spike =
{
newmis = spawn ( ) ;
newmis . voided = 0 ;
newmis . owner = self ;
newmis . movetype = MOVETYPE_FLYMISSILE ;
newmis . solid = SOLID_BBOX ;
newmis . angles = vectoangles ( dir ) ;
newmis . touch = spike_touch ;
newmis . classname = " spike " ;
newmis . think = SUB_Remove ;
newmis . nextthink = time + 6 ;
setmodel ( newmis , " progs/spike.mdl " ) ;
setsize ( newmis , VEC_ORIGIN , VEC_ORIGIN ) ;
setorigin ( newmis , org ) ;
newmis . velocity = dir * 1000 ;
} ;
void ( ) W_FireSuperSpikes =
{
local vector dir ;
sound ( self , CHAN_WEAPON , " weapons/spike2.wav " , 1 , ATTN_NORM ) ;
self . attack_finished = time + 0.2 ;
if ( deathmatch ! = 4 )
self . currentammo = self . ammo_nails = self . ammo_nails - 2 ;
dir = aim ( self , 1000 ) ;
launch_spike ( self . origin + ' 0 0 16 ' , dir ) ;
newmis . touch = superspike_touch ;
setmodel ( newmis , " progs/s_spike.mdl " ) ;
setsize ( newmis , VEC_ORIGIN , VEC_ORIGIN ) ;
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
} ;
void ( float ox ) W_FireSpikes =
{
local vector dir ;
makevectors ( self . v_angle ) ;
if ( self . ammo_nails > = 2 & & self . weapon = = IT_SUPER_NAILGUN )
{
W_FireSuperSpikes ( ) ;
return ;
}
if ( self . ammo_nails < 1 )
{
self . weapon = W_BestWeapon ( ) ;
W_SetCurrentAmmo ( ) ;
return ;
}
sound ( self , CHAN_WEAPON , " weapons/rocket1i.wav " , 1 , ATTN_NORM ) ;
self . attack_finished = time + 0.2 ;
if ( deathmatch ! = 4 )
self . currentammo = self . ammo_nails = self . ammo_nails - 1 ;
dir = aim ( self , 1000 ) ;
launch_spike ( self . origin + ' 0 0 16 ' + v_right * ox , dir ) ;
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
} ;
2006-01-02 22:04:05 +00:00
//.float hit_z;
2006-01-01 00:37:52 +00:00
void ( ) spike_touch =
{
if ( other = = self . owner )
return ;
if ( self . voided ) {
return ;
}
self . voided = 1 ;
if ( other . solid = = SOLID_TRIGGER )
return ; // trigger field, do nothing
if ( pointcontents ( self . origin ) = = CONTENT_SKY )
{
remove ( self ) ;
return ;
}
// hit something that bleeds
if ( other . takedamage )
{
spawn_touchblood ( 9 ) ;
other . deathtype = " nail " ;
T_Damage ( other , self , self . owner , 9 ) ;
}
else
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
if ( self . classname = = " wizspike " )
WriteByte ( MSG_MULTICAST , TE_WIZSPIKE ) ;
else if ( self . classname = = " knightspike " )
WriteByte ( MSG_MULTICAST , TE_KNIGHTSPIKE ) ;
else
WriteByte ( MSG_MULTICAST , TE_SPIKE ) ;
WriteCoord ( MSG_MULTICAST , self . origin_x ) ;
WriteCoord ( MSG_MULTICAST , self . origin_y ) ;
WriteCoord ( MSG_MULTICAST , self . origin_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
}
remove ( self ) ;
} ;
void ( ) superspike_touch =
{
if ( other = = self . owner )
return ;
if ( self . voided ) {
return ;
}
self . voided = 1 ;
if ( other . solid = = SOLID_TRIGGER )
return ; // trigger field, do nothing
if ( pointcontents ( self . origin ) = = CONTENT_SKY )
{
remove ( self ) ;
return ;
}
// hit something that bleeds
if ( other . takedamage )
{
spawn_touchblood ( 18 ) ;
other . deathtype = " supernail " ;
T_Damage ( other , self , self . owner , 18 ) ;
}
else
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_SUPERSPIKE ) ;
WriteCoord ( MSG_MULTICAST , self . origin_x ) ;
WriteCoord ( MSG_MULTICAST , self . origin_y ) ;
WriteCoord ( MSG_MULTICAST , self . origin_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
}
remove ( self ) ;
} ;
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PLAYER WEAPON USE
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2006-01-02 03:58:02 +00:00
void ( ) SetWeaponModel =
2006-01-01 00:37:52 +00:00
{
2006-01-02 03:58:02 +00:00
self . weaponmodel = GetItemVModel ( ToIID ( ItemInSlot ( self , self . current_slot ) ) ) ;
2006-01-01 00:37:52 +00:00
} ;
void ( ) W_SetCurrentAmmo =
{
local string x ;
player_run ( ) ; // get out of any weapon firing states
self . items = self . items - ( self . items & ( IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS ) ) ;
2006-01-02 03:58:02 +00:00
/*SPIKEREMOVED
2006-01-01 00:37:52 +00:00
if ( self . current_slot = = 1 )
2006-01-02 03:58:02 +00:00
self . currentammo = ToStatus ( self . islot1 ) ;
2006-01-01 00:37:52 +00:00
else if ( self . current_slot = = 2 )
2006-01-02 03:58:02 +00:00
self . currentammo = ToStatus ( self . islot2 ) ;
2006-01-01 00:37:52 +00:00
else if ( self . current_slot = = 3 & & self . handgrenade > 0 )
self . currentammo = self . handgrenade ;
else if ( self . current_slot = = 4 )
{
if ( self . team = = 1 )
{
sound ( self , CHAN_WEAPON , " misc/tools.wav " , 1 , ATTN_NORM ) ;
self . items = ( self . items | IT_LIGHTNING ) ;
self . currentammo = 0 ;
self . weaponmodel = " " ;
}
else
sound ( self , CHAN_WEAPON , " misc/menu3.wav " , 1 , ATTN_NORM ) ;
}
2006-01-02 03:58:02 +00:00
*/
// else
2006-01-01 00:37:52 +00:00
sound ( self , CHAN_WEAPON , " misc/menu3.wav " , 1 , ATTN_NORM ) ;
if ( self . current_slot = = 1 )
2006-01-02 03:58:02 +00:00
x = GetItemName ( ToIID ( self . islot1 ) ) ;
2006-01-01 00:37:52 +00:00
if ( self . current_slot = = 2 )
2006-01-02 03:58:02 +00:00
x = GetItemName ( ToIID ( self . islot2 ) ) ;
/*SPIKEREMOVED
2006-01-01 00:37:52 +00:00
if ( self . current_slot = = 3 )
x = " grenade " ;
if ( self . current_slot = = 4 )
x = " tools " ;
2006-01-02 03:58:02 +00:00
*/
2006-01-01 00:37:52 +00:00
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " selected. \n " ) ;
sound ( self , CHAN_WEAPON , " misc/weapon.wav " , 1 , ATTN_NORM ) ;
2006-01-02 03:58:02 +00:00
SetWeaponModel ( ) ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
self . currentammo = ToStatus ( ItemInSlot ( self , self . current_slot ) ) ;
2006-01-01 00:37:52 +00:00
} ;
float ( ) W_BestWeapon =
{
local float it ;
it = self . items ;
if ( self . waterlevel < = 1 & & self . ammo_cells > = 1 & & ( it & IT_LIGHTNING ) )
return IT_LIGHTNING ;
else if ( self . ammo_nails > = 2 & & ( it & IT_SUPER_NAILGUN ) )
return IT_SUPER_NAILGUN ;
else if ( self . ammo_shells > = 2 & & ( it & IT_SUPER_SHOTGUN ) )
return IT_SUPER_SHOTGUN ;
else if ( self . ammo_nails > = 1 & & ( it & IT_NAILGUN ) )
return IT_NAILGUN ;
else if ( self . ammo_shells > = 1 & & ( it & IT_SHOTGUN ) )
return IT_SHOTGUN ;
/*
if ( self . ammo_rockets > = 1 & & ( it & IT_ROCKET_LAUNCHER ) )
return IT_ROCKET_LAUNCHER ;
else if ( self . ammo_rockets > = 1 & & ( it & IT_GRENADE_LAUNCHER ) )
return IT_GRENADE_LAUNCHER ;
*/
return IT_AXE ;
} ;
2006-01-02 03:58:02 +00:00
void ( float slotno ) ReloadWeapon =
2006-01-01 00:37:52 +00:00
{
2006-01-02 03:58:02 +00:00
local float at ;
local float as ;
local float asv ;
local float ac ;
2006-01-01 00:37:52 +00:00
local float x ;
2006-01-02 03:58:02 +00:00
local float wid ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
local . float wslot ;
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
if ( self . rtime > time | | self . attack_finished > time )
2006-01-01 21:33:21 +00:00
return ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
wslot = SlotField ( slotno ) ;
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
if ( self . wslot = = 0 )
return ; //already empty..
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
wid = ToIID ( self . wslot ) ;
at = WeaponAmmoType ( wid ) ;
as = SlotOfItem ( self , at ) ;
if ( as = = 0 )
{
sprint ( self , 2 , " no suitable ammo \n " ) ;
2006-01-02 00:14:21 +00:00
return ;
2006-01-01 00:37:52 +00:00
}
2006-01-02 03:58:02 +00:00
asv = ItemInSlot ( self , as ) ;
ac = ToStatus ( asv ) ;
2006-01-02 02:48:58 +00:00
2006-01-02 03:58:02 +00:00
x = WeaponMagQuant ( wid ) ; //get the max ammo capacity
x = x - ToStatus ( self . wslot ) ; //take away the ammo currently in the weapon
if ( x > ac ) //make sure there's enough ammo
x = ac ;
ac - = x ;
if ( ac )
asv = SlotVal ( at , ac ) ;
else
asv = 0 ; //totally used up.
SetItemSlot ( self , as , asv ) ;
self . wslot = SlotVal ( wid , x + ToStatus ( self . wslot ) ) ;
if ( wid = = IID_WP_PIPERIFLE | | wid = = IID_WP_WINCHESTER | | wid = = IID_WP_MOSSBERG )
sound ( self , CHAN_WEAPON , " weapons/shell.wav " , TRUE , ATTN_NORM ) ;
else
2006-01-01 21:33:21 +00:00
sound ( self , CHAN_WEAPON , " weapons/reload.wav " , TRUE , ATTN_NORM ) ;
2006-01-02 03:58:02 +00:00
sprint ( self , 2 , " reloading... \n " ) ;
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
if ( self . perk = = 3 )
{
self . attack_finished = time + 1 ;
self . rtime = time + 1 ;
}
else
{
self . attack_finished = time + 2 ;
2006-01-02 00:14:21 +00:00
self . rtime = time + 2 ;
2006-01-01 00:37:52 +00:00
}
2006-01-02 03:58:02 +00:00
if ( self . current_slot = = slotno )
self . currentammo = ToStatus ( ItemInSlot ( self , slotno ) ) ;
player_run ( ) ;
2006-01-01 00:37:52 +00:00
} ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
float ( ) W_CheckNoAmmo =
{
2006-01-02 03:58:02 +00:00
local float at ;
local . float slotfield ;
slotfield = SlotField ( self . current_slot ) ;
2006-01-02 02:48:58 +00:00
2006-01-02 03:58:02 +00:00
if ( ToIID ( self . slotfield ) = = IID_NONE )
return FALSE ;
if ( ToStatus ( self . slotfield ) < 1 )
2006-01-01 00:37:52 +00:00
{
2006-01-02 03:58:02 +00:00
at = WeaponAmmoType ( ToIID ( self . slotfield ) ) ;
if ( at = = 0 )
2006-01-01 00:37:52 +00:00
return FALSE ;
2006-01-02 03:58:02 +00:00
at = SlotOfItem ( self , at ) ;
if ( at = = 0 )
2006-01-01 00:37:52 +00:00
{
self . attack_finished = ( time + 0.2 ) ;
stuffcmd ( self , " -attack \n " ) ;
sound ( self , CHAN_WEAPON , " weapons/click.wav " , TRUE , ATTN_NORM ) ;
return TRUE ;
}
2006-01-02 03:58:02 +00:00
else
2006-01-01 00:37:52 +00:00
{
stuffcmd ( self , " -attack \n " ) ;
2006-01-02 03:58:02 +00:00
ReloadWeapon ( self . current_slot ) ;
2006-01-01 00:37:52 +00:00
return TRUE ;
}
}
return FALSE ;
} ;
/*
= = = = = = = = = = = =
W_Attack
An attack impulse can be triggered now
= = = = = = = = = = = =
*/
void ( ) W_Attack =
{
2006-01-02 22:04:05 +00:00
local float weap ;
2006-01-01 00:37:52 +00:00
makevectors ( self . v_angle ) ; // calculate forward angle for velocity
self . show_hostile = time + 1 ; // wake monsters up
2006-01-02 03:58:02 +00:00
if ( self . rtime > time )
return ;
2006-01-01 00:37:52 +00:00
2006-01-01 21:33:21 +00:00
if ( W_CheckNoAmmo ( ) )
return ;
2006-01-02 03:58:02 +00:00
weap = ToIID ( self . ( SlotField ( self . current_slot ) ) ) ;
2006-01-01 00:37:52 +00:00
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
if ( weap = = IID_NONE | |
weap = = IID_WP_KNIFE | |
weap = = IID_WP_AXE | |
weap = = IID_WP_VIBROBLADE | |
weap = = IID_WP_POWERAXE )
2006-01-01 00:37:52 +00:00
{
2006-01-01 21:33:21 +00:00
self . attack_finished = time + 0.25 ;
player_knife1 ( ) ;
2006-01-01 00:37:52 +00:00
}
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_USP )
2006-01-01 21:33:21 +00:00
FirePistol ( 10 , 2 , " weapons/1911.wav " , 2000 , 0.25 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_DEAGLE )
2006-01-01 21:33:21 +00:00
FirePistol ( 10 , 2 , " weapons/deagle.wav " , 2000 , 0.25 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_NEEDLER )
2006-01-01 21:33:21 +00:00
FirePistol ( 10 , 2 , " weapons/needler.wav " , 2000 , 0.25 ) ;
2006-01-02 03:58:02 +00:00
//if (weap == IID_WP_ALIENBLASTER)
2006-01-01 21:33:21 +00:00
// FireAlienBlaster();
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_PIPERIFLE )
2006-01-01 21:33:21 +00:00
FireAssaultRifle ( 18 , 2 , " weapons/rangem.wav " , 3000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_WINCHESTER )
2006-01-01 21:33:21 +00:00
W_FireShotgun ( 1 , 5 , 6 , 160 , 3000 , 0 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_MOSSBERG )
2006-01-01 21:33:21 +00:00
W_FireShotgun ( 1 , 5 , 6 , 160 , 3000 , 0 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_JACKHAMMER )
2006-01-01 21:33:21 +00:00
W_FireShotgun ( 1 , 5 , 6 , 160 , 3000 , 1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_MP9 )
2006-01-02 00:14:21 +00:00
FireSMG ( 12 , 2 , " weapons/mp9.wav " , 2000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_MP7 )
2006-01-02 00:14:21 +00:00
FireSMG ( 12 , 2 , " weapons/mp7.wav " , 2000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_RANGERMASTER )
2006-01-01 21:33:21 +00:00
FireAssaultRifle ( 14 , 2 , " weapons/rangem.wav " , 4000 , 0.5 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_AK112 )
2006-01-01 21:33:21 +00:00
FireAssaultRifle ( 14 , 2 , " weapons/rangem.wav " , 4000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_AK74 )
2006-01-01 00:37:52 +00:00
FireAssaultRifle ( 18 , 2 , " weapons/ak47.wav " , 6000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_DKS1 )
2006-01-01 21:33:21 +00:00
FireAssaultRifle ( 30 , 2 , " weapons/dks-1.wav " , 8000 , 0.5 ) ;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_WP_MOONLIGHT )
2006-01-01 21:33:21 +00:00
FireAssaultRifle ( 16 , 2 , " weapons/m4a1.wav " , 4000 , 0.1 ) ;
2006-01-02 03:58:02 +00:00
2006-01-02 22:04:05 +00:00
//float IID_WP_SA80 = 420;
//float IID_WP_GAUSERIFLE = 421;
//float IID_WP_PULSERIFLE = 422;
2006-01-02 03:58:02 +00:00
else if ( weap = = IID_GREN_FRAG )
player_throw1 ( ) ;
else if ( weap = = IID_GREN_EMP )
player_throw1 ( ) ;
else if ( weap = = IID_GREN_SMOKE )
player_throw1 ( ) ;
else if ( weap = = IID_GREN_FLASH )
player_throw1 ( ) ;
2006-01-02 22:04:05 +00:00
else if ( IsChem ( weap ) )
{
self . attack_finished = time + 0.25 ;
player_knife1 ( ) ;
}
2006-01-02 03:58:02 +00:00
else
centerprint ( self , " Not implemented ( " , ftos ( weap ) , " ) " ) ;
2006-01-01 00:37:52 +00:00
} ;
/*
= = = = = = = = = = = =
W_ChangeWeapon
= = = = = = = = = = = =
*/
void ( ) W_ChangeWeapon =
{
2006-01-02 22:04:05 +00:00
local float it , am , fl ;
2006-01-01 00:37:52 +00:00
it = self . items ;
am = 0 ;
if ( self . impulse = = 1 )
{
fl = IT_NAILGUN ;
self . current_slot = 1 ;
}
if ( self . impulse = = 2 )
{
fl = IT_SUPER_NAILGUN ;
self . current_slot = 2 ;
}
if ( self . impulse = = 3 )
{
if ( self . handgrenade = = 0 )
{
sprint ( self , PRINT_HIGH , " no grenade. \n " ) ;
sound ( self , CHAN_AUTO , " misc/noweapon.wav " , 1 , ATTN_STATIC ) ;
return ;
}
else
self . current_slot = 3 ;
}
self . weapon = fl ;
W_SetCurrentAmmo ( ) ;
} ;
/*
= = = = = = = = = = = =
CheatCommand
= = = = = = = = = = = =
*/
void ( ) CheatCommand =
{
} ;
/*
= = = = = = = = = = = =
CycleWeaponCommand
Go to the next weapon with ammo
= = = = = = = = = = = =
*/
void ( ) CycleWeaponCommand =
{
local float it , am ;
it = self . items ;
self . impulse = 0 ;
while ( 1 )
{
am = 0 ;
if ( self . weapon = = IT_LIGHTNING )
{
self . weapon = IT_AXE ;
}
else if ( self . weapon = = IT_AXE )
{
self . weapon = IT_SHOTGUN ;
if ( self . ammo_shells < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_SHOTGUN )
{
self . weapon = IT_SUPER_SHOTGUN ;
if ( self . ammo_shells < 2 )
am = 1 ;
}
else if ( self . weapon = = IT_SUPER_SHOTGUN )
{
self . weapon = IT_NAILGUN ;
if ( self . ammo_nails < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_NAILGUN )
{
self . weapon = IT_SUPER_NAILGUN ;
if ( self . ammo_nails < 2 )
am = 1 ;
}
else if ( self . weapon = = IT_SUPER_NAILGUN )
{
self . weapon = IT_GRENADE_LAUNCHER ;
if ( self . ammo_rockets < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_GRENADE_LAUNCHER )
{
self . weapon = IT_ROCKET_LAUNCHER ;
if ( self . ammo_rockets < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_ROCKET_LAUNCHER )
{
self . weapon = IT_LIGHTNING ;
if ( self . ammo_cells < 1 )
am = 1 ;
}
if ( ( self . items & self . weapon ) & & am = = 0 )
{
W_SetCurrentAmmo ( ) ;
return ;
}
}
} ;
void ( ) ProneOff =
{
sprint ( self , 2 , " position: stand. \n " ) ;
self . position = 0 ;
2006-01-02 00:14:21 +00:00
PositionControl ( ) ;
2006-01-01 00:37:52 +00:00
player_run ( ) ;
} ;
void ( ) ProneOn =
{
if ( self . velocity_z ! = 0 )
return ;
if ( self . position = = 2 )
{
ProneOff ( ) ;
return ;
}
self . maxspeed = ( self . maxspeed * 0.25 ) ;
self . position = 2 ;
self . view_ofs = ' 0 0 - 10 ' ;
sprint ( self , 2 , " position: prone. \n " ) ;
2006-01-02 00:14:21 +00:00
PositionControl ( ) ;
2006-01-01 00:37:52 +00:00
} ;
void ( ) DuckOff =
{
sprint ( self , 2 , " position: stand. \n " ) ;
self . position = 0 ;
2006-01-02 00:14:21 +00:00
PositionControl ( ) ;
2006-01-01 00:37:52 +00:00
player_run ( ) ;
} ;
void ( ) DuckOn =
{
if ( self . velocity_z ! = 0 )
return ;
if ( self . position = = 1 )
{
DuckOff ( ) ;
return ;
}
self . maxspeed = ( self . maxspeed * 0.50 ) ;
self . position = 1 ;
sprint ( self , 2 , " position: duck. \n " ) ;
2006-01-02 00:14:21 +00:00
PositionControl ( ) ;
2006-01-01 00:37:52 +00:00
} ;
/*
= = = = = = = = = = = =
CycleWeaponReverseCommand
Go to the prev weapon with ammo
= = = = = = = = = = = =
*/
void ( ) CycleWeaponReverseCommand =
{
local float it , am ;
it = self . items ;
self . impulse = 0 ;
while ( 1 )
{
am = 0 ;
if ( self . weapon = = IT_LIGHTNING )
{
self . weapon = IT_ROCKET_LAUNCHER ;
if ( self . ammo_rockets < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_ROCKET_LAUNCHER )
{
self . weapon = IT_GRENADE_LAUNCHER ;
if ( self . ammo_rockets < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_GRENADE_LAUNCHER )
{
self . weapon = IT_SUPER_NAILGUN ;
if ( self . ammo_nails < 2 )
am = 1 ;
}
else if ( self . weapon = = IT_SUPER_NAILGUN )
{
self . weapon = IT_NAILGUN ;
if ( self . ammo_nails < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_NAILGUN )
{
self . weapon = IT_SUPER_SHOTGUN ;
if ( self . ammo_shells < 2 )
am = 1 ;
}
else if ( self . weapon = = IT_SUPER_SHOTGUN )
{
self . weapon = IT_SHOTGUN ;
if ( self . ammo_shells < 1 )
am = 1 ;
}
else if ( self . weapon = = IT_SHOTGUN )
{
self . weapon = IT_AXE ;
}
else if ( self . weapon = = IT_AXE )
{
self . weapon = IT_LIGHTNING ;
if ( self . ammo_cells < 1 )
am = 1 ;
}
if ( ( it & self . weapon ) & & am = = 0 )
{
W_SetCurrentAmmo ( ) ;
return ;
}
}
} ;
/*
= = = = = = = = = = = =
ServerflagsCommand
Just for development
= = = = = = = = = = = =
*/
void ( ) ServerflagsCommand =
{
serverflags = serverflags * 2 + 1 ;
} ;
/*
= = = = = = = = = = = =
ImpulseCommands
= = = = = = = = = = = =
*/
void ( ) ImpulseCommands =
{
if ( self . impulse > = 1 & & self . impulse < = 4 & & self . currentmenu = = " none " )
W_ChangeWeapon ( ) ;
if ( self . impulse > = 1 & & self . impulse < = 10 & & self . currentmenu ! = " none " )
W_PlayerMenu ( ) ;
if ( self . impulse = = 11 )
ServerflagsCommand ( ) ;
if ( self . impulse = = 12 )
CycleWeaponReverseCommand ( ) ;
if ( self . impulse = = 200 )
DuckOn ( ) ;
if ( self . impulse = = 201 )
ProneOn ( ) ;
2006-01-01 21:33:21 +00:00
if ( self . impulse = = 50 )
2006-01-02 03:58:02 +00:00
ReloadWeapon ( self . current_slot ) ;
// if (self.impulse == 51)
// UseChem ();
2006-01-01 21:33:21 +00:00
if ( self . impulse = = 52 )
BuyMenu ( ) ;
if ( self . impulse = = 53 )
Special ( ) ;
if ( self . impulse = = 54 )
ExitScreen ( ) ;
if ( self . impulse = = 55 )
2006-01-02 03:58:02 +00:00
DropFromSlot ( self . current_slot , 1 , 0 ) ;
2006-01-01 21:33:21 +00:00
if ( self . impulse = = 56 )
CharacterSheet ( ) ;
if ( self . impulse = = 57 )
UseEquipment ( ) ;
2006-01-01 00:37:52 +00:00
self . impulse = 0 ;
} ;
/*
= = = = = = = = = = = =
W_WeaponFrame
Called every frame so impulse events can be handled as well as possible
= = = = = = = = = = = =
*/
void ( ) W_WeaponFrame =
{
if ( time < self . attack_finished )
return ;
ImpulseCommands ( ) ;
// check for attack
if ( self . button0 )
{
SuperDamageSound ( ) ;
W_Attack ( ) ;
}
} ;
/*
= = = = = = = =
SuperDamageSound
Plays sound if needed
= = = = = = = =
*/
void ( ) SuperDamageSound =
{
if ( self . super_damage_finished > time )
{
if ( self . super_sound < time )
{
self . super_sound = time + 1 ;
sound ( self , CHAN_BODY , " items/damage3.wav " , 1 , ATTN_NORM ) ;
}
}
return ;
} ;
void ( ) DropAmmo =
{
2006-01-02 03:58:02 +00:00
local . float wslot ;
wslot = SlotField ( self . current_slot ) ;
self . wslot = SlotVal ( ToIID ( self . wslot ) , ToStatus ( self . wslot ) - 1 ) ;
self . currentammo = ToStatus ( self . wslot ) ;
2006-01-01 00:37:52 +00:00
} ;
2006-01-02 03:58:02 +00:00
void ( ) muzzleflash =
2006-01-01 00:37:52 +00:00
{
WriteByte ( MSG_MULTICAST , SVC_MUZZLEFLASH ) ;
WriteEntity ( MSG_MULTICAST , self ) ;
multicast ( self . origin , MULTICAST_PVS ) ;
} ;
void ( ) autofire =
{
if ( self . frame = = 88 )
self . frame = 89 ;
else
self . frame = 88 ;
if ( self . weaponframe = = 1 )
2006-01-02 03:58:02 +00:00
self . weaponframe = 2 ;
2006-01-01 00:37:52 +00:00
else if ( self . weaponframe = = 2 )
2006-01-02 03:58:02 +00:00
self . weaponframe = 1 ;
2006-01-01 00:37:52 +00:00
muzzleflash ( ) ;
} ;
void ( ) autofire_s =
{
if ( self . frame = = 88 )
self . frame = 89 ;
else
self . frame = 88 ;
if ( self . weaponframe = = 1 )
2006-01-02 03:58:02 +00:00
self . weaponframe = 2 ;
2006-01-01 00:37:52 +00:00
else if ( self . weaponframe = = 2 )
2006-01-02 03:58:02 +00:00
self . weaponframe = 1 ;
2006-01-01 00:37:52 +00:00
muzzleflash ( ) ;
} ;
void ( ) player_single1 = [ 88 , player_single2 ]
{
self . weaponframe = 1 ;
muzzleflash ( ) ;
} ;
void ( ) player_single2 = [ 89 , player_run ]
{
self . weaponframe = 2 ;
} ;
void ( ) player_single1_s = [ 183 , player_single2_s ]
{
self . weaponframe = 1 ;
muzzleflash ( ) ;
} ;
void ( ) player_single2_s = [ 184 , player_run ]
{
self . weaponframe = 2 ;
} ;
void ( vector org ) bullet_hole =
{
local float r ;
local entity ric ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_SPIKE ) ;
WriteCoord ( MSG_MULTICAST , org_x ) ;
WriteCoord ( MSG_MULTICAST , org_y ) ;
WriteCoord ( MSG_MULTICAST , org_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
r = random ( ) ;
ric = spawn ( ) ;
setorigin ( ric , org ) ;
if ( r < = 0.20 )
sound ( ric , CHAN_WEAPON , " weapons/ric1.wav " , TRUE , ATTN_NORM ) ;
else if ( r < = 0.40 )
sound ( ric , CHAN_WEAPON , " weapons/ric2.wav " , TRUE , ATTN_NORM ) ;
else if ( r < = 0.60 )
sound ( ric , CHAN_WEAPON , " weapons/ric3.wav " , TRUE , ATTN_NORM ) ;
else if ( r < = 0.80 )
sound ( ric , CHAN_WEAPON , " weapons/ric4.wav " , TRUE , ATTN_NORM ) ;
else
sound ( ric , CHAN_WEAPON , " weapons/ric5.wav " , TRUE , ATTN_NORM ) ;
remove ( ric ) ;
} ;
void ( vector test , float length , float dam ) penetrate =
{
local vector org ;
local vector start ;
local vector end ;
local float go ;
local float tl ;
go = 0 ;
tl = 8 ;
length = 32 + dam ;
while ( tl < length )
{
makevectors ( self . v_angle ) ;
start = ( test + v_forward * tl ) ;
if ( pointcontents ( start ) ! = CONTENT_SOLID & & go = = 0 ) //object penetrated
{
makevectors ( self . v_angle ) ;
end = ( test + ( v_forward * 8 * length ) ) ;
traceline ( start , end , FALSE , self ) ;
if ( trace_fraction = = 1 ) //nothing behind object
return ;
if ( trace_fraction > 0 )
{
go = 1 ;
if ( trace_ent . takedamage )
{
if ( trace_ent . solid ! = SOLID_BSP )
SpawnBlood ( org , 1 ) ;
T_Damage ( trace_ent , self , self , dam ) ;
}
else
{
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_SPIKE ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_x ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_y ) ;
WriteCoord ( MSG_MULTICAST , trace_endpos_z ) ;
multicast ( trace_endpos , MULTICAST_PHS ) ;
}
}
}
tl = tl + 4 ;
}
} ;
void ( entity temp , vector org , float damage ) SpawnWood =
{
if ( random ( ) * 6 < = 3 )
sound ( temp , CHAN_WEAPON , " misc/woodhit.wav " , TRUE , ATTN_NORM ) ;
else
sound ( temp , CHAN_WEAPON , " misc/woodhit2.wav " , TRUE , ATTN_NORM ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_SUPERSPIKE ) ;
WriteCoord ( MSG_MULTICAST , org_x ) ;
WriteCoord ( MSG_MULTICAST , org_y ) ;
WriteCoord ( MSG_MULTICAST , org_z ) ;
multicast ( self . origin , MULTICAST_PHS ) ;
} ;
void ( ) EMPExplode =
{
local entity te ;
self . velocity = VEC_ORIGIN ;
WriteByte ( MSG_BROADCAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_BROADCAST , TE_TAREXPLOSION ) ;
WriteCoord ( MSG_BROADCAST , self . origin_x ) ;
WriteCoord ( MSG_BROADCAST , self . origin_y ) ;
WriteCoord ( MSG_BROADCAST , self . origin_z ) ;
sound ( self , CHAN_BODY , " misc/flash.wav " , 1 , ATTN_NORM ) ;
sound ( self , CHAN_BODY , " misc/flash.wav " , 0.2 , ATTN_NONE ) ;
te = findradius ( self . origin , 300 ) ;
while ( te )
{
if ( ( ( ( te . classname = = " camera " ) | | ( te . classname = = " alarm " ) ) & & ( te . owner . pcamera = = 0 ) ) )
{
te . owner . pcamera = 0 ;
te . owner . pcamera2 = 0 ;
te . owner . equipment_state = 0 ;
sprint ( self . owner , 2 , te . owner . netname ) ;
sprint ( self . owner , 2 , " 's " ) ;
sprint ( self . owner , 2 , te . classname ) ;
sprint ( self . owner , 2 , " was wiped out! \n " ) ;
remove ( te ) ;
}
te = te . chain ;
}
T_RadiusDamage ( self , self . owner , 45 + random ( ) * 45 , other , " " ) ;
remove ( self ) ;
} ;
void ( vector org ) CreateSmoke =
{
newmis = spawn ( ) ;
setmodel ( newmis , " progs/smoke.mdl " ) ;
setorigin ( newmis , org ) ;
newmis . movetype = MOVETYPE_NONE ;
newmis . solid = SOLID_NOT ;
newmis . velocity = VEC_ORIGIN ;
newmis . nextthink = ( time + SVC_BIGKICK ) ;
newmis . think = SUB_Remove ;
newmis . touch = SUB_Null ;
newmis . classname = " smoke " ;
newmis . frame = 0 ;
newmis . cnt = 0 ;
newmis . avelocity_x = ( random ( ) * 100 ) ;
newmis . avelocity_y = ( random ( ) * 100 ) ;
setsize ( newmis , VEC_ORIGIN , VEC_ORIGIN ) ;
} ;
void ( ) SmokeThink =
{
self . cnt = ( self . cnt + 1 ) ;
WriteByte ( MSG_MULTICAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_MULTICAST , TE_GUNSHOT ) ;
WriteByte ( MSG_MULTICAST , 2 ) ;
WriteCoord ( MSG_MULTICAST , self . origin_x ) ;
WriteCoord ( MSG_MULTICAST , self . origin_y ) ;
WriteCoord ( MSG_MULTICAST , self . origin_z ) ;
multicast ( self . origin , MULTICAST_PVS ) ;
self . nextthink = ( time + 0.33 ) ;
if ( self . cnt > = 90 )
remove ( self ) ;
} ;
void ( ) FragExplode =
{
local float r ;
sound ( self , CHAN_VOICE , " ambience/gunfire7.wav " , 1 , ATTN_NONE ) ;
self . origin = ( self . origin + ' 0 0 16 ' ) ;
WriteByte ( MSG_BROADCAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_BROADCAST , TE_EXPLOSION ) ;
WriteCoord ( MSG_BROADCAST , self . origin_x ) ;
WriteCoord ( MSG_BROADCAST , self . origin_y ) ;
WriteCoord ( MSG_BROADCAST , self . origin_z ) ;
r = random ( ) ;
if ( ( r < 0.3 ) )
{
sound ( self , CHAN_BODY , " misc/exp1.wav " , 1 , ATTN_NORM ) ;
}
if ( ( r < 0.65 ) )
{
sound ( self , CHAN_BODY , " misc/exp2.wav " , 1 , ATTN_NORM ) ;
}
else
{
sound ( self , CHAN_BODY , " misc/exp3.wav " , 1 , ATTN_NORM ) ;
}
T_RadiusDamage ( self , self . owner , 50 + random ( ) * 50 , other , " " ) ;
remove ( self ) ;
} ;
void ( ) PlasmaExplode =
{
sound ( self , CHAN_VOICE , " ambience/gunfire7.wav " , 1 , ATTN_NONE ) ;
self . origin = ( self . origin + ' 0 0 16 ' ) ;
self . velocity = VEC_ORIGIN ;
WriteByte ( MSG_BROADCAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_BROADCAST , TE_TAREXPLOSION ) ;
WriteCoord ( MSG_BROADCAST , self . origin_x ) ;
WriteCoord ( MSG_BROADCAST , self . origin_y ) ;
WriteCoord ( MSG_BROADCAST , self . origin_z ) ;
sound ( self , CHAN_BODY , " misc/flash.wav " , 1 , ATTN_NORM ) ;
T_RadiusDamage ( self , self . owner , 80 + random ( ) * 80 , other , " " ) ;
remove ( self ) ;
} ;
void ( ) FlashExplode =
{
local entity te ;
local float dot ;
local float dot2 ;
local vector vec ;
self . velocity = VEC_ORIGIN ;
setmodel ( self , " progs/blast.mdl " ) ;
WriteByte ( 0 , SVC_TEMPENTITY ) ;
WriteByte ( 0 , WEAPON_SPIKES ) ;
WriteCoord ( 0 , self . origin_x ) ;
WriteCoord ( 0 , self . origin_y ) ;
WriteCoord ( 0 , self . origin_z ) ;
sound ( self , CHAN_BODY , " misc/flash.wav " , 1 , ATTN_NORM ) ;
te = findradius ( self . origin , 1200 ) ;
while ( te )
{
if ( te . classname = = " raider " )
te . attack_finished = time + 6 ;
if ( te . classname = = " radwolf " )
te . attack_finished = time + 6 ;
if ( ( te . classname = = " player " ) )
{
makevectors ( te . angles ) ;
vec = normalize ( ( self . origin - te . origin ) ) ;
dot = ( vec * v_forward ) ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
if ( ( ( ( dot > 0.3 ) & & CanDamage ( self , te ) ) & & ( dot2 = = 0 ) ) )
{
stuffcmd ( te , " v_cshift 255 255 255 255 \n " ) ;
stuffcmd ( te , " v_idlescale 10 \n " ) ;
te . flash = 6 ;
}
}
te = te . chain ;
}
remove ( self ) ;
} ;
2006-01-02 03:58:02 +00:00
/*
2006-01-01 00:37:52 +00:00
void ( ) HandGrenExplode =
{
if ( ( self . cnt = = 0 ) )
{
FragExplode ( ) ;
}
else
{
if ( ( self . cnt = = 1 ) )
{
EMPExplode ( ) ;
}
else
{
if ( ( self . cnt = = 2 ) )
{
self . nextthink = ( time + 0.5 ) ;
self . think = SmokeThink ;
}
else
{
if ( ( self . cnt = = AS_MELEE ) )
{
FlashExplode ( ) ;
}
else
{
if ( ( self . cnt = = WEAPON_SPIKES ) )
{
PlasmaExplode ( ) ;
}
}
}
}
}
} ;
2006-01-02 03:58:02 +00:00
*/
2006-01-01 00:37:52 +00:00
void ( ) HandGrenBounce =
{
local float r ;
r = ( random ( ) * TE_LIGHTNING3 ) ;
self . velocity = self . velocity * 0.75 ;
if ( ( r < AS_MELEE ) )
{
sound ( self , CHAN_VOICE , " misc/bounce_1.wav " , 0.9 , ATTN_NORM ) ;
}
else
{
if ( ( r < TE_LIGHTNING2 ) )
{
sound ( self , CHAN_VOICE , " misc/bounce_2.wav " , 0.9 , ATTN_NORM ) ;
}
else
{
sound ( self , CHAN_VOICE , " misc/bounce_3.wav " , 0.9 , ATTN_NORM ) ;
}
}
} ;
void ( ) FireHandGrenade =
{
2006-01-02 03:58:02 +00:00
local float item , iid ;
2006-01-02 22:04:05 +00:00
local float amcount ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
item = ItemInSlot ( self , self . current_slot ) ;
iid = ToIID ( item ) ;
2006-01-02 22:04:05 +00:00
amcount = ToStatus ( item ) ;
2006-01-02 03:58:02 +00:00
if ( iid = = 0 )
2006-01-01 00:37:52 +00:00
return ;
2006-01-02 03:58:02 +00:00
2006-01-02 22:04:05 +00:00
self . currentammo = amcount - 1 ;
if ( amcount < = 1 )
2006-01-02 03:58:02 +00:00
SetItemSlot ( self , self . current_slot , 0 ) ;
else
SetItemSlot ( self , self . current_slot , SlotVal ( iid , self . currentammo ) ) ;
2006-01-01 00:37:52 +00:00
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_SMALLKICK ) ;
newmis = spawn ( ) ;
newmis . owner = self ;
newmis . movetype = MOVETYPE_BOUNCE ;
newmis . solid = SOLID_BBOX ;
newmis . classname = " grenade " ;
newmis . skin = 0 ;
makevectors ( self . v_angle ) ;
newmis . velocity = aim ( self , 800 ) ;
newmis . velocity = ( newmis . velocity * 800 ) ;
newmis . velocity_z = ( newmis . velocity_z + 200 ) ;
newmis . angles = vectoangles ( newmis . velocity ) ;
newmis . avelocity_x = ( random ( ) * 300 ) ;
newmis . avelocity_y = ( random ( ) * 300 ) ;
newmis . avelocity_z = ( random ( ) * 300 ) ;
newmis . touch = HandGrenBounce ;
newmis . nextthink = ( time + 2.5 ) ;
2006-01-02 03:58:02 +00:00
if ( iid = = IID_GREN_FRAG )
2006-01-01 00:37:52 +00:00
newmis . think = FragExplode ;
2006-01-02 03:58:02 +00:00
else if ( iid = = IID_GREN_EMP )
2006-01-01 00:37:52 +00:00
newmis . think = EMPExplode ;
2006-01-02 03:58:02 +00:00
else if ( iid = = IID_GREN_SMOKE )
2006-01-01 00:37:52 +00:00
newmis . think = SmokeThink ;
2006-01-02 03:58:02 +00:00
else //if (iid == IID_GREN_FLASH)
2006-01-01 00:37:52 +00:00
newmis . think = FlashExplode ;
newmis . frame = 1 ;
setmodel ( newmis , " progs/handgren.mdl " ) ;
setsize ( newmis , VEC_ORIGIN , VEC_ORIGIN ) ;
setorigin ( newmis , ( ( self . origin + ( v_right * TE_BLOOD ) ) + ( v_up * TE_BLOOD ) ) ) ;
} ;
void ( float slot , float magazine ) GiveAmmo =
{
2006-01-02 03:58:02 +00:00
local float wi ;
local float wt ;
local float at ;
local float as ;
//give ammo to the weapon in a slot
wi = ItemInSlot ( self , slot ) ;
wt = ToIID ( wi ) ;
SetItemSlot ( self , slot , SlotVal ( wt , magazine ) ) ;
2006-01-02 05:40:11 +00:00
magazine = magazine * 4 ;
if ( magazine < 30 )
magazine = 30 ; //be generous.
2006-01-02 03:58:02 +00:00
at = WeaponAmmoType ( wt ) ;
//make sure we have enough ammo
as = SlotOfItem ( self , at ) ;
if ( as = = 0 )
as = SlotOfItem ( self , IID_NONE ) ;
if ( as = = 0 )
return ; //no free slots, so we can't give them ammo
2006-01-02 05:40:11 +00:00
if ( ToStatus ( ItemInSlot ( self , as ) ) < magazine )
SetItemSlot ( self , as , SlotVal ( at , magazine ) ) ;
2006-01-01 00:37:52 +00:00
} ;
void ( float dam , float rec , string snd , float rng , float rate ) FirePistol =
{
2006-01-02 22:04:05 +00:00
local float tmp , zdif , xdif , ydif , tru ;
2006-01-01 00:37:52 +00:00
local vector dir , source , targ , org , org2 , adjust ;
stuffcmd ( self , " -attack \n " ) ;
sound ( self , CHAN_WEAPON , snd , 1 , ATTN_NORM ) ;
self . attack_finished = ( time + rate ) ;
if ( self . attack = = 0 & & self . position = = POS_STAND )
player_single1 ( ) ;
if ( self . attack = = 0 & & self . position > = POS_DUCK )
player_single1_s ( ) ;
if ( self . position = = 0 )
adjust = ' 0 0 0 ' ;
if ( self . position = = 1 )
adjust = ' 0 0 - 16 ' ;
if ( self . position = = 2 )
adjust = ' 0 0 - 32 ' ;
DropAmmo ( ) ;
makevectors ( self . v_angle ) ;
if ( self . recoil > = 15 )
self . recoil = 15 ;
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
player_single1 ( ) ;
if ( self . position = = 1 )
player_single1_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
autofire ( ) ;
if ( self . position = = 1 )
autofire_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
2006-01-02 03:58:02 +00:00
tmp = 50 ;
2006-01-01 00:37:52 +00:00
if ( self . velocity ! = ' 0 0 0 ' )
2006-01-02 03:58:02 +00:00
tmp = 400 ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
tmp = tmp + ( 40 * self . recoil ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 1 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.75 ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 2 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.5 ) ;
2006-01-01 00:37:52 +00:00
self . attack = self . attack + 1 ;
self . recoil = self . recoil + 4 ;
source = self . origin + ' 0 0 22 ' ;
2006-01-02 03:58:02 +00:00
targ = self . origin + ' 0 0 22 ' + v_right * crandom ( ) * tmp + v_up * crandom ( ) * tmp ;
2006-01-01 00:37:52 +00:00
traceline ( source + adjust , targ + adjust + v_forward * 4000 , FALSE , self ) ;
if ( trace_fraction = = 1 )
return ;
2006-01-01 21:33:21 +00:00
org = trace_endpos - v_forward * 1 ;
2006-01-01 00:37:52 +00:00
org2 = trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ;
if ( trace_ent . takedamage )
{
org2 = ( trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ) ;
zdif = org_z - trace_ent . origin_z ;
ydif = org2_y - trace_ent . origin_y ;
xdif = org2_x - trace_ent . origin_x ;
2006-01-02 03:58:02 +00:00
tru = 0 ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
if ( ( ( ydif > = CONTENT_SKY ) & & ( ydif < = TE_LIGHTNING2 ) ) )
2006-01-02 03:58:02 +00:00
tru = 1 ;
2006-01-01 00:37:52 +00:00
if ( ( ( xdif > = CONTENT_SKY ) & & ( xdif < = TE_LIGHTNING2 ) ) )
2006-01-02 03:58:02 +00:00
tru = 1 ;
if ( self . attack < = 5 & & tru = = 1 & & zdif > = ( trace_ent . size_z / 2 * 0.8 ) )
2006-01-01 00:37:52 +00:00
self . critical = 3 ;
dam = ( dam * ( 1 - trace_fraction ) ) ;
if ( trace_ent . solid ! = SOLID_BSP )
SpawnBlood ( org , 1 ) ;
if ( trace_ent . solid = = SOLID_BSP )
SpawnWood ( trace_ent , org , 1 ) ;
T_Damage ( trace_ent , self , self , dam ) ;
if ( trace_ent . solid = = SOLID_BSP )
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
}
else
{
bullet_hole ( org ) ;
dir = vectoangles ( source - targ ) ;
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
return ;
}
} ;
void ( float dam , float rec , string snd , float rng , float rate ) FireSMG =
{
2006-01-02 22:04:05 +00:00
local float tmp , zdif , xdif , ydif , tru ;
2006-01-01 00:37:52 +00:00
local vector dir , source , targ , org , org2 , adjust ;
sound ( self , CHAN_WEAPON , snd , 1 , ATTN_NORM ) ;
self . attack_finished = ( time + rate ) ;
if ( self . attack = = 0 & & self . position = = POS_STAND )
2006-01-02 05:40:11 +00:00
autofire ( ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack = = 0 & & self . position > = POS_DUCK )
2006-01-02 05:40:11 +00:00
autofire_s ( ) ;
2006-01-01 00:37:52 +00:00
if ( self . position = = 0 )
adjust = ' 0 0 0 ' ;
if ( self . position = = 1 )
adjust = ' 0 0 - 16 ' ;
if ( self . position = = 2 )
adjust = ' 0 0 - 32 ' ;
DropAmmo ( ) ;
makevectors ( self . v_angle ) ;
if ( self . recoil > = 15 )
self . recoil = 15 ;
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
player_single1 ( ) ;
if ( self . position = = 1 )
player_single1_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
autofire ( ) ;
if ( self . position = = 1 )
autofire_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
2006-01-02 03:58:02 +00:00
tmp = 200 ;
2006-01-01 00:37:52 +00:00
if ( self . velocity ! = ' 0 0 0 ' )
2006-01-02 03:58:02 +00:00
tmp = 200 ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
tmp = tmp + ( 40 * self . recoil ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 1 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.75 ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 2 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.5 ) ;
2006-01-01 00:37:52 +00:00
self . attack = self . attack + 1 ;
self . recoil = self . recoil + 3 ;
source = self . origin + ' 0 0 22 ' ;
2006-01-02 03:58:02 +00:00
targ = self . origin + ' 0 0 22 ' + v_right * crandom ( ) * tmp + v_up * crandom ( ) * tmp ;
2006-01-01 00:37:52 +00:00
traceline ( source + adjust , targ + adjust + v_forward * 4000 , FALSE , self ) ;
if ( trace_fraction = = 1 )
return ;
org = trace_endpos - v_forward * 2 ;
org2 = trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ;
if ( trace_ent . takedamage )
{
org2 = ( trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ) ;
zdif = org_z - trace_ent . origin_z ;
ydif = org2_y - trace_ent . origin_y ;
xdif = org2_x - trace_ent . origin_x ;
2006-01-02 03:58:02 +00:00
tru = 0 ;
2006-01-01 00:37:52 +00:00
if ( ( ( ydif > = CONTENT_SKY ) & & ( ydif < = TE_LIGHTNING2 ) ) )
2006-01-02 03:58:02 +00:00
tru = 1 ;
2006-01-01 00:37:52 +00:00
if ( ( ( xdif > = CONTENT_SKY ) & & ( xdif < = TE_LIGHTNING2 ) ) )
2006-01-02 03:58:02 +00:00
tru = 1 ;
if ( self . attack < = 5 & & tru = = 1 & & zdif > = ( trace_ent . size_z / 2 * 0.8 ) )
2006-01-01 00:37:52 +00:00
self . critical = 3 ;
dam = ( dam * ( 1 - trace_fraction ) ) ;
if ( trace_ent . solid ! = SOLID_BSP )
SpawnBlood ( org , 1 ) ;
if ( trace_ent . solid = = SOLID_BSP )
SpawnWood ( trace_ent , org , 1 ) ;
T_Damage ( trace_ent , self , self , dam ) ;
if ( trace_ent . solid = = SOLID_BSP )
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
}
else
{
bullet_hole ( org ) ;
dir = vectoangles ( source - targ ) ;
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
return ;
}
} ;
void ( float dam , float rec , string snd , float rng , float rate ) FireAssaultRifle =
{
2006-01-02 22:04:05 +00:00
local float tmp , zdif , xdif , ydif , tru , z ;
2006-01-02 03:58:02 +00:00
2006-01-01 00:37:52 +00:00
local vector dir , source , targ , org , org2 , adjust ;
sound ( self , CHAN_WEAPON , snd , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
self . attack_finished = ( time + rate ) ;
if ( self . attack = = 0 & & self . position = = POS_STAND )
player_single1 ( ) ;
if ( self . attack = = 0 & & self . position > = POS_DUCK )
player_single1_s ( ) ;
if ( self . attack > = 1 & & self . position = = POS_STAND )
autofire ( ) ;
if ( self . attack > = 1 & & self . position > = POS_DUCK )
autofire_s ( ) ;
if ( self . position = = 0 )
adjust = ' 0 0 0 ' ;
if ( self . position = = 1 )
adjust = ' 0 0 - 16 ' ;
if ( self . position = = 2 )
adjust = ' 0 0 - 32 ' ;
DropAmmo ( ) ;
makevectors ( self . v_angle ) ;
if ( self . recoil > = 15 )
self . recoil = 15 ;
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
player_single1 ( ) ;
if ( self . position = = 1 )
player_single1_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
if ( self . attack > = 1 )
{
if ( self . position = = 0 )
autofire ( ) ;
if ( self . position = = 1 )
autofire_s ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
}
2006-01-02 03:58:02 +00:00
tmp = 50 ;
2006-01-01 00:37:52 +00:00
2006-01-02 00:14:21 +00:00
if ( self . velocity_y < 0 )
z = z + ( self . velocity_y * - 1 ) ;
else if ( self . velocity_y > 0 )
z = z + ( self . velocity_y ) ;
if ( self . velocity_x < 0 )
z = z + ( self . velocity_x * - 1 ) ;
else if ( self . velocity_x > 0 )
z = z + ( self . velocity_x ) ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
tmp = tmp + z ;
tmp = tmp + ( 40 * self . recoil ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 1 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.75 ) ;
2006-01-01 00:37:52 +00:00
if ( self . attack < = 3 & & self . position = = 2 & & self . velocity_z = = 0 )
2006-01-02 03:58:02 +00:00
tmp = ( tmp * 0.5 ) ;
2006-01-01 00:37:52 +00:00
self . attack = self . attack + 1 ;
self . recoil = self . recoil + 5 ;
source = self . origin + ' 0 0 22 ' ;
2006-01-02 03:58:02 +00:00
targ = self . origin + ' 0 0 22 ' + v_right * crandom ( ) * tmp + v_up * crandom ( ) * tmp ;
2006-01-01 00:37:52 +00:00
traceline ( source + adjust , targ + adjust + v_forward * 4000 , FALSE , self ) ;
if ( trace_fraction = = 1 )
return ;
org = trace_endpos - v_forward * 2 ;
org2 = trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ;
if ( trace_ent . takedamage )
{
org2 = ( trace_endpos + ( v_forward * ( ( trace_ent . size_y / 2 ) + ( trace_ent . size_x / 2 ) ) ) ) ;
zdif = org_z - trace_ent . origin_z ;
ydif = org2_y - trace_ent . origin_y ;
xdif = org2_x - trace_ent . origin_x ;
2006-01-02 03:58:02 +00:00
tru = 0 ;
2006-01-02 00:14:21 +00:00
if ( ydif > = - 6 & & ydif < = 6 )
2006-01-02 03:58:02 +00:00
tru = 1 ;
2006-01-02 00:14:21 +00:00
if ( xdif > = - 6 & & xdif < = 6 )
2006-01-02 03:58:02 +00:00
tru = 1 ;
if ( self . attack < = 5 & & tru = = 1 & & zdif > = ( trace_ent . size_z / 2 * 0.8 ) )
2006-01-01 00:37:52 +00:00
self . critical = 3 ;
dam = ( dam * ( 1 - trace_fraction ) ) ;
2006-01-02 00:14:21 +00:00
if ( trace_ent . solid ! = SOLID_BSP & & self . critical = = 3 )
2006-01-01 00:37:52 +00:00
SpawnBlood ( org , 1 ) ;
2006-01-02 00:14:21 +00:00
else
SpawnBlood ( org , 0.5 ) ;
2006-01-01 00:37:52 +00:00
if ( trace_ent . solid = = SOLID_BSP )
SpawnWood ( trace_ent , org , 1 ) ;
T_Damage ( trace_ent , self , self , dam ) ;
if ( trace_ent . solid = = SOLID_BSP )
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
}
else
{
bullet_hole ( org ) ;
dir = vectoangles ( source - targ ) ;
penetrate ( org , ( dam / 2 ) , ( dam / 2 ) ) ;
return ;
}
} ;
void ( ) Screenshake =
{
local entity te ;
te = findradius ( self . origin , 700 ) ;
while ( te )
{
if ( ( ( te . classname = = " player " ) & & ( te . ghost = = 0 ) ) )
{
stuffcmd ( te , " v_iyaw_level 2 \n " ) ;
stuffcmd ( te , " v_iyaw_cycle 32 \n " ) ;
stuffcmd ( te , " v_ipitch_level 2 \n " ) ;
stuffcmd ( te , " v_ipitch_cycle 32 \n " ) ;
stuffcmd ( te , " v_iroll_level 2 \n " ) ;
stuffcmd ( te , " v_iroll_cycle 32 \n " ) ;
stuffcmd ( te , " v_idlescale 1 \n " ) ;
}
te = te . chain ;
}
} ;
void ( ) ScreenshakeSingle =
{
stuffcmd ( self , " v_iyaw_level 2 \n " ) ;
stuffcmd ( self , " v_iyaw_cycle 32 \n " ) ;
stuffcmd ( self , " v_ipitch_level 2 \n " ) ;
stuffcmd ( self , " v_ipitch_cycle 32 \n " ) ;
stuffcmd ( self , " v_iroll_level 2 \n " ) ;
stuffcmd ( self , " v_iroll_cycle 32 \n " ) ;
stuffcmd ( self , " v_idlescale 1 \n " ) ;
} ;
void ( ) ExplosionFrames =
{
self . avelocity = ' 300 300 250 ' ;
self . nextthink = ( time + 0.02 ) ;
self . frame = ( self . frame + 1 ) ;
if ( self . frame = = 16 )
remove ( self ) ;
} ;
void ( float input ) Explosion =
{
local float r ;
self . effects = EF_DIMLIGHT ;
self . touch = SUB_Null ;
setmodel ( self , " progs/blast.mdl " ) ;
r = random ( ) ;
if ( ( r < 0.3 ) )
sound ( self , CHAN_BODY , " misc/exp1.wav " , 1 , ATTN_NORM ) ;
if ( ( r < 0.65 ) )
sound ( self , CHAN_BODY , " misc/exp2.wav " , 1 , ATTN_NORM ) ;
else
sound ( self , CHAN_BODY , " misc/exp3.wav " , 1 , ATTN_NORM ) ;
WriteByte ( MSG_BROADCAST , SVC_TEMPENTITY ) ;
WriteByte ( MSG_BROADCAST , TE_EXPLOSION ) ;
WriteCoord ( MSG_BROADCAST , self . origin_x ) ;
WriteCoord ( MSG_BROADCAST , self . origin_y ) ;
WriteCoord ( MSG_BROADCAST , self . origin_z ) ;
Screenshake ( ) ;
self . frame = AS_MELEE ;
self . velocity = VEC_ORIGIN ;
self . avelocity = ' 300 300 250 ' ;
self . think = ExplosionFrames ;
self . nextthink = ( time + 0.02 ) ;
} ;
void ( ) WeaponTouch =
{
if ( other . classname ! = " player " )
return ;
if ( other . ghost ! = 0 )
return ;
if ( other . current_slot = = WEAPON_SPIKES )
{
return ;
}
if ( other . current_slot = = AS_MELEE )
return ;
if ( self . handgrenade = = 1 )
{
if ( other . handgrenade > 0 )
{
sprint ( other , 2 , " already have a grenade. \n " ) ;
return ;
}
sound ( other , CHAN_BODY , " misc/item1.wav " , 1 , ATTN_NORM ) ;
other . handgrenade = self . handgrenade ;
other . grenadetype = self . grenadetype ;
sprint ( other , 2 , " picked up a grenade. \n " ) ;
remove ( self ) ;
return ;
}
2006-01-02 03:58:02 +00:00
if ( ItemInSlot ( other , other . current_slot ) ! = 0 )
2006-01-01 00:37:52 +00:00
return ;
2006-01-02 03:58:02 +00:00
sound ( other , CHAN_BODY , " misc/item1.wav " , 1 , ATTN_NORM ) ;
2006-01-02 02:48:58 +00:00
2006-01-02 03:58:02 +00:00
SetItemSlot ( other , other . current_slot , self . islot1 ) ;
remove ( self ) ;
self = other ;
SetWeaponModel ( ) ;
2006-01-01 00:37:52 +00:00
if ( ( other . current_slot = = 1 ) )
2006-01-02 03:58:02 +00:00
stuffcmd ( self , " impulse 1 \n " ) ;
2006-01-01 00:37:52 +00:00
if ( ( other . current_slot = = 2 ) )
2006-01-02 03:58:02 +00:00
stuffcmd ( self , " impulse 2 \n " ) ;
2006-01-01 00:37:52 +00:00
} ;
2006-01-02 03:58:02 +00:00
void ( float slotnum , float snd , float force ) DropFromSlot =
2006-01-01 00:37:52 +00:00
{
2006-01-02 03:58:02 +00:00
local float weap ;
2006-01-01 00:37:52 +00:00
local string mdel ;
2006-01-02 03:58:02 +00:00
if ( self . attack_finished > time & & ! force )
2006-01-01 00:37:52 +00:00
return ;
2006-01-02 03:58:02 +00:00
if ( slotnum = = 0 )
2006-01-01 00:37:52 +00:00
return ;
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
weap = ItemInSlot ( self , slotnum ) ;
2006-01-01 21:33:21 +00:00
if ( snd = = 1 )
2006-01-01 00:37:52 +00:00
sound ( self , CHAN_WEAPON , " weapons/lock4.wav " , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
makevectors ( self . v_angle ) ;
newmis = spawn ( ) ;
newmis . owner = self ;
newmis . classname = " dropped_weapon " ;
newmis . movetype = MOVETYPE_TOSS ;
newmis . solid = SOLID_TRIGGER ;
newmis . velocity = aim ( self , 500 ) ;
newmis . velocity = ( newmis . velocity * 500 ) ;
newmis . angles_y = ( random ( ) * 360 ) ;
2006-01-02 22:04:05 +00:00
mdel = GetItemWModel ( ToIID ( weap ) ) ;
2006-01-01 00:37:52 +00:00
setmodel ( newmis , mdel ) ;
setsize ( newmis , ' - 2 - 2 0 ' , ' 2 2 1 ' ) ;
makevectors ( self . v_angle ) ;
traceline ( self . origin , ( ( self . origin + ( v_forward * IT_LIGHTNING ) ) + ' 0 0 32 ' ) , FALSE , self ) ;
trace_endpos = ( trace_endpos - ( v_forward * WEAPON_SPIKES ) ) ;
setorigin ( newmis , trace_endpos ) ;
newmis . origin_z = self . origin_z ;
newmis . nextthink = ( time + 180 ) ;
newmis . think = SUB_Remove ;
newmis . touch = WeaponTouch ;
2006-01-02 03:58:02 +00:00
newmis . islot1 = weap ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
SetItemSlot ( self , slotnum , 0 ) ;
2006-01-01 21:33:21 +00:00
2006-01-02 03:58:02 +00:00
if ( self . attack_finished < time + 0.6 )
self . attack_finished = time + 0.6 ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
if ( self . current_slot = = slotnum )
SetWeaponModel ( ) ;
2006-01-01 00:37:52 +00:00
} ;
void ( float slot ) WeaponAmmo =
{
local float weap , amount ;
2006-01-02 03:58:02 +00:00
weap = ToIID ( ItemInSlot ( self , slot ) ) ;
amount = WeaponMagQuant ( weap ) ;
GiveAmmo ( slot , amount ) ;
2006-01-01 00:37:52 +00:00
} ;
void ( ) Crosshair =
{
local float r ;
local string new ;
r = 32 + ( self . recoil * 8 ) ;
if ( r > 256 )
r = 256 ;
if ( r < 0 )
r = 0 ;
new = ftos ( r ) ;
stuffcmd ( self , " crosshairsize " ) ;
stuffcmd ( self , new ) ;
stuffcmd ( self , " \n " ) ;
r = 0.75 - ( self . recoil * 0.03 ) ;
if ( r < = 0.25 )
r = 0.25 ;
new = ftos ( r ) ;
stuffcmd ( self , " crosshairalpha " ) ;
stuffcmd ( self , new ) ;
stuffcmd ( self , " \n " ) ;
} ;
void ( entity healer , entity saved ) RevivePlayer =
{
local entity oself ;
saved . deadflag = DEAD_NO ;
saved . takedamage = DAMAGE_AIM ;
saved . movetype = MOVETYPE_WALK ;
saved . solid = SOLID_SLIDEBOX ;
saved . ghost = 0 ;
saved . health = 2 ;
saved . air_finished = time + 10 ;
saved . view_ofs = ' 0 0 22 ' ;
oself = self ;
self = saved ;
player_run ( ) ;
self = oself ;
stuffcmd ( saved , " impulse 1 \n " ) ;
sprint ( healer , PRINT_HIGH , " you revive " ) ;
sprint ( healer , PRINT_HIGH , trace_ent . netname ) ;
sprint ( healer , PRINT_HIGH , " . \n " ) ;
sprint ( saved , PRINT_HIGH , healer . netname ) ;
sprint ( saved , PRINT_HIGH , " saves you from death. \n " ) ;
saved . view2 = world ;
} ;
2006-01-02 03:58:02 +00:00
float ( float iid ) UseBoostingChem =
2006-01-01 00:37:52 +00:00
{
local vector source ;
local string x ;
2006-01-02 03:58:02 +00:00
local float duration ;
2006-01-01 00:37:52 +00:00
if ( self . attack_finished > time )
2006-01-02 03:58:02 +00:00
return false ;
x = GetItemName ( iid ) ;
if ( iid = = IID_CHEM_ADRENALINE )
duration = 30 + random ( ) * 30 ;
else if ( iid = = IID_CHEM_PSYCHO )
duration = 30 + random ( ) * 30 ;
else if ( iid = = IID_CHEM_BESERK )
duration = 30 + random ( ) * 30 ;
else
{
sprint ( self , PRINT_HIGH , " Not a boosting chem \n " ) ;
return false ;
}
2006-01-01 00:37:52 +00:00
self . attack_finished = time + 1 ;
makevectors ( self . v_angle ) ;
source = self . origin + ' 0 0 0 ' ;
traceline ( source , source + v_forward * 64 , FALSE , self ) ;
if ( trace_ent . classname = = " player " & & trace_ent . team = = self . team )
{
if ( trace_ent . health < = 0 )
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
if ( trace_ent . rage > = 1 )
{
sprint ( self , 2 , trace_ent . netname ) ;
sprint ( self , PRINT_HIGH , " is already affected. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
sprint ( trace_ent , 2 , self . netname ) ;
sprint ( trace_ent , PRINT_HIGH , " used a " ) ;
sprint ( trace_ent , PRINT_HIGH , x ) ;
sprint ( trace_ent , PRINT_HIGH , " on you. \n " ) ;
sound ( trace_ent , CHAN_BODY , " player/berserk.wav " , 1 , ATTN_NORM ) ;
2006-01-02 03:58:02 +00:00
trace_ent . rage = iid ;
trace_ent . ragetime = duration ;
return true ;
2006-01-02 02:48:58 +00:00
}
2006-01-02 03:58:02 +00:00
if ( trace_fraction = = 1.0 )
{
if ( self . health < self . max_health & & self . rage = = 0 )
{
sound ( self , CHAN_BODY , " player/berserk.wav " , 1 , ATTN_NORM ) ;
self . rage = iid ;
self . ragetime = duration ;
return true ;
}
}
return false ;
2006-01-01 00:37:52 +00:00
} ;
2006-01-02 03:58:02 +00:00
float ( float iid ) UseHealingChem =
2006-01-01 00:37:52 +00:00
{
local vector source ;
local float heal ;
local string x ;
if ( self . attack_finished > time )
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
x = GetItemName ( iid ) ;
if ( iid = = IID_CHEM_STIMPACK )
heal = 2 * 5 ;
else if ( iid = = IID_CHEM_MEDICALBAG )
{
heal = 3 * 5 ;
x = " bandage " ;
}
else if ( iid = = IID_CHEM_SUPERSTIM )
heal = 4 * 5 ;
else
{
sprint ( self , PRINT_HIGH , " Not a healing chem \n " ) ;
return false ;
}
2006-01-01 00:37:52 +00:00
self . attack_finished = time + 1 ;
makevectors ( self . v_angle ) ;
source = self . origin + ' 0 0 0 ' ;
traceline ( source , source + v_forward * 64 , FALSE , self ) ;
if ( trace_ent . classname = = " player " & & trace_ent . team = = self . team )
{
if ( trace_ent . health < = 0 & & coop = = 1 )
{
RevivePlayer ( self , trace_ent ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( trace_ent . health < = 0 & & coop = = 0 )
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
if ( trace_ent . regen > = 1 )
{
2006-01-02 03:58:02 +00:00
sprint ( self , PRINT_HIGH , trace_ent . netname ) ;
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " is already healing. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 21:33:21 +00:00
}
if ( trace_ent . health > = trace_ent . max_health )
{
2006-01-02 03:58:02 +00:00
sprint ( self , PRINT_HIGH , trace_ent . netname ) ;
sprint ( self , PRINT_HIGH , " isn't injured. \n " ) ;
return false ;
2006-01-01 00:37:52 +00:00
}
2006-01-02 03:58:02 +00:00
sprint ( trace_ent , PRINT_HIGH , self . netname ) ;
2006-01-01 00:37:52 +00:00
sprint ( trace_ent , PRINT_HIGH , " used a " ) ;
sprint ( trace_ent , PRINT_HIGH , x ) ;
sprint ( trace_ent , PRINT_HIGH , " to heal you. \n " ) ;
trace_ent . regen = heal ;
trace_ent . health = trace_ent . health + heal ;
stuffcmd ( trace_ent , " v_cshift 0 0 0 0 \n " ) ;
sound ( self , CHAN_BODY , " items/r_item2.wav " , 1 , ATTN_NORM ) ;
2006-01-02 03:58:02 +00:00
return true ;
2006-01-01 00:37:52 +00:00
}
2006-01-02 03:58:02 +00:00
if ( trace_fraction = = 1.0 )
2006-01-02 03:53:58 +00:00
{
2006-01-02 03:58:02 +00:00
if ( self . health < self . max_health & & self . regen = = 0 )
{
sound ( self , CHAN_BODY , " items/r_item2.wav " , 1 , ATTN_NORM ) ;
self . health = self . health + heal ;
self . regen = heal ;
return true ;
}
2006-01-02 03:53:58 +00:00
}
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
} ;
void ( ) DisplayMenu =
{
local string menu ;
if ( self . currentmenu = = " none " )
return ;
if ( self . currentmenu = = " shop_list " )
{
menu = ShopString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_trait " )
{
menu = TraitString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_perks " )
{
menu = PerkString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_armor " )
{
menu = ArmorString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_protect " )
{
menu = ProtectString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_melee " )
{
menu = MeleeString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_thrown " )
{
menu = ThrownString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_pistols " )
{
menu = PistolString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_shotguns " )
{
menu = ShotgunString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_rifles " )
{
menu = RifleString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_chems " )
{
menu = ChemString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_other " )
{
menu = OtherString ( ) ;
centerprint ( self , menu ) ;
}
if ( self . currentmenu = = " shop_equipment " )
{
menu = EquipmentString ( ) ;
centerprint ( self , menu ) ;
}
2006-01-01 21:33:21 +00:00
if ( self . currentmenu = = " shop_weapons " )
{
menu = WeaponString ( ) ;
centerprint ( self , menu ) ;
}
2006-01-01 00:37:52 +00:00
if ( ( ( self . currentmenu = = " select_skill " ) & & ( self . team = = 1 ) ) )
{
centerprint ( self , " <EFBFBD> CHOOSE SKILL SET<45> \n \n <EFBFBD> 1<EFBFBD> Medic \n <EFBFBD> 2<EFBFBD> Assassin \n <EFBFBD> 3<EFBFBD> Soldier \n <EFBFBD> 4<EFBFBD> Scientist\n " ) ;
}
if ( ( ( self . currentmenu = = " select_skill " ) & & ( self . team = = 2 ) ) )
{
centerprint ( self , " <EFBFBD> CHOOSE SKILL SET<45> \n \n <EFBFBD> 1<EFBFBD> Medic \n <EFBFBD> 2<EFBFBD> Assassin \n <EFBFBD> 3<EFBFBD> Soldier \n <EFBFBD> 4<EFBFBD> Scientist\n " ) ;
}
if ( ( self . currentmenu = = " select_team " ) )
{
if ( self . class = = 0 )
centerprint ( self , " <EFBFBD> CHOOSE YOUR TEAM<41> \n \n <EFBFBD> 1<EFBFBD> Rangers (good)\n <EFBFBD> 2<EFBFBD> Raiders (evil)\n <EFBFBD> 3<EFBFBD> Auto-Assign \n " ) ;
if ( self . class > = 0 & & self . oldteam = = 0 )
centerprint ( self , " <EFBFBD> CHOOSE YOUR TEAM<41> \n \n <EFBFBD> 1<EFBFBD> Rangers (good)\n <EFBFBD> 2<EFBFBD> Raiders (evil)\n <EFBFBD> 3<EFBFBD> Auto-Assign \n " ) ;
if ( self . class > 0 & & self . oldteam > 0 )
centerprint ( self , " <EFBFBD> CHOOSE YOUR TEAM<41> \n \n <EFBFBD> 1<EFBFBD> Rangers (good)\n <EFBFBD> 2<EFBFBD> Raiders (evil)\n <EFBFBD> 3<EFBFBD> Auto-Assign \n <EFBFBD> 4<EFBFBD> Keep Previous \n " ) ;
}
if ( self . currentmenu = = " confirm_team " )
{
sound ( self , CHAN_BODY , " player/yourturn.wav " , 1 , ATTN_NORM ) ;
if ( self . team = = 1 )
centerprint ( self , " <EFBFBD> you will respawn as<61> \n \n Ranger - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
if ( self . team = = 2 )
centerprint ( self , " <EFBFBD> you will respawn as<61> \n \n Raider - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
}
if ( self . currentmenu = = " confirm_skill " )
{
sound ( self , CHAN_BODY , " player/yourturn.wav " , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
if ( self . class = = 1 )
2006-01-01 00:37:52 +00:00
centerprint ( self , " <EFBFBD> your class will be<62> \n \n Medic - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
2006-01-01 21:33:21 +00:00
if ( self . class = = 2 )
2006-01-01 00:37:52 +00:00
centerprint ( self , " <EFBFBD> your class will be<62> \n \n Assassin - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
2006-01-01 21:33:21 +00:00
if ( self . class = = 3 )
2006-01-01 00:37:52 +00:00
centerprint ( self , " <EFBFBD> your class will be<62> \n \n Soldiier - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
2006-01-01 21:33:21 +00:00
if ( self . class = = 4 )
2006-01-01 00:37:52 +00:00
centerprint ( self , " <EFBFBD> your class will be<62> \n \n Scientist - OK? \n <EFBFBD> 1<EFBFBD> Yes \n <EFBFBD> 2<EFBFBD> No \n " ) ;
}
2006-01-01 21:33:21 +00:00
if ( self . currentmenu = = " menu_build " )
{
menu = BuildString ( ) ;
centerprint ( self , menu ) ;
}
2006-01-01 00:37:52 +00:00
} ;
void ( ) Special =
{
2006-01-02 03:58:02 +00:00
#if 0
< < < < < < < weapons . qc
/*
= = = = = = =
2006-01-01 21:33:21 +00:00
if ( self . class = = 1 )
2006-01-01 00:37:52 +00:00
Bandage ( ) ;
2006-01-02 03:58:02 +00:00
> > > > > > > 1.2
2006-01-01 21:33:21 +00:00
if ( self . class = = 2 )
2006-01-02 03:58:02 +00:00
< < < < < < < weapons . qc
Cmd_InvUse ( GetItemName ( IID_CHEM_MEDICALBAG ) ) ;
if ( self . class = = 3 )
Cmd_InvUse ( " sneak-boy " ) ;
if ( self . class = = 4 )
Cmd_InvUse ( GetItemName ( IID_GREN_FRAG ) ) ;
if ( self . class = = 6 )
Cmd_InvUse ( " shield " ) ;
*/
= = = = = = =
2006-01-01 00:37:52 +00:00
Sneak ( ) ;
2006-01-01 21:33:21 +00:00
if ( self . class = = 4 )
self . currentmenu = " menu_build " ;
2006-01-02 03:58:02 +00:00
> > > > > > > 1.2
# endif
2006-01-01 00:37:52 +00:00
} ;
void ( ) hos_run1 ;
void ( ) hos_stand1 ;
2006-01-02 03:58:02 +00:00
float ( float iid ) spawn_station ;
2006-01-01 00:37:52 +00:00
void ( ) ExitScreen =
{
if ( self . class = = 0 )
return ;
if ( self . ghost = = 1 )
return ;
if ( self . team = = 0 )
return ;
if ( self . attack_finished > time )
return ;
if ( trace_ent . classname = = " hostage " & & trace_ent . health > 0 & & trace_fraction < 1 )
{
if ( self . team ! = 1 )
return ;
if ( self . currentmenu = = " menu_build " )
return ;
if ( trace_ent . cnt = = 0 )
{
sprint ( self , 2 , " hostage is now following you. \n " ) ;
trace_ent . nextthink = ( time + 0.1 ) ;
trace_ent . think = hos_run1 ;
trace_ent . cnt = 1 ;
trace_ent . friend = self ;
return ;
}
else
{
if ( trace_ent . cnt = = 1 )
{
sprint ( self , 2 , " hostage stopped following you. \n " ) ;
trace_ent . nextthink = ( time + 0.1 ) ;
trace_ent . think = hos_stand1 ;
trace_ent . cnt = 0 ;
trace_ent . friend = trace_ent ;
return ;
}
}
return ;
}
if ( ( self . currentmenu ! = " none " ) )
{
centerprint ( self , " \n " ) ;
self . currentmenu = " none " ;
}
} ;
void ( ) Sneak =
{
local float w ;
w = weightx ( ) ;
2006-01-01 21:33:21 +00:00
if ( self . sneak > = 1 )
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " items/inv1.wav " , 1 , ATTN_NORM ) ;
centerprint ( self , " <EFBFBD> Uncloaked <20> \n " ) ;
setmodel ( self , " progs/guy.mdl " ) ;
self . sneak = 0 ;
return ;
}
if ( self . ammo_cells < 20 )
{
sprint ( self , PRINT_HIGH , " wait for stealth-boy to recharge. \n " ) ;
return ;
}
2006-01-01 21:33:21 +00:00
if ( self . sneak = = 0 & & self . class = = 2 )
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " items/inv1.wav " , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
centerprint ( self , " <EFBFBD> cloaked and sneaking <20> \n (1% detection chance) " ) ;
2006-01-01 00:37:52 +00:00
self . sneak = 1 ;
return ;
}
2006-01-01 21:33:21 +00:00
else if ( self . sneak = = 0 & & self . class ! = 2 )
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " items/inv1.wav " , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
centerprint ( self , " <EFBFBD> cloaked <20> \n (15% detection chance) " ) ;
2006-01-01 00:37:52 +00:00
self . sneak = 3 ;
return ;
}
else if ( self . sneak = = 0 & & w > 20 )
{
sound ( self , CHAN_BODY , " items/inv1.wav " , 1 , ATTN_NORM ) ;
2006-01-01 21:33:21 +00:00
centerprint ( self , " <EFBFBD> too much gear <20> \n " ) ;
2006-01-01 00:37:52 +00:00
setmodel ( self , " progs/guy.mdl " ) ;
self . sneak = 0 ;
return ;
}
} ;
void ( ) Shield =
{
if ( self . class ! = 6 )
{
centerprint ( self , " You can't shield yourself! \n " ) ;
return ;
}
if ( self . sneak = = 2 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> <EFBFBD> Unshielded <20> <> <EFBFBD> \n " ) ;
self . sneak = 0 ;
sound ( self , CHAN_BODY , " items/protect2.wav " , 1 , ATTN_NORM ) ;
return ;
}
if ( self . ammo_cells < 10 )
{
centerprint ( self , " wait for your shield to recharge. \n " ) ;
return ;
}
if ( self . sneak = = 0 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> <EFBFBD> Energy Shield <20> <> <EFBFBD> \n " ) ;
self . sneak = 2 ;
sound ( self , CHAN_BODY , " items/protect.wav " , 1 , ATTN_NORM ) ;
return ;
}
} ;
void ( ) station_die =
{
2006-01-02 03:58:02 +00:00
if ( ( self . buildtype = = IID_BUILD_MRAMMO ) )
2006-01-01 00:37:52 +00:00
{
if ( ( self . team = = 1 ) )
{
blue_weapon = 0 ;
}
else
{
if ( ( self . team = = 2 ) )
{
red_weapon = 0 ;
}
}
}
2006-01-02 03:58:02 +00:00
if ( ( self . buildtype = = IID_BUILD_SHIELDGEN ) )
2006-01-01 00:37:52 +00:00
{
if ( ( self . team = = 1 ) )
{
blue_armor = 0 ;
}
else
{
if ( ( self . team = = 2 ) )
{
red_armor = 0 ;
}
}
}
2006-01-02 03:58:02 +00:00
if ( ( self . buildtype = = IID_BUILD_AUTODOC ) )
2006-01-01 00:37:52 +00:00
{
if ( ( self . team = = 1 ) )
{
blue_gadget = 0 ;
}
else
{
if ( ( self . team = = 2 ) )
{
red_gadget = 0 ;
}
}
}
Explosion ( 2 ) ;
} ;
void ( ) station_think =
{
2006-01-02 03:58:02 +00:00
# define chemcount attack_finished
2006-01-01 00:37:52 +00:00
local entity te ;
self . nextthink = time + 2 ;
self . frame = self . buildtype ;
if ( self . track . team ! = self . team )
{
station_die ( ) ;
return ;
}
if ( self . chemcount < = 0 )
{
station_die ( ) ;
return ;
}
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_SHIELDGEN ) //barricade
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " items/protect2.wav " , 1 , ATTN_NORM ) ;
te = findradius ( self . origin , 256 ) ;
while ( te )
{
if ( te . classname = = " player " & & te . team = = self . team )
{
if ( self . chemcount < = 0 )
{
sound ( self , CHAN_BODY , " misc/menu2.wav " , TRUE , ATTN_NORM ) ;
sprint ( te , 2 , " the shield generator is out of power. \n " ) ;
return ;
}
if ( te . classname = = " player " )
{
te . protect = 3 ;
self . chemcount = self . chemcount - 1 ;
stuffcmd ( te , " v_cshift 0 100 100 100 \n " ) ;
}
}
te = te . chain ;
}
}
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_AUTODOC ) //autodoc
2006-01-01 00:37:52 +00:00
{
te = findradius ( self . origin , 70 ) ;
while ( te )
{
if ( te . classname = = " player " & & te . team = = self . team )
{
if ( self . chemcount < = 0 )
{
sound ( self , CHAN_BODY , " misc/item1.wav " , TRUE , ATTN_NORM ) ;
sprint ( te , 2 , " the autodoc is out of medical supplies. \n " ) ;
return ;
}
if ( te . health < te . max_health )
{
sound ( self , CHAN_BODY , " items/r_item2.wav " , 1 , ATTN_NORM ) ;
sprint ( te , 2 , " the auto-doc heals you for 3 health. \n " ) ;
te . health = te . health + 3 ;
self . chemcount = self . chemcount - 1 ;
if ( te . health > te . max_health )
te . health = te . max_health ;
}
}
te = te . chain ;
}
}
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_MRAMMO ) //mr. ammo
2006-01-01 00:37:52 +00:00
{
te = findradius ( self . origin , 60 ) ;
while ( te )
{
if ( te . classname = = " player " & & te . team = = self . team )
{
if ( self . chemcount < = 0 )
{
sound ( self , CHAN_BODY , " misc/item1.wav " , TRUE , ATTN_NORM ) ;
sprint ( te , 2 , " this mr.ammo is out of ammunition. \n " ) ;
return ;
}
2006-01-02 03:58:02 +00:00
sprint ( te , 2 , " mr.ammo incorporated would like to appologise for any inconvienience caused by this unit being offline. \n Our engineers have diagnosed the fault and will remove the stub whenever they can be arsed. \n " ) ;
/*
2006-01-01 00:37:52 +00:00
x = 300 ;
2006-01-02 03:58:02 +00:00
if ( te . current_slot = = 1 & & te . ammo2 < x )
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " misc/item1.wav " , TRUE , ATTN_NORM ) ;
zz = ( te . maxmag1 / 2 ) ;
zz = ceil ( zz ) ;
qq = ftos ( zz ) ;
sprint ( te , 2 , qq ) ;
sprint ( te , 2 , " ammo was received from the mr.ammo. \n " ) ;
2006-01-02 03:58:02 +00:00
te . ammo1 = te . ammo1 + zz ;
2006-01-01 00:37:52 +00:00
te . ammo1 = ceil ( te . ammo1 ) ;
self . chemcount = self . chemcount - 1 ;
}
else
{
2006-01-02 03:58:02 +00:00
if ( te . current_slot = = 2 & & te . ammo2 < x )
2006-01-01 00:37:52 +00:00
{
sound ( self , CHAN_BODY , " misc/item1.wav " , TRUE , ATTN_NORM ) ;
zz = ( te . maxmag2 / 2 ) ;
zz = ceil ( zz ) ;
qq = ftos ( zz ) ;
sprint ( te , 2 , qq ) ;
sprint ( te , 2 , " ammo was received from the mr.ammo. \n " ) ;
2006-01-02 03:58:02 +00:00
te . ammo2 = te . ammo2 + zz ;
2006-01-01 00:37:52 +00:00
te . ammo2 = ceil ( te . ammo2 ) ;
self . chemcount = self . chemcount - 1 ;
}
}
2006-01-02 03:58:02 +00:00
*/
2006-01-01 00:37:52 +00:00
}
te = te . chain ;
}
}
} ;
void ( ) Bar_Think =
{
local float dot1 ;
if ( ( self . owner . health < WEAPON_SHOTGUN ) )
{
remove ( self ) ;
return ;
}
if ( ( self . owner . health > = self . owner . max_health ) )
{
remove ( self ) ;
return ;
}
self . flags = self . flags ;
2006-01-01 21:33:21 +00:00
2006-01-01 00:37:52 +00:00
if ( ( self . owner . position = = WEAPON_SHOTGUN ) )
{
dot1 = WEAPON_SHOTGUN ;
}
if ( ( dot1 = = WEAPON_SHOTGUN ) )
{
self . frame = MULTICAST_ALL ;
setmodel ( self , " " ) ;
self . nextthink = ( time + 0.01 ) ;
return ;
}
if ( ( ( self . owner . health > = WEAPON_SHOTGUN ) & & ( dot1 = = MULTICAST_ALL ) ) )
{
self . frame = floor ( ( ( self . owner . health / self . owner . max_health ) * TE_WIZSPIKE ) ) ;
setorigin ( self , ( self . owner . origin + ' 0 0 48 ' ) ) ;
self . nextthink = ( time + 0.01 ) ;
setmodel ( self , " progs/hbar.spr " ) ;
}
} ;
void ( entity guy ) spawn_dot =
{
local entity hologram ;
hologram = spawn ( ) ;
hologram . movetype = MOVETYPE_NONE ;
hologram . solid = SOLID_NOT ;
hologram . owner = self ;
setmodel ( hologram , " progs/hbar.spr " ) ;
hologram . skin = self . skin ;
setorigin ( hologram , self . origin ) ;
setsize ( hologram , VEC_ORIGIN , VEC_ORIGIN ) ;
hologram . angles = self . angles ;
hologram . colormap = self . colormap ;
hologram . cnt = MULTICAST_ALL ;
hologram . think = Bar_Think ;
hologram . nextthink = ( time + 0.01 ) ;
} ;
2006-01-02 03:58:02 +00:00
float ( float iid ) spawn_station =
2006-01-01 00:37:52 +00:00
{
2006-01-02 03:58:02 +00:00
local entity oself ;
2006-01-01 00:37:52 +00:00
local entity te ;
2006-01-02 03:58:02 +00:00
local vector org ;
2006-01-01 00:37:52 +00:00
2006-01-02 03:58:02 +00:00
if ( iid = = IID_BUILD_ROBOFANG )
2006-01-01 00:37:52 +00:00
{
te = find ( world , classname , " robofang " ) ;
while ( te )
{
2006-01-02 03:58:02 +00:00
if ( te . track = = self & & te . buildtype = = IID_BUILD_ROBOFANG )
2006-01-01 00:37:52 +00:00
{
makevectors ( self . v_angle ) ;
setorigin ( te , self . origin + v_forward * 32 ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
te = find ( te , classname , " robofang " ) ;
}
}
te = find ( world , classname , " station " ) ;
while ( te )
{
2006-01-02 03:58:02 +00:00
if ( te . track = = self & & te . buildtype = = iid )
2006-01-01 00:37:52 +00:00
{
sprint ( self , 2 , " already have one. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
te = find ( te , classname , " station " ) ;
}
2006-01-02 03:58:02 +00:00
if ( iid = = IID_BUILD_ROBOFANG )
2006-01-01 00:37:52 +00:00
{
te = findradius ( self . origin , 128 ) ;
while ( te )
{
if ( te ! = self & & te . classname = = " player " & & te . health > 0 )
{
sprint ( self , PRINT_HIGH , " not with other players nearby. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
te = te . chain ;
}
}
makevectors ( self . v_angle ) ;
2006-01-02 03:58:02 +00:00
org = ( ( self . origin + ( v_forward * IT_LIGHTNING ) ) + ( v_up * EF_FLAG2 ) ) ;
2006-01-01 00:37:52 +00:00
if ( ( pointcontents ( ( org + ' 0 20 0 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( pointcontents ( ( org + ' 0 - 20 0 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( pointcontents ( ( org + ' 20 0 0 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( pointcontents ( ( org + ' - 20 0 0 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( pointcontents ( ( org + ' 0 0 50 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( pointcontents ( ( org + ' 0 0 - 10 ' ) ) ! = CONTENT_EMPTY ) )
{
sprint ( self , 2 , " can't build there. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
self . impulse = 0 ;
te = findradius ( org , 40 ) ;
while ( te )
{
if ( te . classname = = " spawn1 " )
{
sprint ( self , 2 , " can't build at spawn. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( te . classname = = " spawn2 " )
{
sprint ( self , 2 , " can't build at spawn. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( te . classname = = " ghoul " )
{
sprint ( self , 2 , " somethings in the way. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( ( te . classname = = " player " ) & & ( te . health > 0 ) ) )
{
sprint ( self , 2 , " can't build on players. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
if ( ( ( te . classname = = " station " ) & & ( te . health > 0 ) ) )
{
sprint ( self , 2 , " can't build on other stations. \n " ) ;
2006-01-02 03:58:02 +00:00
return false ;
2006-01-01 00:37:52 +00:00
}
te = te . chain ;
}
2006-01-02 03:58:02 +00:00
oself = self ;
self = spawn ( ) ;
self . team = oself . team ;
self . track = oself ;
spawn_dot ( self ) ;
2006-01-01 00:37:52 +00:00
self . origin = org ;
self . takedamage = DAMAGE_YES ;
self . solid = SOLID_SLIDEBOX ;
self . movetype = MOVETYPE_TOSS ;
setsize ( self , ' - 16 - 16 0 ' , ' 16 16 40 ' ) ;
2006-01-02 03:58:02 +00:00
self . health = 30 ;
self . max_health = 300 ;
2006-01-01 00:37:52 +00:00
self . th_die = station_die ;
setmodel ( self , " progs/station.mdl " ) ;
self . classname = " station " ;
self . think = station_think ;
self . helmet = 2 ;
2006-01-02 03:58:02 +00:00
self . buildtype = iid ;
if ( self . buildtype = = IID_BUILD_MRAMMO )
2006-01-01 00:37:52 +00:00
self . netname = " mr. ammo " ;
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_SHIELDGEN )
2006-01-01 00:37:52 +00:00
self . netname = " shield generator " ;
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_AUTODOC )
2006-01-01 00:37:52 +00:00
self . netname = " autodoc " ;
2006-01-02 03:58:02 +00:00
if ( self . buildtype = = IID_BUILD_ROBOFANG )
2006-01-01 00:37:52 +00:00
{
setsize ( self , ' - 24 - 24 - 24 ' , ' 24 24 24 ' ) ;
self . netname = " robofang " ;
setmodel ( self , " progs/dog.mdl " ) ;
}
self . frame = 4 ;
2006-01-02 03:58:02 +00:00
self = oself ;
return true ;
2006-01-01 00:37:52 +00:00
} ;
2006-01-01 21:33:21 +00:00
void ( ) BuyMenu =
{
local float is_shop ;
local entity te ;
local string menu ;
if ( self . currentmenu = = " 777 " )
return ;
is_shop = 0 ;
if ( coop = = 0 )
{
te = findradius ( self . origin , 250 ) ;
while ( te )
{
if ( te . classname = = " buyzone1 " & & self . team = = 1 )
is_shop = 1 ;
if ( te . classname = = " buyzone2 " & & self . team = = 2 )
is_shop = 1 ;
te = te . chain ;
}
}
if ( coop = = 1 )
{
te = findradius ( self . origin , 80 ) ;
while ( te )
{
if ( te . classname = = " buyzone " )
is_shop = 1 ;
if ( te . classname = = " merchant " )
is_shop = 1 ;
te = te . chain ;
}
}
if ( ( is_shop = = 0 ) )
{
centerprint ( self , " nothing but the afterglow, here. \n (find a trader) " ) ;
return ;
}
if ( ( is_shop = = 1 ) )
{
menu = ShopString ( ) ;
centerprint ( self , menu ) ;
self . currentmenu = " shop_list " ;
if ( self . current_slot ! = 0 & & self . current_slot ! = 2 )
self . current_slot = 1 ;
return ;
}
} ;
void ( ) CharacterSheet =
{
local string x ;
local float qq ;
local float ratio ;
local float r1 ;
local float r2 ;
stuffcmd ( self , " toggleconsole \n " ) ;
sprint ( self , PRINT_HIGH , " \n \n \n \n ** INFO ** \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Class <20> " ) ;
if ( self . class = = 1 )
sprint ( self , 2 , " Medic " ) ;
if ( self . class = = 2 )
sprint ( self , 2 , " Assassin " ) ;
if ( self . class = = 3 )
sprint ( self , 2 , " Soldier " ) ;
if ( self . class = = 4 )
sprint ( self , 2 , " Scientist " ) ;
sprint ( self , PRINT_HIGH , " \n <EFBFBD> Team <20> " ) ;
if ( self . team = = 1 )
sprint ( self , 2 , " Rangers \n " ) ;
if ( self . team = = 2 )
sprint ( self , 2 , " Raiders \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Score <20> " ) ;
r1 = ( self . dead ) ;
r2 = ( self . kills ) ;
if ( r1 = = 0 )
r1 = 1 ;
ratio = ( r2 / r1 ) ;
x = ftos ( ratio ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ( " ) ;
x = ftos ( self . kills ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " / " ) ;
x = ftos ( self . dead ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ) " ) ;
sprint ( self , PRINT_HIGH , " \n <EFBFBD> Speed <20> " ) ;
x = ftos ( self . maxspeed ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " /300 \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Money <20> " ) ;
x = ftos ( self . ammo_shells ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " $ \n " ) ;
if ( self . class = = 2 )
{
sprint ( self , PRINT_HIGH , " <EFBFBD> Bandages <20> " ) ;
x = ftos ( self . bandages ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " \n " ) ;
}
if ( self . class = = 6 )
{
sprint ( self , PRINT_HIGH , " <EFBFBD> Scraps <20> " ) ;
x = ftos ( self . scraps ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " \n " ) ;
}
2006-01-02 03:58:02 +00:00
/*
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " \n <EFBFBD> Armor <20> " ) ;
x = GetArmorName ( ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ( " ) ;
x = ftos ( self . armor_weight ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ) \n " ) ;
2006-01-02 03:58:02 +00:00
*/
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " <EFBFBD> Protective<EFBFBD> " ) ;
x = GetProtectName ( ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " \n " ) ;
2006-01-02 03:58:02 +00:00
/*
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " <EFBFBD> Chem <20> " ) ;
x = GetChemName ( ) ;
sprint ( self , 2 , x ) ;
x = ftos ( self . chemcount ) ;
sprint ( self , 2 , " [ " ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ] " ) ;
sprint ( self , 2 , " \n " ) ;
2006-01-02 03:58:02 +00:00
*/
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " <EFBFBD> Gadget <20> " ) ;
x = GetEquipmentName ( ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Perk <20> " ) ;
x = GetPerkName ( ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Trait <20> " ) ;
x = GetTraitName ( ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " \n " ) ;
2006-01-02 03:58:02 +00:00
/*
2006-01-01 21:33:21 +00:00
sprint ( self , PRINT_HIGH , " <EFBFBD> Weapon 1 <20> " ) ;
x = GetWeaponName ( self , self . slot1 ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ( " ) ;
x = ftos ( self . slot1_weight ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ) ( " ) ;
sprint ( self , 2 , self . ammotype1 ) ;
sprint ( self , 2 , " ) \n " ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Weapon 2 <20> " ) ;
x = GetWeaponName ( self , self . slot2 ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ( " ) ;
x = ftos ( self . slot2_weight ) ;
sprint ( self , 2 , x ) ;
sprint ( self , 2 , " ) ( " ) ;
sprint ( self , 2 , self . ammotype2 ) ;
sprint ( self , 2 , " ) \n \n " ) ;
2006-01-02 03:58:02 +00:00
*/
2006-01-01 21:33:21 +00:00
qq = weightx ( ) ;
sprint ( self , PRINT_HIGH , " <EFBFBD> Weight <20> " ) ;
x = ftos ( qq ) ;
sprint ( self , 2 , x ) ;
qq = self . max_weight ;
sprint ( self , PRINT_HIGH , " / " ) ;
x = ftos ( qq ) ;
sprint ( self , 2 , x ) ;
sprint ( self , PRINT_HIGH , " \n " ) ;
return ;
} ;
void ( ) UseEquipment =
{
if ( self . equipment = = 0 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> no extra equipment <20> <> \n " ) ;
return ;
}
if ( self . equipment = = 1 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> medic's bag <20> <> \n lets you carry more stimpacks \n " ) ;
return ;
}
if ( self . equipment = = 4 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> belt pouch <20> <> \n gives you room for two extra grenades \n " ) ;
return ;
}
if ( self . equipment = = 5 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> backpack <20> <> \n lets you carry more ammunition \n " ) ;
return ;
}
if ( self . equipment = = 6 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> toolkit mark ii <20> <> \n build, defuse and open doors faster \n " ) ;
return ;
}
if ( self . equipment = = 7 & & self . equipment_state = = 0 )
{
sprint ( self , PRINT_HIGH , " climbing gear in place. \n " ) ;
sound ( self , CHAN_BODY , " misc/item2.wav " , 1 , ATTN_NORM ) ;
self . maxspeed = 100 ;
self . velocity_z = 0 ;
self . equipment_state = 1 ;
}
if ( self . equipment = = 7 & & self . equipment_state = = 1 )
{
sprint ( self , PRINT_HIGH , " climbing gear retrieved. \n " ) ;
sound ( self , CHAN_BODY , " misc/item2.wav " , 1 , ATTN_NORM ) ;
self . grab = 0 ;
self . equipment_state = 0 ;
return ;
}
if ( self . equipment = = 8 )
{
centerprint ( self , " <EFBFBD> <EFBFBD> enhanced battery <20> <> \n allows longer cloaking \n " ) ;
return ;
}
if ( self . equipment = = 9 )
{
Sneak ( ) ;
return ;
}
} ;
2006-01-02 03:58:02 +00:00
void ( vector s_aim , float dam , float tmp , float ran ) W_FireBuckshotSpread1 =
2006-01-01 21:33:21 +00:00
{
local vector source ;
local vector targ ;
local vector org ;
local float zdif ;
local float ydif ;
local float xdif ;
2006-01-02 03:58:02 +00:00
local float tru ;
2006-01-01 21:33:21 +00:00
makevectors ( self . v_angle ) ;
2006-01-02 03:58:02 +00:00
2006-01-02 00:14:21 +00:00
if ( self . position = = 0 )
source = ( self . origin + ' 0 0 20 ' ) ;
if ( self . position = = 1 )
source = ( self . origin + ' 0 0 4 ' ) ;
if ( self . position = = 2 )
source = ( self . origin + ' 0 0 - 12 ' ) ;
2006-01-02 03:58:02 +00:00
targ = ( ( ( ( ( ( s_aim + ( ( v_right * random ( ) ) * tmp ) ) - ( ( v_right * random ( ) ) * tmp ) ) + ( ( v_up * random ( ) ) * tmp ) ) - ( ( v_up * random ( ) ) * tmp ) ) + ( ( ( v_up * random ( ) ) * tmp ) * 0.5 ) ) + ( v_forward * ran ) ) ;
2006-01-01 21:33:21 +00:00
traceline ( source , targ , FALSE , self ) ;
if ( ( trace_fraction = = 1 ) )
{
return ;
}
org = ( trace_endpos - ( v_forward * 2 ) ) ;
if ( trace_ent . takedamage )
{
dam = ( ( random ( ) * dam ) + dam ) ;
dam = ( dam * ( 1 - trace_fraction ) ) ;
if ( trace_ent . solid ! = SOLID_BSP )
SpawnBlood ( org , 1 ) ;
if ( trace_ent . solid = = SOLID_BSP )
SpawnWood ( trace_ent , org , 1 ) ;
zdif = ( org_z - trace_ent . origin_z ) ;
ydif = ( org_y - trace_ent . origin_y ) ;
xdif = ( org_x - trace_ent . origin_x ) ;
2006-01-02 03:58:02 +00:00
tru = 0 ;
2006-01-01 21:33:21 +00:00
if ( ( ( ydif > = CONTENT_SLIME ) & & ( ydif < = WEAPON_SPIKES ) ) )
{
2006-01-02 03:58:02 +00:00
tru = 1 ;
2006-01-01 21:33:21 +00:00
}
if ( ( ( xdif > = CONTENT_SLIME ) & & ( xdif < = WEAPON_SPIKES ) ) )
{
2006-01-02 03:58:02 +00:00
tru = 1 ;
2006-01-01 21:33:21 +00:00
}
2006-01-02 03:58:02 +00:00
if ( ( ( tru = = 1 ) & & ( zdif > = ( ( trace_ent . size_z / 2 ) * 0.8 ) ) ) )
2006-01-01 21:33:21 +00:00
{
if ( self . attack > 2 )
dam = ( dam * 0.4 ) ;
self . critical = 3 ;
}
T_Damage ( trace_ent , self , self , dam ) ;
}
else
{
bullet_hole ( org ) ;
}
} ;
2006-01-02 03:58:02 +00:00
void ( float rec , float number , float dam , float spread , float ran , float auto ) W_FireShotgun =
2006-01-01 21:33:21 +00:00
{
local vector dir ;
local vector p_aim ;
local float var1 ;
local float var2 ;
local float var3 ;
local float var4 ;
if ( self . velocity ! = ' 0 0 0 ' )
{
var1 = ( ( random ( ) * 48 ) * ( 6 + self . recoil * 1.5 ) ) ;
var2 = ( ( random ( ) * 48 ) * ( 6 + self . recoil * 1.5 ) ) ;
var3 = ( ( random ( ) * 48 ) * ( 6 + self . recoil * 1.5 ) ) ;
var4 = ( ( random ( ) * 48 ) * ( 6 + self . recoil * 1.5 ) ) ;
}
if ( self . position = = 2 )
{
var1 = ( ( random ( ) * 12 ) * ( 6 + self . recoil * 1.5 ) ) ;
var2 = ( ( random ( ) * 12 ) * ( 6 + self . recoil * 1.5 ) ) ;
var3 = ( ( random ( ) * 12 ) * ( 6 + self . recoil * 1.5 ) ) ;
var4 = ( ( random ( ) * 12 ) * ( 6 + self . recoil * 1.5 ) ) ;
}
if ( self . position = = 1 )
{
var1 = ( ( random ( ) * IDLE3A ) * ( 6 + self . recoil * 1.5 ) ) ;
var2 = ( ( random ( ) * IDLE3A ) * ( 6 + self . recoil * 1.5 ) ) ;
var3 = ( ( random ( ) * IDLE3A ) * ( 6 + self . recoil * 1.5 ) ) ;
var4 = ( ( random ( ) * IDLE3A ) * ( 6 + self . recoil * 1.5 ) ) ;
}
if ( self . position = = 0 )
{
var1 = ( ( random ( ) * IDLE10A ) * ( 6 + ( self . recoil * 3 ) ) ) ;
var2 = ( ( random ( ) * IDLE10A ) * ( 6 + ( self . recoil * 3 ) ) ) ;
var3 = ( ( random ( ) * IDLE10A ) * ( 6 + ( self . recoil * 3 ) ) ) ;
var4 = ( ( random ( ) * IDLE10A ) * ( 6 + ( self . recoil * 3 ) ) ) ;
}
if ( self . position = = 0 )
player_single1 ( ) ;
if ( self . position = = 2 )
player_single1 ( ) ;
if ( self . position = = 1 )
player_single1_s ( ) ;
stuffcmd ( self , " +lookup \n " ) ;
stuffcmd ( self , " wait \n " ) ;
stuffcmd ( self , " -lookup \n " ) ;
sound ( self , CHAN_WEAPON , " weapons/shotgun1.wav " , 1.5 , ATTN_NORM ) ;
2006-01-02 00:14:21 +00:00
p_aim = ( ( ( ( ( self . origin + ' 0 0 20 ' ) + ( v_right * var1 ) ) - ( v_right * var2 ) ) + ( v_up * var3 ) ) - ( v_up * var4 ) ) ;
2006-01-01 21:33:21 +00:00
msg_entity = self ;
WriteByte ( MSG_ONE , SVC_BIGKICK ) ;
DropAmmo ( ) ;
self . attack = ( self . attack + 1 ) ;
self . recoil = ( self . recoil + 8 ) ;
Crosshair ( ) ;
2006-01-02 00:14:21 +00:00
if ( self . recoil > = 30 )
2006-01-01 21:33:21 +00:00
self . recoil = 30 ;
2006-01-02 00:14:21 +00:00
if ( auto = = 0 )
2006-01-01 21:33:21 +00:00
self . attack_finished = ( time + 0.5 ) ;
2006-01-02 00:14:21 +00:00
if ( auto = = 1 )
2006-01-01 21:33:21 +00:00
self . attack_finished = ( time + 0.2 ) ;
2006-01-02 00:14:21 +00:00
2006-01-01 21:33:21 +00:00
dir = aim ( self , 10000 ) ;
2006-01-02 03:58:02 +00:00
spread = 30 ;
2006-01-01 21:33:21 +00:00
if ( ( number = = MULTICAST_PVS_R ) )
{
2006-01-02 03:58:02 +00:00
W_FireBuckshotSpread1 ( p_aim , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( ( p_aim + ( v_right * 80 ) ) , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( ( p_aim - ( v_right * 80 ) ) , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( ( p_aim + ( v_up * 80 ) ) , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( ( p_aim - ( v_up * 80 ) ) , dam , spread , ran ) ;
2006-01-01 21:33:21 +00:00
}
else
{
if ( ( number = = AS_MELEE ) )
{
2006-01-02 03:58:02 +00:00
W_FireBuckshotSpread1 ( p_aim , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( p_aim , dam , spread , ran ) ;
W_FireBuckshotSpread1 ( p_aim , dam , spread , ran ) ;
2006-01-01 21:33:21 +00:00
}
}
} ;