-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
…turns 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]>
- Loading branch information
There are no files selected for viewing
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) |
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(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") | ||
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (runtimestation) / run_integration_testsRuntime Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (multiz_debug) / run_integration_testsMultiZ Debug: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Alternate Tests (515, 1627, runtimestation) / run_integration_testsRuntime Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (nssjourney) / run_integration_testsNSS Journey: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (kilostation2) / run_integration_testsKilo Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (voidraptor) / run_integration_testsVoid Raptor: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (deltastation) / run_integration_testsDelta Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (birdshot) / run_integration_testsBirdshot Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (tramstation) / run_integration_testsTramstation: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (ouroboros) / run_integration_testsOuroboros: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (icebox) / run_integration_testsIce Box Station: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (metastation) / run_integration_testsMetaStation: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (northstar) / run_integration_testsNorthStar: /datum/unit_test/stamcrit
Check failure on line 11 in code/modules/unit_tests/combat_stamina.dm GitHub Actions / Integration Tests (blueshift) / run_integration_testsBlueshift: /datum/unit_test/stamcrit
|
||
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") |