// Nailgun void CBasePlayer::W_FireSpikes(int iQuadSound) { // If we're wielding the Super nailgun and we've got ammo for it, fire Super nails if(*m_pCurrentAmmo >= 2 && m_iQuakeWeapon == IT_SUPER_NAILGUN) { W_FireSuperSpikes(iQuadSound); return; } // Swap to next best weapon if this one just ran out if(*m_pCurrentAmmo < 1) { m_iQuakeWeapon = W_BestWeapon(); W_SetCurrentAmmo(); return; } PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usSpike, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iQuadSound, 0, m_iNailOffset > 0.0 ? 1 : 0, 0); // Fire left then right if(m_iNailOffset == 2) m_iNailOffset = -2; else m_iNailOffset = 2; if(gpGlobals->deathmatch != 4) *m_pCurrentAmmo -= 1; m_flNextAttack = UTIL_WeaponTimeBase() + 0.1; // Fire the nail UTIL_MakeVectors(pev->v_angle); Vector vecDir = GetAutoaimVector(AUTOAIM_5DEGREES); CQuakeNail *pNail = CQuakeNail::CreateNail(pev->origin + Vector(0, 0, 10) + (gpGlobals->v_right * m_iNailOffset), vecDir, this); }
void W_FireSpikes( float ox ) { vec3_t dir, tmp; // gedict_t* old; makevectors( self->s.v.v_angle ); if ( self->s.v.ammo_nails >= 2 && self->s.v.weapon == IT_SUPER_NAILGUN ) { W_FireSuperSpikes(); return; } if ( self->s.v.ammo_nails < 1 ) { self->s.v.weapon = W_BestWeapon(); W_SetCurrentAmmo(); return; } sound( self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM ); self->attack_finished = g_globalvars.time + 0.2; if ( deathmatch != 4 ) self->s.v.currentammo = self->s.v.ammo_nails = self->s.v.ammo_nails - 1; aim( dir ); // dir = aim (self, 1000); VectorScale( g_globalvars.v_right, ox, tmp ); VectorAdd( tmp, self->s.v.origin, tmp ); tmp[2] += 16; launch_spike( tmp, dir ); g_globalvars.msg_entity = EDICT_TO_PROG( self ); trap_WriteByte( MSG_ONE, SVC_SMALLKICK ); }
// Return TRUE if the weapon still has ammo BOOL CBasePlayer::W_CheckNoAmmo() { if(m_pCurrentAmmo && *m_pCurrentAmmo > 0) return TRUE; if(m_iQuakeWeapon == IT_AXE) return TRUE; #ifdef THREEWAVE if(m_iQuakeWeapon == IT_EXTRA_WEAPON) return TRUE; #endif if(m_iQuakeWeapon == IT_LIGHTNING) { PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usLightning, 0, (float *)&pev->origin, (float *)&pev->angles, 0.0, 0.0, 0, 1, 0, 0); if(m_pActiveItem) ((CQuakeGun *)m_pActiveItem)->DestroyEffect(); } m_iQuakeWeapon = W_BestWeapon(); W_SetCurrentAmmo(); return FALSE; }
int W_CheckNoAmmo() { if ( self->s.v.currentammo > 0 ) return true; if ( self->s.v.weapon == IT_AXE ) return true; self->s.v.weapon = W_BestWeapon(); W_SetCurrentAmmo(); // drop the weapon down return false; }
//========================================================================= // Function handling the Engineer's build impulse void TeamFortress_EngineerBuild( ) { gedict_t *te; /* if ( !( ( int ) self->s.v.flags & FL_ONGROUND ) ) { CenterPrint( self, "You can't build in the air!\n\n" ); return; }*/ // Pop up the menu if ( !self->is_building ) { if(!tg_data.tg_enabled) { if ( self->s.v.ammo_cells < 100 && !self->has_dispenser && !self->has_sentry ) { CenterPrint( self, "You don't have enough metal to \nbuild anything.\n\n" ); return; } } self->current_menu = MENU_ENGINEER; self->menu_count = MENU_REFRESH_RATE; } else { // if ( self->is_building == 1 ) // { G_sprint( self, 2, "You stop building.\n" ); self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE ); TeamFortress_SetSpeed( self ); // Remove the timer for ( te = world; (te = trap_find( te, FOFS( s.v.netname ), "build_timer" )); ) { if ( te->s.v.owner == EDICT_TO_PROG( self ) ) { dremove( te ); break; } } self->is_building = 0; self->current_weapon = self->s.v.weapon; W_SetCurrentAmmo( ); // } } }
/* ============ CheatCommand ============ */ void CheatCommand() { // if (deathmatch || coop) return; self->s.v.ammo_rockets = 100; self->s.v.ammo_nails = 200; self->s.v.ammo_shells = 100; self->s.v.items = ( int ) self->s.v.items | IT_AXE | IT_SHOTGUN | IT_SUPER_SHOTGUN | IT_NAILGUN | IT_SUPER_NAILGUN | IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | IT_KEY1 | IT_KEY2; self->s.v.ammo_cells = 200; self->s.v.items = ( int ) self->s.v.items | IT_LIGHTNING; self->s.v.weapon = IT_ROCKET_LAUNCHER; impulse = 0; W_SetCurrentAmmo(); }
// add/remove hook item to/from player void AddHook( qbool yes ) { gedict_t *e, *oself; oself = self; for ( e = world; (e = find_plr( e )); ) { e->s.v.items = (yes ? ((int) e->s.v.items | IT_HOOK) : ((int) e->s.v.items & ~IT_HOOK)); self = e; // warning if ( self->hook_out ) GrappleReset( self->hook ); self->hook_out = false; self->on_hook = false; if ( !yes && self->s.v.weapon == IT_HOOK ) { // actually remove hook from hands if hold, not just from items self->s.v.weapon = 0; W_SetCurrentAmmo(); } } self = oself; }
void DestroyBuilding( gedict_t * eng, char *bld ) { gedict_t *te; gedict_t *oldself; float pos; for ( te = world; (te = trap_find( te, FOFS( s.v.classname ), bld )); ) { if ( te->real_owner == eng ) { pos = trap_pointcontents( PASSVEC3( te->s.v.origin ) ); if ( pos == CONTENT_SOLID || pos == CONTENT_SKY ) { oldself = self; self = eng; self->s.v.ammo_cells = self->s.v.ammo_cells + 100; bound_other_ammo( self ); W_SetCurrentAmmo( ); self = oldself; } if ( te->real_owner->building == te ) { if ( !te->real_owner->StatusBarSize ) CenterPrint( te->real_owner, "\n" ); else te->real_owner->StatusRefreshTime = g_globalvars.time + 0.1; te->real_owner->menu_count = MENU_REFRESH_RATE; te->real_owner->current_menu = MENU_DEFAULT; te->real_owner->building = world; } if( tg_data.tg_enabled ) te->has_sentry = 0; TF_T_Damage( te, world, world, 500, 0, 0 ); } } }
void TeamFortress_FinishedBuilding( ) { gedict_t *oldself; gedict_t *owner; vec3_t end; owner = PROG_TO_EDICT( self->s.v.owner ); if ( owner->is_building != 1 ) return; if ( self->s.v.weapon == BUILD_SENTRYGUN && tg_data.tg_enabled ) { VectorCopy( self->s.v.origin, end ); end[2] -= 2048; TraceCapsule( PASSVEC3( self->s.v.origin ), PASSVEC3( end ), 0, self, -16, -16, 0, 16, 16, 4 ); VectorCopy( g_globalvars.trace_endpos, end ); end[2]++; setorigin( self, PASSVEC3( end ) ); } oldself = self; self = owner; oldself->s.v.owner = 0; oldself->real_owner = self; self->is_building = 0; self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE ); self->current_weapon = self->s.v.weapon; self->StatusRefreshTime = g_globalvars.time + 0.1; TeamFortress_SetSpeed( self ); if ( oldself->s.v.weapon == BUILD_DISPENSER ) { self->has_dispenser = self->has_dispenser + 1; G_sprint( self, 2, "You finish building the dispenser.\n" ); teamsprint( self->team_no, self, self->s.v.netname ); teamsprint( self->team_no, self, " has built a Dispenser.\n" ); if( !tg_data.tg_enabled ) self->s.v.ammo_cells = self->s.v.ammo_cells - 100; // Create the dispenser oldself->s.v.classname = "building_dispenser"; oldself->s.v.netname = "dispenser"; oldself->s.v.blocked = ( func_t ) T_Dispenser; oldself->s.v.touch = ( func_t ) T_Dispenser; oldself->s.v.max_health = BUILD_HEALTH_DISPENSER; oldself->s.v.health = BUILD_HEALTH_DISPENSER; oldself->hook_out = 1; oldself->s.v.think = ( func_t ) DispenserThink; oldself->s.v.nextthink = g_globalvars.time + 3; oldself->th_die = Dispenser_Die; //oldself->mdl = "progs/disp.mdl"; oldself->mdl = "progs/dispencr.mdl"; oldself->team_no = self->team_no; oldself->real_owner = self; // The Engineer owns this item oldself->s.v.colormap = self->s.v.colormap; // Set the Color oldself->s.v.takedamage = 2; oldself->s.v.owner = EDICT_TO_PROG( world ); oldself->s.v.movetype = MOVETYPE_TOSS; SetVector( oldself->s.v.velocity, 0, 0, 8 ); oldself->s.v.flags = ( int ) oldself->s.v.flags - ( ( int ) oldself->s.v.flags & FL_ONGROUND ); // Put some ammo in the Dispenser oldself->s.v.ammo_shells = ceil( self->s.v.ammo_shells * 0.25 ); oldself->s.v.ammo_nails = ceil( self->s.v.ammo_nails * 0.25 ); oldself->s.v.ammo_rockets = ceil( self->s.v.ammo_rockets * 0.25 ); oldself->s.v.ammo_cells = ceil( self->s.v.ammo_cells * 0.25 ); oldself->s.v.armorvalue = ceil( self->s.v.armorvalue * 0.25 ); // Remove ours self->s.v.ammo_shells = ceil( self->s.v.ammo_shells * 0.75 ); self->s.v.ammo_nails = ceil( self->s.v.ammo_nails * 0.75 ); self->s.v.ammo_rockets = ceil( self->s.v.ammo_rockets * 0.75 ); self->s.v.ammo_cells = ceil( self->s.v.ammo_cells * 0.75 ); self->s.v.armorvalue = ceil( self->s.v.armorvalue * 0.75 ); oldself->s.v.solid = SOLID_BBOX; setmodel( oldself, oldself->mdl ); setsize( oldself, -8, -8, 0, 8, 8, 24 ); oldself->s.v.origin[2] += 8; setorigin( oldself, PASSVEC3( oldself->s.v.origin ) ); } else { if ( oldself->s.v.weapon == BUILD_SENTRYGUN ) { self->has_sentry = self->has_sentry + 1; G_sprint( self, 2, "You finish building the sentry gun.\n" ); teamsprint( self->team_no, self, self->s.v.netname ); teamsprint( self->team_no, self, " has built a Sentry Gun.\n" ); oldself->s.v.classname = "building_sentrygun_base"; oldself->s.v.netname = "sentry gun"; oldself->s.v.takedamage = 0; oldself->th_die = Sentry_Die; oldself->team_no = self->team_no; if( !tg_data.tg_enabled ) self->s.v.ammo_cells = self->s.v.ammo_cells - 130; setsize( oldself, -16, -16, 0, 16, 16, 4 ); newmis = spawn( ); g_globalvars.newmis = EDICT_TO_PROG( newmis ); newmis->s.v.classname = "building_sentrygun"; newmis->s.v.health = BUILD_HEALTH_SENTRYGUN; newmis->s.v.max_health = newmis->s.v.health; newmis->s.v.weapon = 1; newmis->th_die = Sentry_Die; newmis->th_pain = Sentry_Pain; newmis->mdl = "progs/turrgun.mdl"; sound( oldself, 3, "weapons/turrset.wav", 1, 1 ); newmis->s.v.solid = SOLID_BBOX; setmodel( newmis, newmis->mdl ); setsize( newmis, -16, -16, 0, 16, 16, 48 ); VectorCopy( oldself->s.v.origin, newmis->s.v.origin ); newmis->s.v.origin[2] += 8; setorigin( newmis, PASSVEC3( newmis->s.v.origin ) ); SetVector( newmis->s.v.view_ofs, 0, 0, 22 ); newmis->real_owner = oldself->real_owner; newmis->trigger_field = oldself; oldself->oldenemy = newmis; newmis->s.v.movetype = MOVETYPE_STEP; oldself->s.v.colormap = self->s.v.colormap; // Set the Base Color newmis->s.v.colormap = self->s.v.colormap; // Set the Color newmis->s.v.takedamage = DAMAGE_AIM; SetVector( newmis->s.v.velocity, 0, 0, -8 ); newmis->s.v.flags = ( int ) newmis->s.v.flags - ( ( int ) newmis->s.v.flags & FL_ONGROUND ); oldself->s.v.flags = ( int ) oldself->s.v.flags - ( ( int ) oldself->s.v.flags & FL_ONGROUND ); newmis->team_no = self->team_no; newmis->s.v.think = ( func_t ) lvl1_sentry_stand; newmis->s.v.nextthink = g_globalvars.time + 0.5; // Rotate Details newmis->s.v.yaw_speed = 10; newmis->heat = 0; // Turn Right newmis->s.v.angles[0] = 0; newmis->s.v.angles[1] = ( int ) ( oldself->s.v.angles[1] ); newmis->s.v.angles[2] = 0; newmis->waitmin = ( int ) ( newmis->s.v.angles[1] - 50 ); newmis->waitmin = anglemod( newmis->waitmin ); newmis->waitmax = ( int ) ( newmis->s.v.angles[1] + 50 ); newmis->waitmax = anglemod( newmis->waitmax ); if ( newmis->waitmin > newmis->waitmax ) { newmis->waitmin = newmis->waitmax; newmis->waitmax = anglemod( newmis->s.v.angles[1] - 50 ); } // Give the Gun some ammo newmis->s.v.ammo_shells = 25; newmis->maxammo_shells = 100; newmis->maxammo_rockets = 20; } } W_SetCurrentAmmo( ); self = oldself; }
// Go to the prev weapon with ammo void CBasePlayer::W_CycleWeaponReverseCommand() { while(1) { BOOL bHaveAmmo = TRUE; if(m_iQuakeWeapon == IT_EXTRA_WEAPON) { m_iQuakeWeapon = IT_LIGHTNING; } else if(m_iQuakeWeapon == IT_LIGHTNING) { m_iQuakeWeapon = IT_ROCKET_LAUNCHER; if(m_iAmmoRockets < 1) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_ROCKET_LAUNCHER) { m_iQuakeWeapon = IT_GRENADE_LAUNCHER; if(m_iAmmoRockets < 1) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_GRENADE_LAUNCHER) { m_iQuakeWeapon = IT_SUPER_NAILGUN; if(m_iAmmoNails < 2) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_SUPER_NAILGUN) { m_iQuakeWeapon = IT_NAILGUN; if(m_iAmmoNails < 1) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_NAILGUN) { m_iQuakeWeapon = IT_SUPER_SHOTGUN; if(m_iAmmoShells < 2) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_SUPER_SHOTGUN) { m_iQuakeWeapon = IT_SHOTGUN; if(m_iAmmoShells < 1) bHaveAmmo = FALSE; } else if(m_iQuakeWeapon == IT_SHOTGUN) { m_iQuakeWeapon = IT_AXE; } else if(m_iQuakeWeapon == IT_AXE) { m_iQuakeWeapon = IT_EXTRA_WEAPON; } else if(m_iQuakeWeapon == IT_EXTRA_WEAPON) { m_iQuakeWeapon = IT_LIGHTNING; if(m_iAmmoCells < 1) bHaveAmmo = FALSE; } if((m_iQuakeItems & m_iQuakeWeapon) && bHaveAmmo) { W_SetCurrentAmmo(); return; } } }
//========================================================================= // EMP Grenade explode function, for when the PRIMETIME runs out void EMPGrenadeExplode( ) { float expsize; gedict_t *te; gedict_t *oldself; trap_WriteByte( MSG_BROADCAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_BROADCAST, TE_TAREXPLOSION ); trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[0] ); trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[1] ); trap_WriteCoord( MSG_BROADCAST, self->s.v.origin[2] ); trap_multicast( PASSVEC3( self->s.v.origin ), 1 ); for ( te = world; (te = findradius( te, self->s.v.origin, 240 )); ) { if ( te->s.v.touch == ( func_t ) ammo_touch || te->s.v.touch == ( func_t ) weapon_touch ) { if ( strneq( te->s.v.classname, "item_spikes" ) ) { te->s.v.solid = SOLID_NOT; te->s.v.enemy = self->s.v.owner; te->s.v.nextthink = g_globalvars.time + 1 + g_random( ) * 2; te->s.v.think = ( func_t ) EMPExplode; } continue; } if ( te->s.v.think == ( func_t ) TeamFortress_DetpackExplode ) { te->s.v.solid = SOLID_NOT; te->s.v.nextthink = g_globalvars.time + 1 + g_random( ) * 2; dremove( te->oldenemy ); continue; } if ( streq( te->s.v.classname, "pipebomb" ) ) { te->s.v.nextthink = g_globalvars.time + 0.1; continue; } // No sentrygun damage in mtf vanilla :( // Clan Edition should have tho.. // - XavioR if ( streq( te->s.v.classname, "building_dispenser" ) /*|| streq( te->s.v.classname, "building_sentrygun" )*/ ) { if ( ! ( ( teamplay & TEAMPLAY_NOEXPLOSIVE ) && te->team_no > 0 && te->team_no == PROG_TO_EDICT( self->s.v.owner )->team_no ) ) TF_T_Damage( te, self, PROG_TO_EDICT( self->s.v.owner ), 200, 0, 4 ); continue; } if ( streq( te->s.v.classname, "ammobox" ) ) { expsize = 0; expsize = expsize + te->s.v.ammo_shells * 0.75; expsize = expsize + te->s.v.ammo_rockets * 0.75 * 2; expsize = expsize + te->s.v.ammo_cells * 0.75 * 2; if ( expsize > 0 ) { te->s.v.solid = SOLID_NOT; tf_data.deathmsg = DMSG_GREN_EMP; T_RadiusDamage( te, PROG_TO_EDICT( self->s.v.owner ), expsize, te ); te->s.v.think = ( func_t ) TeamFortress_AmmoboxRemove;//SUB_Remove; te->s.v.nextthink = g_globalvars.time + 0.1; trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_EXPLOSION ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[0] ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[1] ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[2] ); trap_multicast( PASSVEC3( te->s.v.origin ), 1 ); } continue; } if ( streq( te->s.v.classname, "player" ) || te->s.v.touch == ( func_t ) BackpackTouch ) { // if ( !( ( teamplay & 16 ) && te->team_no > 0 && te->team_no == PROG_TO_EDICT( self->s.v.owner )->team_no ) ) // { // ^ yeah it's also kinda dumb that in mtf you can emp teammates but wtva.. expsize = 0; expsize = expsize + te->s.v.ammo_shells * 0.75; expsize = expsize + te->s.v.ammo_rockets * 0.75 * 2; if ( te->playerclass != PC_ENGINEER ) expsize = expsize + te->s.v.ammo_cells * 0.75; if ( expsize > 0 ) { tf_data.deathmsg = DMSG_GREN_EMP; T_RadiusDamage( te, PROG_TO_EDICT( self->s.v.owner ), expsize, te ); if ( te->s.v.touch != ( func_t ) BackpackTouch ) { TF_T_Damage( te, self, PROG_TO_EDICT( self->s.v.owner ), expsize, 2, 4 ); te->s.v.ammo_shells = ceil( te->s.v.ammo_shells * 0.25 ); te->s.v.ammo_rockets = ceil( te->s.v.ammo_rockets * 0.25 ); if ( te->playerclass != 9 ) te->s.v.ammo_cells = ceil( te->s.v.ammo_cells * 0.25 ); oldself = self; self = te; W_SetCurrentAmmo( ); self = oldself; } else { te->s.v.think = ( func_t ) SUB_Remove; te->s.v.nextthink = g_globalvars.time + 0.1; } trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_EXPLOSION ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[0] ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[1] ); trap_WriteCoord( MSG_MULTICAST, te->s.v.origin[2] ); trap_multicast( PASSVEC3( te->s.v.origin ), 1 ); } // } continue; } } dremove( self ); }
// Lightning Gun void CBasePlayer::W_FireLightning(int iQuadSound) { if(*m_pCurrentAmmo < 1) { //This should already be IT_LIGHTNING but what the heck. if(m_iQuakeWeapon == IT_LIGHTNING) { PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usLightning, 0, (float *)&pev->origin, (float *)&pev->angles, 0.0, 0.0, 0, 1, 0, 0); if(m_pActiveItem) ((CQuakeGun *)m_pActiveItem)->DestroyEffect(); } m_iQuakeWeapon = W_BestWeapon(); W_SetCurrentAmmo(); return; } bool playsound = false; // Make lightning sound every 0.6 seconds if(m_flLightningTime <= gpGlobals->time) { playsound = true; m_flLightningTime = gpGlobals->time + 0.6; } // explode if under water if(pev->waterlevel > 1) { if((gpGlobals->deathmatch > 3) && (RANDOM_FLOAT(0, 1) <= 0.5)) { strcpy(gszQ_DeathType, "selfwater"); TakeDamage(pev, pev, 4000, DMG_GENERIC); } else { float flCellsBurnt = *m_pCurrentAmmo; *m_pCurrentAmmo = 0; W_SetCurrentAmmo(); #if !defined(CLIENT_DLL) Q_RadiusDamage(this, this, 35 * flCellsBurnt, NULL); #endif return; } } PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usLightning, 0, (float *)&pev->origin, (float *)&pev->angles, 0.0, 0.0, iQuadSound, 0, playsound, 0); #if !defined(CLIENT_DLL) if(gpGlobals->deathmatch != 4) *m_pCurrentAmmo -= 1; // Lightning bolt effect TraceResult trace; Vector vecOrg = pev->origin + Vector(0, 0, 16); UTIL_MakeVectors(pev->v_angle); UTIL_TraceLine(vecOrg, vecOrg + (gpGlobals->v_forward * 600), ignore_monsters, ENT(pev), &trace); Vector vecDir = gpGlobals->v_forward + (0.001 * gpGlobals->v_right) + (0.001 * gpGlobals->v_up); // Do damage LightningDamage(pev->origin, trace.vecEndPos + (gpGlobals->v_forward * 4), this, 30, vecDir); #endif }
void W_FireLightning() { vec3_t org; float cells; vec3_t tmp; if ( self->s.v.ammo_cells < 1 ) { self->s.v.weapon = W_BestWeapon(); W_SetCurrentAmmo(); return; } // explode if under water if ( self->s.v.waterlevel > 1 ) { if ( deathmatch > 3 ) { if ( g_random() <= 0.5 ) { self->deathtype = "selfwater"; T_Damage( self, self, PROG_TO_EDICT( self->s.v.owner ), 4000 ); } else { cells = self->s.v.ammo_cells; self->s.v.ammo_cells = 0; W_SetCurrentAmmo(); T_RadiusDamage( self, self, 35 * cells, world, "" ); return; } } else { cells = self->s.v.ammo_cells; self->s.v.ammo_cells = 0; W_SetCurrentAmmo(); T_RadiusDamage( self, self, 35 * cells, world, "" ); return; } } if ( self->t_width < g_globalvars.time ) { sound( self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM ); self->t_width = g_globalvars.time + 0.6; } g_globalvars.msg_entity = EDICT_TO_PROG( self ); trap_WriteByte( MSG_ONE, SVC_SMALLKICK ); if ( deathmatch != 4 ) self->s.v.currentammo = self->s.v.ammo_cells = self->s.v.ammo_cells - 1; VectorCopy( self->s.v.origin, org ); //org = self->s.v.origin + '0 0 16'; org[2] += 16; traceline( PASSVEC3( org ), org[0] + g_globalvars.v_forward[0] * 600, org[1] + g_globalvars.v_forward[1] * 600, org[2] + g_globalvars.v_forward[2] * 600, true, self ); trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_LIGHTNING2 ); WriteEntity( MSG_MULTICAST, self ); trap_WriteCoord( MSG_MULTICAST, org[0] ); trap_WriteCoord( MSG_MULTICAST, org[1] ); trap_WriteCoord( MSG_MULTICAST, org[2] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] ); trap_multicast( PASSVEC3( org ), MULTICAST_PHS ); VectorScale( g_globalvars.v_forward, 4, tmp ); VectorAdd( g_globalvars.trace_endpos, tmp, tmp ); LightningDamage( self->s.v.origin, tmp, self, 30 ); }
/* ============ CycleWeaponReverseCommand Go to the prev weapon with ammo ============ */ void CycleWeaponReverseCommand() { int it, am; it = self->s.v.items; impulse = 0; while ( 1 ) { am = 0; switch ( ( int ) self->s.v.weapon ) { case IT_LIGHTNING: self->s.v.weapon = IT_ROCKET_LAUNCHER; if ( self->s.v.ammo_rockets < 1 ) am = 1; break; case IT_ROCKET_LAUNCHER: self->s.v.weapon = IT_GRENADE_LAUNCHER; if ( self->s.v.ammo_rockets < 1 ) am = 1; break; case IT_GRENADE_LAUNCHER: self->s.v.weapon = IT_SUPER_NAILGUN; if ( self->s.v.ammo_nails < 2 ) am = 1; break; case IT_SUPER_NAILGUN: self->s.v.weapon = IT_NAILGUN; if ( self->s.v.ammo_nails < 1 ) am = 1; break; case IT_NAILGUN: self->s.v.weapon = IT_SUPER_SHOTGUN; if ( self->s.v.ammo_shells < 2 ) am = 1; break; case IT_SUPER_SHOTGUN: self->s.v.weapon = IT_SHOTGUN; if ( self->s.v.ammo_shells < 1 ) am = 1; break; case IT_SHOTGUN: self->s.v.weapon = IT_AXE; break; case IT_AXE: self->s.v.weapon = IT_LIGHTNING; if ( self->s.v.ammo_cells < 1 ) am = 1; break; } if ( ( it & ( int ) self->s.v.weapon ) && am == 0 ) { W_SetCurrentAmmo(); return; } } }
// Change to the specified weapon void CBasePlayer::W_ChangeWeapon(int iWeaponNumber) { if(m_iQuakeWeapon == IT_LIGHTNING) { PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usLightning, 0, (float *)&pev->origin, (float *)&pev->angles, 0.0, 0.0, 0, 1, 0, 0); if(m_pActiveItem) ((CQuakeGun *)m_pActiveItem)->DestroyEffect(); } int iWeapon = 0; BOOL bHaveAmmo = TRUE; if(iWeaponNumber == 1) { iWeapon = IT_AXE; } else if(iWeaponNumber == 2) { iWeapon = IT_SHOTGUN; if(m_iAmmoShells < 1) bHaveAmmo = FALSE; } else if(iWeaponNumber == 3) { iWeapon = IT_SUPER_SHOTGUN; if(m_iAmmoShells < 2) bHaveAmmo = FALSE; } else if(iWeaponNumber == 4) { iWeapon = IT_NAILGUN; if(m_iAmmoNails < 1) bHaveAmmo = FALSE; } else if(iWeaponNumber == 5) { iWeapon = IT_SUPER_NAILGUN; if(m_iAmmoNails < 2) bHaveAmmo = FALSE; } else if(iWeaponNumber == 6) { iWeapon = IT_GRENADE_LAUNCHER; if(m_iAmmoRockets < 1) bHaveAmmo = FALSE; } else if(iWeaponNumber == 7) { iWeapon = IT_ROCKET_LAUNCHER; if(m_iAmmoRockets < 1) bHaveAmmo = FALSE; } else if(iWeaponNumber == 8) { iWeapon = IT_LIGHTNING; if(m_iAmmoCells < 1) bHaveAmmo = FALSE; } #ifdef THREEWAVE else if(iWeaponNumber == 9) { iWeapon = IT_EXTRA_WEAPON; } #endif // Have the weapon? if(!(m_iQuakeItems & iWeapon)) { ClientPrint(pev, HUD_PRINTCONSOLE, "#No_Weapon"); return; } // Have ammo for it? if(!bHaveAmmo) { ClientPrint(pev, HUD_PRINTCONSOLE, "#No_Ammo"); return; } // Set weapon, update ammo m_iQuakeWeapon = iWeapon; W_SetCurrentAmmo(); #ifdef CLIENT_DLL g_flLightTime = 0.0; #endif }
/* ============ W_ChangeWeapon ============ */ void W_ChangeWeapon() { int it, am, fl = 0; it = self->s.v.items; am = 0; switch ( impulse ) { case 1: fl = IT_AXE; break; case 2: fl = IT_SHOTGUN; if ( self->s.v.ammo_shells < 1 ) am = 1; break; case 3: fl = IT_SUPER_SHOTGUN; if ( self->s.v.ammo_shells < 2 ) am = 1; break; case 4: fl = IT_NAILGUN; if ( self->s.v.ammo_nails < 1 ) am = 1; break; case 5: fl = IT_SUPER_NAILGUN; if ( self->s.v.ammo_nails < 2 ) am = 1; break; case 6: fl = IT_GRENADE_LAUNCHER; if ( self->s.v.ammo_rockets < 1 ) am = 1; break; case 7: fl = IT_ROCKET_LAUNCHER; if ( self->s.v.ammo_rockets < 1 ) am = 1; break; case 8: fl = IT_LIGHTNING; if ( self->s.v.ammo_cells < 1 ) am = 1; break; default: break; } impulse = 0; if ( !( ( int ) self->s.v.items & fl ) ) { // don't have the weapon or the ammo G_sprint( self, PRINT_HIGH, "no weapon.\n" ); return; } if ( am ) { // don't have the ammo G_sprint( self, PRINT_HIGH, "not enough ammo.\n" ); return; } // // set weapon, set ammo // self->s.v.weapon = fl; W_SetCurrentAmmo(); }
//========================================================================= // Function handling the Spy's feign death ability void TeamFortress_SpyFeignDeath( int issilent ) { int i, j; gedict_t *at_spot; gedict_t *te; self->StatusRefreshTime = g_globalvars.time + 0.1; if ( self->is_feigning ) { // Check to make sure there isn't anyone on top of us at_spot = findradius( world, self->s.v.origin, 64 ); i = 1; j = 0; while ( at_spot ) { if ( streq( at_spot->mdl, "progs/detpack.mdl" ) ) j = 1; if ( streq( at_spot->mdl, "progs/detpack2.mdl" ) && tf_data.birthday == 1 ) j = 1; if ( streq( at_spot->mdl, "progs/turrbase.mdl" ) ) j = 1; if ( streq( at_spot->mdl, "progs/turrgun.mdl" ) ) j = 1; // if ( streq( at_spot->mdl, "progs/disp.mdl" ) ) // j = 1; if ( streq( at_spot->mdl, "progs/dispencr.mdl" ) ) j = 1; if ( streq( at_spot->s.v.classname, "player" ) && !at_spot->s.v.deadflag && self != at_spot ) j = 2; switch ( j ) { case 1: G_sprint( self, 2, "You can't get up with something\non top of you.\n" ); return; case 2: G_sprint( self, 2, "You can't get up while someone\nis standing on you.\n" ); return; } at_spot = findradius( at_spot, self->s.v.origin, 64 ); } if ( self->is_squating == TRUE ) unlay ( ); SetVector( self->s.v.velocity, 0, 0, 0 ); setsize( self, -16, -16, -24, 16, 16, 32 ); SetVector( self->s.v.view_ofs, 0, 0, 22 ); self->s.v.movetype = MOVETYPE_WALK; self->is_feigning = 0; self->current_weapon = self->s.v.weapon; W_SetCurrentAmmo( ); self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE ); TeamFortress_SetSpeed( self ); // Check .weapon, because .current_weapon has been reset if ( self->s.v.weapon <= 16 ) { spy_upaxe1( ); return; } switch ( ( int ) ( g_random( ) * 4 ) ) { case 0: spy_upb1( ); break; case 1: spy_upc1( ); break; case 2: spy_upd1( ); break; default: spy_upe1( ); break; } return; } else // !self->is_feigning { if ( self->hook_out ) { G_sprint( self, 2, "You can't feign with the hook out.\n" ); return; } //REMOVE!!! /* if (self.is_unabletospy == 1) { G_sprint(self, 2, "You can't go undercover right now.\n"); return; }*/ /* if (!(self.flags & 512) && !self->s.v.waterlevel) { G_sprint(self, 2, "You can't feign in the air.\n"); return; }*/ for ( at_spot = world; ( at_spot = findradius( at_spot, self->s.v.origin, 64 ) ) ; ) { if ( streq( at_spot->s.v.classname, "player" ) && self != at_spot && at_spot->is_feigning == 1 ) { G_sprint( self, 2, "You can't feign on top of another spy!\n" ); return; } } self->tfstate = self->tfstate | TFSTATE_CANT_MOVE; TeamFortress_SetSpeed( self ); self->is_feigning = 1; Attack_Finished( 0.8 ); self->invisible_finished = 0; self->s.v.modelindex = modelindex_player; self->s.v.weapon = self->current_weapon; self->current_weapon = 0; self->s.v.weaponmodel = ""; self->s.v.weaponframe = 0; setsize( self, -16, -16, -24, 16, 16, -16 ); SetVector( self->s.v.view_ofs, 0, 0, 4 ); self->s.v.movetype = MOVETYPE_TOSS; if ( !issilent ) DeathSound( ); self->s.v.angles[0] = 0; self->s.v.angles[2] = 0; if ( self->s.v.weapon <= 16 ) { spy_die_ax1( ); return; } te = world; for( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "item_tfgoal" ) ) ;) { if ( te->s.v.owner != EDICT_TO_PROG( self ) ) continue; if ( !( te->goal_activation & TFGI_KEEP ) || self->has_disconnected == 1 ) tfgoalitem_RemoveFromPlayer( te, self, 0 ); if ( CTF_Map == 1 ) { if ( te->goal_no == 1 ) G_bprint( 2, "%s лост the блуе flag!\n", self->s.v.netname ); else G_bprint( 2, "%s лост the ред flag!\n", self->s.v.netname ); } } switch ( ( int ) ( g_random( ) * 5 ) ) { case 0: spy_diea1( ); break; case 1: spy_dieb1( ); break; case 2: spy_diec1( ); break; case 3: spy_died1( ); break; default: spy_diee1( ); break; } } }