From: Freddy Date: Mon, 10 Oct 2016 14:24:27 +0000 (+0200) Subject: InstaGib: add cvars to convert ammo packs into insta cells X-Git-Tag: xonotic-v0.8.2~524^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F374%2Fhead;p=xonotic%2Fxonotic-data.pk3dir.git InstaGib: add cvars to convert ammo packs into insta cells --- 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; }