From 181a88c471d3a70b6d40e527f0e2cbddd5932d6a Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 28 May 2005 03:11:34 +0000 Subject: [PATCH] weapon firing state git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1061 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- quakec/basemod/basemod.txt | 24 +++++++++++++----------- quakec/basemod/client.qc | 1 + quakec/basemod/combat.qc | 19 ++++++------------- quakec/basemod/defs.qc | 25 +++++++++++++++---------- quakec/basemod/player.qc | 10 +++++----- quakec/basemod/weapons.qc | 28 ++++++++++++++++++++-------- 6 files changed, 60 insertions(+), 47 deletions(-) diff --git a/quakec/basemod/basemod.txt b/quakec/basemod/basemod.txt index eac5c3cb..31c2e616 100644 --- a/quakec/basemod/basemod.txt +++ b/quakec/basemod/basemod.txt @@ -12,21 +12,23 @@ Suicide timer limit Suicide backpack/quad/ring drop Condense bprint, sprint, centerprints te_explode sprite +NQ/QW cross compatibility Todo - -Track oldbutton presses +Track oldbutton presses/weaponstate Samelevel 4 (exit acts as a spawnpoint teleporter) -Don't use newmis/spawn projectiles in front +Generic projectile spawning +Effects/decal system Fix weird deathmatch modes, cvar checking -sv_gravity change? +Add monsters back +Rogue/hipnotic weapons/monsters/hud stuffs +Q2/Q3 ents +H2/HL ents + +Stray Ideas - Advanced heal decay (only decay health that the megahealth added?) -Effects system, NQ/QW cross compatibility -Object-oriented?/Unionize? -Add monsters back? -H2 ents? -HL ents? -Q3 ents? -Decal system based on visibility from players? Clean up backpack pickup prints? +Decal system based on visibility from players? CSQC? -Rogue/hipnotic weapons/monsters? +Don't use newmis/spawn projectiles in front? +sv_gravity change? \ No newline at end of file diff --git a/quakec/basemod/client.qc b/quakec/basemod/client.qc index 0df3e67f..2d8dab21 100644 --- a/quakec/basemod/client.qc +++ b/quakec/basemod/client.qc @@ -514,6 +514,7 @@ void() PutClientInServer = self.effects = 0; self.invincible_time = 0; self.suicide_time = time + 3; + self.weaponstate = WS_IDLE; DecodeLevelParms (); diff --git a/quakec/basemod/combat.qc b/quakec/basemod/combat.qc index e2662c66..5a66103b 100644 --- a/quakec/basemod/combat.qc +++ b/quakec/basemod/combat.qc @@ -214,19 +214,12 @@ void(entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5; dir = normalize(dir); // Set kickback for smaller weapons -//Zoid -- use normal NQ kickback -// // Read: only if it's not yourself doing the damage -// if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname)) -// targ.velocity = targ.velocity + dir * damage * 11; -// else - // Otherwise, these rules apply to rockets and grenades - // for blast velocity - targ.velocity = targ.velocity + dir * damage * 8; + targ.velocity = targ.velocity + dir * damage * 8; // Rocket Jump modifiers - if ( (rj > 1) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker == targ)) - targ.velocity = targ.velocity + dir * damage * rj; - + if (rj > 1 && attacker == targ) + if (targ.classname == "player") + targ.velocity = targ.velocity + dir * damage * rj; } @@ -236,10 +229,10 @@ void(entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) return; if (targ.invincible_finished >= time) { - if (self.invincible_sound < time) + if (targ.invincible_sound < time) { sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM); - self.invincible_sound = time + 2; + targ.invincible_sound = time + 2; } return; } diff --git a/quakec/basemod/defs.qc b/quakec/basemod/defs.qc index 93fdb7ea..fe8a0bae 100644 --- a/quakec/basemod/defs.qc +++ b/quakec/basemod/defs.qc @@ -421,6 +421,7 @@ float EF_FLAG2 = 32; // GLQuakeWorld Stuff // float EF_BLUE = 64; // Blue Globe effect for Quad // float EF_RED = 128; // Red Globe effect for Pentagram + // messages #define MSG_BROADCAST 0 // unreliable to all #define MSG_ONE 1 // reliable to one (msg_entity) @@ -435,12 +436,12 @@ float EF_FLAG2 = 32; #define PRINT_CHAT 3 // multicast sets -float MULTICAST_ALL = 0; // every client -float MULTICAST_PHS = 1; // within hearing -float MULTICAST_PVS = 2; // within sight -float MULTICAST_ALL_R = 3; // every client, reliable -float MULTICAST_PHS_R = 4; // within hearing, reliable -float MULTICAST_PVS_R = 5; // within sight, reliable +#define MULTICAST_ALL 0 // every client +#define MULTICAST_PHS 1 // within hearing +#define MULTICAST_PVS 2 // within sight +#define MULTICAST_ALL_R 3 // every client, reliable +#define MULTICAST_PHS_R 4 // within hearing, reliable +#define MULTICAST_PVS_R 5 // within sight, reliable @@ -565,8 +566,6 @@ float AS_MISSILE = 4; // doors, etc // .vector dest, dest1, dest2; -// .float wait, see unions -// .float delay, see unions .entity trigger_field; // door's trigger entity .string noise4; @@ -604,6 +603,11 @@ float intermission_exittime; entity newmis; #endif +// weaponstate defines +#define WS_IDLE 0 +#define WS_FIRING1 1 +#define WS_FIRING2 2 // used with nailgun + // unions // DO NOT MIX UNION TYPES LIKE I AM DOING .union { @@ -619,14 +623,15 @@ entity newmis; }; struct { // fields used with players float weaponframe_time; // weapon frame advance time + INTEGER weaponstate; // firing state of current weapon float suicide_time; // time to allow suicide after spawn float healdecay; // time when health will decay float show_hostile; // used to alert monsters - float lsound_time; // used for lightning sound playback + float lightning_sound; // used for lightning sound playback float fly_sound; // used with trigger_push and maintaining wind sound }; struct { // fields used with bubbles spawned from drowning - float bubble_count; // keeps track of the number of bubbles + INTEGER bubble_count; // keeps track of the number of bubbles }; struct { // fields used with items float healamount; // amount healed with health item diff --git a/quakec/basemod/player.qc b/quakec/basemod/player.qc index 95471d18..2c6dd76a 100644 --- a/quakec/basemod/player.qc +++ b/quakec/basemod/player.qc @@ -168,12 +168,12 @@ void() player_axed4 = [$axattd4, player_run ] {}; void() player_nail1 =[$nailatt1, player_nail2 ] { - if (!self.button0 || intermission_running || self.impulse) + if (self.weaponstate == WS_IDLE || intermission_running || self.impulse) {player_run ();return;} }; void() player_nail2 =[$nailatt2, player_nail1 ] { - if (!self.button0 || intermission_running || self.impulse) + if (self.weaponstate == WS_IDLE || intermission_running || self.impulse) {player_run ();return;} }; @@ -181,12 +181,12 @@ void() player_nail2 =[$nailatt2, player_nail1 ] void() player_light1 =[$light1, player_light2 ] { - if (!self.button0 || intermission_running) + if (self.weaponstate == WS_IDLE || intermission_running) {player_run ();return;} }; void() player_light2 =[$light2, player_light1 ] { - if (!self.button0 || intermission_running) + if (self.weaponstate == WS_IDLE || intermission_running) {player_run ();return;} }; @@ -276,7 +276,7 @@ void() player_axpain6 = [ $axpain6, player_run ] {}; void() player_pain = { - if (self.weaponframe) + if (self.weaponstate != WS_IDLE) return; if (self.invisible_finished > time) diff --git a/quakec/basemod/weapons.qc b/quakec/basemod/weapons.qc index e0d09999..a1a1dcfc 100644 --- a/quakec/basemod/weapons.qc +++ b/quakec/basemod/weapons.qc @@ -486,10 +486,10 @@ void() W_FireLightning = return; } - if (self.lsound_time < time) + if (self.lightning_sound < time) { sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM); - self.lsound_time = time + 0.6; + self.lightning_sound = time + 0.6; } VK_smallkick(self); @@ -919,7 +919,7 @@ void() W_Attack = makevectors (self.v_angle); // calculate forward angle for velocity self.show_hostile = time + 1; // wake monsters up - if (self.weaponframe == 0) // start delay + if (self.weaponstate == WS_IDLE) // start delay self.delay = time + 0.1; // animations are dealt with here @@ -1003,10 +1003,16 @@ void() W_Attack = r = 0.7; break; case IT_NAILGUN: - if (self.weaponframe & 1) - W_FireSpikes(4); - else + if (self.weaponstate == WS_FIRING1) + { W_FireSpikes(-4); + self.weaponstate = WS_FIRING2; + } + else + { + W_FireSpikes(4); + self.weaponstate = WS_FIRING1; + } r = 0.1; break; @@ -1028,6 +1034,9 @@ void() W_Attack = break; } + if (self.weaponstate == WS_IDLE) + self.weaponstate = WS_FIRING1; + // advance attack time if (self.attack_finished <= time) self.attack_finished = self.attack_finished + r; @@ -1300,7 +1309,7 @@ void() W_HandlePlayerFrame = case IT_NAILGUN: case IT_SUPER_NAILGUN: // cycle until fire button is released - if (self.button0) + if (self.weaponstate != WS_IDLE) { self.weaponframe_time = time + 0.1; self.weaponframe = self.weaponframe + 1; @@ -1313,7 +1322,7 @@ void() W_HandlePlayerFrame = return; case IT_LIGHTNING: // cycle until fire button is released - if (self.button0) + if (self.weaponstate != WS_IDLE) { self.weaponframe_time = time + 0.1; self.weaponframe = self.weaponframe + 1; @@ -1368,7 +1377,10 @@ void() W_WeaponFrame = } } else + { self.attack_finished = time; + self.weaponstate = WS_IDLE; + } }; /*