-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Incoming stamina damage while in stamcrit has diminishing re…
…turns applied (#3788) * [MIRROR] Incoming stamina damage while in stamcrit has diminishing returns applied [MDB IGNORE] (#2987) * Incoming stamina damage while in stamcrit has diminishing returns applied * This was not even used * Update death_consequences_trauma.dm --------- Co-authored-by: MrMelbert <[email protected]> Co-authored-by: Mal <[email protected]> * Update combat_stamina.dm --------- Co-authored-by: NovaBot <[email protected]> Co-authored-by: MrMelbert <[email protected]> Co-authored-by: Mal <[email protected]> Co-authored-by: Iajret <[email protected]>
- Loading branch information
1 parent
3eff499
commit 66c341c
Showing
18 changed files
with
149 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/datum/status_effect/incapacitating/stamcrit | ||
status_type = STATUS_EFFECT_UNIQUE | ||
// Lasts until we go back to 0 stamina, which is handled by the mob | ||
duration = -1 | ||
tick_interval = -1 | ||
/// Cooldown between displaying warning messages that we hit diminishing returns | ||
COOLDOWN_DECLARE(warn_cd) | ||
/// A counter that tracks every time we've taken enough damage to trigger diminishing returns | ||
var/diminishing_return_counter = 0 | ||
|
||
/datum/status_effect/incapacitating/stamcrit/on_creation(mob/living/new_owner, set_duration) | ||
. = ..() | ||
if(!.) | ||
return . | ||
|
||
// This should be in on apply but we need it to happen AFTER being added to the mob | ||
// (Because we need to wait until the status effect is in their status effect list, or we'll add two) | ||
if(owner.getStaminaLoss() < 120) | ||
// Puts you a little further into the initial stamcrit, makes stamcrit harder to outright counter with chems. | ||
owner.adjustStaminaLoss(30, FALSE) | ||
|
||
// Same | ||
RegisterSignal(owner, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, PROC_REF(update_diminishing_return)) | ||
RegisterSignal(owner, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(check_remove)) | ||
|
||
/datum/status_effect/incapacitating/stamcrit/on_apply() | ||
if(owner.stat == DEAD) | ||
return FALSE | ||
if(owner.check_stun_immunity(CANKNOCKDOWN)) | ||
return FALSE | ||
|
||
. = ..() | ||
if(!.) | ||
return . | ||
|
||
if(owner.stat == CONSCIOUS) | ||
to_chat(owner, span_notice("You're too exhausted to keep going...")) | ||
owner.add_traits(list(TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED, TRAIT_FLOORED), STAMINA) | ||
return . | ||
|
||
/datum/status_effect/incapacitating/stamcrit/on_remove() | ||
UnregisterSignal(owner, COMSIG_LIVING_HEALTH_UPDATE) | ||
UnregisterSignal(owner, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE) | ||
owner.remove_traits(list(TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED, TRAIT_FLOORED), STAMINA) | ||
return ..() | ||
|
||
/datum/status_effect/incapacitating/stamcrit/proc/update_diminishing_return(datum/source, type, amount, forced) | ||
SIGNAL_HANDLER | ||
if(amount <= 0 || forced) | ||
return NONE | ||
// Here we fake the effect of having diminishing returns | ||
// We don't actually decrease incoming stamina damage because that would be pointless, the mob is at stam damage cap anyways | ||
// Instead we just "ignore" the damage if we have a sufficiently high diminishing return counter | ||
var/mod_amount = ceil(sqrt(amount) / 2) - diminishing_return_counter | ||
// We check base amount not mod_amount because we still want to up tick it even if we've already got a high counter | ||
// We also only uptick it after calculating damage so we start ticking up after the damage and not before | ||
switch(amount) | ||
if(5 to INFINITY) | ||
diminishing_return_counter += 1 | ||
if(2 to 5) // Prevent chems from skyrockting DR | ||
diminishing_return_counter += 0.05 | ||
if(mod_amount > 0) | ||
return NONE | ||
|
||
if(COOLDOWN_FINISHED(src, warn_cd) && owner.stat == CONSCIOUS) | ||
to_chat(owner, span_notice("You start to recover from the exhaustion!")) | ||
owner.visible_message(span_warning("[owner] starts to recover from the exhaustion!"), ignored_mobs = owner) | ||
COOLDOWN_START(src, warn_cd, 2.5 SECONDS) | ||
|
||
return COMPONENT_IGNORE_CHANGE | ||
|
||
/datum/status_effect/incapacitating/stamcrit/proc/check_remove(datum/source, ...) | ||
SIGNAL_HANDLER | ||
if(owner.maxHealth - owner.getStaminaLoss() > owner.crit_threshold) | ||
qdel(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// Tests 100 stamina damage = stamcrit | ||
/datum/unit_test/stamcrit | ||
priority = TEST_LONGER | ||
|
||
/datum/unit_test/stamcrit/Run() | ||
var/mob/living/carbon/human/consistent/tider = allocate(__IMPLIED_TYPE__) | ||
tider.stamina_regen_time = 0.2 SECONDS | ||
tider.adjustStaminaLoss(tider.maxHealth-1) // NOVA EDIT CHANGE - ORIGINAL: tider.adjustStaminaLoss(99) | ||
TEST_ASSERT(!tider.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Stamcrit should not be applied at 99 stamina damage") | ||
tider.adjustStaminaLoss(1) | ||
TEST_ASSERT(tider.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Stamcrit should be applied at 100 stamina damage") | ||
sleep(tider.stamina_regen_time * 2) | ||
TEST_ASSERT(!tider.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Stamcrit should be removed after regen time") | ||
|
||
/// Tests stamina regen after the set time | ||
/datum/unit_test/stam_regen | ||
priority = TEST_LONGER | ||
|
||
/datum/unit_test/stam_regen/Run() | ||
var/mob/living/carbon/human/consistent/tider = allocate(__IMPLIED_TYPE__) | ||
tider.stamina_regen_time = 0.2 SECONDS | ||
tider.adjustStaminaLoss(50) | ||
sleep(tider.stamina_regen_time * 2) | ||
TEST_ASSERT_EQUAL(tider.getStaminaLoss(), 0, "Stamina should be fully regenerated after regen time") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters