From 7cc8d03b0071048f7b9fe278663a39e4e04fa1ec Mon Sep 17 00:00:00 2001 From: avirox Date: Sun, 15 Jan 2006 01:18:05 +0000 Subject: [PATCH] - Added pistol weapon & reload function - Soldier no longer has Electro - Added pistol as weapon 1 for Soldier (may replace all laser guns with it later) - Added "reload" alias git-svn-id: svn://svn.icculus.org/nexuiz/trunk@828 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- TeamNexuiz/game/gamec/GameC.dsp | 4 ++++ TeamNexuiz/game/gamec/cl_impulse.c | 8 ++++++- TeamNexuiz/game/gamec/cl_weapons.c | 18 +++++++++++++--- TeamNexuiz/game/gamec/cl_weaponsystem.c | 2 ++ TeamNexuiz/game/gamec/class.c | 4 +++- TeamNexuiz/game/gamec/defs.h | 1 + TeamNexuiz/game/gamec/g_world.c | 2 ++ TeamNexuiz/game/gamec/soldier.c | 2 +- TeamNexuiz/game/gamec/tfdefs.c | 9 +++++++- TeamNexuiz/game/gamec/tffunctions.c | 6 ++++++ TeamNexuiz/game/gamec/w_common.c | 5 ++++- TeamNexuiz/game/gamec/w_flamer.c | 28 ++++++++++++++++++++----- 12 files changed, 76 insertions(+), 13 deletions(-) diff --git a/TeamNexuiz/game/gamec/GameC.dsp b/TeamNexuiz/game/gamec/GameC.dsp index 8648ffe1b..ef90fb27d 100644 --- a/TeamNexuiz/game/gamec/GameC.dsp +++ b/TeamNexuiz/game/gamec/GameC.dsp @@ -393,6 +393,10 @@ SOURCE=.\cl_weaponsystem.c # End Source File # Begin Source File +SOURCE=.\tf_w_pistol.c +# End Source File +# Begin Source File + SOURCE=.\w_common.c # End Source File # Begin Source File diff --git a/TeamNexuiz/game/gamec/cl_impulse.c b/TeamNexuiz/game/gamec/cl_impulse.c index efc176295..9c5942109 100644 --- a/TeamNexuiz/game/gamec/cl_impulse.c +++ b/TeamNexuiz/game/gamec/cl_impulse.c @@ -21,7 +21,8 @@ void DummyThink(void) void CopyBody2(float keepvelocity, float testbody); void ImpulseCommands (void) { - local float swpn; + local float swpn; // returns self.weapon amount -- the slot that weapon is in (WEP1, WEP2 etc) + local float awpn; // returns self.wpn amount (WEP_PISTOL, WEP_NEX etc.) if (self.impulse_wait > time) // So the GUI menus doesnt flicker return; @@ -61,6 +62,11 @@ void ImpulseCommands (void) } if (self.impulse == 70) { // reload impulse swpn = self.weapon; + awpn = self.wpn; + + if (awpn == WEP_PISTOL) + DoReload (1, (CLIP_MAX_PISTOL - self.clip_pistol)); + if(self.class == CLASS_SOLDIER) { if (swpn == WEP4) diff --git a/TeamNexuiz/game/gamec/cl_weapons.c b/TeamNexuiz/game/gamec/cl_weapons.c index dd62fec36..3321499d3 100644 --- a/TeamNexuiz/game/gamec/cl_weapons.c +++ b/TeamNexuiz/game/gamec/cl_weapons.c @@ -4,6 +4,7 @@ void (float wreq) w_railgun; void (float wreq) w_healgun; void (float wreq) w_mac; +void (float wreq) w_pistol; void(float wpn, float wrequest) weapon_action = { if ((self.reload_time + .25) > time) { @@ -60,11 +61,14 @@ void(float wpn, float wrequest) weapon_action = else if(self.class == CLASS_SOLDIER) { if (wpn == WEP1) - w_shotgun(wrequest); + w_pistol(wrequest); + //w_shotgun(wrequest); else if (wpn == WEP2) - w_namek(wrequest); + w_shotgun(wrequest); + //w_namek(wrequest); else if (wpn == WEP3) - w_electro(wrequest); + w_namek(wrequest); +// w_electro(wrequest); else if (wpn == WEP4) w_rlauncher(wrequest); } @@ -292,10 +296,18 @@ void() W_WeaponFrame = } if (self.button0) + { + if (self.pistol_fired == 1) // code so that if fire is held down with pistol, + { //// it will not keep firing automatically. + self.next_pistol_fire = time + .2; + } weapon_action(self.weapon, WR_FIRE1); + } if (self.button3) weapon_action(self.weapon, WR_FIRE2); + if (!self.button0 && self.pistol_fired == 1) + self.pistol_fired = 0; // do weapon think if (time >= self.weapon_nextthink) if (self.weapon_nextthink > 0) diff --git a/TeamNexuiz/game/gamec/cl_weaponsystem.c b/TeamNexuiz/game/gamec/cl_weaponsystem.c index c88f4050e..8e52e745c 100644 --- a/TeamNexuiz/game/gamec/cl_weaponsystem.c +++ b/TeamNexuiz/game/gamec/cl_weaponsystem.c @@ -50,6 +50,8 @@ void() CL_ExteriorWeaponentity_Think = else if (self.owner.wpn == WEP_NAMEK) setmodel(self, "models/weapons/v_namek.md3"); else if (self.owner.wpn == WEP_RAILGUN) setmodel(self, "models/weapons/v_nex.md3"); else if (self.owner.wpn == WEP_MAC) setmodel(self, "models/weapons/v_mac.md3"); + else if (self.owner.wpn == WEP_FLAMER) setmodel(self, "models/weapons/v_flamethrower.md3"); + else if (self.owner.wpn == WEP_PISTOL) setmodel(self, "models/weapons/v_soldpistol.md3"); setattachment(self, self.owner, "bip01 r hand"); // if that didn't find a tag, hide the exterior weapon model if (!self.tag_index) diff --git a/TeamNexuiz/game/gamec/class.c b/TeamNexuiz/game/gamec/class.c index 9b98f5ea5..68193931b 100644 --- a/TeamNexuiz/game/gamec/class.c +++ b/TeamNexuiz/game/gamec/class.c @@ -488,7 +488,8 @@ void (float classnum) SetMaxAmmoFor = self.maxammo_cells = 40; self.maxammo_rockets = 40; self.no_grenades_1 = 4; - self.clip_rockets = 4; + self.clip_rockets = CLIP_MAX_ROCKETS; + self.clip_pistol = CLIP_MAX_PISTOL; self.tp_grenades_1 = 1; self.tp_grenades_2 = 0; @@ -509,6 +510,7 @@ void (float classnum) SetMaxAmmoFor = self.ammo_nails = 100; } else if (classnum == CLASS_SOLDIER) { + self.ammo_rockets = 62; //translates to 20 self.maxammo_rockets = 40; self.tp_grenades_2 = 3; } diff --git a/TeamNexuiz/game/gamec/defs.h b/TeamNexuiz/game/gamec/defs.h index 3ed60ce02..ddb242118 100644 --- a/TeamNexuiz/game/gamec/defs.h +++ b/TeamNexuiz/game/gamec/defs.h @@ -146,6 +146,7 @@ float WEP_NAMEK = 15; float WEP_RAILGUN = 16; float WEP_HEALGUN = 17; float WEP_MAC = 18; +float WEP_PISTOL = 19; float WEP_SCOUT_SPECIAL = 50; float WEP_SPY_SPECIAL = 51; diff --git a/TeamNexuiz/game/gamec/g_world.c b/TeamNexuiz/game/gamec/g_world.c index 26b2c8c19..d42b618a3 100644 --- a/TeamNexuiz/game/gamec/g_world.c +++ b/TeamNexuiz/game/gamec/g_world.c @@ -120,6 +120,7 @@ void worldspawn (void) precache_model ("models/weapons/v_namek.md3"); // namek precache_model ("models/weapons/v_railgun.md3"); // railgun (engineer) precache_model ("models/weapons/v_mac.md3"); // MAC10 (spy) + precache_model ("models/weapons/v_soldpistol.md3"); // Pistol precache_model ("models/weapons/w_rli.zym"); precache_model ("models/weapons/w_flamer.zym"); @@ -129,6 +130,7 @@ void worldspawn (void) precache_model ("models/weapons/w_namek.zym"); precache_model ("models/weapons/w_railgun.zym"); precache_model ("models/weapons/w_mac.zym"); + precache_model ("models/weapons/w_soldpistol.zym"); // other stuff diff --git a/TeamNexuiz/game/gamec/soldier.c b/TeamNexuiz/game/gamec/soldier.c index 2ae69f0cb..9f35c7e04 100644 --- a/TeamNexuiz/game/gamec/soldier.c +++ b/TeamNexuiz/game/gamec/soldier.c @@ -211,7 +211,7 @@ void BecomeSoldier(float portion) SetPlayerSpeed(self); self.items = IT_WEP1 | IT_WEP2 | IT_WEP3 | IT_WEP4; - self.switchweapon = WEP3; + self.switchweapon = WEP4; // used to be WEP3 self.ammo_shells = floor(20 * portion); self.ammo_nails = floor(150 * portion); self.ammo_rockets = floor(12 * portion); diff --git a/TeamNexuiz/game/gamec/tfdefs.c b/TeamNexuiz/game/gamec/tfdefs.c index cbd0f9e37..97df5383d 100644 --- a/TeamNexuiz/game/gamec/tfdefs.c +++ b/TeamNexuiz/game/gamec/tfdefs.c @@ -93,9 +93,11 @@ float blueflagexists; // Weapon Clips .float reload_time; +.float clip_pistol; .float clip_crylink; .float clip_rockets; .float clip_pipegrenades; +float CLIP_MAX_PISTOL = 10; float CLIP_MAX_CRYLINK = 8; float CLIP_MAX_ROCKETS = 4; float CLIP_MAX_PIPEGRENADES = 6; @@ -154,6 +156,10 @@ float CLIP_MAX_PIPEGRENADES = 6; .float current_menu; .float menu_count; +.float pistol_fired; // has the pistol been fired? 1 - yes, 2- no +.float next_pistol_fire; // pistol cannot be fired again until this value < time + //// check W_WeaponFrame for more detail on these 2 + .float heat; // What tf uses for powering up weapons. Could be useful later? entity otemp; @@ -298,4 +304,5 @@ float toggleflags; /***************** Impulse Defs **********************/ /////////////////////////////////////////////////////// /*****************************************************/ -float DROP_FLAG_IMPULSE = 203; \ No newline at end of file +float DROP_FLAG_IMPULSE = 203; +float RELOAD_IMPULSE = 70; \ No newline at end of file diff --git a/TeamNexuiz/game/gamec/tffunctions.c b/TeamNexuiz/game/gamec/tffunctions.c index 269dfb718..8f29c8b30 100644 --- a/TeamNexuiz/game/gamec/tffunctions.c +++ b/TeamNexuiz/game/gamec/tffunctions.c @@ -82,6 +82,7 @@ void () DoTFAliases = TeamFortress_Alias("-gren1", 152, TF_FLARE_LIT); TeamFortress_Alias("-gren2", 152, TF_FLARE_LIT); TeamFortress_Alias("dropflag", DROP_FLAG_IMPULSE, TF_FLARE_LIT); + TeamFortress_Alias("reload", RELOAD_IMPULSE, TF_FLARE_LIT); }; void (entity tempent) dremove = @@ -1882,6 +1883,11 @@ void (float rweapon, float amount) DoReload = if (rweapon != 5) sprint(self, "Reloading...\n"); + if (rweapon == 1) // Pistol + { + rtime = (amount * .35); + self.clip_pistol = CLIP_MAX_PISTOL; + } if (rweapon == 2) // CryLink (flak cannon) { rtime = (amount * .80); diff --git a/TeamNexuiz/game/gamec/w_common.c b/TeamNexuiz/game/gamec/w_common.c index 8c93f5890..7429fe18e 100644 --- a/TeamNexuiz/game/gamec/w_common.c +++ b/TeamNexuiz/game/gamec/w_common.c @@ -676,7 +676,10 @@ void fireBullet2 (vector start, vector dir, float spread, float damage, float dt e.solid = SOLID_NOT; e.think = SUB_Remove; e.nextthink = time + vlen(trace_endpos - start) / 6000; - e.velocity = dir * 6000; + if (dtype == WEP_PISTOL) // if pistol, show slower bullet + e.velocity = dir * 1750; + else + e.velocity = dir * 6000; e.angles = vectoangles(e.velocity); setmodel (e, "models/tracer.mdl"); setsize (e, '0 0 0', '0 0 0'); diff --git a/TeamNexuiz/game/gamec/w_flamer.c b/TeamNexuiz/game/gamec/w_flamer.c index 2d7440454..fac47fb9d 100644 --- a/TeamNexuiz/game/gamec/w_flamer.c +++ b/TeamNexuiz/game/gamec/w_flamer.c @@ -15,7 +15,7 @@ void(float req) w_flamer = if (req == WR_IDLE) flamer_ready_01(); else if (req == WR_FIRE1 || req == WR_FIRE2) - weapon_prepareattack(flamer_check, flamer_check, flamer_fire1_01, cvar("g_balance_flamer_refire")); + weapon_prepareattack(flamer_check, flamer_check, flamer_fire1_01, .09); else if (req == WR_RAISE) flamer_select_01(); else if (req == WR_UPDATECOUNTS) @@ -23,7 +23,7 @@ void(float req) w_flamer = else if (req == WR_DROP) flamer_deselect_01(); else if (req == WR_SETUP) - weapon_setup(WEP_FLAMER, "w_flamer.zym", IT_ROCKETS); + weapon_setup(WEP_FLAMER, "w_flamethrower.zym", IT_ROCKETS); else if (req == WR_CHECKAMMO) weapon_hasammo = flamer_check(); }; @@ -101,7 +101,7 @@ void W_Flamer_Attack (void) sound (self, CHAN_WEAPON, "weapons/flamer.wav", 1, ATTN_NORM); self.ammo_nails = self.ammo_nails - 4; - org = self.origin + self.view_ofs + v_forward * 1 + v_right * 5 + v_up * -8; + org = self.origin + self.view_ofs + v_forward * 1 + v_right * 14 + v_up * -5; missile = spawn (); missile.owner = self; @@ -130,10 +130,28 @@ void W_Flamer_Attack (void) void() flamer_ready_01 = {weapon_thinkf(WFRAME_IDLE, 0.1, flamer_ready_01); self.weaponentity.state = WS_READY;}; void() flamer_select_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');}; void() flamer_deselect_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);}; + +void() flamer_fire1_02 = +{ + if (self.button0 || self.button3) + { + weapon_doattack(flamer_check, flamer_check, W_Flamer_Attack); + weapon_thinkf(WFRAME_FIRE1, 0.09, flamer_fire1_02); + weapon_prepareattack(flamer_check, flamer_check, SUB_Null, .09); + } + else + weapon_thinkf(WFRAME_FIRE1, 0.09, flamer_ready_01); +}; void() flamer_fire1_01 = { weapon_doattack(flamer_check, flamer_check, W_Flamer_Attack); - //weapon_thinkf(WFRAME_IDLE, 0.003, flamer_ready_01); - flamer_ready_01(); + weapon_thinkf(WFRAME_FIRE1, 0.09, flamer_fire1_02); }; +/* +void() flamer_fire1_01 = +{ + weapon_doattack(flamer_check, flamer_check, W_Flamer_Attack); + weapon_thinkf(WFRAME_FIRE1, 0.003, flamer_ready_01); + //flamer_ready_01(); +};*/ -- 2.39.2