relatively small 71 file 700 lines changed refactor/rework to combat mode/sprint and some miscellaneous things that totally aren't important (#11376)

* combat refactoring

* i hate this

* mobility flags part 2 time xd

* whew

* stuff

* a

* ok

* changes

* Wew

* k

* add flags

* FUCKYOUVORE

* fixes

* typo

* no using this in hard stamcrit

* update icon

* woopsy

* . = ..()

* sigh

* Update living_combat.dm

* wew

* wups

* fix

* i hate you

* wrong button

* k

* ok

* bet

* k

* Update code/modules/mob/living/living_combat.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update code/modules/mob/living/living_combat.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update code/modules/mob/living/living_combat.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* early returns

* skreee

* agony

* k

* k

* k

* k

* wack

* compile

* wack

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
kevinz000
2020-03-21 08:04:26 -07:00
committed by GitHub
parent 84a44e226c
commit 0e3193e929
79 changed files with 788 additions and 486 deletions
@@ -1,73 +1,29 @@
/mob/living/carbon
var/combatmode = FALSE //literally lifeweb
var/lastmousedir
var/wrongdirmovedelay
var/lastdirchange
var/combatmessagecooldown
//oh no vore time
var/voremode = FALSE
/mob/living/carbon/proc/toggle_combat_mode(forced, silent)
if(!forced)
if(recoveringstam || stat != CONSCIOUS)
return TRUE
for(var/i in status_effects)
var/datum/status_effect/S = i
if(S.blocks_combatmode)
return TRUE
combatmode = !combatmode
if(voremode)
toggle_vore_mode()
if(!silent)
if(combatmode)
if(world.time >= combatmessagecooldown)
if(a_intent != INTENT_HELP)
visible_message("<span class='warning'>[src] [resting ? "tenses up" : (prob(95)? "drops into a combative stance" : (prob(95)? "poses aggressively" : "asserts dominance with their pose"))].</span>")
else
visible_message("<span class='notice'>[src] [pick("looks","seems","goes")] [pick("alert","attentive","vigilant")].</span>")
playsound_local(src, 'sound/misc/ui_toggle.ogg', 50, FALSE, pressure_affected = FALSE) //Sound from interbay!
else
playsound_local(src, 'sound/misc/ui_toggleoff.ogg', 50, FALSE, pressure_affected = FALSE) //Slightly modified version of the above!
if(client)
client.show_popup_menus = !combatmode // So we can right-click for alternate actions and all that other good shit. Also moves examine to shift+rightclick to make it possible to attack while sprinting
var/obj/screen/combattoggle/T = locate() in hud_used?.static_inventory
T?.update_icon_state()
combatmessagecooldown = 10 SECONDS + world.time //This is set 100% of the time to make sure squeezing regen out of process cycles doesn't result in the combat mode message getting spammed
SEND_SIGNAL(src, COMSIG_COMBAT_TOGGLED, src, combatmode)
return TRUE
mob/living/carbon/proc/toggle_vore_mode()
/mob/living/carbon/proc/toggle_vore_mode()
voremode = !voremode
var/obj/screen/voretoggle/T = locate() in hud_used?.static_inventory
T?.update_icon_state()
if(combatmode)
if(combat_flags & COMBAT_FLAG_COMBAT_TOGGLED)
return FALSE //let's not override the main draw of the game these days
SEND_SIGNAL(src, COMSIG_VORE_TOGGLED, src, voremode)
return TRUE
/mob/living/carbon/Move(atom/newloc, direct = 0)
var/currentdirection = dir
. = ..()
wrongdirmovedelay = FALSE
if(combatmode && client && lastmousedir)
if((combat_flags & COMBAT_FLAG_COMBAT_ACTIVE) && client && lastmousedir)
if(lastmousedir != dir)
wrongdirmovedelay = TRUE
setDir(lastmousedir, ismousemovement = TRUE)
if(currentdirection != dir)
lastdirchange = world.time
/mob/living/carbon/onMouseMove(object, location, control, params)
if(!combatmode)
if(!(combat_flags & COMBAT_FLAG_COMBAT_ACTIVE))
return
mouse_face_atom(object)
lastmousedir = dir
/mob/living/carbon/setDir(newdir, ismousemovement = FALSE)
if(!combatmode || ismousemovement)
if(dir != newdir)
lastdirchange = world.time
. = ..()
else
return
@@ -15,24 +15,6 @@
if(!forced && (status_flags & GODMODE))
return FALSE
apply_damage(amount > 0 ? amount*incomingstammult : amount, STAMINA, affected_zone)
if(recoveringstam && amount > 20)
if((combat_flags & COMBAT_FLAG_HARD_STAMCRIT) && 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()
@@ -1,37 +0,0 @@
/mob/living/carbon/human/Move(NewLoc, direct)
var/oldpseudoheight = pseudo_z_axis
. = ..()
if(. && sprinting && !(movement_type & FLYING) && CHECK_MULTIPLE_BITFIELDS(mobility_flags, MOBILITY_MOVE|MOBILITY_STAND) && m_intent == MOVE_INTENT_RUN && has_gravity(loc) && !pulledby)
if(!HAS_TRAIT(src, TRAIT_FREESPRINT))
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)
accident(I)
DefaultCombatKnockdown(80)
/mob/living/carbon/human/movement_delay()
. = 0
if((mobility_flags & MOBILITY_STAND) && m_intent == MOVE_INTENT_RUN && sprinting)
var/static/datum/config_entry/number/movedelay/sprint_speed_increase/SSI
if(!SSI)
SSI = CONFIG_GET_ENTRY(number/movedelay/sprint_speed_increase)
. -= SSI.config_entry_value
if(wrongdirmovedelay)
. += 1
. += ..()
/mob/living/carbon/human/proc/togglesprint() // If you call this proc outside of hotkeys or clicking the HUD button, I'll be disappointed in you.
sprinting = !sprinting
if((m_intent == MOVE_INTENT_RUN) && CHECK_MULTIPLE_BITFIELDS(mobility_flags, MOBILITY_STAND|MOBILITY_MOVE))
if(sprinting)
playsound_local(src, 'sound/misc/sprintactivate.ogg', 50, FALSE, pressure_affected = FALSE)
else
playsound_local(src, 'sound/misc/sprintdeactivate.ogg', 50, FALSE, pressure_affected = FALSE)
var/obj/screen/sprintbutton/S = locate() in hud_used?.static_inventory
S?.update_icon_state()
return TRUE
/mob/living/carbon/human/proc/sprint_hotkey(targetstatus)
if(targetstatus ? !sprinting : sprinting)
togglesprint()
@@ -1,5 +1,2 @@
/mob/living/proc/adjustStaminaLossBuffered(amount, updating_health = TRUE, forced = FALSE)
return
/mob/living/proc/doSprintLossTiles(amount)
return
@@ -1,32 +1,4 @@
/mob/living
var/sprinting = FALSE
var/recoveringstam = FALSE
var/incomingstammult = 1
var/bufferedstam = 0
var/stambuffer = 20
var/stambufferregentime
var/attemptingstandup = FALSE
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.70 //stamina loss per tile while insufficient sprint buffer.
//---End
/mob/living/update_config_movespeed()
. = ..()
sprint_buffer_max = CONFIG_GET(number/movedelay/sprint_buffer_max)
sprint_buffer_regen_ds = CONFIG_GET(number/movedelay/sprint_buffer_regen_per_ds)
sprint_stamina_cost = CONFIG_GET(number/movedelay/sprint_stamina_cost)
/mob/living/movement_delay(ignorewalk = 0)
. = ..()
if(!CHECK_MOBILITY(src, MOBILITY_STAND))
. += 6
/atom
var/pseudo_z_axis
@@ -55,22 +27,23 @@
/mob/living/carbon/update_stamina()
var/total_health = getStaminaLoss()
if(total_health >= STAMINA_SOFTCRIT)
if(!(combat_flags & COMBAT_FLAG_SOFT_STAMCRIT))
ENABLE_BITFIELD(combat_flags, COMBAT_FLAG_SOFT_STAMCRIT)
else
if(combat_flags & COMBAT_FLAG_SOFT_STAMCRIT)
DISABLE_BITFIELD(combat_flags, COMBAT_FLAG_SOFT_STAMCRIT)
if(total_health)
if(!recoveringstam && total_health >= STAMINA_CRIT && !stat)
if(!(combat_flags & COMBAT_FLAG_HARD_STAMCRIT) && total_health >= STAMINA_CRIT && !stat)
to_chat(src, "<span class='notice'>You're too exhausted to keep going...</span>")
set_resting(TRUE, FALSE, FALSE)
if(combatmode)
toggle_combat_mode(TRUE)
recoveringstam = TRUE
disable_intentional_combat_mode(TRUE, FALSE)
ENABLE_BITFIELD(combat_flags, COMBAT_FLAG_HARD_STAMCRIT)
filters += CIT_FILTER_STAMINACRIT
update_mobility()
if(recoveringstam && total_health <= STAMINA_SOFTCRIT)
if((combat_flags & COMBAT_FLAG_HARD_STAMCRIT) && total_health <= STAMINA_SOFTCRIT)
to_chat(src, "<span class='notice'>You don't feel nearly as exhausted anymore.</span>")
recoveringstam = FALSE
DISABLE_BITFIELD(combat_flags, COMBAT_FLAG_HARD_STAMCRIT | COMBAT_FLAG_SOFT_STAMCRIT)
filters -= CIT_FILTER_STAMINACRIT
update_mobility()
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)
@@ -1,30 +0,0 @@
/mob/living/silicon/robot/Move(NewLoc, direct)
. = ..()
if(. && sprinting && !(movement_type & FLYING) && CHECK_MULTIPLE_BITFIELDS(mobility_flags, MOBILITY_STAND | MOBILITY_MOVE))
if(!(cell?.use(25)))
togglesprint(TRUE)
/mob/living/silicon/robot/movement_delay()
. = ..()
if(!resting && !sprinting)
. += 1
. += speed
/mob/living/silicon/robot/proc/togglesprint(shutdown = FALSE) //Basically a copypaste of the proc from /mob/living/carbon/human
if(!shutdown && (!cell || cell.charge < 25) || !cansprint)
return FALSE
sprinting = shutdown ? FALSE : !sprinting
if(CHECK_MULTIPLE_BITFIELDS(mobility_flags, MOBILITY_STAND|MOBILITY_MOVE))
if(sprinting)
playsound_local(src, 'sound/misc/sprintactivate.ogg', 50, FALSE, pressure_affected = FALSE)
else
if(shutdown)
playsound_local(src, 'sound/effects/light_flicker.ogg', 50, FALSE, pressure_affected = FALSE)
playsound_local(src, 'sound/misc/sprintdeactivate.ogg', 50, FALSE, pressure_affected = FALSE)
var/obj/screen/sprintbutton/S = locate() in hud_used?.static_inventory
S?.update_icon_state()
return TRUE
/mob/living/silicon/robot/proc/sprint_hotkey(targetstatus)
if(targetstatus ? !sprinting : sprinting)
togglesprint()