From 51ee8fc360973cfab450bf8b3e89168ab692413e Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 20 Jul 2021 12:32:48 +1000 Subject: [PATCH] Make powerup timer stacking configurable and disabled by default --- .../mutators/mutator/powerups/sv_powerups.qh | 1 + qcsrc/server/items/items.qc | 28 ++++++++++++++++--- xonotic-server.cfg | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh index c2dcfa034..b51438538 100644 --- a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh +++ b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qh @@ -5,6 +5,7 @@ #include "powerups.qh" int autocvar_g_powerups; +bool autocvar_g_powerups_stack; REGISTER_MUTATOR(powerups, true); diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index faea9449e..db9b3fece 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -551,22 +551,42 @@ bool Item_GiveTo(entity item, entity player) if (item.strength_finished) { pickedup = true; - StatusEffects_apply(STATUSEFFECT_Strength, player, max(StatusEffects_gettime(STATUSEFFECT_Strength, player), time) + item.strength_finished, 0); + float t = max(StatusEffects_gettime(STATUSEFFECT_Strength, player), time); + if (autocvar_g_powerups_stack) + t += item.strength_finished; + else + t = max(t, time + item.strength_finished); + StatusEffects_apply(STATUSEFFECT_Strength, player, t, 0); } if (item.invincible_finished) { pickedup = true; - StatusEffects_apply(STATUSEFFECT_Shield, player, max(StatusEffects_gettime(STATUSEFFECT_Shield, player), time) + item.invincible_finished, 0); + float t = max(StatusEffects_gettime(STATUSEFFECT_Shield, player), time); + if (autocvar_g_powerups_stack) + t += item.invincible_finished; + else + t = max(t, time + item.invincible_finished); + StatusEffects_apply(STATUSEFFECT_Shield, player, t, 0); } if (item.speed_finished) { pickedup = true; - StatusEffects_apply(STATUSEFFECT_Speed, player, max(StatusEffects_gettime(STATUSEFFECT_Speed, player), time) + item.speed_finished, 0); + float t = max(StatusEffects_gettime(STATUSEFFECT_Speed, player), time); + if (autocvar_g_powerups_stack) + t += item.speed_finished; + else + t = max(t, time + item.speed_finished); + StatusEffects_apply(STATUSEFFECT_Speed, player, t, 0); } if (item.invisibility_finished) { pickedup = true; - StatusEffects_apply(STATUSEFFECT_Invisibility, player, max(StatusEffects_gettime(STATUSEFFECT_Invisibility, player), time) + item.invisibility_finished, 0); + float t = max(StatusEffects_gettime(STATUSEFFECT_Invisibility, player), time); + if (autocvar_g_powerups_stack) + t += item.invisibility_finished; + else + t = max(t, time + item.invisibility_finished); + StatusEffects_apply(STATUSEFFECT_Invisibility, player, t, 0); } if (item.superweapons_finished) { diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 28d5101ed..39323f0dc 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -198,6 +198,7 @@ set g_shootfromfixedorigin "" "if set to a string like 0 y z, the gun is moved t set g_weapon_stay 0 "1: ghost weapons can be picked up but give no ammo, thrown guns have ammo 2: ghost weapons can be picked up and refill ammo to one pickup size, thrown guns have no ammo (to prevent infinite ammo abuse)" set g_weapon_throwable 1 "if set to 1, weapons can be dropped" set g_powerups -1 "if set to 0 no powerups will spawn, if 1 they will spawn in all game modes, -1 is game mode default" +set g_powerups_stack 0 "enables stacking of powerup timers when picking up a powerup you already have; otherwise timer is reset to the time granted by the item, if greater than the time you currently have" set g_powerups_strength 1 "allow strength powerups to spawn" set g_powerups_shield 1 "allow shield powerups to spawn" set g_powerups_speed 1 "allow speed powerups to spawn" -- 2.39.2