Ports Bay's stamina/sprinting intent system. (#8805)

Now this might actually be the last of the ports before I actually code things I swear.

Ports Baystation12/Baystation12#25773 and adds sprinting by holding the shift key, also adding the option to add more movement intents for species with their own slowdown etc etc.
This commit is contained in:
Matt Atlas
2020-06-18 23:35:29 +03:00
committed by GitHub
parent ab7aeccca6
commit 56a3c517e7
60 changed files with 466 additions and 310 deletions
@@ -25,6 +25,12 @@
maxHealth = 33.3
health = 33.3
pass_flags = PASSTABLE
stamina = 35
stamina_recovery = 0.5
move_intents = list(
/decl/move_intent/walk,
/decl/move_intent/run
)
// Decorative head flower.
var/flower_color
@@ -76,11 +82,8 @@
/mob/living/carbon/alien/diona/movement_delay()
. = ..()
switch(m_intent)
if("walk")
. += 3
if("run")
species.handle_sprint_cost(src,.+config.walk_speed)
if(MOVING_QUICKLY(src))
species.handle_sprint_cost(src, . + config.walk_delay)
/mob/living/carbon/alien/diona/ex_act(severity)
if(life_tick < 4)
+17 -11
View File
@@ -35,20 +35,26 @@
. = ..()
if(.)
if(src.stat != 2)
if(src.nutrition)
adjustNutritionLoss(nutrition_loss*0.1)
if(src.hydration)
adjustHydrationLoss(hydration_loss*0.1)
if(src.stat != DEAD)
if((move_intent.flags & MOVE_INTENT_EXERTIVE) && src.bodytemperature <= (species ? species.heat_level_1 - 5 : 360))
bodytemperature += 2
if((FAT in src.mutations) && src.m_intent == "run" && src.bodytemperature <= 360)
src.bodytemperature += 2
var/nut_removed = nutrition_loss
var/hyd_removed = hydration_loss
if(move_intent.flags & MOVE_INTENT_EXERTIVE)
nut_removed *= 2
hyd_removed *= 2
// Moving around increases germ_level faster
if(germ_level < GERM_LEVEL_MOVE_CAP && prob(8))
germ_level++
if(nutrition)
adjustNutritionLoss(nut_removed*0.1)
if(hydration)
adjustHydrationLoss(hyd_removed*0.1)
src.help_up_offer = 0
// Moving around increases germ_level faster
if(germ_level < GERM_LEVEL_MOVE_CAP && prob(8))
germ_level++
src.help_up_offer = FALSE
/mob/living/carbon/relaymove(var/mob/living/user, direction)
if((user in contents) && istype(user))
@@ -179,7 +179,7 @@
..()
if(statpanel("Status"))
stat("Intent:", "[a_intent]")
stat("Move Mode:", "[m_intent]")
stat("Move Mode:", "[move_intent.name]")
if(emergency_shuttle)
var/eta_status = emergency_shuttle.get_status_panel_eta()
if(eta_status)
@@ -1484,13 +1484,20 @@
burn_mod = species.burn_mod
brute_mod = species.brute_mod
default_walk_intent = null
default_run_intent = null
move_intent = null
move_intents = species.move_intents.Copy()
set_move_intent(decls_repository.get_decl(move_intents[1]))
if(!istype(move_intent))
set_next_usable_move_intent()
max_stamina = species.stamina
stamina = max_stamina
sprint_speed_factor = species.sprint_speed_factor
sprint_cost_factor = species.sprint_cost_factor
stamina_recovery = species.stamina_recovery
exhaust_threshold = species.exhaust_threshold
max_nutrition = BASE_MAX_NUTRITION * species.max_nutrition_factor
max_hydration = BASE_MAX_HYDRATION * species.max_hydration_factor
@@ -375,8 +375,7 @@
M.do_attack_animation(src)
if(usesStamina)
M.stamina = M.stamina - disarm_cost //attempting to knock something out of someone's hands, or pushing them over, is exhausting!
M.stamina = Clamp(M.stamina, 0, M.max_stamina)
M.adjust_stamina(-disarm_cost) //attempting to knock something out of someone's hands, or pushing them over, is exhausting!
else
M.nutrition = M.nutrition - disarm_cost
M.nutrition = Clamp(M.nutrition, 0, M.max_nutrition)
@@ -1,36 +1,42 @@
/mob/living/carbon/human
move_intents = list(/decl/move_intent/walk)
/mob/living/carbon/human/movement_delay()
var/tally = ..()
var/tally = 0
if(species.slowdown)
tally = species.slowdown
tally += species.slowdown
if (istype(loc, /turf/space)) return -1 // It's hard to be slowed down in space by... anything
var/area/A = get_area(src)
if(A && !(A.has_gravity()))
tally -= 1
if (isopenturf(loc)) //open space checks
if(isopenturf(loc)) //open space checks
if(!(locate(/obj/structure/lattice, loc) || locate(/obj/structure/stairs, loc) || locate(/obj/structure/ladder, loc)))
return -1
if(embedded_flag)
handle_embedded_objects() //Moving with objects stuck in you can cause bad times.
var/health_deficiency = (100 - health)
if(health_deficiency >= 40) tally += (health_deficiency / 25)
if(can_feel_pain())
if(get_shock() >= 10) tally += (get_shock() / 10) //pain shouldn't slow you down if you can't even feel it
if(get_shock() >= 10)
tally += (get_shock() / 10) //pain shouldn't slow you down if you can't even feel it
for(var/obj/item/I in list(wear_suit, w_uniform, back, gloves, head))
tally += I.slowdown
var/health_deficiency = (maxHealth - health)
if(health_deficiency >= 40)
tally += (health_deficiency / 25)
if(species)
tally += species.get_species_tally(src)
if (nutrition < (max_nutrition * 0.2))
if(nutrition < (max_nutrition * 0.2))
tally++
if (nutrition < (max_nutrition * 0.1))
tally++
if (hydration < (max_hydration * 0.2))
if(hydration < (max_hydration * 0.2))
tally++
if (hydration < (max_hydration * 0.1))
tally++
@@ -58,40 +64,41 @@
tally += 1.5
if (can_feel_pain())
if(shock_stage >= 10)
if(shock_stage >= 10 || get_stamina() <= 0)
tally += 3
if(is_asystole())
tally += 10 //heart attacks are kinda distracting
if(aiming && aiming.aiming_at) tally += 5 // Iron sights make you slower, it's a well-known fact.
if(aiming && aiming.aiming_at)
tally += 5 // Iron sights make you slower, it's a well-known fact.
if (drowsyness) tally += 6
if(drowsyness)
tally += 6
if (!(species.flags & IS_MECHANICAL)) // Machines don't move slower when cold.
if(!(species.flags & IS_MECHANICAL)) // Machines don't move slower when cold.
if(FAT in src.mutations)
tally += 1.5
if (bodytemperature < 283.222)
tally += (283.222 - bodytemperature) / 10 * 1.75
tally += max(2 * stance_damage, 0) //damaged/missing feet or legs is slow
if(mRun in mutations)
tally = 0
tally += move_delay_mod
if(tally > 0 && (CE_SPEEDBOOST in chem_effects))
tally = max(0, tally-3)
tally = max(0, tally - 3)
var/turf/T = get_turf(src)
if(T)
tally += T.movement_cost
tally += config.human_delay
tally = round(tally, 1)
tally = round(tally,1)
return tally
return tally + config.human_delay
/mob/living/carbon/human/Allow_Spacemove(var/check_drift = 0)
@@ -155,7 +162,7 @@
return
last_x = x
last_y = y
if (m_intent == "run")
if (MOVING_QUICKLY(src))
playsound(src, footsound, 70, 1, required_asfx_toggles = ASFX_FOOTSTEPS)
else
footstep++
@@ -169,3 +176,6 @@
/mob/living/carbon/human/mob_negates_gravity()
return (shoes && shoes.negates_gravity())
/mob/living/carbon/human/can_sprint()
return (stamina > 0)
@@ -90,14 +90,14 @@
var/mob/living/carbon/human/H = target
if(istype(H))
H.move_delay_mod += -0.75
H.sprint_cost_factor += -0.1
H.sprint_cost_factor += -0.2
/datum/modifier/buzzed/deactivate()
..()
var/mob/living/carbon/human/H = target
if(istype(H))
H.move_delay_mod -= -0.75
H.sprint_cost_factor -= -0.1
H.sprint_cost_factor -= -0.2
/datum/modifier/buzzed/custom_validity()
var/mob/living/carbon/human/H = target
@@ -116,14 +116,14 @@
var/mob/living/carbon/human/H = target
if(istype(H))
H.move_delay_mod += 2
H.sprint_cost_factor += 0.2
H.sprint_cost_factor += 0.4
/datum/modifier/drunk/deactivate()
..()
var/mob/living/carbon/human/H = target
if(istype(H))
H.move_delay_mod -= 2
H.sprint_cost_factor -= -0.2
H.sprint_cost_factor -= -0.4
/datum/modifier/drunk/custom_validity()
var/mob/living/carbon/human/H = target
+25 -34
View File
@@ -74,7 +74,6 @@
handle_medical_side_effects()
//Handles regenerating stamina if we have sufficient air and no oxyloss
handle_stamina()
if (is_diona())
@@ -85,7 +84,7 @@
handle_stasis_bag()
if(!handle_some_updates())
return //We go ahead and process them 5 times for HUD images and other stuff though.
return //We go ahead and process them 5 times for HUD images and other stuff though.
//Update our name based on whether our face is obscured/disfigured
name = get_visible_name()
@@ -97,6 +96,30 @@
..()
species.handle_npc(src)
/mob/living/carbon/human/get_stamina()
return stamina
/mob/living/carbon/human/get_maximum_stamina()
return max_stamina
/mob/living/carbon/human/adjust_stamina(var/amt)
var/last_stamina = stamina
if(stat == DEAD)
stamina = 0
else
stamina = Clamp(stamina + amt, 0, max_stamina)
if(stamina <= 0)
to_chat(src, SPAN_WARNING("You are exhausted!"))
if(MOVING_QUICKLY(src))
set_moving_slowly()
if(last_stamina != stamina && hud_used)
hud_used.move_intent.update_stamina_bar(src)
/mob/living/carbon/human/proc/handle_stamina()
if((world.time - last_quick_move_time) > 5 SECONDS)
var/mod = (lying + (nutrition / initial(nutrition))) / 2
adjust_stamina(max(config.minimum_stamina_recovery, config.maximum_stamina_recovery * mod) * (1+chem_effects[CE_ENERGETIC]))
/mob/living/carbon/human/proc/handle_some_updates()
if(life_tick > 5 && timeofdeath && (timeofdeath < 5 || world.time - timeofdeath > 6000)) //We are long dead, or we're junk mobs spawned like the clowns on the clown shuttle
return 0
@@ -1311,38 +1334,6 @@
if(XRAY in mutations)
sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
/mob/living/carbon/human/proc/handle_stamina()
if (species.stamina == -1) //If species stamina is -1, it has special mechanics which will be handled elsewhere
return //so quit this function
if (!exhaust_threshold) // Also quit if there's no exhaust threshold specified, because division by 0 is amazing.
return
if (failed_last_breath || (getOxyLoss() + get_shock()) > exhaust_threshold)//Can't catch our breath if we're suffocating
flash_pain()
return
if (nutrition <= 0)
if (prob(1.5))
to_chat(src, span("warning", "You feel hungry and exhausted, eat something to regain your energy!"))
return
if (hydration <= 0)
if (prob(1.5))
to_chat(src, span("warning", "You feel thirsty and exhausted, drink something to regain your energy!"))
return
if (stamina != max_stamina)
//Any suffocation damage slows stamina regen.
//This includes oxyloss from low blood levels
var/regen = stamina_recovery * (1 - min(((getOxyLoss()) / exhaust_threshold) + ((get_shock()) / exhaust_threshold), 1))
if (regen > 0)
stamina = min(max_stamina, stamina+regen)
adjustNutritionLoss(stamina_recovery*0.09)
adjustHydrationLoss(stamina_recovery*0.32)
if (client)
hud_used.move_intent.update_move_icon(src)
/mob/living/carbon/human/proc/update_oxy_overlay()
var/new_oxy
if(getOxyLoss())
@@ -79,7 +79,6 @@
stamina = 500 //Tireless automatons
stamina_recovery = 1
sprint_speed_factor = 0.3
exhaust_threshold = 0 //No oxyloss, so zero threshold
inherent_verbs = list(
/mob/living/carbon/human/proc/shatter_light,
@@ -85,7 +85,6 @@
stamina = 500 //Tireless automatons
stamina_recovery = 1
sprint_speed_factor = 0.3
exhaust_threshold = 0 //No oxyloss, so zero threshold
max_nutrition_factor = -1
@@ -133,7 +132,6 @@
stamina = 500 //Tireless automatons
stamina_recovery = 1
sprint_speed_factor = 0.3
exhaust_threshold = 0 //No oxyloss, so zero threshold
max_nutrition_factor = -1
@@ -210,7 +208,6 @@
stamina = 500 //Tireless automatons
stamina_recovery = 1
sprint_speed_factor = 0.3
exhaust_threshold = 0 //No oxyloss, so zero threshold
inherent_verbs = list(/mob/living/carbon/human/proc/darkness_eyes)
@@ -98,7 +98,7 @@
stamina = 120 // Vox are even faster than unathi and can go longer, but recover slowly
sprint_speed_factor = 3
stamina_recovery = 1
sprint_cost_factor = 0.7
sprint_cost_factor = 1.4
cold_level_1 = 80
cold_level_2 = 50
@@ -165,6 +165,8 @@
var/appearance_flags = 0 // Appearance/display related features.
var/spawn_flags = 0 // Flags that specify who can spawn as this species
var/slowdown = 0 // Passive movement speed malus (or boost, if negative)
// Move intents. Earlier in list == default for that type of movement.
var/list/move_intents = list(/decl/move_intent/walk, /decl/move_intent/run, /decl/move_intent/creep)
var/primitive_form // Lesser form, if any (ie. monkey for humans)
var/greater_form // Greater form, if any, ie. human for monkeys.
var/holder_type
@@ -176,7 +178,6 @@
var/stamina_recovery = 3 // Flat amount of stamina species recovers per proc
var/sprint_speed_factor = 0.7 // The percentage of bonus speed you get when sprinting. 0.4 = 40%
var/sprint_cost_factor = 0.9 // Multiplier on stamina cost for sprinting
var/exhaust_threshold = 50 // When stamina runs out, the mob takes oxyloss up til this value. Then collapses and drops to walk
var/gluttonous = 0 // Can eat some mobs. Values can be GLUT_TINY, GLUT_SMALLER, GLUT_ANYTHING, GLUT_ITEM_TINY, GLUT_ITEM_NORMAL, GLUT_ITEM_ANYTHING, GLUT_PROJECTILE_VOMIT
var/stomach_capacity = 5 // How much stuff they can stick in their stomach
@@ -501,53 +502,6 @@
return 1
/datum/species/proc/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
if (!H.exhaust_threshold)
return 1 // Handled.
cost *= H.sprint_cost_factor
if (H.stamina == -1)
log_debug("Error: Species with special sprint mechanics has not overridden cost function.")
return 0
var/remainder = 0
if (H.stamina > cost)
H.stamina -= cost
H.hud_used.move_intent.update_move_icon(H)
return 1
else if (H.stamina > 0)
remainder = cost - H.stamina
H.stamina = 0
else
remainder = cost
if(H.disabilities & ASTHMA)
H.adjustOxyLoss(remainder*0.15)
if(H.disabilities & COUGHING)
H.adjustHalLoss(remainder*0.1)
if (breathing_organ && has_organ[breathing_organ])
var/obj/item/organ/O = H.internal_organs_by_name[breathing_organ]
if(O.is_bruised())
H.adjustOxyLoss(remainder*0.15)
H.adjustHalLoss(remainder*0.25)
H.adjustHalLoss(remainder*0.25)
H.updatehealth()
if((H.get_shock() >= 10) && prob(H.get_shock() *2))
H.flash_pain()
if ((H.get_shock() + H.getOxyLoss()) >= (exhaust_threshold * 0.8))
H.m_intent = "walk"
H.hud_used.move_intent.update_move_icon(H)
to_chat(H, span("danger", "You're too exhausted to run anymore!"))
H.flash_pain()
return 0
H.hud_used.move_intent.update_move_icon(H)
return 1
/datum/species/proc/get_light_color(mob/living/carbon/human/H)
return
@@ -603,3 +557,9 @@
/datum/species/proc/handle_despawn()
return
/datum/species/proc/has_special_sprint()
return FALSE
/datum/species/proc/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
return
@@ -111,9 +111,9 @@
reagent_tag = IS_DIONA
stamina = -1 // Diona sprinting uses energy instead of stamina
sprint_speed_factor = 0.5 //Speed gained is minor
sprint_cost_factor = 0.8
stamina = 1 // Diona sprinting uses energy instead of stamina
sprint_speed_factor = 0.6 //Speed gained is minor
sprint_cost_factor = 1.6
climb_coeff = 1.3
vision_organ = BP_HEAD
@@ -122,34 +122,33 @@
allowed_citizenships = list(CITIZENSHIP_BIESEL, CITIZENSHIP_JARGON, CITIZENSHIP_SOL, CITIZENSHIP_COALITION, CITIZENSHIP_DOMINIA, CITIZENSHIP_IZWESKI, CITIZENSHIP_NONE)
allowed_religions = list(RELIGION_QEBLAK, RELIGION_WEISHII, RELIGION_MOROZ, RELIGION_THAKH, RELIGION_SKAKH, RELIGION_NONE, RELIGION_OTHER)
/datum/species/diona/has_special_sprint()
return TRUE
/datum/species/diona/handle_sprint_cost(var/mob/living/carbon/H, var/cost)
var/datum/dionastats/DS = H.get_dionastats()
if (!DS)
return 0 //Something is very wrong
return //Something is very wrong
var/remainder = cost * H.sprint_cost_factor
if (H.total_radiation && !DS.regening_organ)
if (H.total_radiation > (cost*0.5))//Radiation counts as double energy
H.apply_radiation(cost*(-0.5))
return 1
else
remainder = cost - (H.total_radiation*2)
H.total_radiation = 0
if (DS.stored_energy > remainder)
DS.stored_energy -= remainder
return 1
else
remainder -= DS.stored_energy
DS.stored_energy = 0
H.adjustHalLoss(remainder*5, 1)
H.updatehealth()
H.m_intent = "walk"
H.hud_used.move_intent.update_move_icon(H)
H.set_moving_slowly()
to_chat(H, span("danger", "We have expended our energy reserves, and cannot continue to move at such a pace. We must find light!"))
return 0
/datum/species/diona/can_understand(var/mob/other)
var/mob/living/carbon/alien/diona/D = other
@@ -85,7 +85,6 @@ var/global/list/golem_types = list("Coal Golem",
stamina = 500 //Tireless automatons
stamina_recovery = 1
sprint_speed_factor = 0.3
exhaust_threshold = 0 //No oxyloss, so zero threshold
remains_type = /obj/effect/decal/cleanable/ash
@@ -31,7 +31,7 @@
stamina = 130 // Humans can sprint for longer than any other species
stamina_recovery = 5
sprint_speed_factor = 0.9
sprint_cost_factor = 0.5
sprint_cost_factor = 1.25
grab_mod = 1.25 //humans are wily fuckers - geeves
climb_coeff = 1
@@ -107,8 +107,8 @@
heat_discomfort_strings = list(
"Your CPU temperature probes warn you that you are approaching critical heat levels!"
)
stamina = -1 // Machines use power and generate heat, stamina is not a thing
sprint_speed_factor = 1 // About as capable of speed as a human
stamina = 1 // Machines use power and generate heat, stamina is not a thing
sprint_speed_factor = 0.8 //Slightly slower than a human.
max_hydration_factor = -1
@@ -124,21 +124,6 @@ datum/species/machine/handle_post_spawn(var/mob/living/carbon/human/H)
. = ..()
check_tag(H, H.client)
/datum/species/machine/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
if (H.stat == CONSCIOUS)
H.bodytemperature += cost * sprint_temperature_factor
H.adjustNutritionLoss(cost * sprint_charge_factor)
if(H.nutrition <= 0 && H.max_nutrition > 0)
H.Weaken(15)
H.m_intent = "walk"
H.hud_used.move_intent.update_move_icon(H)
to_chat(H, span("danger", "ERROR: Power reserves depleted, emergency shutdown engaged. Backup power will come online in approximately 30 seconds, initiate charging as primary directive."))
playsound(H.loc, 'sound/machines/buzz-two.ogg', 100, 0)
else
return 1
return 0
/datum/species/machine/handle_death(var/mob/living/carbon/human/H)
..()
H.f_style = ""
@@ -297,6 +282,22 @@ datum/species/machine/handle_post_spawn(var/mob/living/carbon/human/H)
. = ..()
check_tag(H, H.client)
/datum/species/machine/has_special_sprint()
return TRUE
/datum/species/machine/handle_sprint_cost(var/mob/living/carbon/human/H, var/cost)
if (H.stat == CONSCIOUS)
H.bodytemperature += cost * sprint_temperature_factor
H.adjustNutritionLoss(cost * sprint_charge_factor)
if(H.nutrition <= 0 && H.max_nutrition > 0)
H.Weaken(15)
H.set_moving_slowly()
to_chat(H, span("danger", "ERROR: Power reserves depleted, emergency shutdown engaged. Backup power will come online in approximately 30 seconds, initiate charging as primary directive."))
playsound(get_turf(H), 'sound/machines/buzz-two.ogg', 100, 0)
else
return
return
/datum/species/machine/handle_death_check(var/mob/living/carbon/human/H)
if(H.get_total_health() <= config.health_threshold_dead)
return TRUE
@@ -32,7 +32,7 @@
stamina = 90 // Tajara evolved to maintain a steady pace in the snow, sprinting wastes energy
stamina_recovery = 4
sprint_speed_factor = 0.65
sprint_cost_factor = 0.75
sprint_cost_factor = 1.5
blurb = "The Tajaran race is a species of feline-like bipeds hailing from the planet of Adhomai in the S'rendarr \
system. They have been brought up into the space age by the Humans and Skrell, who alledgedly influenced their \
@@ -36,9 +36,8 @@
stamina = 120 // Unathi have the shortest but fastest sprint of all
stamina_recovery = 5
sprint_cost_factor = 1.45
sprint_cost_factor = 7
sprint_speed_factor = 3.2
exhaust_threshold = 65
rarity_value = 3
breakcuffs = list(MALE)
@@ -89,7 +89,7 @@
stamina = 100 // Long period of sprinting, but relatively low speed gain
sprint_speed_factor = 0.7
sprint_cost_factor = 0.30
sprint_cost_factor = 0.6
stamina_recovery = 2 //slow recovery
has_organ = list(
@@ -31,7 +31,7 @@
stamina = 115
sprint_speed_factor = 1.0
sprint_cost_factor = 0.40
sprint_cost_factor = 0.8
stamina_recovery = 3
@@ -70,7 +70,7 @@
stamina = 175
sprint_speed_factor = 1
sprint_cost_factor = 0.80
sprint_cost_factor = 1.6
stamina_recovery = 3
spawn_flags = IS_RESTRICTED
@@ -126,7 +126,7 @@
stamina = 200
stamina_recovery = 5
sprint_speed_factor = 0.9
sprint_cost_factor = 0.5
sprint_cost_factor = 1.0
heat_level_1 = 1000 //Default 360
heat_level_2 = 4000 //Default 400
@@ -1112,11 +1112,8 @@ There are several things that need to be remembered:
standing = image('icons/mob/mob.dmi', "legcuff1")
overlays_raw[LEGCUFF_LAYER] = standing
if(m_intent != "walk")
m_intent = "walk"
if(hud_used && hud_used.move_intent)
hud_used.move_intent.icon_state = "walking"
if(!MOVING_DELIBERATELY(src))
set_moving_slowly()
else
overlays_raw[LEGCUFF_LAYER] = null
+1 -1
View File
@@ -202,7 +202,7 @@
if((isunathi(src)) || (HULK in mutations))
say(pick("RAAAAAAAARGH!", "HNNNNNNNNNGGGGGGH!", "GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", "AAAAAAARRRGH!" ))
stamina -= 100 //takes a bunch of stamina
stamina = max(0, (stamina - 100)) //takes a bunch of stamina
qdel(handcuffed)
handcuffed = null
+7 -2
View File
@@ -123,7 +123,12 @@ default behaviour is:
now_pushing = FALSE
spawn(0)
. = ..()
if (!istype(AM, /atom/movable))
if (!istype(AM, /atom/movable) || AM.anchored)
if(confused && prob(50) && !MOVING_DELIBERATELY(src))
Weaken(2)
playsound(loc, "punch", 25, 1, -1)
visible_message(SPAN_WARNING("\The [src] [pick("ran", "slammed")] into \the [AM]!"))
src.apply_damage(5, BRUTE)
return
if (!now_pushing)
now_pushing = TRUE
@@ -927,4 +932,4 @@ default behaviour is:
if(auras)
for(var/a in auras)
remove_aura(a)
return ..()
return ..()
+2 -3
View File
@@ -49,13 +49,12 @@
//These values are duplicated from the species datum so we can handle things on a per-mob basis, allows for chemicals to affect them
var/stamina = 0
var/max_stamina = 100//Maximum stamina. We start taking oxyloss when this runs out while sprinting
var/max_stamina = 100 //Maximum stamina.
var/sprint_speed_factor = 0.4
var/sprint_cost_factor = 1
var/stamina_recovery = 1
var/min_walk_delay = 0//When move intent is walk, movedelay is clamped to this value as a lower bound
var/exhaust_threshold = 50
var/datum/progressbar/stamina_bar // Progress bar shown when stamina is not at full, and the mob supports stamina. Deleted on Logout or when stamina is full.
var/datum/progressbar/stamina_bar
var/move_delay_mod = 0//Added to move delay, used for calculating movement speeds. Provides a centralised value for modifiers to alter
+1 -1
View File
@@ -20,7 +20,7 @@
//First a quick block of code to calculate our normal/best movedelay
var/delay = config.walk_speed + movement_delay()
var/delay = config.walk_delay + movement_delay()
var/speed = 1 / (delay/10)
var/newspeed
var/list/options = list("No limit",speed*0.95,speed*0.9,speed*0.85,speed*0.8,speed*0.7,speed*0.6,speed*0.5, "Custom")
+2 -2
View File
@@ -1,7 +1,7 @@
/mob/living/Logout()
if (stamina_bar)
QDEL_NULL(stamina_bar)
..()
if(stamina_bar)
QDEL_NULL(stamina_bar)
if (mind)
//Per BYOND docs key remains set if the player DCs, becomes null if switching bodies.
if(!key) //key and mind have become seperated.
+1 -1
View File
@@ -112,7 +112,7 @@
light_wedge = 45
/mob/living/silicon/pai/movement_delay()
return 0.8
return 4
/mob/living/silicon/pai/attack_hand(mob/living/carbon/human/M)
..()
@@ -114,6 +114,8 @@
var/list/butchering_products //if anything else is created when butchering this creature, like bones and leather
move_intent = /decl/move_intent/walk/animal
/mob/living/simple_animal/proc/update_nutrition_stats()
nutrition_step = mob_size * 0.03 * metabolic_factor
@@ -481,9 +483,9 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
/mob/living/simple_animal/movement_delay()
var/tally = 0 //Incase I need to add stuff other than "speed" later
var/tally = ..()
tally = speed
tally += speed
if(purge)//Purged creatures will move more slowly. The more time before their purge stops, the slower they'll move.
if(tally <= 0)
tally = 1
@@ -492,7 +494,7 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
if (!nutrition)
tally += 4
return tally+config.animal_delay
return tally + config.animal_delay
/mob/living/simple_animal/cat/proc/handle_movement_target()
//if our target is neither inside a turf or inside a human(???), stop
+7 -2
View File
@@ -74,10 +74,14 @@
dead_mob_list += src
else
living_mob_list += src
if (!ckey && mob_thinks)
MOB_START_THINKING(src)
if(!move_intent)
move_intent = move_intents[1]
if(ispath(move_intent))
move_intent = decls_repository.get_decl(move_intent)
/mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
if(!client) return
@@ -207,7 +211,7 @@
return 0
/mob/proc/movement_delay()
return 0
. = move_intent.move_delay
/mob/proc/Life()
return
@@ -215,6 +219,7 @@
#define UNBUCKLED 0
#define PARTIALLY_BUCKLED 1
#define FULLY_BUCKLED 2
/mob/proc/buckled()
// Preliminary work for a future buckle rewrite,
// where one might be fully restrained (like an elecrical chair), or merely secured (shuttle chair, keeping you safe but not otherwise restrained from acting)
+8 -2
View File
@@ -6,7 +6,7 @@
sight = DEFAULT_SIGHT
var/datum/mind/mind
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
var/stat = CONSCIOUS //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
var/can_buckle = TRUE
var/obj/screen/flash = null
@@ -132,7 +132,6 @@
var/intent = null//Living
var/shakecamera = 0
var/a_intent = I_HELP//Living
var/m_intent = "walk"//Living
var/lastKnownIP = null
var/obj/buckled = null//Living
var/obj/item/l_hand = null//Living
@@ -142,6 +141,13 @@
var/obj/item/storage/s_active = null//Carbon
var/obj/item/clothing/mask/wear_mask = null//Carbon
var/decl/move_intent/move_intent = /decl/move_intent/walk
var/list/move_intents = list(/decl/move_intent/walk)
var/decl/move_intent/default_walk_intent
var/decl/move_intent/default_run_intent
var/last_quick_move_time = 0
var/seer = 0 //for cult//Carbon, probably Human
var/datum/hud/hud_used = null
+114 -20
View File
@@ -229,9 +229,6 @@
if(!mob.canmove)
return
//if(istype(mob.loc, /turf/space) || (mob.flags & NOGRAV))
// if(!mob.Process_Spacemove(0)) return 0
if(!mob.lastarea)
mob.lastarea = get_area(mob.loc)
@@ -245,7 +242,6 @@
else
mob.inertia_dir = 0 //If not then we can reset inertia and move
if(mob.restrained()) //Why being pulled while cuffed prevents you from moving
for(var/mob/M in range(mob, 1))
if(M.pulling == mob)
@@ -285,28 +281,27 @@
//drunk wheelchair driving
if(mob.confused && prob(25))
direct = pick(cardinal)
move_delay += max((mob.movement_delay() + config.walk_speed) * config.walk_delay_multiplier, min_move_delay)
move_delay += max((mob.movement_delay() + config.walk_delay) * config.walk_delay_multiplier, min_move_delay)
return mob.buckled.relaymove(mob,direct)
var/tally = mob.movement_delay() + config.walk_speed
var/tally = mob.movement_delay()
var/mob_is_human = ishuman(mob) //Calculate this once to reuse it later.
// Apply human specific modifiers.
var/mob_is_human = ishuman(mob) // Only check this once and just reuse the value.
if (mob_is_human)
if(mob_is_human)
var/mob/living/carbon/human/H = mob
//If we're sprinting and able to continue sprinting, then apply the sprint bonus ontop of this
if (H.m_intent == "run" && H.species.handle_sprint_cost(H, tally)) //This will return false if we collapse from exhaustion
if(MOVING_QUICKLY(H))
if(H.species.has_special_sprint())
H.species.handle_sprint_cost(H, tally)
else
H.adjust_stamina(-(H.get_stamina_used_per_step()))
tally = (tally / (1 + H.sprint_speed_factor)) * config.run_delay_multiplier
H.last_quick_move_time = world.time
else
tally = max(tally * config.walk_delay_multiplier, H.min_walk_delay) //clamp walking speed if its limited
else
tally *= config.walk_delay_multiplier
tally = max(tally * config.walk_delay_multiplier, H.min_walk_delay)
move_delay += tally
var/tickcomp = 0 //moved this out here so we can use it for vehicles
if(config.Tickcomp)
// move_delay -= 1.3 //~added to the tickcomp calculation below
tickcomp = ((1/(world.tick_lag))*1.3) - 1.3
move_delay = move_delay + tickcomp
@@ -347,10 +342,10 @@
if(mob != M)
M.animate_movement = 3
for(var/mob/M in L)
spawn( 0 )
spawn(0)
step(M, direct)
return
spawn( 1 )
spawn(1)
M.other_mobs = null
M.animate_movement = 2
return
@@ -360,12 +355,12 @@
else
. = mob.SelfMove(n, direct)
for (var/obj/item/grab/G in list(mob:l_hand, mob:r_hand))
for(var/obj/item/grab/G in list(mob:l_hand, mob:r_hand))
if (G.state == GRAB_NECK)
mob.set_dir(reverse_dir[direct])
G.adjust_position()
for (var/obj/item/grab/G in mob.grabbed_by)
for(var/obj/item/grab/G in mob.grabbed_by)
G.adjust_position()
moving = 0
@@ -374,6 +369,12 @@
var/atom/O = mob.loc
return O.relaymove(mob, direct)
/mob/proc/get_stamina_used_per_step()
return 1
/mob/living/carbon/human/get_stamina_used_per_step()
return sprint_cost_factor
/mob/proc/SelfMove(turf/n, direct)
return Move(n, direct)
@@ -550,3 +551,96 @@
/mob/proc/mob_negates_gravity()
return 0
/mob/proc/set_next_usable_move_intent()
var/checking_intent = (istype(move_intent) ? move_intent.type : move_intents[1])
for(var/i = 1 to length(move_intents)) // One full iteration of the move set.
checking_intent = next_in_list(checking_intent, move_intents)
if(set_move_intent(decls_repository.get_decl(checking_intent)))
return
/mob/proc/set_move_intent(var/decl/move_intent/next_intent)
if(next_intent && move_intent != next_intent && next_intent.can_be_used_by(src))
move_intent = next_intent
if(hud_used)
hud_used.move_intent.icon_state = move_intent.hud_icon_state
return TRUE
return FALSE
/mob/proc/get_movement_datum_by_flag(var/move_flag = MOVE_INTENT_DELIBERATE)
for(var/m_intent in move_intents)
var/decl/move_intent/check_move_intent = decls_repository.get_decl(m_intent)
if(check_move_intent.flags & move_flag)
return check_move_intent
/mob/proc/get_movement_datum_by_missing_flag(var/move_flag = MOVE_INTENT_DELIBERATE)
for(var/m_intent in move_intents)
var/decl/move_intent/check_move_intent = decls_repository.get_decl(m_intent)
if(!(check_move_intent.flags & move_flag))
return check_move_intent
/mob/proc/get_movement_datums_by_flag(var/move_flag = MOVE_INTENT_DELIBERATE)
. = list()
for(var/m_intent in move_intents)
var/decl/move_intent/check_move_intent = decls_repository.get_decl(m_intent)
if(check_move_intent.flags & move_flag)
. += check_move_intent
/mob/proc/get_movement_datums_by_missing_flag(var/move_flag = MOVE_INTENT_DELIBERATE)
. = list()
for(var/m_intent in move_intents)
var/decl/move_intent/check_move_intent = decls_repository.get_decl(m_intent)
if(!(check_move_intent.flags & move_flag))
. += check_move_intent
/mob/verb/SetDefaultWalk()
set name = "Set Default Walk"
set desc = "Select your default walking style."
set category = "IC"
var/choice = input(usr, "Select a default walk.", "Set Default Walk") as null|anything in get_movement_datums_by_missing_flag(MOVE_INTENT_QUICK)
if(choice && (choice in get_movement_datums_by_missing_flag(MOVE_INTENT_QUICK)))
default_walk_intent = choice
to_chat(src, "You will now default to [default_walk_intent] when moving deliberately.")
/mob/verb/SetDefaultRun()
set name = "Set Default Run"
set desc = "Select your default running style."
set category = "IC"
var/choice = input(usr, "Select a default run.", "Set Default Run") as null|anything in get_movement_datums_by_flag(MOVE_INTENT_QUICK)
if(choice && (choice in get_movement_datums_by_flag(MOVE_INTENT_QUICK)))
default_run_intent = choice
to_chat(src, "You will now default to [default_run_intent] when moving quickly.")
/client/verb/setmovingslowly()
set hidden = 1
if(mob)
mob.set_moving_slowly()
/mob/proc/set_moving_slowly()
if(!default_walk_intent)
default_walk_intent = get_movement_datum_by_missing_flag(MOVE_INTENT_QUICK)
if(default_walk_intent && move_intent != default_walk_intent)
set_move_intent(default_walk_intent)
/client/verb/setmovingquickly()
set hidden = 1
if(mob)
mob.set_moving_quickly()
/mob/proc/set_moving_quickly()
if(!default_run_intent)
default_run_intent = get_movement_datum_by_flag(MOVE_INTENT_QUICK)
if(default_run_intent && move_intent != default_run_intent)
set_move_intent(default_run_intent)
/mob/proc/can_sprint()
return FALSE
/mob/proc/adjust_stamina(var/amt)
return
/mob/proc/get_stamina()
return 100
/mob/proc/get_maximum_stamina()
return 100