From f31fd63f70c9577ca1ad9a0292c73f42a33ce11f Mon Sep 17 00:00:00 2001 From: Freddy Date: Mon, 10 Oct 2016 16:24:27 +0200 Subject: [PATCH] InstaGib: add cvars to convert ammo packs into insta cells --- mutators.cfg | 4 ++ .../mutators/mutator/instagib/sv_instagib.qc | 55 ++++++++++++++++--- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/mutators.cfg b/mutators.cfg index 2cf382a02..a95c034f1 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -31,6 +31,10 @@ set g_instagib 0 "enable instagib" set g_instagib_extralives 1 "how many extra lives you will get per powerup" set g_instagib_ammo_start 10 "starting ammo" set g_instagib_ammo_drop 5 "how much ammo you'll get for weapons or cells" +set g_instagib_ammo_convert_bullets 0 "convert bullet ammo packs to insta cell ammo packs" +set g_instagib_ammo_convert_cells 0 "convert normal cell ammo packs to insta cell ammo packs" +set g_instagib_ammo_convert_rockets 0 "convert rocket ammo packs to insta cell ammo packs" +set g_instagib_ammo_convert_shells 0 "convert shell ammo packs to insta cell ammo packs" set g_instagib_invis_alpha 0.15 set g_instagib_speed_highspeed 1.5 "speed-multiplier that applies while you carry the invincibility powerup" set g_instagib_damagedbycontents 1 "allow damage from lava pits in instagib" diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 0cf3ed978..6135e72b5 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -1,6 +1,10 @@ #include "sv_instagib.qh" 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; @@ -356,12 +360,53 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems) start_items |= IT_UNLIMITED_SUPERWEAPONS; } +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 +416,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; } -- 2.39.2