Skip to content

Commit

Permalink
Adds momentum
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert committed Oct 16, 2023
1 parent 25a458f commit c13bb17
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
9 changes: 9 additions & 0 deletions code/modules/mob/living/carbon/carbon_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
// 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
29 changes: 20 additions & 9 deletions maplestation_modules/code/modules/mob/living/sprint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,32 @@
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 = 0
var/sprint_length = 75
/// How many tiles you can sprint before returning to "walk"
var/sprint_length_max = 50
var/sprint_length_max = 75
/// How many tiles you get back per second
var/sprint_regen_per_second = 0.5

/mob/living/carbon/human/Initialize(mapload)
. = ..()
sprint_length = sprint_length_max
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
Expand All @@ -50,7 +61,7 @@
return

/mob/living/carbon/human/adjust_sprint_left(amount)
sprint_length = clamp(sprint_length + (amount), 0, sprint_length_max)
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)

Expand All @@ -68,7 +79,7 @@
toggle_move_intent()
return

adjustStaminaLoss(0.5)
adjustStaminaLoss(1)

/mob/living/carbon/human/fully_heal(heal_flags)
. = ..()
Expand Down

0 comments on commit c13bb17

Please sign in to comment.