]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/overkill/okvortex.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / okvortex.qc
index 53a893460716898084d2e0efe763bbbcaa4ad385..0341cc953117c9c1f4c395d91f83e6541b638f42 100644 (file)
@@ -70,7 +70,7 @@ void W_OverkillVortex_Attack(Weapon thiswep, entity actor, .entity weaponentity,
        float flying;
        flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
 
-       if(WEP_CVAR(okvortex, charge))
+       if (WEP_CVAR(okvortex, charge))
        {
                charge = WEP_CVAR(okvortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(okvortex, charge_mindmg) / mydmg) * actor.(weaponentity).okvortex_charge;
                actor.(weaponentity).okvortex_charge *= WEP_CVAR(okvortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
@@ -78,7 +78,9 @@ void W_OverkillVortex_Attack(Weapon thiswep, entity actor, .entity weaponentity,
                // YA RLY -- FruitieX
        }
        else
+       {
                charge = 1;
+       }
        mydmg *= charge;
        myforce *= charge;
 
@@ -123,16 +125,20 @@ METHOD(OverkillVortex, wr_aim, void(entity thiswep, entity actor, .entity weapon
 
 METHOD(OverkillVortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-       if(WEP_CVAR(okvortex, charge) && actor.(weaponentity).okvortex_charge < WEP_CVAR(okvortex, charge_limit))
+       if (WEP_CVAR(okvortex, charge) && actor.(weaponentity).okvortex_charge < WEP_CVAR(okvortex, charge_limit))
+       {
                actor.(weaponentity).okvortex_charge = min(1, actor.(weaponentity).okvortex_charge + WEP_CVAR(okvortex, charge_rate) * frametime / W_TICSPERFRAME);
+       }
 
-       if(weaponslot(weaponentity) == 0)
+       if (weaponslot(weaponentity) == 0)
+       {
                actor.okvortex_charge = actor.(weaponentity).okvortex_charge;
+       }
 
-       if(WEP_CVAR_SEC(okvortex, chargepool))
-               if(actor.(weaponentity).okvortex_chargepool_ammo < 1)
+       if (WEP_CVAR_SEC(okvortex, chargepool))
+               if (actor.(weaponentity).okvortex_chargepool_ammo < 1)
                {
-                       if(actor.okvortex_chargepool_pauseregen_finished < time)
+                       if (actor.okvortex_chargepool_pauseregen_finished < time)
                                actor.(weaponentity).okvortex_chargepool_ammo = min(1, actor.(weaponentity).okvortex_chargepool_ammo + WEP_CVAR_SEC(okvortex, chargepool_regen) * frametime / W_TICSPERFRAME);
                        actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(okvortex, chargepool_pause_regen));
                }
@@ -140,131 +146,179 @@ METHOD(OverkillVortex, wr_think, void(entity thiswep, entity actor, .entity weap
        if(weaponslot(weaponentity) == 0)
                actor.okvortex_chargepool_ammo = actor.(weaponentity).okvortex_chargepool_ammo;
 
-       if(autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(okvortex, ammo), WEP_CVAR_SEC(okvortex, ammo))) { // forced reload
-               thiswep.wr_reload(thiswep, actor, weaponentity);
-       } else
+       if ((WEP_CVAR_SEC(okvortex, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
        {
-               if (fire & 1)
+               // Secondary uses it's own refire timer if refire_type is 1.
+               actor.jump_interval = time + WEP_CVAR_SEC(okvortex, 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(okvortex, shotangle),
+                       WEP_CVAR_SEC(okvortex, damage),
+                       WEP_CVAR_SEC(okvortex, edgedamage),
+                       WEP_CVAR_SEC(okvortex, radius),
+                       WEP_CVAR_SEC(okvortex, force),
+                       WEP_CVAR_SEC(okvortex, speed),
+                       WEP_CVAR_SEC(okvortex, spread),
+                       WEP_CVAR_SEC(okvortex, delay),
+                       WEP_CVAR_SEC(okvortex, lifetime)
+               );
+               actor.(weaponentity).m_weapon = oldwep;
+               if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
+                       (actor.(weaponentity).wframe == WFRAME_FIRE2))
                {
-                       if (weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okvortex, refire)))
-                       {
-                               W_OverkillVortex_Attack(thiswep, actor, weaponentity, 0);
-                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okvortex, animtime), w_ready);
-                       }
+                       // Set secondary fire animation.
+                       vector a = '0 0 0';
+                       actor.(weaponentity).wframe = WFRAME_FIRE2;
+                       a = actor.(weaponentity).anim_fire2;
+                       a.z *= g_weaponratefactor;
+                       FOREACH_CLIENT(true, LAMBDA(
+                               if (it == actor || (IS_SPEC(it) && it.enemy == actor))
+                               {
+                                       wframe_send(it, actor.(weaponentity), a, true);
+                               }
+                       ));
+                       animdecide_setaction(actor, ANIMACTION_SHOOT, true);
                }
-               else if ((fire & 2) && (WEP_CVAR(okvortex, secondary) == 2))
+       }
+
+       if (autocvar_g_balance_okvortex_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okvortex, ammo))
+       {
+               // Rorced reload
+               thiswep.wr_reload(thiswep, actor, weaponentity);
+               return;
+       }
+       if (fire & 1) // Primary attack
+       {
+               if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okvortex, refire)))
                {
-                       if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
-                       {
-                               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(okshotgun, shotangle),
-                               WEP_CVAR_SEC(okshotgun, damage),
-                               WEP_CVAR_SEC(okshotgun, edgedamage),
-                               WEP_CVAR_SEC(okshotgun, radius),
-                               WEP_CVAR_SEC(okshotgun, force),
-                               WEP_CVAR_SEC(okshotgun, speed),
-                               WEP_CVAR_SEC(okshotgun, spread),
-                               WEP_CVAR_SEC(okshotgun, delay),
-                               WEP_CVAR_SEC(okshotgun, lifetime)
-                       );
-                       actor.(weaponentity).m_weapon = oldwep;
-                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
                        return;
                }
-               if((WEP_CVAR(okvortex, charge) && !WEP_CVAR(okvortex, secondary)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))
+               W_OverkillVortex_Attack(thiswep, actor, weaponentity, 0);
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okvortex, animtime), w_ready);
+               return;
+       }
+       if ((fire & 2) && (WEP_CVAR(okvortex, secondary) == 2) && (WEP_CVAR_SEC(okvortex, refire_type) == 0))
+       {
+               // Secondary attack
+               if (!weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(okshotgun, refire)))
                {
-                       if(WEP_CVAR(okvortex, charge))
-                       {
-                               actor.(weaponentity).okvortex_charge_rottime = time + WEP_CVAR(okvortex, charge_rot_pause);
-                               float dt = frametime / W_TICSPERFRAME;
-
-                               if(actor.(weaponentity).okvortex_charge < 1)
-                               {
-                                       if(WEP_CVAR_SEC(okvortex, chargepool))
-                                       {
-                                               if(WEP_CVAR_SEC(okvortex, ammo))
-                                               {
-                                                       // always deplete if secondary is held
-                                                       actor.okvortex_chargepool_ammo = max(0, actor.okvortex_chargepool_ammo - WEP_CVAR_SEC(okvortex, ammo) * dt);
-
-                                                       dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
-                                                       actor.okvortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(okvortex, chargepool_pause_regen);
-                                                       dt = min(dt, actor.okvortex_chargepool_ammo);
-                                                       dt = max(0, dt);
-
-                                                       actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
-                                               }
-                                       }
-
-                                       else if(WEP_CVAR_SEC(okvortex, ammo))
-                                       {
-                                               if(fire & 2) // only eat ammo when the button is pressed
-                                               {
-                                                       dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
-                                                       if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
-                                                       {
-                                                               // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
-                                                               if(autocvar_g_balance_vortex_reload_ammo)
-                                                               {
-                                                                       dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
-                                                                       dt = max(0, dt);
-                                                                       if(dt > 0)
-                                                                       {
-                                                                               actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(okvortex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(okvortex, ammo) * dt);
-                                                                       }
-                                                                       actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) = actor.(weaponentity).clip_load;
-                                                               }
-                                                               else
-                                                               {
-                                                                       dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
-                                                                       dt = max(0, dt);
-                                                                       if(dt > 0)
-                                                                       {
-                                                                               actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(okvortex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(okvortex, ammo) * dt);
-                                                                       }
-                                                               }
-                                                       }
-                                                       actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
-                                               }
-                                       }
-
-                                       else
-                                       {
-                                               dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
-                                               actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
-                                       }
-                               }
-                       }
-                       else if(WEP_CVAR(okvortex, secondary))
-                       {
-                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okvortex, refire)))
-                               {
-                                       W_OverkillVortex_Attack(thiswep, actor, weaponentity, 1);
-                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(okvortex, animtime), w_ready);
-                               }
-                       }
+                       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(okvortex, shotangle),
+                       WEP_CVAR_SEC(okvortex, damage),
+                       WEP_CVAR_SEC(okvortex, edgedamage),
+                       WEP_CVAR_SEC(okvortex, radius),
+                       WEP_CVAR_SEC(okvortex, force),
+                       WEP_CVAR_SEC(okvortex, speed),
+                       WEP_CVAR_SEC(okvortex, spread),
+                       WEP_CVAR_SEC(okvortex, delay),
+                       WEP_CVAR_SEC(okvortex, lifetime)
+               );
+               actor.(weaponentity).m_weapon = oldwep;
+               weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okvortex, animtime), w_ready);
+               return;
        }
+       //if ((WEP_CVAR(okvortex, charge) && (WEP_CVAR(okvortex, secondary) == 1)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))
+       //{
+       //      if(WEP_CVAR(okvortex, charge))
+       //      {
+       //              actor.(weaponentity).okvortex_charge_rottime = time + WEP_CVAR(okvortex, charge_rot_pause);
+       //              float dt = frametime / W_TICSPERFRAME;
+       //
+       //              if(actor.(weaponentity).okvortex_charge < 1)
+       //              {
+       //                      if(WEP_CVAR_SEC(okvortex, chargepool))
+       //                      {
+       //                              if(WEP_CVAR_SEC(okvortex, ammo))
+       //                              {
+       //                                      // always deplete if secondary is held
+       //                                      actor.okvortex_chargepool_ammo = max(0, actor.okvortex_chargepool_ammo - WEP_CVAR_SEC(okvortex, ammo) * dt);
+
+       //                                      dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
+       //                                      actor.okvortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(okvortex, chargepool_pause_regen);
+       //                                      dt = min(dt, actor.okvortex_chargepool_ammo);
+       //                                      dt = max(0, dt);
+
+       //                                      actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
+       //                              }
+       //                      }
+
+       //                      else if(WEP_CVAR_SEC(okvortex, ammo))
+       //                      {
+       //                              if(fire & 2) // only eat ammo when the button is pressed
+       //                              {
+       //                                      dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
+       //                                      if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
+       //                                      {
+       //                                              // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
+       //                                              if(autocvar_g_balance_vortex_reload_ammo)
+       //                                              {
+       //                                                      dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
+       //                                                      dt = max(0, dt);
+       //                                                      if(dt > 0)
+       //                                                      {
+       //                                                              actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(okvortex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(okvortex, ammo) * dt);
+       //                                                      }
+       //                                                      actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) = actor.(weaponentity).clip_load;
+       //                                              }
+       //                                              else
+       //                                              {
+       //                                                      dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
+       //                                                      dt = max(0, dt);
+       //                                                      if(dt > 0)
+       //                                                      {
+       //                                                              actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(okvortex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(okvortex, ammo) * dt);
+       //                                                      }
+       //                                              }
+       //                                      }
+       //                                      actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
+       //                              }
+       //                      }
+
+       //                      else
+       //                      {
+       //                              dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
+       //                              actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
+       //                      }
+       //              }
+       //      }
+       //      else if(WEP_CVAR(okvortex, secondary))
+       //      {
+       //              if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okvortex, refire)))
+       //              {
+       //                      W_OverkillVortex_Attack(thiswep, actor, weaponentity, 1);
+       //                      weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(okvortex, animtime), w_ready);
+       //              }
+       //      }
+       //}
 }
+
 METHOD(OverkillVortex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
        actor.okvortex_lasthit = 0;
 }
+
 METHOD(OverkillVortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
        float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(okvortex, ammo);
        ammo_amount += (autocvar_g_balance_okvortex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) >= WEP_CVAR_PRI(okvortex, ammo));
        return ammo_amount;
 }
+
 METHOD(OverkillVortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
        if(WEP_CVAR(okvortex, secondary))
@@ -279,6 +333,7 @@ METHOD(OverkillVortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity
                return false; // zoom is not a fire mode
        }
 }
+
 METHOD(OverkillVortex, wr_resetplayer, void(entity thiswep, entity actor))
 {
        if (WEP_CVAR(okvortex, charge)) {
@@ -297,18 +352,22 @@ METHOD(OverkillVortex, wr_resetplayer, void(entity thiswep, entity actor))
        }
        actor.okvortex_lasthit = 0;
 }
+
 METHOD(OverkillVortex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-       W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(okvortex, ammo), WEP_CVAR_SEC(okvortex, ammo)), SND_RELOAD);
+       W_Reload(actor, weaponentity, WEP_CVAR_PRI(okvortex, ammo), SND_RELOAD);
 }
+
 METHOD(OverkillVortex, wr_suicidemessage, Notification(entity thiswep))
 {
        return WEAPON_THINKING_WITH_PORTALS;
 }
+
 METHOD(OverkillVortex, wr_killmessage, Notification(entity thiswep))
 {
        return WEAPON_VORTEX_MURDER;
 }
+
 METHOD(OverkillVortex, wr_zoom, bool(entity thiswep, entity actor))
 {
        return PHYS_INPUT_BUTTON_ATCK2(actor) && !WEP_CVAR(okvortex, secondary);
@@ -325,6 +384,7 @@ METHOD(OverkillVortex, wr_impacteffect, void(entity thiswep, entity actor))
        if(!w_issilent)
                sound(this, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
 }
+
 METHOD(OverkillVortex, wr_init, void(entity thiswep))
 {
        if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
@@ -332,6 +392,7 @@ METHOD(OverkillVortex, wr_init, void(entity thiswep))
                precache_pic("gfx/reticle_nex");
        }
 }
+
 METHOD(OverkillVortex, wr_zoom, bool(entity thiswep, entity actor))
 {
        if(button_zoom || zoomscript_caught || (!WEP_CVAR(okvortex, secondary) && button_attack2))