Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds better trait for no stamina stun, adds it to various things that need it. #1435

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/__DEFINES/stamina.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@
#define STAMINA_GRAB_AGGRESSIVE_RESIST_CHANCE 60
/// Chance to resist out of chokeholds grabs.
#define STAMINA_GRAB_CHOKE_RESIST_CHANCE 45

////
/// TRAITS
////
#define TRAIT_CANT_STAMCRIT "cant_stamcrit"
6 changes: 5 additions & 1 deletion code/game/objects/items/melee/baton.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@
target.Paralyze((isnull(stun_override) ? stun_time_cyborg : stun_override) * (trait_check ? 0.1 : 1))
additional_effects_cyborg(target, user)
else
target.stamina.adjust(-stamina_damage)
if(!trait_check)
target.stamina.adjust(-stamina_damage)
else
var/stamina_to_min = (target.stamina.maximum * 0.35)
target.stamina.adjust_to(-stamina_damage, stamina_to_min)
if(!trait_check)
target.Knockdown((isnull(stun_override) ? knockdown_time : stun_override))
additional_effects_non_cyborg(target, user)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/antagonists/heretic/magic/realignment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

/datum/status_effect/realignment/on_apply()
ADD_TRAIT(owner, TRAIT_PACIFISM, id)
ADD_TRAIT(owner, TRAIT_CANT_STAMCRIT, id)
owner.add_filter(id, 2, list("type" = "outline", "color" = "#d6e3e7", "size" = 2))
var/filter = owner.get_filter(id)
animate(filter, alpha = 127, time = 1 SECONDS, loop = -1)
Expand All @@ -67,10 +68,11 @@

/datum/status_effect/realignment/on_remove()
REMOVE_TRAIT(owner, TRAIT_PACIFISM, id)
REMOVE_TRAIT(owner, TRAIT_CANT_STAMCRIT, id)
owner.remove_filter(id)

/datum/status_effect/realignment/tick(seconds_per_tick, times_fired)
owner.stamina.adjust(5, TRUE)
owner.stamina.adjust(15, TRUE)
owner.AdjustAllImmobility(-0.5 SECONDS)

/atom/movable/screen/alert/status_effect/realignment
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/status_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
return

/mob/living/carbon/stamina_stun()
if(HAS_TRAIT(src, TRAIT_BATON_RESISTANCE))
if(HAS_TRAIT(src, TRAIT_CANT_STAMCRIT))
return //baton resistance can't stam crit but can still be non sprinted
if(HAS_TRAIT_FROM(src, TRAIT_INCAPACITATED, STAMINA)) //Already in stamcrit
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@
. = TRUE

/datum/reagent/medicine/c2/probital/overdose_process(mob/living/affected_mob, seconds_per_tick, times_fired)
affected_mob.stamina.adjust(-3 * REM * seconds_per_tick, FALSE)
affected_mob.stamina.adjust(-3 * REM * seconds_per_tick, TRUE)
if(affected_mob.stamina.loss >= 80)
affected_mob.adjust_drowsiness(2 SECONDS * REM * seconds_per_tick)
if(affected_mob.stamina.loss >= 100)
to_chat(affected_mob,span_warning("You feel more tired than you usually do, perhaps if you rest your eyes for a bit..."))
affected_mob.stamina.adjust(100, TRUE)
if(HAS_TRAIT(affected_mob, TRAIT_INCAPACITATED))
affected_mob.exit_stamina_stun()
affected_mob.Sleeping(10 SECONDS)
..()
. = TRUE
Expand Down
10 changes: 6 additions & 4 deletions code/modules/reagents/chemistry/reagents/medicine_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,12 @@
ph = 8.7
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED|REAGENT_NO_RANDOM_RECIPE
addiction_types = list(/datum/addiction/stimulants = 4) //0.8 per 2 seconds
metabolized_traits = list(TRAIT_BATON_RESISTANCE, TRAIT_ANALGESIA)
metabolized_traits = list(TRAIT_BATON_RESISTANCE, TRAIT_ANALGESIA, TRAIT_CANT_STAMCRIT)

/datum/reagent/medicine/stimulants/on_mob_metabolize(mob/living/affected_mob)
..()
if(HAS_TRAIT(affected_mob, TRAIT_INCAPACITATED))
affected_mob.exit_stamina_stun()
affected_mob.add_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants)

/datum/reagent/medicine/stimulants/on_mob_end_metabolize(mob/living/affected_mob)
Expand All @@ -1084,7 +1086,7 @@
affected_mob.adjustBruteLoss(-1 * REM * seconds_per_tick, FALSE, required_bodytype = affected_bodytype)
affected_mob.adjustFireLoss(-1 * REM * seconds_per_tick, FALSE, required_bodytype = affected_bodytype)
affected_mob.AdjustAllImmobility(-60 * REM * seconds_per_tick)
affected_mob.stamina.adjust(5 * REM * seconds_per_tick, TRUE)
affected_mob.stamina.adjust(10 * REM * seconds_per_tick, TRUE)
..()
. = TRUE

Expand Down Expand Up @@ -1294,12 +1296,12 @@

/datum/reagent/medicine/changelingadrenaline/on_mob_metabolize(mob/living/affected_mob)
..()
affected_mob.add_traits(list(TRAIT_SLEEPIMMUNE, TRAIT_BATON_RESISTANCE), type)
affected_mob.add_traits(list(TRAIT_SLEEPIMMUNE, TRAIT_BATON_RESISTANCE, TRAIT_CANT_STAMCRIT), type)
affected_mob.add_movespeed_mod_immunities(type, /datum/movespeed_modifier/damage_slowdown)

/datum/reagent/medicine/changelingadrenaline/on_mob_end_metabolize(mob/living/affected_mob)
..()
affected_mob.remove_traits(list(TRAIT_SLEEPIMMUNE, TRAIT_BATON_RESISTANCE), type)
affected_mob.remove_traits(list(TRAIT_SLEEPIMMUNE, TRAIT_BATON_RESISTANCE, TRAIT_CANT_STAMCRIT), type)
affected_mob.remove_movespeed_mod_immunities(type, /datum/movespeed_modifier/damage_slowdown)
affected_mob.remove_status_effect(/datum/status_effect/dizziness)
affected_mob.remove_status_effect(/datum/status_effect/jitter)
Expand Down
14 changes: 14 additions & 0 deletions monkestation/code/datums/stamina_container.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@
/// Revitalize the stamina to the maximum this container can have.
/datum/stamina_container/proc/revitalize(forced = FALSE)
return adjust(maximum, forced)

/datum/stamina_container/proc/adjust_to(amount, lowest_stamina_value, forced = FALSE)
if((!amount || !COOLDOWN_FINISHED(src, stamina_grace_period)) && !forced)
return

var/stamina_after_loss = current + amount
if(stamina_after_loss < lowest_stamina_value)
amount = current - lowest_stamina_value

current = round(clamp(current + amount, 0, maximum), DAMAGE_PRECISION)
update()
if((amount < 0) && is_regenerating)
pause(STAMINA_REGEN_TIME)
return amount
Loading