Converts gravity slowdown into a movespeed mod and removes movement_delay() (#47808)

Gravity still needs a rewrite but at least it's a speed modification now.

EDIT: And now it's the last one, goodbye movement_delay()!

cl ninjanomnom
fix: Gravity slowdown applies to all mobs instead of just humanoids
tweak: If you're floating in high gravity somehow you're no longer slowed down
/cl
This commit is contained in:
Emmett Gaines
2019-11-17 13:21:31 +13:00
committed by oranges
parent c2985cc5a4
commit 6ffc35a83b
12 changed files with 61 additions and 86 deletions
+1
View File
@@ -19,6 +19,7 @@
#define MOVESPEED_ID_MOB_WALK_RUN_CONFIG_SPEED "MOB_WALK_RUN"
#define MOVESPEED_ID_MOB_GRAB_STATE "MOB_GRAB_STATE"
#define MOVESPEED_ID_MOB_EQUIPMENT "MOB_EQUIPMENT"
#define MOVESPEED_ID_MOB_GRAVITY "MOB_GRAVITY"
#define MOVESPEED_ID_CONFIG_SPEEDMOD "MOB_CONFIG_MODIFIER"
#define MOVESPEED_ID_SLIME_REAGENTMOD "SLIME_REAGENT_MODIFIER"
-45
View File
@@ -622,51 +622,6 @@ GLOBAL_LIST_EMPTY(teleportlocs)
/client/proc/ResetAmbiencePlayed()
played = FALSE
/**
* Returns true if this atom has gravity for the passed in turf
*
* Sends signals COMSIG_ATOM_HAS_GRAVITY and COMSIG_TURF_HAS_GRAVITY, both can force gravity with
* the forced gravity var
*
* Gravity situations:
* * No gravity if you're not in a turf
* * No gravity if this atom is in is a space turf
* * Gravity if the area it's in always has gravity
* * Gravity if there's a gravity generator on the z level
* * Gravity if the Z level has an SSMappingTrait for ZTRAIT_GRAVITY
* * otherwise no gravity
*/
/atom/proc/has_gravity(turf/T)
if(!T || !isturf(T))
T = get_turf(src)
if(!T)
return 0
var/list/forced_gravity = list()
SEND_SIGNAL(src, COMSIG_ATOM_HAS_GRAVITY, T, forced_gravity)
if(!forced_gravity.len)
SEND_SIGNAL(T, COMSIG_TURF_HAS_GRAVITY, src, forced_gravity)
if(forced_gravity.len)
var/max_grav
for(var/i in forced_gravity)
max_grav = max(max_grav, i)
return max_grav
if(isspaceturf(T)) // Turf never has gravity
return 0
var/area/A = get_area(T)
if(A.has_gravity) // Areas which always has gravity
return A.has_gravity
else
// There's a gravity generator on our z level
if(GLOB.gravity_generators["[T.z]"])
var/max_grav = 0
for(var/obj/machinery/gravity_generator/main/G in GLOB.gravity_generators["[T.z]"])
max_grav = max(G.setting,max_grav)
return max_grav
return SSmapping.level_trait(T.z, ZTRAIT_GRAVITY)
/**
* Setup an area (with the given name)
*
+45
View File
@@ -1202,3 +1202,48 @@
custom_material.on_applied(src, materials[custom_material] * multiplier * material_modifier, material_flags)
custom_materials[custom_material] += materials[x] * multiplier
/**
* Returns true if this atom has gravity for the passed in turf
*
* Sends signals COMSIG_ATOM_HAS_GRAVITY and COMSIG_TURF_HAS_GRAVITY, both can force gravity with
* the forced gravity var
*
* Gravity situations:
* * No gravity if you're not in a turf
* * No gravity if this atom is in is a space turf
* * Gravity if the area it's in always has gravity
* * Gravity if there's a gravity generator on the z level
* * Gravity if the Z level has an SSMappingTrait for ZTRAIT_GRAVITY
* * otherwise no gravity
*/
/atom/proc/has_gravity(turf/T)
if(!T || !isturf(T))
T = get_turf(src)
if(!T)
return 0
var/list/forced_gravity = list()
SEND_SIGNAL(src, COMSIG_ATOM_HAS_GRAVITY, T, forced_gravity)
if(!forced_gravity.len)
SEND_SIGNAL(T, COMSIG_TURF_HAS_GRAVITY, src, forced_gravity)
if(forced_gravity.len)
var/max_grav
for(var/i in forced_gravity)
max_grav = max(max_grav, i)
return max_grav
if(isspaceturf(T)) // Turf never has gravity
return 0
var/area/A = get_area(T)
if(A.has_gravity) // Areas which always has gravity
return A.has_gravity
else
// There's a gravity generator on our z level
if(GLOB.gravity_generators["[T.z]"])
var/max_grav = 0
for(var/obj/machinery/gravity_generator/main/G in GLOB.gravity_generators["[T.z]"])
max_grav = max(G.setting,max_grav)
return max_grav
return SSmapping.level_trait(T.z, ZTRAIT_GRAVITY)
+1 -1
View File
@@ -545,7 +545,7 @@
//They are moving! Wouldn't it be cool if we calculated their momentum and added it to the throw?
if (thrower && thrower.last_move && thrower.client && thrower.client.move_delay >= world.time + world.tick_lag*2)
var/user_momentum = thrower.movement_delay()
var/user_momentum = thrower.cached_multiplicative_slowdown
if (!user_momentum) //no movement_delay, this means they move once per byond tick, lets calculate from that instead.
user_momentum = world.tick_lag
+3 -3
View File
@@ -904,12 +904,12 @@
var/mob/living/simple_animal/hostile/illusion/M = new(owner.loc)
M.faction = list("cult")
M.Copy_Parent(owner, 70, 10, 5)
M.move_to_delay = owner.movement_delay()
M.move_to_delay = owner.cached_multiplicative_slowdown
else
var/mob/living/simple_animal/hostile/illusion/escape/E = new(owner.loc)
E.Copy_Parent(owner, 70, 10)
E.GiveTarget(owner)
E.Goto(owner, owner.movement_delay(), E.minimum_distance)
E.Goto(owner, owner.cached_multiplicative_slowdown, E.minimum_distance)
return TRUE
else
if(prob(50))
@@ -917,7 +917,7 @@
H.Copy_Parent(owner, 100, 20, 5)
H.faction = list("cult")
H.GiveTarget(owner)
H.move_to_delay = owner.movement_delay()
H.move_to_delay = owner.cached_multiplicative_slowdown
to_chat(owner, "<span class='danger'><b>[src] betrays you!</b></span>")
return FALSE
@@ -7,11 +7,6 @@
if(data[MOVESPEED_DATA_INDEX_FLAGS] & IGNORE_NOSLOW)
.[id] = data
/mob/living/carbon/human/movement_delay()
. = ..()
if(dna && dna.species)
. += dna.species.movement_delay(src)
/mob/living/carbon/human/slip(knockdown_amount, obj/O, lube, paralyze, forcedrop)
if(HAS_TRAIT(src, TRAIT_NOSLIPALL))
return 0
@@ -1150,21 +1150,6 @@ GLOBAL_LIST_EMPTY(roundstart_races)
H.hairstyle = "Bald"
H.update_hair()
////////////////
// MOVE SPEED //
////////////////
/datum/species/proc/movement_delay(mob/living/carbon/human/H)
. = 0 //We start at 0.
var/gravity = H.has_gravity()
if(!HAS_TRAIT(H, TRAIT_IGNORESLOWDOWN) && gravity > STANDARD_GRAVITY)
//Moving in high gravity is very slow (Flying too)
var/grav_force = min(gravity - STANDARD_GRAVITY,3)
. += 1 + grav_force
return .
//////////////////
// ATTACK PROCS //
//////////////////
+2 -1
View File
@@ -755,7 +755,8 @@
/mob/living/proc/get_visible_name()
return name
/mob/living/update_gravity(has_gravity,override = 0)
/mob/living/update_gravity(has_gravity, override)
. = ..()
if(!SSticker.HasRoundStarted())
return
if(has_gravity)
@@ -132,7 +132,7 @@ Difficulty: Hard
var/mob/living/L
if(isliving(target))
L = target
target_slowness += L.movement_delay()
target_slowness += L.cached_multiplicative_slowdown
if(client)
target_slowness += 1
@@ -390,7 +390,6 @@
if(client && stat == CONSCIOUS && parrot_state != icon_living)
icon_state = icon_living
//Because the most appropriate place to set icon_state is movement_delay(), clearly
//-----SLEEPING
if(parrot_state == PARROT_PERCH)
@@ -99,7 +99,7 @@
AIproc = 0
break
var/sleeptime = movement_delay()
var/sleeptime = cached_multiplicative_slowdown
if(sleeptime <= 0)
sleeptime = 1
+7 -13
View File
@@ -2,16 +2,6 @@
/mob/CanPass(atom/movable/mover, turf/target)
return TRUE //There's almost no cases where non /living mobs should be used in game as actual mobs, other than ghosts.
/**
* Get the current movespeed delay of the mob
*
* DO NOT OVERRIDE THIS UNLESS YOU ABSOLUTELY HAVE TO.
* THIS IS BEING PHASED OUT FOR THE MOVESPEED MODIFICATION SYSTEM.
* See mob_movespeed.dm
*/
/mob/proc/movement_delay() //update /living/movement_delay() if you change this
return cached_multiplicative_slowdown
/**
* If your mob is concious, drop the item in the active hand
*
@@ -131,7 +121,7 @@
if(!mob.Process_Spacemove(direct))
return FALSE
//We are now going to move
var/add_delay = mob.movement_delay()
var/add_delay = mob.cached_multiplicative_slowdown
if(old_move_delay + (add_delay*MOVEMENT_DELAY_BUFFER_DELTA) + MOVEMENT_DELAY_BUFFER > world.time)
move_delay = old_move_delay
else
@@ -337,8 +327,12 @@
return
/// Update the gravity status of this mob
/mob/proc/update_gravity()
return
/mob/proc/update_gravity(has_gravity, override=FALSE)
var/speed_change = max(0, has_gravity - STANDARD_GRAVITY)
if(!speed_change)
remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAVITY, update=TRUE)
else
add_movespeed_modifier(MOVESPEED_ID_MOB_GRAVITY, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=speed_change, blacklisted_movetypes=FLOATING)
//bodypart selection verbs - Cyberboss
//8:repeated presses toggles through head - eyes - mouth