]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_nex.qc
why does fteqcc fail so much? seems like f *= x now is equivalent to f = x
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_nex.qc
index 8bce2ebc429f04be578795c3a89abc6ea4591246..68790617dffab9b2df702495c2c7f9e2a3308801 100644 (file)
@@ -2,23 +2,23 @@
 REGISTER_WEAPON(NEX, w_nex, IT_CELLS, 7, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex");
 #else
 #ifdef SVQC
-void SendCSQCNexBeamParticle() {
+void SendCSQCNexBeamParticle(float charge) {
        vector v;
        v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
        WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
        WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
-       
        WriteCoord(MSG_BROADCAST, w_shotorg_x);
        WriteCoord(MSG_BROADCAST, w_shotorg_y);
        WriteCoord(MSG_BROADCAST, w_shotorg_z);
        WriteCoord(MSG_BROADCAST, v_x);
        WriteCoord(MSG_BROADCAST, v_y);
        WriteCoord(MSG_BROADCAST, v_z);
+       WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
 }
 
 void W_Nex_Attack (float issecondary)
 {
-       float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, f;
+       float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
        if(issecondary)
        {
                mydmg = cvar("g_balance_nex_secondary_damage");
@@ -43,11 +43,15 @@ void W_Nex_Attack (float issecondary)
        float flying;
        flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
 
-       f = ExponentiaFalloff(cvar("g_balance_nex_velocitydependent_minspeed"), cvar("g_balance_nex_velocitydependent_maxspeed"), cvar("g_balance_nex_velocitydependent_halflife"), vlen(self.velocity));
-
-       // TODO: make it more obvious (through effects, indicator on weapon) that damage increases when speed increases
-       mydmg *= f;
-       myforce *= f;
+       if(cvar("g_balance_nex_charge"))
+       {
+               charge = cvar("g_balance_nex_charge_mindmg") / mydmg + (1 - cvar("g_balance_nex_charge_mindmg") / mydmg) * self.nex_charge;
+               self.nex_charge *= cvar("g_balance_nex_charge_shot_multiplier"); // do this AFTER setting mydmg/myforce
+       }
+       else
+               charge = 1;
+       mydmg = mydmg * charge;
+       myforce = myforce * charge;
 
        W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", mydmg);
 
@@ -58,7 +62,7 @@ void W_Nex_Attack (float issecondary)
                AnnounceTo(self, "yoda");
 
        //beam and muzzle flash done on client
-       SendCSQCNexBeamParticle();
+       SendCSQCNexBeamParticle(charge);
        
        // flash and burn the wall
        if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
@@ -72,6 +76,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);
@@ -79,6 +84,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")))
@@ -89,7 +96,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")))
                                {
@@ -115,7 +143,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