sprint stamina stuff

This commit is contained in:
kevinz000
2019-05-22 12:18:47 -07:00
parent d40d9791c4
commit 5d40d4b9a2
9 changed files with 80 additions and 24 deletions

View File

@@ -319,6 +319,9 @@
staminas = new /obj/screen/staminas()
infodisplay += staminas
sprint_buffer = new
infodisplay += sprint_buffer
if(!CONFIG_GET(flag/disable_stambuffer))
staminabuffer = new /obj/screen/staminabuffer()
infodisplay += staminabuffer

View File

@@ -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'

View File

@@ -0,0 +1,38 @@
/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 ubffer"
icon = 'icons/effects/progressbar.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)
icon_state = "prog_bar_[round(min((L.sprint_buffer / L.sprint_buffer_max) * 100, 100), 5)]"

View File

@@ -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 >= 1)
var/use = min(tiles, sprint_buffer)
sprint_buffer -= use
tiles -= use
if(!tiles) //we had enough, we're done!
return
adjustStaminaLoss(tiles * sprint_stamina_cost) //use stamina to cover deficit.
update_hud_sprint_bar()
/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()

View File

@@ -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)

View File

@@ -0,0 +1,2 @@
/mob/living/carbon/Life()
doSprintBufferRegen()

View File

@@ -1,2 +1,5 @@
/mob/living/proc/adjustStaminaLossBuffered(amount, updating_stamina = TRUE, forced = FALSE)
return
/mob/living/proc/doSprintLossTiles(amount)
return

View File

@@ -8,6 +8,14 @@
var/intentionalresting = FALSE
var/attemptingcrawl = FALSE
//Sprint buffer---
var/sprint_buffer = 35 //Tiles
var/sprint_buffer_max
var/sprint_buffer_regen_ds = 0.2 //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.3 //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)

View File

@@ -1226,13 +1226,13 @@
#include "code\modules\antagonists\clockcult\clock_scriptures\scripture_scripts.dm"
#include "code\modules\antagonists\clockcult\clock_structures\_trap_object.dm"
#include "code\modules\antagonists\clockcult\clock_structures\ark_of_the_clockwork_justicar.dm"
#include "code\modules\antagonists\clockcult\clock_structures\stargazer.dm"
#include "code\modules\antagonists\clockcult\clock_structures\clockwork_obelisk.dm"
#include "code\modules\antagonists\clockcult\clock_structures\eminence_spire.dm"
#include "code\modules\antagonists\clockcult\clock_structures\heralds_beacon.dm"
#include "code\modules\antagonists\clockcult\clock_structures\mania_motor.dm"
#include "code\modules\antagonists\clockcult\clock_structures\ocular_warden.dm"
#include "code\modules\antagonists\clockcult\clock_structures\ratvar_the_clockwork_justicar.dm"
#include "code\modules\antagonists\clockcult\clock_structures\stargazer.dm"
#include "code\modules\antagonists\clockcult\clock_structures\taunting_trail.dm"
#include "code\modules\antagonists\clockcult\clock_structures\wall_gear.dm"
#include "code\modules\antagonists\clockcult\clock_structures\trap_triggers\lever.dm"
@@ -2795,6 +2795,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"
@@ -2948,6 +2949,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"