From 5efb118f74cfb850ac81ca7c290826b80c3ef664 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 19 Apr 2021 14:44:30 +0200 Subject: [PATCH] Compact instagib no-ammo countdown code; also fix a typo in notification_lifetime_runtime description --- notifications.cfg | 2 +- .../mutators/mutator/instagib/sv_instagib.qc | 78 +++++-------------- qcsrc/common/util.qc | 1 + 3 files changed, 23 insertions(+), 58 deletions(-) diff --git a/notifications.cfg b/notifications.cfg index 00c921ddbb..0a0934b136 100644 --- a/notifications.cfg +++ b/notifications.cfg @@ -745,7 +745,7 @@ seta notification_debug "0" "Print extra debug information on all notification f seta notification_errors_are_fatal "1" "If a notification fails upon initialization, cause a Host_Error to stop the program" seta notification_item_centerprinttime "1.5" "How long to show item information centerprint messages (like 'You got the Electro' or such)" seta notification_lifetime_mapload "10" "Amount of time that notification entities last immediately at mapload (in seconds) to help prevent notifications from being lost on early init (like gamestart countdown)" -seta notification_lifetime_runtime "0.5" "Amount of time that notification entities last on the server during runtime (In seconds)" +seta notification_lifetime_runtime "0.5" "Amount of time that notification entities last on the server during runtime (in seconds)" seta notification_server_allows_location "1" "Server side cvar for allowing death messages to show location information too" seta notification_show_location "0" "Append location information to MSG_INFO death/kill messages" seta notification_show_location_string "" "Replacement string piped into sprintf, so you can do different messages like this: ' at the %s' or ' (near %s)'" diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 34a16b8a7a..44c476a3a9 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -62,6 +62,26 @@ void instagib_stop_countdown(entity e) Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_INSTAGIB_FINDAMMO); e.instagib_needammo = false; } + +void instagib_countdown(entity this) +{ + float hp = GetResource(this, RES_HEALTH); + + float dmg = (hp <= 10) ? 5 : 10; + Damage(this, this, this, dmg, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); + + entity annce = (hp <= 5) ? ANNCE_INSTAGIB_TERMINATED : Announcer_PickNumber(CNT_NORMAL, ceil(hp / 10)); + Send_Notification(NOTIF_ONE, this, MSG_ANNCE, annce); + + if (hp > 80) + { + if (hp <= 90) + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO); + else + Send_Notification(NOTIF_ONE_ONLY, this, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO); + } +} + void instagib_ammocheck(entity this) { if(time < this.instagib_nextthink) @@ -83,64 +103,8 @@ void instagib_ammocheck(entity this) } else { - float hp = GetResource(this, RES_HEALTH); this.instagib_needammo = true; - if (hp <= 5) - { - Damage(this, this, this, 5, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED); - } - else if (hp <= 10) - { - Damage(this, this, this, 5, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_1); - } - else if (hp <= 20) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_2); - } - else if (hp <= 30) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_3); - } - else if (hp <= 40) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_4); - } - else if (hp <= 50) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_5); - } - else if (hp <= 60) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_6); - } - else if (hp <= 70) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_7); - } - else if (hp <= 80) - { - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_8); - } - else if (hp <= 90) - { - Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO); - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_9); - } - else - { - Send_Notification(NOTIF_ONE_ONLY, this, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO); - Damage(this, this, this, 10, DEATH_NOAMMO.m_id, DMG_NOWEP, this.origin, '0 0 0'); - } + instagib_countdown(this); } this.instagib_nextthink = time + 1; } diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 964e89520c..8dd6c341b3 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1778,6 +1778,7 @@ Notification Announcer_PickNumber(int type, int num) } break; } + case CNT_NORMAL: default: { switch(num) -- 2.39.2