]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_nex.qc
nex charge: properly support g_use_ammunition; don't bite off more than you can chew...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_nex.qc
index b5eacda72ab9dadab58463d62f9252105ba9e24f..64c9c385b7890aff7f92fe04c94d0ddd023d95ac 100644 (file)
@@ -18,7 +18,7 @@ void SendCSQCNexBeamParticle() {
 
 void W_Nex_Attack (float issecondary)
 {
-       float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, myvel;
+       float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo;
        if(issecondary)
        {
                mydmg = cvar("g_balance_nex_secondary_damage");
@@ -43,16 +43,12 @@ void W_Nex_Attack (float issecondary)
        float flying;
        flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
 
-       if(cvar("g_balance_nex_velocitydependent")) // player velocity dependent damage and force
+       if(cvar("g_balance_nex_charge"))
        {
-               myvel = vlen(self.velocity);
-
-               if(myvel < cvar("g_balance_nex_velocitydependent_minspeed"))
-                       myvel = bound(cvar("g_balance_nex_velocitydependent_minspeed"), myvel, cvar("g_balance_nex_velocitydependent_maxspeed"));
-
-               // TODO: make it more obvious (through effects, indicator on weapon) that damage increases when speed increases
-               mydmg *= cvar("g_balance_nex_velocitydependent_maxspeed") / myvel;
-               myforce *= cvar("g_balance_nex_velocitydependent_maxspeed") / myvel;
+               mydmg *= self.nex_charge;
+               myforce *= self.nex_charge;
+               //print("^1Damage: ^7", ftos(mydmg), "\n");
+               self.nex_charge *= cvar("g_balance_nex_charge_shot_multiplier"); // do this AFTER setting mydmg/myforce
        }
 
        W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", mydmg);
@@ -78,6 +74,7 @@ void spawnfunc_weapon_nex (void); // defined in t_items.qc
 
 float w_nex(float req)
 {
+       float dt;
        if (req == WR_AIM)
        {
                self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
@@ -85,6 +82,8 @@ float w_nex(float req)
        }
        else if (req == WR_THINK)
        {
+               if(cvar("g_balance_nex_charge") && self.nex_charge < cvar("g_balance_nex_charge_limit"))
+                       self.nex_charge = min(1, self.nex_charge + cvar("g_balance_nex_charge_rate") * frametime / W_TICSPERFRAME);
                if (self.BUTTON_ATCK)
                {
                        if (weapon_prepareattack(0, cvar("g_balance_nex_primary_refire")))
@@ -95,7 +94,28 @@ float w_nex(float req)
                }
                if (self.BUTTON_ATCK2)
                {
-                       if(cvar("g_balance_nex_secondary"))
+                       if(cvar("g_balance_nex_secondary_charge"))
+                       {
+                               dt = frametime / W_TICSPERFRAME;
+                               if(self.nex_charge < 1)
+                               {
+                                       dt = min(dt, (1 - self.nex_charge) / cvar("g_balance_nex_secondary_charge_rate"));
+                                       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+                                       {
+                                               if(cvar("g_balance_nex_secondary_ammo"))
+                                               {
+                                                       dt = min(dt, (self.ammo_cells - cvar("g_balance_nex_primary_ammo")) / cvar("g_balance_nex_secondary_ammo"));
+                                                       dt = max(0, dt);
+                                                       if(dt > 0)
+                                                       {
+                                                               self.ammo_cells = max(cvar("g_balance_nex_secondary_ammo"), self.ammo_cells - cvar("g_balance_nex_secondary_ammo") * dt);
+                                                       }
+                                               }
+                                       }
+                                       self.nex_charge += dt * cvar("g_balance_nex_secondary_charge_rate");
+                               }
+                       }
+                       else if(cvar("g_balance_nex_secondary"))
                        {
                                if (weapon_prepareattack(0, cvar("g_balance_nex_secondary_refire")))
                                {
@@ -121,7 +141,11 @@ float w_nex(float req)
        else if (req == WR_CHECKAMMO1)
                return self.ammo_cells >= cvar("g_balance_nex_primary_ammo");
        else if (req == WR_CHECKAMMO2)
+       {
+               if(cvar("g_balance_nex_secondary_charge"))
+                       return self.ammo_cells >= cvar("g_balance_nex_primary_ammo");
                return self.ammo_cells >= cvar("g_balance_nex_secondary_ammo");
+       }
        return TRUE;
 };
 #endif