]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/overkill/oknex.qc
GetResourceAmount --> GetResource, SetResourceAmount --> SetResource
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / oknex.qc
index a27634320e0f68c151e1afa41db285763b874638..e1b26c36d17c790ab334067c0dcd198c5ef13028 100644 (file)
@@ -82,7 +82,7 @@ void W_OverkillNex_Attack(Weapon thiswep, entity actor, .entity weaponentity, fl
        mydmg *= charge;
        myforce *= charge;
 
-       W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg);
+       W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg, thiswep.m_id);
        if(charge > WEP_CVAR(oknex, charge_animlimit) && WEP_CVAR(oknex, charge_animlimit)) // if the OverkillNex is overcharged, we play an extra sound
        {
                sound(actor, CH_WEAPON_B, SND_NEXCHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(oknex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(oknex, charge_animlimit)), ATTN_NORM);
@@ -90,7 +90,7 @@ void W_OverkillNex_Attack(Weapon thiswep, entity actor, .entity weaponentity, fl
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_OVERKILL_NEX.m_id);
+       FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, thiswep.m_id);
 
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
@@ -128,11 +128,6 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
                actor.(weaponentity).oknex_charge = min(1, actor.(weaponentity).oknex_charge + WEP_CVAR(oknex, charge_rate) * frametime / W_TICSPERFRAME);
        }
 
-       if (weaponslot(weaponentity) == 0)
-       {
-               actor.oknex_charge = actor.(weaponentity).oknex_charge;
-       }
-
        if (WEP_CVAR_SEC(oknex, chargepool))
                if (actor.(weaponentity).oknex_chargepool_ammo < 1)
                {
@@ -141,32 +136,11 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
                        actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(oknex, chargepool_pause_regen));
                }
 
-       if(weaponslot(weaponentity) == 0)
-               actor.oknex_chargepool_ammo = actor.(weaponentity).oknex_chargepool_ammo;
-
        if ((WEP_CVAR_SEC(oknex, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
        {
                // Secondary uses it's own refire timer if refire_type is 1.
                actor.jump_interval = time + WEP_CVAR_SEC(oknex, refire) * W_WeaponRateFactor(actor);
-               // Ugly hack to reuse the fire mode of the blaster.
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(oknex, shotangle),
-                       WEP_CVAR_SEC(oknex, damage),
-                       WEP_CVAR_SEC(oknex, edgedamage),
-                       WEP_CVAR_SEC(oknex, radius),
-                       WEP_CVAR_SEC(oknex, force),
-                       WEP_CVAR_SEC(oknex, speed),
-                       WEP_CVAR_SEC(oknex, spread),
-                       WEP_CVAR_SEC(oknex, delay),
-                       WEP_CVAR_SEC(oknex, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
                if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
                        (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
@@ -208,25 +182,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
                {
                        return;
                }
-               // ugly instagib hack to reuse the fire mode of the laser
-               makevectors(actor.v_angle);
-               Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
-               actor.(weaponentity).m_weapon = WEP_BLASTER;
-               W_Blaster_Attack(
-                       actor,
-                       weaponentity,
-                       WEP_BLASTER.m_id | HITTYPE_SECONDARY,
-                       WEP_CVAR_SEC(oknex, shotangle),
-                       WEP_CVAR_SEC(oknex, damage),
-                       WEP_CVAR_SEC(oknex, edgedamage),
-                       WEP_CVAR_SEC(oknex, radius),
-                       WEP_CVAR_SEC(oknex, force),
-                       WEP_CVAR_SEC(oknex, speed),
-                       WEP_CVAR_SEC(oknex, spread),
-                       WEP_CVAR_SEC(oknex, delay),
-                       WEP_CVAR_SEC(oknex, lifetime)
-               );
-               actor.(weaponentity).m_weapon = oldwep;
+               BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready);
                return;
        }
@@ -244,11 +200,11 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone
        //                              if(WEP_CVAR_SEC(oknex, ammo))
        //                              {
        //                                      // always deplete if secondary is held
-       //                                      actor.oknex_chargepool_ammo = max(0, actor.oknex_chargepool_ammo - WEP_CVAR_SEC(oknex, ammo) * dt);
+       //                                      actor.(weaponentity).oknex_chargepool_ammo = max(0, actor.(weaponentity).oknex_chargepool_ammo - WEP_CVAR_SEC(oknex, ammo) * dt);
 
        //                                      dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
        //                                      actor.oknex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(oknex, chargepool_pause_regen);
-       //                                      dt = min(dt, actor.oknex_chargepool_ammo);
+       //                                      dt = min(dt, actor.(weaponentity).oknex_chargepool_ammo);
        //                                      dt = max(0, dt);
 
        //                                      actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
@@ -312,8 +268,8 @@ METHOD(OverkillNex, wr_setup, void(entity thiswep, entity actor, .entity weapone
 
 METHOD(OverkillNex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
-       float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
-       ammo_amount += (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) >= WEP_CVAR_PRI(oknex, ammo));
+       float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
+       ammo_amount += (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(oknex, ammo));
        return ammo_amount;
 }
 
@@ -322,8 +278,8 @@ METHOD(OverkillNex, wr_checkammo2, bool(entity thiswep, entity actor, .entity we
        if (WEP_CVAR(oknex, secondary))
        {
                // don't allow charging if we don't have enough ammo
-               float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
-               ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) >= WEP_CVAR_SEC(oknex, ammo);
+               float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
+               ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(oknex, ammo);
                return ammo_amount;
        }
        else
@@ -335,17 +291,10 @@ METHOD(OverkillNex, wr_checkammo2, bool(entity thiswep, entity actor, .entity we
 METHOD(OverkillNex, wr_resetplayer, void(entity thiswep, entity actor))
 {
        if (WEP_CVAR(oknex, charge)) {
-               if (WEP_CVAR_SEC(oknex, chargepool)) {
-                       actor.oknex_chargepool_ammo = 1;
-               }
-               actor.oknex_charge = WEP_CVAR(oknex, charge_start);
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                        .entity weaponentity = weaponentities[slot];
                        actor.(weaponentity).oknex_charge = WEP_CVAR(oknex, charge_start);
-
-                       if (WEP_CVAR_SEC(oknex, chargepool))
-                               actor.(weaponentity).oknex_chargepool_ammo = 1;
                }
        }
        actor.oknex_lasthit = 0;
@@ -363,7 +312,7 @@ METHOD(OverkillNex, wr_suicidemessage, Notification(entity thiswep))
 
 METHOD(OverkillNex, wr_killmessage, Notification(entity thiswep))
 {
-       return WEAPON_VORTEX_MURDER;
+       return WEAPON_OVERKILL_NEX_MURDER;
 }
 
 METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
@@ -404,4 +353,9 @@ METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
        }
 }
 
+METHOD(OverkillNex, wr_zoomdir, bool(entity thiswep))
+{
+    return button_attack2 && !WEP_CVAR(oknex, secondary);
+}
+
 #endif