]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/instagib/sv_instagib.qc
Sneak in another feature (simple option to enable ammo in the grappling hook mutator)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / instagib / sv_instagib.qc
index 0cf3ed978134babe2cc6135d237e3b3b197e934f..578294a725491b698591b37699f543b51a961a19 100644 (file)
@@ -1,6 +1,10 @@
 #include "sv_instagib.qh"
 
-int autocvar_g_instagib_ammo_drop;
+//int autocvar_g_instagib_ammo_drop;
+bool autocvar_g_instagib_ammo_convert_cells;
+bool autocvar_g_instagib_ammo_convert_rockets;
+bool autocvar_g_instagib_ammo_convert_shells;
+bool autocvar_g_instagib_ammo_convert_bullets;
 int autocvar_g_instagib_extralives;
 float autocvar_g_instagib_speed_highspeed;
 
@@ -13,7 +17,6 @@ REGISTER_MUTATOR(mutator_instagib, cvar("g_instagib") && !g_nexball);
 spawnfunc(item_minst_cells)
 {
        if (!g_instagib) { delete(this); return; }
-       if (!this.ammo_cells) this.ammo_cells = autocvar_g_instagib_ammo_drop;
        StartItem(this, ITEM_VaporizerCells);
 }
 
@@ -50,7 +53,7 @@ void instagib_ammocheck(entity this)
        if(!IS_PLAYER(this))
                return; // not a player
 
-       if(IS_DEAD(this) || gameover)
+       if(IS_DEAD(this) || game_stopped)
                instagib_stop_countdown(this);
        else if (this.ammo_cells > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
                instagib_stop_countdown(this);
@@ -134,7 +137,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterDropItem)
 {
        entity item = M_ARGV(1, entity);
 
-       item.monster_loot = spawnfunc_item_minst_cells;
+       item.monster_loot = ITEM_VaporizerCells;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterSpawn)
@@ -253,7 +256,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ForbidThrowCurrentWeapon)
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
+MUTATOR_HOOKFUNCTION(mutator_instagib, Damage_Calculate)
 {
        entity frag_attacker = M_ARGV(1, entity);
        entity frag_target = M_ARGV(2, entity);
@@ -350,18 +353,65 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems)
        start_ammo_cells   = warmup_start_ammo_cells   = cvar("g_instagib_ammo_start");
        start_ammo_plasma  = warmup_start_ammo_plasma  = 0;
        start_ammo_rockets = warmup_start_ammo_rockets = 0;
-       start_ammo_fuel    = warmup_start_ammo_fuel    = 0;
+       //start_ammo_fuel    = warmup_start_ammo_fuel    = 0;
 
        start_weapons = warmup_start_weapons = WEPSET(VAPORIZER);
        start_items |= IT_UNLIMITED_SUPERWEAPONS;
 }
 
+MUTATOR_HOOKFUNCTION(mutator_instagib, SetWeaponArena)
+{
+       // turn weapon arena off
+       M_ARGV(0, string) = "off";
+}
+
+void replace_with_insta_cells(entity item)
+{
+       entity e = spawn();
+       setorigin(e, item.origin);
+       e.noalign = item.noalign;
+       e.cnt = item.cnt;
+       e.team = item.team;
+       e.spawnfunc_checked = true;
+       spawnfunc_item_minst_cells(e);
+}
+
 MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
        if(item.classname == "item_cells")
-               return true; // no normal cells?
+       {
+               if(autocvar_g_instagib_ammo_convert_cells)
+               {
+                       replace_with_insta_cells(item);
+               }
+               return true;
+       }
+       else if(item.classname == "item_rockets")
+       {
+               if(autocvar_g_instagib_ammo_convert_rockets)
+               {
+                       replace_with_insta_cells(item);
+               }
+               return true;
+       }
+       else if(item.classname == "item_shells")
+       {
+               if(autocvar_g_instagib_ammo_convert_shells)
+               {
+                       replace_with_insta_cells(item);
+               }
+               return true;
+       }
+       else if(item.classname == "item_bullets")
+       {
+               if(autocvar_g_instagib_ammo_convert_bullets)
+               {
+                       replace_with_insta_cells(item);
+               }
+               return true;
+       }
 
        if(item.weapon == WEP_VAPORIZER.m_id && item.classname == "droppedweapon")
        {
@@ -371,13 +421,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
 
        if(item.weapon == WEP_DEVASTATOR.m_id || item.weapon == WEP_VORTEX.m_id)
        {
-               entity e = spawn();
-               setorigin(e, item.origin);
-               e.noalign = item.noalign;
-        e.cnt = item.cnt;
-        e.team = item.team;
-        e.spawnfunc_checked = true;
-               spawnfunc_item_minst_cells(e);
+               replace_with_insta_cells(item);
                return true;
        }