Merge pull request #20298 from ShiftyRail/SyndieShoes

Slip refactor
This commit is contained in:
MadmanMartian
2019-02-12 21:33:55 +00:00
committed by GitHub
19 changed files with 206 additions and 101 deletions

View File

@@ -12,3 +12,4 @@
#define GOLIATHREINFORCE 64
#define CANEXTINGUISH 128
#define CONTAINPLASMAMAN 256
#define IGNORE_LUBE 512

View File

@@ -1,6 +1,9 @@
#define TURF_DRY 0
#define TURF_WET_WATER 1
#define TURF_WET_LUBE 2
#define TURF_WET_ICE 3
#define TURF_CONTAINS_REGULAR_ROCKERNAUT 1
#define TURF_CONTAINS_BOSS_ROCKERNAUT 2
#define SLIP_HAS_MAGBOOTS -1 // Magbooties !

View File

@@ -70,7 +70,7 @@ atom/movable/GotoAirflowDest(n)
if(locked_to || (flags & INVULNERABLE))
return FALSE
if(shoes)
if(CheckSlip() < 1)
if((CheckSlip()) != TRUE)
return FALSE
if(!(status_flags & CANSTUN) && !(status_flags & CANKNOCKDOWN))
to_chat(src, "<span class='notice'>You stay upright as the air rushes past you.</span>")
@@ -94,7 +94,7 @@ atom/movable/GotoAirflowDest(n)
return FALSE
if(locked_to)
return FALSE
if(CheckSlip() < 0)
if(CheckSlip() == SLIP_HAS_MAGBOOTS)
return FALSE
if (grabbed_by.len)

View File

@@ -1,4 +1,3 @@
/obj/effect/overlay
name = "overlay"
w_type=NOT_RECYCLABLE
@@ -82,57 +81,12 @@
qdel(src)
/obj/effect/overlay/puddle/Crossed(atom/movable/AM)
//Check what can slip
if(isliving(AM))
var/mob/living/M = AM
if(!M.on_foot()) //Checks lying, flying and locked.to
return ..()
if(isslime(AM)) //Slimes just don't slip, end of story. Hard to slip when you're a living puddle.
if (!isliving(AM))
return ..()
var/mob/living/L = AM
if (!L.ApplySlip(src))
return ..()
if(iscarbon(AM))
var/mob/living/carbon/M = AM
switch(src.wet)
if(1) //Water
if (M.Slip(5, 3))
step(M, M.dir)
M.visible_message("<span class='warning'>[M] slips on the wet floor!</span>", \
"<span class='warning'>You slip on the wet floor!</span>")
if(2) //Lube
step(M, M.dir)
spawn(1)
if(!M.locked_to)
step(M, M.dir)
spawn(2)
if(!M.locked_to)
step(M, M.dir)
spawn(3)
if(!M.locked_to)
step(M, M.dir)
spawn(4)
if(!M.locked_to)
step(M, M.dir)
M.take_organ_damage(2) // Was 5 -- TLE
M.visible_message("<span class='warning'>[M] slips on the floor!</span>", \
"<span class='warning'>You slip on the floor!</span>")
playsound(src, 'sound/misc/slip.ogg', 50, 1, -3)
M.Knockdown(10)
if(3) // Ice
if(prob(30) && M.Slip(4, 3))
step(M, M.dir)
M.visible_message("<span class='warning'>[M] slips on the icy floor!</span>", \
"<span class='warning'>You slip on the icy floor!</span>")
if(isrobot(AM) && wet == 1) //Only exactly water makes borgs glitch
var/mob/living/silicon/robot/R = AM
if(R.Slip(5,3))
//Don't step forward as a robot, we're not slipping just glitching.
R.visible_message("<span class='warning'>[R] short circuits on the water!</span>", \
"<span class='warning'>You short circuit on the water!</span>")
/obj/effect/overlay/wallrot
name = "Wallrot"

View File

@@ -75,7 +75,7 @@
"<span class='userdanger'>They're eating your back!</span>")
return
if(ishuman(M))
if(M.CheckSlip() < 1)
if(M.CheckSlip() != TRUE)
return
else
M.simple_message("<span class='warning'>Your feet feel like they're on fire!</span>",\

View File

@@ -667,7 +667,7 @@
return base_slowdown
/turf/proc/has_gravity(mob/M)
if(istype(M) && M.CheckSlip() == -1) //Wearing magboots - good enough
if(istype(M) && M.CheckSlip() == SLIP_HAS_MAGBOOTS) //Wearing magboots - good enough
return 1
var/area/A = loc

View File

@@ -27,7 +27,7 @@
//NUCLEAR MAGBOOT STUMP INCOMING (it takes 3 seconds)
user.visible_message("<span class='danger'>\The [user] slowly raises \his [stomp_boot] above the lying [victim.name], preparing to stomp on \him.</span>")
toggle()
toggle(user)
if(do_after(user, src, stomp_delay))
if(magpulse)
@@ -44,25 +44,25 @@
else
return
toggle()
toggle(user)
playsound(victim, 'sound/mecha/mechstep.ogg', 100, 1)
/obj/item/clothing/shoes/magboots/proc/toggle()
if(usr.isUnconscious())
/obj/item/clothing/shoes/magboots/proc/toggle(var/mob/user = usr)
if(user.isUnconscious())
return
if(src.magpulse)
src.clothing_flags &= ~NOSLIP
src.slowdown = NO_SLOWDOWN
src.magpulse = 0
icon_state = "[base_state]0"
to_chat(usr, "You disable the mag-pulse traction system.")
to_chat(user, "You disable the mag-pulse traction system.")
else
src.clothing_flags |= NOSLIP
src.slowdown = mag_slow
src.magpulse = 1
icon_state = "[base_state]1"
to_chat(usr, "You enable the mag-pulse traction system.")
usr.update_inv_shoes() //so our mob-overlays update
to_chat(user, "You enable the mag-pulse traction system.")
user.update_inv_shoes() //so our mob-overlays update
/obj/item/clothing/shoes/magboots/attack_self()
src.toggle()
@@ -128,22 +128,22 @@
icon_state = "MAGNIFICENTboots0"
base_state = "MAGNIFICENTboots"
/obj/item/clothing/shoes/magboots/captain/toggle()
/obj/item/clothing/shoes/magboots/captain/toggle(var/mob/user = usr)
//set name = "Toggle Floor Grip"
if(usr.isUnconscious())
if(user.isUnconscious())
return
if(src.magpulse)
src.clothing_flags &= ~NOSLIP
src.slowdown = NO_SLOWDOWN
src.magpulse = 0
icon_state = "[base_state]0"
to_chat(usr, "You stop ruining the carpet.")
to_chat(user, "You stop ruining the carpet.")
else
src.clothing_flags |= NOSLIP
src.slowdown = mag_slow
src.magpulse = 1
icon_state = "[base_state]1"
to_chat(usr, "Small spikes shoot from your shoes and dig into the flooring, bracing you.")
to_chat(user, "Small spikes shoot from your shoes and dig into the flooring, bracing you.")
/obj/item/clothing/shoes/magboots/funk
@@ -154,12 +154,12 @@
var/funk_level = 0
canremove = 0
/obj/item/clothing/shoes/magboots/funk/toggle()
if(usr.isUnconscious())
/obj/item/clothing/shoes/magboots/funk/toggle(var/mob/user = usr)
if(user.isUnconscious())
return
if(funk_level >= 11) //WE HAVE GONE TOO FAR, COMRADE
return
usr.visible_message("<span class = 'warning'>[usr] dials up \the [src]'s funk level to [funk_level+1]</span>")
user.visible_message("<span class = 'warning'>[usr] dials up \the [src]'s funk level to [funk_level+1]</span>")
funk_level++
if(funk_level >= 2)
clothing_flags |= NOSLIP
@@ -202,7 +202,7 @@
explosion(get_turf(src), round((1*funk_level)/russian)*0.25, round((1*funk_level)/russian)*0.5, round((1*funk_level)/russian))
if(prob((funk_level/russian)*2)) //IT WAS ALWAYS TOO LATE
toggle()
toggle(H)
/obj/item/clothing/shoes/magboots/funk/OnMobDeath(var/mob/living/carbon/human/wearer)
var/mob/living/carbon/human/W = wearer

View File

@@ -505,22 +505,14 @@
return 1
return 0
/mob/living/carbon/CheckSlip()
return !locked_to && !lying && !unslippable
/mob/living/carbon/CheckSlip(slip_on_walking = FALSE, overlay_type = TURF_WET_WATER, slip_on_magbooties = FALSE)
var/walking_factor = (!slip_on_walking && m_intent == M_INTENT_WALK)
return (on_foot()) && !locked_to && !lying && !unslippable && !walking_factor
/mob/living/proc/Slip(stun_amount, weaken_amount, slip_on_walking = 0)
stop_pulling()
Stun(stun_amount)
Knockdown(weaken_amount)
score["slips"]++
return 1
/mob/living/carbon/Slip(stun_amount, weaken_amount, slip_on_walking = 0)
if(!slip_on_walking && m_intent == "walk")
/mob/living/carbon/Slip(stun_amount, weaken_amount, slip_on_walking = 0, overlay_type, slip_on_magbooties = 0)
if ((CheckSlip(slip_on_walking, overlay_type, slip_on_magbooties)) != TRUE)
return 0
if (CheckSlip() < 1 || !on_foot())
return 0
if(..())
playsound(src, 'sound/misc/slip.ogg', 50, 1, -3)
return 1
@@ -709,3 +701,35 @@
if(src)
body_alphas.Remove(source_define)
regenerate_icons()
/mob/living/carbon/ApplySlip(var/obj/effect/overlay/puddle/P)
if (!..())
return FALSE
switch(P.wet)
if(TURF_WET_WATER)
if (!Slip(stun_amount = 5, weaken_amount = 3, slip_on_walking = FALSE, overlay_type = TURF_WET_WATER))
return FALSE
step(src, dir)
visible_message("<span class='warning'>[src] slips on the wet floor!</span>", \
"<span class='warning'>You slip on the wet floor!</span>")
if(TURF_WET_LUBE)
step(src, dir)
if (!Slip(stun_amount = 10, weaken_amount = 3, slip_on_walking = TRUE, overlay_type = TURF_WET_LUBE, slip_on_magbooties = TRUE))
return FALSE
for (var/i = 1 to 4)
spawn(i)
if(!locked_to)
step(src, dir)
take_organ_damage(2) // Was 5 -- TLE
visible_message("<span class='warning'>[src] slips on the floor!</span>", \
"<span class='warning'>You slip on the floor!</span>")
if(TURF_WET_ICE)
if(prob(30) && Slip(stun_amount = 4, weaken_amount = 3, overlay_type = TURF_WET_ICE))
step(src, dir)
visible_message("<span class='warning'>[src] slips on the icy floor!</span>", \
"<span class='warning'>You slip on the icy floor!</span>")
return TRUE

View File

@@ -12,7 +12,7 @@
if(reagents.has_any_reagents(HYPERZINES))
return // Hyperzine ignores base slowdown
if(istype(loc, /turf/space))
return // Space ignores slowdown
return // Space ignores
if (species && species.move_speed_mod)
. += species.move_speed_mod
@@ -111,7 +111,7 @@
prob_slip = 0 // Changing this to zero to make it line up with the comment, and also, make more sense.
//Do we have magboots or such on if so no slip
if(CheckSlip() < 0)
if(CheckSlip() == SLIP_HAS_MAGBOOTS)
prob_slip = 0
//Check hands and mod slip
@@ -151,8 +151,21 @@
if(dispenser.spam_bomb)
dispenser.attack_self(src)
/mob/living/carbon/human/CheckSlip()
/mob/living/carbon/human/CheckSlip(slip_on_walking = FALSE, overlay_type = TURF_WET_WATER, slip_on_magbooties = FALSE)
var/shoes_slip_factor
switch (overlay_type)
if (TURF_WET_WATER, TURF_WET_ICE)
shoes_slip_factor = shoes && (shoes.clothing_flags & NOSLIP)
if (TURF_WET_LUBE)
shoes_slip_factor = shoes && (shoes.clothing_flags & IGNORE_LUBE)
else
shoes_slip_factor = TRUE // Shoes are of no interest for this.
var/magboots_slip_factor = (!slip_on_magbooties && shoes_slip_factor && istype(shoes, /obj/item/clothing/shoes/magboots))
. = ..()
if(. && shoes && shoes.clothing_flags & NOSLIP)
. = (istype(shoes, /obj/item/clothing/shoes/magboots) ? -1 : 0)
return .
// We have magboots, and magboots can protect us
if (. && magboots_slip_factor)
return SLIP_HAS_MAGBOOTS
// We don't have magboots, or magboots can't protect us
return (. && !shoes_slip_factor)

View File

@@ -1082,6 +1082,9 @@ mob/living/carbon/slime/var/temperature_resistance = T0C+75
/mob/living/carbon/slime/IgniteMob()
return 0
/mob/living/carbon/slime/ApplySlip(var/obj/effect/overlay/puddle/P)
return FALSE
//////////////////////////////Old shit from metroids/RoRos, and the old cores, would not take much work to re-add them////////////////////////
/*

View File

@@ -1526,9 +1526,6 @@ Thanks.
health = 0
stat = DEAD
/mob/proc/CheckSlip()
return 0
/mob/living/proc/turn_into_statue(forever = 0, force)
if(!force)
if(mob_property_flags & (MOB_UNDEAD|MOB_CONSTRUCT|MOB_ROBOTIC|MOB_HOLOGRAPHIC|MOB_SUPERNATURAL))
@@ -1817,3 +1814,13 @@ Thanks.
// TODO which is pretty irrelevant now but should be fixed
tool.reagents.reaction(src, INGEST)
return ..()
/mob/living/proc/ApplySlip(var/obj/effect/overlay/puddle/P)
return on_foot() // Check if we have legs, gravity, etc. Checked by the children.
/mob/living/proc/Slip(stun_amount, weaken_amount, slip_on_walking = 0, overlay_type, slip_with_magbooties = 0)
stop_pulling()
Stun(stun_amount)
Knockdown(weaken_amount)
score["slips"]++
return 1

View File

@@ -3,8 +3,19 @@
return FALSE
..()
/mob/living/silicon/robot/CheckSlip()
return ((HAS_MODULE_QUIRK(src, MODULE_HAS_MAGPULSE))? -1 : 0)
/mob/living/silicon/robot/CheckSlip(slip_on_walking = FALSE, overlay_type = TURF_WET_WATER, slip_on_magbooties = FALSE)
return ((HAS_MODULE_QUIRK(src, MODULE_HAS_MAGPULSE))? SLIP_HAS_MAGBOOTS : FALSE)
/mob/living/silicon/robot/ApplySlip(var/obj/effect/overlay/puddle/P)
if (P.wet != TURF_WET_WATER)
return FALSE
if(Slip(5,3))
//Don't step forward as a robot, we're not slipping just glitching.
visible_message("<span class='warning'>[src] short circuits on the water!</span>", \
"<span class='warning'>You short circuit on the water!</span>")
return TRUE
/mob/living/silicon/robot/Process_Spacemove(var/check_drift = FALSE)
if(module)

View File

@@ -130,3 +130,6 @@
overlay_fullscreen("brute", /obj/abstract/screen/fullscreen/brute, severity)
else
clear_fullscreen("brute")
/mob/living/simple_animal/slime/ApplySlip(var/obj/effect/overlay/puddle/P)
return FALSE

View File

@@ -323,8 +323,8 @@
if(src.held_item)
to_chat(user, "It is carrying \a [src.held_item] [bicon(src.held_item)].")
/mob/living/simple_animal/spiderbot/CheckSlip()
return -1
/mob/living/simple_animal/spiderbot/CheckSlip(slip_on_walking = FALSE, overlay_type = TURF_WET_WATER, slip_on_magbooties = FALSE)
return SLIP_HAS_MAGBOOTS
/mob/living/simple_animal/spiderbot/say(var/message)
return ..(message, "R")

View File

@@ -2212,6 +2212,9 @@ mob/proc/on_foot()
var/datum/role/R = mind.antag_roles[role]
R.update_antag_hud()
/mob/proc/CheckSlip(slip_on_walking = FALSE, overlay_type = TURF_WET_WATER, slip_on_magbooties = FALSE)
return FALSE
// Returns TRUE on success
/mob/proc/attempt_crawling(var/turf/target)
return FALSE

View File

@@ -1603,7 +1603,7 @@
/obj/item/weapon/reagent_containers/food/snacks/butter/Crossed(atom/movable/O)
if (istype(O, /mob/living/carbon/human))
var/mob/living/carbon/human/H = O
if (H.CheckSlip() < 1)
if (H.CheckSlip() != TRUE)
return
H.stop_pulling()
@@ -4236,7 +4236,7 @@
/obj/item/weapon/reagent_containers/food/snacks/slider/slippery/Crossed(atom/movable/O) //exactly the same as soap
if (istype(O, /mob/living/carbon/human))
var/mob/living/carbon/human/H = O
if (H.CheckSlip() < 1)
if (H.CheckSlip() != TRUE)
return
H.stop_pulling()
@@ -5720,7 +5720,7 @@ obj/item/weapon/reagent_containers/food/snacks/butterstick
/obj/item/weapon/reagent_containers/food/snacks/butterstick/Crossed(atom/movable/O)
if (istype(O, /mob/living/carbon/human))
var/mob/living/carbon/human/H = O
if (H.CheckSlip() < 1)
if (H.CheckSlip() != TRUE)
return
H.stop_pulling()

View File

@@ -890,7 +890,7 @@ var/list/special_fruits = list()
if(popper)
popper.visible_message("<span class='warning'>[popper] pops the \the [src]!</span>","<span class='warning'>You pop \the [src]!</span>")
for(var/mob/living/carbon/C in view(1))
if(C.CheckSlip() < 1)
if(C.CheckSlip() != TRUE)
continue
C.Knockdown(5)
playsound(src, 'sound/effects/bang.ogg', 10, 1)

View File

@@ -4,4 +4,5 @@
#include "dna_and_disabilities.dm"
#include "hexadecimal.dm"
#include "reagent_recipe_collisions.dm"
#include "slipping.dm"
#endif

View File

@@ -0,0 +1,82 @@
#define RESULT_RUN 1
#define RESULT_WALK 2
#define RESULT_NOSLIP 3
#define RESULT_MAGBOOTS 4
#define TURF_WET_WATER_STR "1" // Byond doesn't like integers in assoc list :-(
#define TURF_WET_LUBE_STR "2"
/datum/unit_test/slipping
/*
We spawn an item, make an human run on it, and check if he slipped or not
The list is of the form :
item_to_spawn = list(RESULT_RUN, RESULT_WALK, RESULT_NOSLIP, RESULT_MAGBOOTS)
*/
var/list/items_and_result_humans = list(
/obj/item/weapon/reagent_containers/food/snacks/butter = list(TRUE, FALSE, FALSE, FALSE),
/obj/item/weapon/bananapeel/ = list(TRUE, TRUE, FALSE, FALSE),
/obj/item/weapon/soap/ = list(TRUE, TRUE, FALSE, FALSE),
/obj/item/device/pda/clown = list(TRUE, FALSE, FALSE, FALSE),
)
/* overlay_to_spawn = list(RESULT_RUN, RESULT_WALK, RESULT_NOSLIP, RESULT_MAGBOOTS) */
var/list/overlays_and_results = list(
TURF_WET_WATER_STR = list(TRUE, FALSE, FALSE, FALSE),
TURF_WET_LUBE_STR = list(TRUE, TRUE, TRUE, TRUE),
)
/datum/unit_test/slipping/start()
// Items
var/turf/centre = locate(100, 100, 1) // Nice place with a good atmosphere and shit
var/turf/simulated/T_test = locate(centre.x, centre.y + 1, centre.z)
for (var/type in items_and_result_humans)
for (var/i = 1 to 4)
var/mob/living/carbon/human/H = new(centre)
sleep(1) // Poor human needs to handle his birth (and the spawn() involved). Be patien
var/obj/O = new type(T_test)
switch (i)
if (RESULT_RUN)
// Nothing
if (RESULT_WALK)
H.m_intent = "walk"
if (RESULT_NOSLIP)
var/obj/item/clothing/shoes/syndigaloshes/S = new
H.equip_or_collect(S, slot_shoes)
if (RESULT_MAGBOOTS)
var/obj/item/clothing/shoes/magboots/M = new
H.equip_or_collect(M, slot_shoes)
M.toggle(H)
H.Move(T_test, NORTH)
if (H.isStunned() != items_and_result_humans[type][i])
fail("Slipping test failed at [type], step [i] ; expected [items_and_result_humans[type][i]], got [H.isStunned()]")
qdel(H)
qdel(O)
// Overlays
for (var/wetness in overlays_and_results)
for (var/j = 1 to 4)
var/mob/living/carbon/human/H = new(centre)
sleep(1) // Poor human needs to handle his birth (and the spawn() involved). Be patient
var/wet_fac = text2num(wetness)
T_test.wet(10 SECONDS, wet_fac)
switch (j)
if (RESULT_RUN)
// Nothing
if (RESULT_WALK)
H.m_intent = "walk"
if (RESULT_NOSLIP)
var/obj/item/clothing/shoes/syndigaloshes/S = new
H.equip_or_collect(S, slot_shoes)
if (RESULT_MAGBOOTS)
var/obj/item/clothing/shoes/magboots/M = new
H.equip_or_collect(M, slot_shoes)
M.toggle(H)
H.Move(T_test, NORTH)
if (H.isStunned() != overlays_and_results[wetness][j])
fail("Slipping test failed at [wetness], step [j] ; expected [overlays_and_results[wetness][j]], got [H.isStunned()]")
qdel(H)
T_test.dry(TURF_WET_LUBE)