]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc
Fix FL_WEAPON flag overlapping FL_JUMPRELEASED. This unintentional change was introdu...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / nexball / sv_weapon.qc
index 3568f221b63fe53fbc440a282cf037bc14a59e6f..d3d3a6a9dcb30ae59eb103760e1f8cb5ca00c952 100644 (file)
@@ -1,7 +1,7 @@
 #include "sv_weapon.qh"
 
-void W_Nexball_Attack(entity actor, .entity weaponentity, float t);
-void W_Nexball_Attack2(entity actor, .entity weaponentity);
+void W_Nexball_Attack(Weapon thiswep, entity actor, .entity weaponentity, float t);
+void W_Nexball_Attack2(Weapon thiswep, entity actor, .entity weaponentity);
 vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity pushed_entity);
 
 METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
@@ -11,26 +11,26 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
             if(autocvar_g_nexball_basketball_meter)
             {
-                if(actor.ballcarried && !actor.metertime)
-                    actor.metertime = time;
+                if(actor.ballcarried && !STAT(NB_METERSTART, actor))
+                    STAT(NB_METERSTART, actor) = time;
                 else
                     weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
             }
             else
             {
-                W_Nexball_Attack(actor, weaponentity, -1);
+                W_Nexball_Attack(thiswep, actor, weaponentity, -1);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
             }
     if(fire & 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
         {
-            W_Nexball_Attack2(actor, weaponentity);
+            W_Nexball_Attack2(thiswep, actor, weaponentity);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
         }
 
-    if(!(fire & 1) && actor.metertime && actor.ballcarried)
+    if(!(fire & 1) && STAT(NB_METERSTART, actor) && actor.ballcarried)
     {
-        W_Nexball_Attack(actor, weaponentity, time - actor.metertime);
+        W_Nexball_Attack(thiswep, actor, weaponentity, time - STAT(NB_METERSTART, actor));
         // DropBall or stealing will set metertime back to 0
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
     }
@@ -44,7 +44,7 @@ METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor, .entity weapo
 
 METHOD(BallStealer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    TC(BallStealer, this);
+    TC(BallStealer, thiswep);
 }
 
 METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor, .entity weaponentity))
@@ -105,19 +105,19 @@ void W_Nexball_Touch(entity this, entity toucher)
        delete(this);
 }
 
-void W_Nexball_Attack(entity actor, .entity weaponentity, float t)
+void W_Nexball_Attack(Weapon thiswep, entity actor, .entity weaponentity, float t)
 {
        entity ball;
        float mul, mi, ma;
        if(!(ball = actor.ballcarried))
                return;
 
-       W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+       W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0, WEP_PORTO.m_id); // TODO: use ballstealer weapon here? we don't want duplicates in the scoreboard
        tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, NULL);
        if(trace_startsolid)
        {
-               if(actor.metertime)
-                       actor.metertime = 0; // Shot failed, hide the power meter
+               if(STAT(NB_METERSTART, actor))
+                       STAT(NB_METERSTART, actor) = 0; // Shot failed, hide the power meter
                return;
        }
 
@@ -141,12 +141,12 @@ void W_Nexball_Attack(entity actor, .entity weaponentity, float t)
        //TODO: use the speed_up cvar too ??
 }
 
-void W_Nexball_Attack2(entity actor, .entity weaponentity)
+void W_Nexball_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
 {
        if(actor.ballcarried.enemy)
        {
                entity _ball = actor.ballcarried;
-               W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+               W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0, WEP_PORTO.m_id | HITTYPE_SECONDARY); // TODO: use the ball stealer weapon here? probably don't want duplicates
                DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32, _ball));
                setthink(_ball, W_Nexball_Think);
                _ball.nextthink = time;
@@ -156,7 +156,7 @@ void W_Nexball_Attack2(entity actor, .entity weaponentity)
        if(!autocvar_g_nexball_tackling)
                return;
 
-       W_SetupShot(actor, weaponentity, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
+       W_SetupShot(actor, weaponentity, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0, WEP_PORTO.m_id);
        entity missile = new(ballstealer);
 
        missile.owner = actor;