Skip to content

Commit

Permalink
Adds sprinting (inspired from Citadel's system), makes walking default (
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert authored Nov 20, 2023
1 parent 18c4e41 commit 3cf7c62
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 3 deletions.
4 changes: 2 additions & 2 deletions code/datums/elements/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
var/mob/living/carbon/carbon_source = source
if(!carbon_source.get_bodypart(BODY_ZONE_L_LEG) && !carbon_source.get_bodypart(BODY_ZONE_R_LEG))
return
if(carbon_source.m_intent == MOVE_INTENT_WALK)
return// stealth
// if(carbon_source.m_intent == MOVE_INTENT_WALK) // NON-MODULE CHANGE
// return// stealth // NON-MODULE CHANGE
steps_for_living[source] += 1
var/steps = steps_for_living[source]

Expand Down
13 changes: 13 additions & 0 deletions code/modules/mob/living/carbon/carbon_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
if(m_intent == MOVE_INTENT_RUN)
adjust_nutrition(-(HUNGER_FACTOR/10))

// NON-MODULE CHANGE START
if(m_intent == MOVE_INTENT_RUN && !(movement_type & FLYING) && (mobility_flags & (MOBILITY_MOVE|MOBILITY_STAND)) && !pulledby)
drain_sprint()
if(momentum_dir & direct)
momentum_distance++
if(!has_momentum && momentum_distance >= 4 && add_movespeed_modifier(/datum/movespeed_modifier/momentum))
has_momentum = TRUE
else
momentum_dir = direct
momentum_distance = 0
if(has_momentum && remove_movespeed_modifier(/datum/movespeed_modifier/momentum))
has_momentum = FALSE
// NON-MODULE CHANGE END

/mob/living/carbon/set_usable_legs(new_value)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion config/game_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COMMENDATION_PERCENT_POLL 0.05

## These modify the run/walk speed of all mobs before the mob-specific modifiers are applied.
RUN_DELAY 1.5
WALK_DELAY 4
WALK_DELAY 2.5

## The variables below affect the movement of specific mob types. THIS AFFECTS ALL SUBTYPES OF THE TYPE YOU CHOOSE!
## Entries completely override all subtypes. Later entries have precedence over earlier entries.
Expand Down
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5630,6 +5630,7 @@
#include "maplestation_modules\code\modules\mob\living\living.dm"
#include "maplestation_modules\code\modules\mob\living\living_movement.dm"
#include "maplestation_modules\code\modules\mob\living\speech_and_radio_sounds.dm"
#include "maplestation_modules\code\modules\mob\living\sprint.dm"
#include "maplestation_modules\code\modules\mob\living\carbon\human\human.dm"
#include "maplestation_modules\code\modules\mob\living\carbon\human\modular_sechud_icons.dm"
#include "maplestation_modules\code\modules\mob\living\carbon\human\skrell_hair.dm"
Expand Down
23 changes: 23 additions & 0 deletions maplestation_modules/code/datums/quirks/good.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,26 @@
carbon_holder.unset_pain_mod(PAIN_MOD_QUIRK)

#undef LANGUAGE_QUIRK_RANDOM_BLACKLIST

/// You can sprint for longer
/// (Maybe tie this to the mob's lungs? An idea)
/datum/quirk/marthon_runner
name = "Marathon Runner"
desc = "You can run for longer without getting tired."
icon = FA_ICON_LUNGS
value = 6
gain_text = span_notice("You feel like you can run for miles (or kilometers).")
lose_text = span_danger("You feel winded.")
medical_record_text = "Patient can run for longer than most."

/datum/quirk/marthon_runner/add_unique(client/client_source)
var/mob/living/carbon/human/human_holder = quirk_holder
if(istype(human_holder))
human_holder.sprint_length_max *= 1.5
human_holder.sprint_length = human_holder.sprint_length_max

/datum/quirk/marthon_runner/remove(client/client_source)
var/mob/living/carbon/human/human_holder = quirk_holder
if(istype(human_holder))
human_holder.sprint_length_max /= 1.5
human_holder.sprint_length = human_holder.sprint_length_max
99 changes: 99 additions & 0 deletions maplestation_modules/code/modules/mob/living/sprint.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/atom/movable/screen/mov_intent
var/mutable_appearance/sprint_bar

/atom/movable/screen/mov_intent/update_overlays()
. = ..()
if(!ishuman(hud?.mymob))
return

if(isnull(sprint_bar))
sprint_bar = mutable_appearance(
icon = 'icons/effects/progessbar.dmi',
icon_state = "prog_bar_100",
)
sprint_bar.pixel_y -= 2

var/mob/living/carbon/human/runner = hud.mymob
sprint_bar.icon_state = "prog_bar_[round(((runner.sprint_length / runner.sprint_length_max) * 100), 5)]"
. += sprint_bar

/datum/movespeed_modifier/momentum
movetypes = GROUND
flags = IGNORE_NOSLOW
multiplicative_slowdown = -0.1

/mob/living/carbon
/// If TRUE, we are being affected by run momentum
var/has_momentum = FALSE
/// Our last move direction, used for tracking momentum
var/momentum_dir = NONE
/// How many tiles we've moved in the momentum direction
var/momentum_distance = 0

/mob/living/carbon/human
m_intent = MOVE_INTENT_WALK
/// How many tiles left in your sprint
var/sprint_length = 100
/// How many tiles you can sprint before spending stamina
var/sprint_length_max = 100
/// How many tiles you get back per second
var/sprint_regen_per_second = 0.75

/mob/living/carbon/human/toggle_move_intent()
. = ..()
if(!client?.prefs.read_preference(/datum/preference/toggle/sound_combatmode))
return
if(m_intent == MOVE_INTENT_RUN)
playsound_local(get_turf(src), 'maplestation_modules/sound/sprintactivate.ogg', 75, vary = FALSE, pressure_affected = FALSE)
else
playsound_local(get_turf(src), 'maplestation_modules/sound/sprintdeactivate.ogg', 75, vary = FALSE, pressure_affected = FALSE)

/mob/living/carbon/human/Life(seconds_per_tick, times_fired)
. = ..()
if(!.)
return
if(m_intent == MOVE_INTENT_RUN || sprint_length >= sprint_length_max)
return

adjust_sprint_left(sprint_regen_per_second * seconds_per_tick * (body_position == LYING_DOWN ? 2 : 1))

/mob/living/carbon/proc/adjust_sprint_left(amount)
return

/mob/living/carbon/human/adjust_sprint_left(amount)
sprint_length = clamp(sprint_length + amount, 0, sprint_length_max)
for(var/atom/movable/screen/mov_intent/selector in hud_used?.static_inventory)
selector.update_appearance(UPDATE_OVERLAYS)

/mob/living/carbon/proc/drain_sprint()
return

/mob/living/carbon/human/drain_sprint()
adjust_sprint_left(-1)
// Sprinting when out of sprint will cost stamina
if(sprint_length > 0)
return

// Okay you're gonna stamcrit yourself, slow your roll
if(getStaminaLoss() >= maxHealth * 0.9)
toggle_move_intent()
return

adjustStaminaLoss(1)

/mob/living/carbon/human/fully_heal(heal_flags)
. = ..()
if(heal_flags & (HEAL_ADMIN|HEAL_STAM|HEAL_CC_STATUS))
adjust_sprint_left(INFINITY)

// Minor stamina regeneration effects, such as stimulants, will replenish sprint capacity
/mob/living/carbon/human/adjustStaminaLoss(amount, updating_stamina, forced, required_biotype)
. = ..()
if(amount < 0 && amount >= -20)
adjust_sprint_left(amount * 0.25)

// Entering stamina critical will drain your sprint capacity entirely
/mob/living/carbon/human/enter_stamcrit()
. = ..()
if(HAS_TRAIT_FROM(src, TRAIT_FLOORED, STAMINA))
adjust_sprint_left(-INFINITY)
Binary file added maplestation_modules/sound/sprintactivate.ogg
Binary file not shown.
Binary file added maplestation_modules/sound/sprintdeactivate.ogg
Binary file not shown.

0 comments on commit 3cf7c62

Please sign in to comment.