From 514e10df996dc9b049995552b84ae6814f8341ad Mon Sep 17 00:00:00 2001 From: PhantornRU Date: Mon, 13 Nov 2023 02:52:35 +1000 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=B8=D0=B3=D0=BD=D0=B0=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modular_ss220/clumsy_table/_clumsy_table.dme | 1 + .../code/clumsy_climb_component.dm | 74 +++++++++++++++++++ .../clumsy_table/code/clumsy_table.dm | 61 ++------------- modular_ss220/emotes/code/emote.dm | 3 +- 4 files changed, 84 insertions(+), 55 deletions(-) create mode 100644 modular_ss220/clumsy_table/code/clumsy_climb_component.dm diff --git a/modular_ss220/clumsy_table/_clumsy_table.dme b/modular_ss220/clumsy_table/_clumsy_table.dme index 0d5dff587102..82516cf41c2f 100644 --- a/modular_ss220/clumsy_table/_clumsy_table.dme +++ b/modular_ss220/clumsy_table/_clumsy_table.dme @@ -1,3 +1,4 @@ #include "_clumsy_table.dm" #include "code/clumsy_table.dm" +#include "code/clumsy_climb_component.dm" diff --git a/modular_ss220/clumsy_table/code/clumsy_climb_component.dm b/modular_ss220/clumsy_table/code/clumsy_climb_component.dm new file mode 100644 index 000000000000..27edda2a2e31 --- /dev/null +++ b/modular_ss220/clumsy_table/code/clumsy_climb_component.dm @@ -0,0 +1,74 @@ +/datum/component/clumsy_climb_component + var/thrown_chance = 80 //default for all human-sized livings + var/force_mod = 0.1 //коэффицент уменьшения урона при сбрасывании предмета + var/max_thrown_objects = 15 + var/max_thrown_objects_low = 5 + +/datum/component/clumsy_climb_component/Initialize() + //RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(Repaint)) + if(!isatom(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/clumsy_climb_component/RegisterWithParent() + RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, PROC_REF(cross)) + RegisterSignal(parent, COMSIG_CLIMBED_ON, PROC_REF(cross)) + +/datum/component/clumsy_climb_component/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_MOVABLE_CROSSED, COMSIG_CLIMBED_ON)) + +/datum/component/clumsy_climb_component/proc/cross(atom/table, mob/living/climber) + if(!table.contents) + return + + if(!istype(climber)) + return + + var/mob/living/user = climber + if(user.mob_size <= MOB_SIZE_SMALL && !user.throwing) + return + + max_thrown_objects = initial(max_thrown_objects) + if(!user.throwing) + max_thrown_objects = max_thrown_objects_low + + clumsy_stuff(user) + + +/datum/component/clumsy_climb_component/proc/clumsy_stuff(mob/living/user) + if(!user) + return + + switch(user.mob_size) + if(MOB_SIZE_LARGE) + thrown_chance = 100 + if(MOB_SIZE_SMALL) + thrown_chance = 20 + if(MOB_SIZE_TINY) + thrown_chance = 10 + + if(HAS_TRAIT(user, TRAIT_CLUMSY)) + thrown_chance += 20 + if(user.mind?.miming) + thrown_chance -= 30 + + thrown_chance = clamp(thrown_chance, 1, 100) + + var/list/thrown_atoms = list() + + for(var/turf/T in range(0, user)) //Preventing from rotating stuff in an inventory + for(var/atom/movable/I in T) + if(!I.anchored && !isliving(I) && prob(thrown_chance)) + thrown_atoms += I + if(thrown_atoms.len >= max_thrown_objects) + break + + var/atom/thrown_target + for(var/obj/item/I in thrown_atoms) + I.force *= force_mod + I.throwforce *= force_mod //no killing using shards :lul: + thrown_target = get_edge_target_turf(user, get_dir(user, get_step_away(I, user))) + I.throw_at(target = thrown_target, range = 1, speed = 1) + I.pixel_x = rand(-6, 6) + I.pixel_y = rand(0, 10) + I.force /= force_mod + I.throwforce /= force_mod diff --git a/modular_ss220/clumsy_table/code/clumsy_table.dm b/modular_ss220/clumsy_table/code/clumsy_table.dm index fbadb8abf7e1..5603df3154dc 100644 --- a/modular_ss220/clumsy_table/code/clumsy_table.dm +++ b/modular_ss220/clumsy_table/code/clumsy_table.dm @@ -1,59 +1,12 @@ -/obj/structure/do_climb(mob/living/user) - if(!user) - return ..() - - if(..()) - clumsy_stuff(user) +#define COMSIG_CLIMBED_ON "climb_on" -/obj/structure/table/Crossed(atom/movable/AM, oldloc) +/obj/structure/table/Initialize(mapload) . = ..() + AddComponent(/datum/component/clumsy_climb_component, 15) - if(!isliving(AM)) - return - var/mob/living/user = AM - if(user.mob_size <= MOB_SIZE_SMALL && !user.throwing) - return - - var/max_throws_count = 5 - if(user.throwing) - max_throws_count = 15 - - clumsy_stuff(user, max_throws_count) - -/obj/structure/proc/clumsy_stuff(mob/living/user, max_throws_count = 15) +/obj/structure/do_climb(mob/living/user) if(!user) - return - var/slopchance = 80 //default for all human-sized livings - var/force_mult = 0.1 //коэффицент уменьшения урона при сбрасывании предмета - - switch(user.mob_size) - if(MOB_SIZE_LARGE) slopchance = 100 - if(MOB_SIZE_SMALL) slopchance = 20 - if(MOB_SIZE_TINY) slopchance = 10 - - if(HAS_TRAIT(user, TRAIT_CLUMSY)) - slopchance += 20 - if(user.mind?.miming) - slopchance -= 30 - - slopchance = clamp(slopchance, 1, 100) - - var/list/thrownatoms = list() - - for(var/turf/T in range(0, src)) //Preventing from rotating stuff in an inventory - for(var/atom/movable/AM in T) - if(!AM.anchored && !isliving(AM) && prob(slopchance)) - thrownatoms += AM - if(thrownatoms.len >= max_throws_count) - break + return ..() - var/atom/throwtarget - for(var/obj/item/AM in thrownatoms) - AM.force *= force_mult - AM.throwforce *= force_mult //no killing using shards :lul: - throwtarget = get_edge_target_turf(user, get_dir(src, get_step_away(AM, src))) - AM.throw_at(target = throwtarget, range = 1, speed = 1) - AM.pixel_x = rand(-6, 6) - AM.pixel_y = rand(0, 10) - AM.force /= force_mult - AM.throwforce /= force_mult + if(..()) + SEND_SIGNAL(src, COMSIG_CLIMBED_ON, user) diff --git a/modular_ss220/emotes/code/emote.dm b/modular_ss220/emotes/code/emote.dm index fb427c2be4bb..781b7c997181 100644 --- a/modular_ss220/emotes/code/emote.dm +++ b/modular_ss220/emotes/code/emote.dm @@ -16,7 +16,8 @@ user.do_jitter_animation(rand(8 SECONDS, 16 SECONDS), dance_time / 4) var/obj/structure/table/T = locate() in user.loc if(T) - T.clumsy_stuff(user) + SEND_SIGNAL(T, COMSIG_CLIMBED_ON, user) + /datum/emote/living/choke/get_sound(mob/living/user) . = ..()