Wall Running (#11312)

This commit is contained in:
Geeves
2021-04-07 16:28:46 +02:00
committed by GitHub
parent 3023212c31
commit e1852e37e6
4 changed files with 38 additions and 17 deletions
@@ -536,7 +536,9 @@
prescriptions -= H.equipment_prescription
return Clamp(prescriptions, 0, 7)
/datum/species/proc/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
// pre_move is set to TRUE when the mob checks whether it's even possible to move, so resources aren't drained until after the move completes
// once the mob moves and its loc actually changes, the pre_move is set to FALSE and all the proper resources are drained
/datum/species/proc/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost, var/pre_move)
if (!H.exhaust_threshold)
return 1 // Handled.
@@ -548,44 +550,49 @@
var/obj/item/organ/internal/augment/calf_override/C = H.internal_organs_by_name[BP_AUG_CALF_OVERRIDE]
if(C && !C.is_broken())
cost = 0
C.do_run_act()
if(!pre_move)
C.do_run_act()
var/remainder = 0
if (H.stamina > cost)
H.stamina -= cost
H.hud_used.move_intent.update_move_icon(H)
if(!pre_move)
H.stamina -= cost
H.hud_used.move_intent.update_move_icon(H)
return 1
else if (H.stamina > 0)
remainder = cost - H.stamina
H.stamina = 0
if(!pre_move)
H.stamina = 0
else
remainder = cost
if(H.disabilities & ASTHMA)
if(!pre_move && (H.disabilities & ASTHMA))
H.adjustOxyLoss(remainder*0.15)
if(H.disabilities & COUGHING)
if(!pre_move && (H.disabilities & COUGHING))
H.adjustHalLoss(remainder*0.1)
if (breathing_organ && has_organ[breathing_organ])
if(!pre_move && breathing_organ && has_organ[breathing_organ])
var/obj/item/organ/O = H.internal_organs_by_name[breathing_organ]
if(O.is_bruised())
H.adjustOxyLoss(remainder*0.15)
H.adjustHalLoss(remainder*0.25)
H.adjustHalLoss(remainder*0.25)
H.updatehealth()
if((H.get_shock() >= 10) && prob(H.get_shock() *2))
H.flash_pain(H.get_shock())
if(!pre_move)
H.adjustHalLoss(remainder*0.25)
H.updatehealth()
if((H.get_shock() >= 10) && prob(H.get_shock() *2))
H.flash_pain(H.get_shock())
if ((H.get_shock() + H.getOxyLoss()) >= (exhaust_threshold * 0.8))
if((H.get_shock() + H.getOxyLoss()) >= (exhaust_threshold * 0.8))
H.m_intent = M_WALK
H.hud_used.move_intent.update_move_icon(H)
to_chat(H, SPAN_DANGER("You're too exhausted to run anymore!"))
H.flash_pain(H.get_shock())
return 0
H.hud_used.move_intent.update_move_icon(H)
if(!pre_move)
H.hud_used.move_intent.update_move_icon(H)
return 1
/datum/species/proc/get_light_color(mob/living/carbon/human/H)
@@ -131,8 +131,8 @@
. = ..()
check_tag(H, H.client)
/datum/species/machine/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
if (H.stat == CONSCIOUS)
/datum/species/machine/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost, var/pre_move)
if(!pre_move && H.stat == CONSCIOUS)
H.bodytemperature += cost * sprint_temperature_factor
return TRUE
+9 -1
View File
@@ -299,10 +299,12 @@
// Apply human specific modifiers.
var/mob_is_human = ishuman(mob) // Only check this once and just reuse the value.
var/sprint_tally = 0
if (mob_is_human)
var/mob/living/carbon/human/H = mob
//If we're sprinting and able to continue sprinting, then apply the sprint bonus ontop of this
if (H.m_intent == M_RUN && (H.status_flags & GODMODE || H.species.handle_sprint_cost(H, tally))) //This will return false if we collapse from exhaustion
if (H.m_intent == M_RUN && (H.status_flags & GODMODE || H.species.handle_sprint_cost(H, tally, TRUE))) //This will return false if we collapse from exhaustion
sprint_tally = tally
tally = (tally / (1 + H.sprint_speed_factor)) * config.run_delay_multiplier
else
tally = max(tally * config.walk_delay_multiplier, H.min_walk_delay) //clamp walking speed if its limited
@@ -327,6 +329,8 @@
move_delay += 1
return mob.pulledby.relaymove(mob, direct)
var/old_loc = mob.loc
//We are now going to move
moving = 1
//Something with pulling things
@@ -377,6 +381,10 @@
moving = 0
if(sprint_tally && mob.loc != old_loc)
var/mob/living/carbon/human/H = mob
H.species.handle_sprint_cost(H, sprint_tally, FALSE)
if(isobj(mob.loc) || ismob(mob.loc)) //Inside an object, tell it we moved
var/atom/O = mob.loc
return O.relaymove(mob, direct)