]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Yay code part basically works now
authorSamual Lenks <samual@xonotic.org>
Tue, 14 May 2013 07:31:14 +0000 (03:31 -0400)
committerSamual Lenks <samual@xonotic.org>
Tue, 14 May 2013 07:31:14 +0000 (03:31 -0400)
qcsrc/common/items.qc
qcsrc/common/items.qh
qcsrc/server/autocvars.qh
qcsrc/server/cl_weapons.qc
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_nex.qc

index 913d16bc89095258a0cfbcde924684e2ca3ef0d4..c961895d95c157aac7ad2439541f9babbd82f557 100644 (file)
@@ -2,7 +2,7 @@
 entity weapon_info[WEP_MAXCOUNT];
 entity dummy_weapon_info;
 
-void register_weapon(float id, float(float) func, float droptime, float raisetime, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
+void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
 {
        entity e;
        weapon_info[id - 1] = e = spawn();
@@ -19,7 +19,6 @@ void register_weapon(float id, float(float) func, float droptime, float raisetim
        e.model2 = strzone(strcat("wpn-", e.mdl));
        e.impulse = i;
        e.bot_pickupbasevalue = pickupbasevalue;
-       
        if(ammotype & IT_SHELLS)
                e.ammo_field = ammo_shells;
        else if(ammotype & IT_NAILS)
@@ -32,9 +31,6 @@ void register_weapon(float id, float(float) func, float droptime, float raisetim
                e.ammo_field = ammo_fuel;
        else
                e.ammo_field = ammo_batteries;
-
-       e.switchdelay_drop = droptime;
-       e.switchdelay_raise = raisetime;
 }
 float w_null(float dummy)
 {
@@ -56,8 +52,6 @@ void register_weapons_done()
        dummy_weapon_info.model2 = "";
        dummy_weapon_info.impulse = -1;
        dummy_weapon_info.bot_pickupbasevalue = 0;
-       dummy_weapon_info.switchdelay_drop = 0;
-       dummy_weapon_info.switchdelay_raise = 0;
 
        float i;
        weaponorder_byid = "";
index c0aab581bf667a3f9d95fd3d8db47b5247fc1e7f..ba42d55ac62ecfffe98b046e1465055bbf607ce2 100644 (file)
@@ -83,13 +83,11 @@ string W_NumberWeaponOrder(string order);
 .float bot_pickupbasevalue; // bot weapon priority
 .string model2; // wpn- sprite name
 ..float ammo_field; // main ammo field
-.float switchdelay_drop; // amount of time to complete drop frame for weapon
-.float switchdelay_raise; // amount of time to complete raise frame for weapon
 // also, weaponinfo ents can act as a WEPSET
 
 // dynamic weapon adding
 float w_null(float dummy);
-void register_weapon(float id, float(float) func, float droptime, float raisetime, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
+void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
 void register_weapons_done();
 
 #define WEP_FIRST 1
@@ -209,7 +207,7 @@ float WEP_LAST;
 WEPSET_DECLARE_A(WEPBIT_ALL);
 WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
 // note: the fabs call is just there to hide "if result is constant" warning
-#define REGISTER_WEAPON_2(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+#define REGISTER_WEAPON_2(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
        float id; \
        float func(float); \
        void RegisterWeapons_##id() \
@@ -219,15 +217,15 @@ WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
                if(fabs(weapontype & WEP_FLAG_SUPERWEAPON)) \
                        WEPSET_OR_AW(WEPBIT_SUPERWEAPONS, id); \
                ++WEP_COUNT; \
-               register_weapon(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
+               register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
        } \
        ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
 #ifdef MENUQC
-#define REGISTER_WEAPON(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
-       REGISTER_WEAPON_2(WEP_##id,w_null,0,0,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+       REGISTER_WEAPON_2(WEP_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
 #else
-#define REGISTER_WEAPON(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
-       REGISTER_WEAPON_2(WEP_##id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+       REGISTER_WEAPON_2(WEP_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
 #endif
 
 #include "../server/w_all.qc"
index 5a4be419963e9cc9dd49c2c715d8e401230118b3..fe96bc0357d6e63ffe6e3392042d0f7ec917fe1d 100644 (file)
@@ -509,8 +509,8 @@ float autocvar_g_balance_nex_secondary_damagefalloff_maxdist;
 float autocvar_g_balance_nex_secondary_damagefalloff_mindist;
 float autocvar_g_balance_nex_secondary_force;
 float autocvar_g_balance_nex_secondary_refire;
-float autocvar_g_balance_nex_switchdelay_drop;
-float autocvar_g_balance_nex_switchdelay_raise;
+noref float autocvar_g_balance_nex_switchdelay_drop;
+noref float autocvar_g_balance_nex_switchdelay_raise;
 float autocvar_g_balance_nex_reload_ammo;
 float autocvar_g_balance_nex_reload_time;
 float autocvar_g_balance_nexball_primary_animtime;
index a34e5fad35bd791e4cd03f24edfd9fadfd635110..44227fda6bd7dd3ea777ba43e3a70ed3849464ff 100644 (file)
@@ -398,30 +398,29 @@ void W_WeaponFrame()
        // Change weapon
        if (self.weapon != self.switchweapon)
        {
-               entity e;
-               e = get_weaponinfo(self.switchweapon);
-               
                if (self.weaponentity.state == WS_CLEAR)
                {
                        // end switching!
                        self.switchingweapon = self.switchweapon;
 
+                       entity newwep = get_weaponinfo(self.switchweapon);
+
                        //setanim(self, self.anim_draw, FALSE, TRUE, TRUE);
                        self.weaponentity.state = WS_RAISE;
                        weapon_action(self.switchweapon, WR_SETUP);
 
                        // set our clip load to the load of the weapon we switched to, if it's reloadable
-                       if(e.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", e.netname, "_reload_ammo"))) // prevent accessing undefined cvars
+                       if(newwep.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"))) // prevent accessing undefined cvars
                        {
                                self.clip_load = self.(weapon_load[self.switchweapon]);
-                               self.clip_size = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+                               self.clip_size = cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"));
                        }
                        else
                                self.clip_load = self.clip_size = 0;
 
                        // VorteX: add player model weapon select frame here
                        // setcustomframe(PlayerWeaponRaise);
-                       weapon_thinkf(WFRAME_IDLE, cvar(sprintf("g_balance_%s_switchdelay_raise", e.netname)), w_ready);
+                       weapon_thinkf(WFRAME_IDLE, cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)), w_ready);
                        weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');
                }
                else if (self.weaponentity.state == WS_DROP)
@@ -434,6 +433,8 @@ void W_WeaponFrame()
                        // start switching!
                        self.switchingweapon = self.switchweapon;
 
+                       entity oldwep = get_weaponinfo(self.weapon);
+                       
 #ifndef INDEPENDENT_ATTACK_FINISHED
                        if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5)
                        {
@@ -441,7 +442,7 @@ void W_WeaponFrame()
                        sound (self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM);
                        self.weaponentity.state = WS_DROP;
                        // set up weapon switch think in the future, and start drop anim
-                       weapon_thinkf(WFRAME_DONTCHANGE, cvar(sprintf("g_balance_%s_switchdelay_drop", e.netname)), w_clear);
+                       weapon_thinkf(WFRAME_DONTCHANGE, cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)), w_clear);
                        weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);
 #ifndef INDEPENDENT_ATTACK_FINISHED
                        }
index ff31a5e26ce91eef54378fe483e5d4822d79b56d..cda4dc72c423e2ed21b85dea1f5b2596d1c755a8 100644 (file)
@@ -541,15 +541,18 @@ void CL_Weaponentity_Think()
        }
 
        self.angles = '0 0 0';
+       
        float f;
        if (self.state == WS_RAISE && !intermission_running)
        {
-               f = (self.owner.weapon_nextthink - time) * g_weaponratefactor / ((self.switchdelay_raise < 0) ? autocvar_g_balance_weaponswitchdelay : self.switchdelay_raise);
+               entity newwep = get_weaponinfo(self.owner.switchweapon);
+               f = (self.owner.weapon_nextthink - time) * g_weaponratefactor / cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname));
                self.angles_x = -90 * f * f;
        }
        else if (self.state == WS_DROP && !intermission_running)
        {
-               f = 1 - (self.owner.weapon_nextthink - time) * g_weaponratefactor / ((self.switchdelay_drop < 0) ? autocvar_g_balance_weaponswitchdelay : self.switchdelay_drop);
+               entity oldwep = get_weaponinfo(self.owner.weapon);
+               f = 1 - (self.owner.weapon_nextthink - time) * g_weaponratefactor / cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname));
                self.angles_x = -90 * f * f;
        }
        else if (self.state == WS_CLEAR)
index ad5e2034284cc2b4f27d893ac628e414a11d88ba..dc3c30ff6123692543bb051949741febc5ed8804 100644 (file)
@@ -218,8 +218,6 @@ float w_nex(float req)
        {
                weapon_setup(WEP_NEX);
                self.current_ammo = ammo_cells;
-               self.weaponentity.switchdelay_drop = autocvar_g_balance_nex_switchdelay_drop;
-               self.weaponentity.switchdelay_raise = autocvar_g_balance_nex_switchdelay_raise;
        }
        else if (req == WR_CHECKAMMO1)
        {