From 3ae581bcb90fdf4a24324c4526124a52ce7e5e4c Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sun, 8 Oct 2017 20:06:52 +0300 Subject: [PATCH] Fixed instagib powerups. --- mutators.cfg | 2 ++ .../common/mutators/mutator/instagib/_mod.inc | 3 +++ .../common/mutators/mutator/instagib/items.qh | 20 ++++++++++++++ .../mutators/mutator/instagib/sv_items.qc | 23 ++++++++++++++++ qcsrc/common/t_items.qc | 26 +++++++++---------- qcsrc/server/mutators/mutator/gamemode_lms.qc | 2 +- 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 qcsrc/common/mutators/mutator/instagib/sv_items.qc diff --git a/mutators.cfg b/mutators.cfg index 2597d518b..1f989d30d 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -36,7 +36,9 @@ set g_instagib_ammo_convert_bullets 0 "convert bullet ammo packs to insta cell a 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_invisibility_time 30 "Time of ivisibility powerup in seconds." set g_instagib_invis_alpha 0.15 +set g_instagib_speed_time 30 "Time of speed powerup in seconds." 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" set g_instagib_blaster_keepdamage 0 "allow secondary fire to hurt players" diff --git a/qcsrc/common/mutators/mutator/instagib/_mod.inc b/qcsrc/common/mutators/mutator/instagib/_mod.inc index 2195111f0..55a67b1e3 100644 --- a/qcsrc/common/mutators/mutator/instagib/_mod.inc +++ b/qcsrc/common/mutators/mutator/instagib/_mod.inc @@ -1,5 +1,8 @@ // generated file; do not modify #include +#ifdef SVQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/mutators/mutator/instagib/items.qh b/qcsrc/common/mutators/mutator/instagib/items.qh index ac2761bd5..f0e18daab 100644 --- a/qcsrc/common/mutators/mutator/instagib/items.qh +++ b/qcsrc/common/mutators/mutator/instagib/items.qh @@ -69,6 +69,13 @@ MODEL(Invisibility_ITEM, Item_Model("g_strength.md3")); SOUND(Invisibility, Item_Sound("powerup")); #endif +#ifdef SVQC +/// \brief Initializes the invisibility powerup. +/// \param[in,out] item Item to initialize. +/// \return No return. +void powerup_invisibility_init(entity item); +#endif + REGISTER_ITEM(Invisibility, Powerup) { this.m_canonical_spawnfunc = "item_invisibility"; #ifdef GAMEQC @@ -82,6 +89,9 @@ REGISTER_ITEM(Invisibility, Powerup) { this.m_waypoint = _("Invisibility"); this.m_waypointblink = 2; this.m_itemid = IT_STRENGTH; +#ifdef SVQC + this.m_iteminit = powerup_invisibility_init; +#endif } #ifdef GAMEQC @@ -89,6 +99,13 @@ MODEL(Speed_ITEM, Item_Model("g_invincible.md3")); SOUND(Speed, Item_Sound("powerup_shield")); #endif +#ifdef SVQC +/// \brief Initializes the speed powerup. +/// \param[in,out] item Item to initialize. +/// \return No return. +void powerup_speed_init(entity item); +#endif + REGISTER_ITEM(Speed, Powerup) { this.m_canonical_spawnfunc = "item_speed"; #ifdef GAMEQC @@ -102,4 +119,7 @@ REGISTER_ITEM(Speed, Powerup) { this.m_waypoint = _("Speed"); this.m_waypointblink = 2; this.m_itemid = IT_INVINCIBLE; +#ifdef SVQC + this.m_iteminit = powerup_speed_init; +#endif } diff --git a/qcsrc/common/mutators/mutator/instagib/sv_items.qc b/qcsrc/common/mutators/mutator/instagib/sv_items.qc new file mode 100644 index 000000000..ffd9bfb0c --- /dev/null +++ b/qcsrc/common/mutators/mutator/instagib/sv_items.qc @@ -0,0 +1,23 @@ +#include "items.qh" + +/// \brief Time of ivisibility powerup in seconds. +float autocvar_g_instagib_invisibility_time; +/// \brief Time of speed powerup in seconds. +float autocvar_g_instagib_speed_time; + +void powerup_invisibility_init(entity item) +{ + if(!item.strength_finished) + { + item.strength_finished = autocvar_g_instagib_invisibility_time; + } +} + + +void powerup_speed_init(entity item) +{ + if(!item.invincible_finished) + { + item.invincible_finished = autocvar_g_instagib_speed_time; + } +} diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 97938e81d..70c462288 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -909,22 +909,22 @@ void Item_Touch(entity this, entity toucher) // Expiring loot will have strength "ticking" will it's dropped. // Not expiring will not tick. // OTOH, do we really need expiring loot? - if (this.classname == "droppedweapon") - { - this.strength_finished = max(0, this.strength_finished - time); - this.invincible_finished = max(0, this.invincible_finished - time); - this.superweapons_finished = max(0, this.superweapons_finished - time); - } + //if (this.classname == "droppedweapon") + //{ + // this.strength_finished = max(0, this.strength_finished - time); + // this.invincible_finished = max(0, this.invincible_finished - time); + // this.superweapons_finished = max(0, this.superweapons_finished - time); + //} bool gave = ITEM_HANDLE(Pickup, this.itemdef, this, toucher); if (!gave) { - if (Item_IsLoot(this)) - { - // undo what we did above - this.strength_finished += time; - this.invincible_finished += time; - this.superweapons_finished += time; - } + //if (this.classname == "droppedweapon") + //{ + // // undo what we did above + // this.strength_finished += time; + // this.invincible_finished += time; + // this.superweapons_finished += time; + //} return; } diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index 4d6f70438..cd8fb390d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -1,6 +1,6 @@ #include "gamemode_lms.qh" -#include +#include #include #include -- 2.39.2