]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
Merge remote-tracking branch 'origin/master' into morosophos/rankings_cnt
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / sv_overkill.qc
index 4ba441be9df4ae898f1624cbd912048da8ae1909..f4432a9cbb830973f25fea4a1e6dffc4e6203f77 100644 (file)
@@ -1,61 +1,11 @@
 #include "sv_overkill.qh"
 
-#include "hmg.qh"
-#include "rpc.qh"
-
-string autocvar_g_overkill;
-
 bool autocvar_g_overkill_powerups_replace;
 
 bool autocvar_g_overkill_itemwaypoints = true;
 
 .Weapon ok_lastwep[MAX_WEAPONSLOTS];
 
-REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
-{
-       MUTATOR_ONADD
-       {
-               precache_all_playermodels("models/ok_player/*.dpm");
-
-               if (autocvar_g_overkill_filter_healthmega)
-               {
-                       ITEM_HealthMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armormedium)
-               {
-                       ITEM_ArmorMedium.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armorbig)
-               {
-                       ITEM_ArmorBig.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-               if (autocvar_g_overkill_filter_armormega)
-               {
-                       ITEM_ArmorMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
-               }
-
-               WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-               WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-
-               //WEP_SHOTGUN.mdl = "ok_shotgun";
-               //WEP_MACHINEGUN.mdl = "ok_mg";
-               //WEP_VORTEX.mdl = "ok_sniper";
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               ITEM_HealthMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorMedium.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorBig.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-               ITEM_ArmorMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
-
-               WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-               WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-       }
-}
-
-void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
-
 MUTATOR_HOOKFUNCTION(ok, Damage_Calculate, CBC_ORDER_LAST)
 {
        entity frag_attacker = M_ARGV(1, entity);
@@ -120,69 +70,59 @@ MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
+MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
 {
+       if (game_stopped)
+       {
+               return;
+       }
        entity player = M_ARGV(0, entity);
-
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       if (!IS_PLAYER(player) || IS_DEAD(player) || STAT(FROZEN, player))
+       {
+               return;
+       }
+       if (!PHYS_INPUT_BUTTON_ATCK2(player) || forbidWeaponUse(player) ||
+               !(round_handler_IsActive() && !round_handler_IsRoundStarted()))
+       {
+               return;
+       }
+       // Allow secondary blaster during countdown.
+       for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
                .entity weaponentity = weaponentities[slot];
-               entity thiswep = player.(weaponentity);
-
-               if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
+               Weapon weapon = player.(weaponentity).m_weapon;
+               if (weapon == WEP_Null && slot != 0)
                {
-                       Weapon newwep = player.ok_lastwep[slot];
-                       if(player.ok_lastwep[slot] == WEP_HMG)
-                               newwep = WEP_MACHINEGUN;
-                       if(player.ok_lastwep[slot] == WEP_RPC)
-                               newwep = WEP_VORTEX;
-                       thiswep.m_switchweapon = newwep;
-                       player.ok_lastwep[slot] = WEP_Null;
+                       continue;
                }
+               weapon.wr_think(weapon, player, weaponentity, 2);
        }
+       PHYS_INPUT_BUTTON_ATCK2(player) = false;
 }
 
-void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
-void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
+MUTATOR_HOOKFUNCTION(ok, ForbidRandomStartWeapons)
+{
+       return true;
+}
 
-MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
+MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
 {
-       entity ent = M_ARGV(0, entity);
+       entity player = M_ARGV(0, entity);
 
-       if(autocvar_g_powerups)
-       if(autocvar_g_overkill_powerups_replace)
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               if(ent.classname == "item_strength")
-               {
-                       entity wep = new(weapon_hmg);
-                       setorigin(wep, ent.origin);
-                       setmodel(wep, MDL_OK_HMG);
-                       wep.ok_item = true;
-                       wep.noalign = ent.noalign;
-                       wep.cnt = ent.cnt;
-                       wep.team = ent.team;
-                       wep.respawntime = g_pickup_respawntime_superweapon;
-                       wep.pickup_anyway = true;
-                       wep.spawnfunc_checked = true;
-                       setthink(wep, self_spawnfunc_weapon_hmg);
-                       wep.nextthink = time + 0.1;
-                       return true;
-               }
-               else if(ent.classname == "item_shield")
+               .entity weaponentity = weaponentities[slot];
+               entity thiswep = player.(weaponentity);
+
+               if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
                {
-                       entity wep = new(weapon_rpc);
-                       setorigin(wep, ent.origin);
-                       setmodel(wep, MDL_OK_RPC);
-                       wep.ok_item = true;
-                       wep.noalign = ent.noalign;
-                       wep.cnt = ent.cnt;
-                       wep.team = ent.team;
-                       wep.respawntime = g_pickup_respawntime_superweapon;
-                       wep.pickup_anyway = true;
-                       wep.spawnfunc_checked = true;
-                       setthink(wep, self_spawnfunc_weapon_rpc);
-                       wep.nextthink = time + 0.1;
-                       return true;
+                       Weapon newwep = player.ok_lastwep[slot];
+                       if(player.ok_lastwep[slot] == WEP_OVERKILL_HMG)
+                               newwep = WEP_OVERKILL_MACHINEGUN;
+                       if(player.ok_lastwep[slot] == WEP_OVERKILL_RPC)
+                               newwep = WEP_OVERKILL_NEX;
+                       thiswep.m_switchweapon = newwep;
+                       player.ok_lastwep[slot] = WEP_Null;
                }
        }
 }
@@ -219,18 +159,58 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
-       if(item.ok_item)
+       if (item.ok_item)
+       {
                return false;
-
+       }
+       switch(item.itemdef)
+       {
+               case ITEM_HealthMega: return autocvar_g_overkill_filter_healthmega;
+               case ITEM_ArmorMedium: return autocvar_g_overkill_filter_armormedium;
+               case ITEM_ArmorBig: return autocvar_g_overkill_filter_armorbig;
+               case ITEM_ArmorMega: return autocvar_g_overkill_filter_armormega;
+       }
+       if (!autocvar_g_powerups || !autocvar_g_overkill_powerups_replace)
+       {
+               return true;
+       }
+       if (item.classname == "item_strength")
+       {
+               entity wep = new(weapon_okhmg);
+               setorigin(wep, item.origin);
+               wep.ok_item = true;
+               wep.noalign = Item_ShouldKeepPosition(item);
+               wep.cnt = item.cnt;
+               wep.team = item.team;
+               wep.respawntime = g_pickup_respawntime_superweapon;
+               wep.pickup_anyway = true;
+               wep.spawnfunc_checked = true;
+               Item_Initialize(wep, "weapon_okhmg"); // doesn't actually use spawnfunc
+               return true;
+       }
+       else if (item.classname == "item_shield")
+       {
+               entity wep = new(weapon_okrpc);
+               setorigin(wep, item.origin);
+               wep.ok_item = true;
+               wep.noalign = Item_ShouldKeepPosition(item);
+               wep.cnt = item.cnt;
+               wep.team = item.team;
+               wep.respawntime = g_pickup_respawntime_superweapon;
+               wep.pickup_anyway = true;
+               wep.spawnfunc_checked = true;
+               Item_Initialize(wep, "weapon_okrpc"); // doesn't actually use spawnfunc
+               return true;
+       }
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
 {
-       WepSet ok_start_items = (WEPSET(OVERKILL_MACHINEGUN) | WEPSET(OVERKILL_VORTEX) | WEPSET(OVERKILL_SHOTGUN));
+       WepSet ok_start_items = (WEPSET(OVERKILL_MACHINEGUN) | WEPSET(OVERKILL_NEX) | WEPSET(OVERKILL_SHOTGUN));
 
-       if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
-       if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
+       if(WEP_OVERKILL_RPC.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_RPC); }
+       if(WEP_OVERKILL_HMG.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_HMG); }
 
        start_items |= IT_UNLIMITED_WEAPON_AMMO;
        start_weapons = warmup_start_weapons = ok_start_items;