mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-11 18:33:36 +00:00
Merge pull request #8415 from Citadel-Station-13/sprint_stamina
Adds a sprint buffer - 35 tiles, regen 2 tiles/second (always active), 0.3 stamcost per tile if empty (as old) directly applied to staminaloss rather than stamina action buffer (unlike old)
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
#define ui_drop_throw "EAST-1:28,SOUTH+1:7"
|
||||
#define ui_pull_resist "EAST-2:26,SOUTH+1:7"
|
||||
#define ui_movi "EAST-2:26,SOUTH:5"
|
||||
#define ui_sprintbufferloc "EAST-2:26,SOUTH:18"
|
||||
#define ui_acti "EAST-3:24,SOUTH:5"
|
||||
#define ui_zonesel "EAST-1:28,SOUTH:5"
|
||||
#define ui_acti_alt "EAST-1:28,SOUTH:5" //alternative intent switcher for when the interface is hidden (F12)
|
||||
|
||||
@@ -134,6 +134,13 @@
|
||||
static_inventory += using
|
||||
//END OF CITADEL CHANGES
|
||||
|
||||
//same as above but buffer.
|
||||
using = new /obj/screen/sprint_buffer
|
||||
using.screen_loc = ui_sprintbufferloc
|
||||
sprint_buffer = using
|
||||
static_inventory += using
|
||||
|
||||
|
||||
using = new /obj/screen/drop()
|
||||
using.icon = ui_style
|
||||
using.screen_loc = ui_drop_throw
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
/obj/screen/mov_intent
|
||||
icon = 'modular_citadel/icons/ui/screen_midnight.dmi'
|
||||
|
||||
/obj/screen/sprintbutton
|
||||
name = "toggle sprint"
|
||||
icon = 'modular_citadel/icons/ui/screen_midnight.dmi'
|
||||
icon_state = "act_sprint"
|
||||
layer = ABOVE_HUD_LAYER - 0.1
|
||||
|
||||
/obj/screen/sprintbutton/Click()
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
H.togglesprint()
|
||||
|
||||
/obj/screen/sprintbutton/proc/insert_witty_toggle_joke_here(mob/living/carbon/human/H)
|
||||
if(!H)
|
||||
return
|
||||
if(H.sprinting)
|
||||
icon_state = "act_sprint_on"
|
||||
else
|
||||
icon_state = "act_sprint"
|
||||
|
||||
/obj/screen/restbutton
|
||||
name = "rest"
|
||||
icon = 'modular_citadel/icons/ui/screen_midnight.dmi'
|
||||
|
||||
41
modular_citadel/code/_onclick/hud/sprint.dm
Normal file
41
modular_citadel/code/_onclick/hud/sprint.dm
Normal file
@@ -0,0 +1,41 @@
|
||||
/obj/screen/mov_intent
|
||||
icon = 'modular_citadel/icons/ui/screen_midnight.dmi'
|
||||
|
||||
/obj/screen/sprintbutton
|
||||
name = "toggle sprint"
|
||||
icon = 'modular_citadel/icons/ui/screen_midnight.dmi'
|
||||
icon_state = "act_sprint"
|
||||
layer = ABOVE_HUD_LAYER - 0.1
|
||||
|
||||
/obj/screen/sprintbutton/Click()
|
||||
if(ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
H.togglesprint()
|
||||
|
||||
/obj/screen/sprintbutton/proc/insert_witty_toggle_joke_here(mob/living/carbon/human/H)
|
||||
if(!H)
|
||||
return
|
||||
if(H.sprinting)
|
||||
icon_state = "act_sprint_on"
|
||||
else
|
||||
icon_state = "act_sprint"
|
||||
|
||||
//Sprint buffer onscreen code.
|
||||
/datum/hud/var/obj/screen/sprint_buffer/sprint_buffer
|
||||
|
||||
/obj/screen/sprint_buffer
|
||||
name = "sprint buffer"
|
||||
icon = 'icons/effects/progessbar.dmi'
|
||||
icon_state = "prog_bar_100"
|
||||
|
||||
/obj/screen/sprint_buffer/Click()
|
||||
if(isliving(usr))
|
||||
var/mob/living/L = usr
|
||||
to_chat(L, "<span class='boldnotice'>Your sprint buffer's maximum capacity is [L.sprint_buffer_max]. It is currently at [L.sprint_buffer], regenerating at [L.sprint_buffer_regen_ds * 10] per second. \
|
||||
Sprinting while this is empty will incur a [L.sprint_stamina_cost] stamina cost per tile.</span>")
|
||||
|
||||
/obj/screen/sprint_buffer/proc/update_to_mob(mob/living/L)
|
||||
var/amount = 0
|
||||
if(L.sprint_buffer_max > 0)
|
||||
amount = round(CLAMP((L.sprint_buffer / L.sprint_buffer_max) * 100, 0, 100), 5)
|
||||
icon_state = "prog_bar_[amount]"
|
||||
@@ -18,3 +18,21 @@
|
||||
if(recoveringstam && amount > 20)
|
||||
incomingstammult = max(0.01, incomingstammult/(amount*0.05))
|
||||
return amount
|
||||
|
||||
/mob/living/carbon/doSprintLossTiles(tiles)
|
||||
doSprintBufferRegen(FALSE) //first regen.
|
||||
if(sprint_buffer)
|
||||
var/use = min(tiles, sprint_buffer)
|
||||
sprint_buffer -= use
|
||||
tiles -= use
|
||||
update_hud_sprint_bar()
|
||||
if(!tiles) //we had enough, we're done!
|
||||
return
|
||||
adjustStaminaLoss(tiles * sprint_stamina_cost) //use stamina to cover deficit.
|
||||
|
||||
/mob/living/carbon/proc/doSprintBufferRegen(updating = TRUE)
|
||||
var/diff = world.time - sprint_buffer_regen_last
|
||||
sprint_buffer_regen_last = world.time
|
||||
sprint_buffer = min(sprint_buffer_max, sprint_buffer + sprint_buffer_regen_ds * diff)
|
||||
if(updating)
|
||||
update_hud_sprint_bar()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
var/oldpseudoheight = pseudo_z_axis
|
||||
. = ..()
|
||||
if(. && sprinting && !(movement_type & FLYING) && canmove && !resting && m_intent == MOVE_INTENT_RUN && has_gravity(loc) && !pulledby)
|
||||
adjustStaminaLossBuffered(0.3)
|
||||
doSprintLossTiles(1)
|
||||
if((oldpseudoheight - pseudo_z_axis) >= 8)
|
||||
to_chat(src, "<span class='warning'>You trip off of the elevated surface!</span>")
|
||||
for(var/obj/item/I in held_items)
|
||||
|
||||
3
modular_citadel/code/modules/mob/living/carbon/life.dm
Normal file
3
modular_citadel/code/modules/mob/living/carbon/life.dm
Normal file
@@ -0,0 +1,3 @@
|
||||
/mob/living/carbon/Life()
|
||||
. = ..()
|
||||
doSprintBufferRegen()
|
||||
@@ -1,2 +1,5 @@
|
||||
/mob/living/proc/adjustStaminaLossBuffered(amount, updating_stamina = TRUE, forced = FALSE)
|
||||
return
|
||||
|
||||
/mob/living/proc/doSprintLossTiles(amount)
|
||||
return
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
var/intentionalresting = FALSE
|
||||
var/attemptingcrawl = FALSE
|
||||
|
||||
//Sprint buffer---
|
||||
var/sprint_buffer = 42 //Tiles
|
||||
var/sprint_buffer_max = 42
|
||||
var/sprint_buffer_regen_ds = 0.3 //Tiles per world.time decisecond
|
||||
var/sprint_buffer_regen_last = 0 //last world.time this was regen'd for math.
|
||||
var/sprint_stamina_cost = 0.55 //stamina loss per tile while insufficient sprint buffer.
|
||||
//---End
|
||||
|
||||
/mob/living/movement_delay(ignorewalk = 0)
|
||||
. = ..()
|
||||
if(resting)
|
||||
@@ -118,3 +126,7 @@
|
||||
filters -= CIT_FILTER_STAMINACRIT
|
||||
update_canmove()
|
||||
update_health_hud()
|
||||
|
||||
/mob/living/proc/update_hud_sprint_bar()
|
||||
if(hud_used && hud_used.sprint_buffer)
|
||||
hud_used.sprint_buffer.update_to_mob(src)
|
||||
|
||||
@@ -2830,6 +2830,7 @@
|
||||
#include "modular_citadel\code\_onclick\item_attack.dm"
|
||||
#include "modular_citadel\code\_onclick\other_mobs.dm"
|
||||
#include "modular_citadel\code\_onclick\hud\screen_objects.dm"
|
||||
#include "modular_citadel\code\_onclick\hud\sprint.dm"
|
||||
#include "modular_citadel\code\_onclick\hud\stamina.dm"
|
||||
#include "modular_citadel\code\controllers\configuration\entries\general.dm"
|
||||
#include "modular_citadel\code\controllers\subsystem\job.dm"
|
||||
@@ -2991,6 +2992,7 @@
|
||||
#include "modular_citadel\code\modules\mob\living\status_procs.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\carbon.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\damage_procs.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\life.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\reindex_screams.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\human\human.dm"
|
||||
#include "modular_citadel\code\modules\mob\living\carbon\human\human_defense.dm"
|
||||
|
||||
Reference in New Issue
Block a user