From b370b98d38f12306737a261ad6c10c7117444dca Mon Sep 17 00:00:00 2001 From: CapybaraExtravagante <110635252+CapybaraExtravagante@users.noreply.github.com> Date: Thu, 2 Feb 2023 03:02:37 +0100 Subject: [PATCH 1/5] Adds grille functionality to wall frames --- code/datums/elements/climbable.dm | 8 +- code/game/turfs/closed/wall/window_frames.dm | 124 ++++++++++++++----- 2 files changed, 99 insertions(+), 33 deletions(-) diff --git a/code/datums/elements/climbable.dm b/code/datums/elements/climbable.dm index cbf19bca20086..3a7acc3961ad7 100644 --- a/code/datums/elements/climbable.dm +++ b/code/datums/elements/climbable.dm @@ -7,8 +7,10 @@ var/climb_stun = (2 SECONDS) ///Assoc list of object being climbed on - climbers. This allows us to check who needs to be shoved off a climbable object when its clicked on. var/list/current_climbers + ///Procpath of the proc to call if someone tries to climb onto our owner! + var/on_try_climb_procpath -/datum/element/climbable/Attach(datum/target, climb_time, climb_stun) +/datum/element/climbable/Attach(datum/target, climb_time, climb_stun, on_try_climb_procpath) . = ..() if(!isatom(target) || isarea(target)) @@ -17,6 +19,8 @@ src.climb_time = climb_time if(climb_stun) src.climb_stun = climb_stun + if(on_try_climb_procpath) + src.on_try_climb_procpath = on_try_climb_procpath RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(attack_hand)) RegisterSignal(target, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine)) @@ -70,6 +74,8 @@ adjusted_climb_stun *= 0.8 LAZYADDASSOCLIST(current_climbers, climbed_thing, user) if(do_after(user, adjusted_climb_time, climbed_thing)) + if(on_try_climb_procpath) + call(climbed_thing, on_try_climb_procpath)(user) if(QDELETED(climbed_thing)) //Checking if structure has been destroyed return if(do_climb(climbed_thing, user, params)) diff --git a/code/game/turfs/closed/wall/window_frames.dm b/code/game/turfs/closed/wall/window_frames.dm index 3191d6352e1d9..865ee3a1b0942 100644 --- a/code/game/turfs/closed/wall/window_frames.dm +++ b/code/game/turfs/closed/wall/window_frames.dm @@ -39,7 +39,7 @@ . = ..() update_appearance() - AddElement(/datum/element/climbable) + AddElement(/datum/element/climbable, on_try_climb_procpath = TYPE_PROC_REF(/obj/structure/window_frame/, on_try_climb)) if(mapload && start_with_window) create_structure_window(window_type, TRUE) @@ -54,6 +54,93 @@ return FALSE +///Called by the climbable element if you try climb up. Better hope you're well protected against shocks! XD +/obj/structure/window_frame/proc/on_try_climb(mob/climber) + shock(climber, 100) + +///Gives the user a shock if they get unlucky (Based on shock chance) +/obj/structure/window_frame/proc/shock(mob/user, shock_chance) + if(!has_grille) // no grille? dont shock. + return FALSE + if(!prob(shock_chance)) + return FALSE + if(!in_range(src, user))//To prevent TK and mech users from getting shocked + return FALSE + var/turf/my_turf = get_turf(src) + var/obj/structure/cable/underlaying_cable = my_turf.get_cable_node() + if(underlaying_cable) + if(electrocute_mob(user, underlaying_cable, src, 1, TRUE)) + var/datum/effect_system/spark_spread/spark_effect = new /datum/effect_system/spark_spread + spark_effect.set_up(3, 1, src) + spark_effect.start() + return TRUE + else + return FALSE + return FALSE + +/obj/structure/window_frame/attack_animal(mob/user, list/modifiers) + . = ..() + if(!.) + return + if(!shock(user, 70) && !QDELETED(src)) //Last hit still shocks but shouldn't deal damage to the grille + take_damage(rand(5,10), BRUTE, MELEE, 1) + +/obj/structure/window_frame/attack_hulk(mob/living/carbon/human/user) + if(shock(user, 70)) + return + . = ..() + +/obj/structure/window_frame/attack_hand(mob/living/user, list/modifiers) + . = ..() + if(.) + return + user.changeNext_move(CLICK_CD_MELEE) + user.do_attack_animation(src, ATTACK_EFFECT_KICK) + user.visible_message(span_warning("[user] hits [src]."), null, null, COMBAT_MESSAGE_RANGE) + log_combat(user, src, "hit") + if(!shock(user, 70)) + take_damage(rand(5,10), BRUTE, MELEE, 1) + +/obj/structure/window_frame/attack_alien(mob/living/user, list/modifiers) + user.do_attack_animation(src) + user.changeNext_move(CLICK_CD_MELEE) + user.visible_message(span_warning("[user] mangles [src]."), null, null, COMBAT_MESSAGE_RANGE) + if(!shock(user, 70)) + take_damage(20, BRUTE, MELEE, 1) + +/obj/structure/window_frame/wirecutter_act(mob/living/user, obj/item/tool) + add_fingerprint(user) + if(shock(user, 100)) + return + if(!has_grille) + return + if(!tool.use_tool(src, user, 0, volume = 50)) + return + tool.play_tool_sound(src, 100) + to_chat(user, "You cut the grille on [src].") + has_grille = FALSE + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS + + +/obj/structure/window_frame/welder_act(mob/living/user, obj/item/tool) + . = ..() + add_fingerprint(user) + if(atom_integrity >= max_integrity) + to_chat(user, span_warning("[src] is already in good condition!")) + return + if(!tool.tool_start_check(user, amount = 0)) + return + + to_chat(user, span_notice("You begin repairing [src]...")) + if(!tool.use_tool(src, user, 40, volume = 50)) + return + + atom_integrity = max_integrity + to_chat(user, span_notice("You repair [src].")) + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS + ///creates a window from the typepath given from window_type, which is either a glass sheet typepath or a /obj/structure/window subtype /obj/structure/window_frame/proc/create_structure_window(window_material_type, start_anchored = TRUE) var/obj/structure/window/our_window @@ -92,38 +179,8 @@ our_window.update_appearance() /obj/structure/window_frame/attackby(obj/item/attacking_item, mob/living/user, params) - add_fingerprint(user) - - if(attacking_item.tool_behaviour == TOOL_WELDER) - if(atom_integrity < max_integrity) - if(!attacking_item.tool_start_check(user, amount = 0)) - return - - to_chat(user, span_notice("You begin repairing [src]...")) - if(!attacking_item.use_tool(src, user, 40, volume = 50)) - return - - atom_integrity = max_integrity - to_chat(user, span_notice("You repair [src].")) - update_appearance() - else - to_chat(user, span_warning("[src] is already in good condition!")) - return - - else if(attacking_item.tool_behaviour == TOOL_WIRECUTTER) - if(has_grille) - - if(!attacking_item.use_tool(src, user, 0, volume = 50)) - return - - to_chat(user, "You cut the grille on [src].") - - has_grille = FALSE - update_appearance() - return - - else if(isstack(attacking_item)) + if(isstack(attacking_item)) var/obj/item/stack/adding_stack = attacking_item var/stack_name = "[adding_stack]" // in case the stack gets deleted after use() @@ -140,6 +197,9 @@ to_chat(user, "You add [stack_name] to [src]") update_appearance() + else if((attacking_item.flags_1 & CONDUCT_1) && shock(user, 70)) + return + return ..() /obj/structure/window_frame/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = NONE) From 4af7f2d67404fe123d71f3e80d1c7d1932841356 Mon Sep 17 00:00:00 2001 From: CapybaraExtravagante <110635252+CapybaraExtravagante@users.noreply.github.com> Date: Thu, 2 Feb 2023 03:12:56 +0100 Subject: [PATCH 2/5] Shocks on enter --- code/datums/elements/climbable.dm | 4 ++-- code/game/turfs/closed/wall/window_frames.dm | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/code/datums/elements/climbable.dm b/code/datums/elements/climbable.dm index 3a7acc3961ad7..600e64082467c 100644 --- a/code/datums/elements/climbable.dm +++ b/code/datums/elements/climbable.dm @@ -73,9 +73,9 @@ adjusted_climb_time *= 0.8 adjusted_climb_stun *= 0.8 LAZYADDASSOCLIST(current_climbers, climbed_thing, user) + if(on_try_climb_procpath) + call(climbed_thing, on_try_climb_procpath)(user) if(do_after(user, adjusted_climb_time, climbed_thing)) - if(on_try_climb_procpath) - call(climbed_thing, on_try_climb_procpath)(user) if(QDELETED(climbed_thing)) //Checking if structure has been destroyed return if(do_climb(climbed_thing, user, params)) diff --git a/code/game/turfs/closed/wall/window_frames.dm b/code/game/turfs/closed/wall/window_frames.dm index 865ee3a1b0942..433ec0bbf9009 100644 --- a/code/game/turfs/closed/wall/window_frames.dm +++ b/code/game/turfs/closed/wall/window_frames.dm @@ -44,6 +44,11 @@ if(mapload && start_with_window) create_structure_window(window_type, TRUE) + var/static/list/loc_connections = list( + COMSIG_ATOM_ENTERED = PROC_REF(on_entered), + ) + AddElement(/datum/element/connect_loc, loc_connections) + ///helper proc to check if we already have a window /obj/structure/window_frame/proc/has_window() SHOULD_BE_PURE(TRUE) @@ -78,6 +83,12 @@ return FALSE return FALSE +/obj/structure/window_frame/proc/on_entered(datum/source, AM as mob|obj) + SIGNAL_HANDLER + if(isliving(AM)) + var/mob/living/potential_victim = AM + if(potential_victim.movement_type & (FLOATING|FLYING)) + /obj/structure/window_frame/attack_animal(mob/user, list/modifiers) . = ..() if(!.) From 17df9dbd61ad7e258bcd30b9d8c36e2804576fbc Mon Sep 17 00:00:00 2001 From: CapybaraExtravagante <110635252+CapybaraExtravagante@users.noreply.github.com> Date: Thu, 2 Feb 2023 03:13:51 +0100 Subject: [PATCH 3/5] Finishes on enter behavior --- code/game/turfs/closed/wall/window_frames.dm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/game/turfs/closed/wall/window_frames.dm b/code/game/turfs/closed/wall/window_frames.dm index 433ec0bbf9009..ab41e769112ee 100644 --- a/code/game/turfs/closed/wall/window_frames.dm +++ b/code/game/turfs/closed/wall/window_frames.dm @@ -85,9 +85,13 @@ /obj/structure/window_frame/proc/on_entered(datum/source, AM as mob|obj) SIGNAL_HANDLER - if(isliving(AM)) - var/mob/living/potential_victim = AM - if(potential_victim.movement_type & (FLOATING|FLYING)) + if(!isliving(AM)) + return + var/mob/living/potential_victim = AM + if(potential_victim.movement_type & (FLOATING|FLYING)) + return + shock(potential_victim, 100) + /obj/structure/window_frame/attack_animal(mob/user, list/modifiers) . = ..() From 530fbeb2b349ff09f9768748eb80d7c373359ff2 Mon Sep 17 00:00:00 2001 From: CapybaraExtravagante <110635252+CapybaraExtravagante@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:46:02 +0100 Subject: [PATCH 4/5] Done --- code/game/turfs/closed/wall/window_frames.dm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/game/turfs/closed/wall/window_frames.dm b/code/game/turfs/closed/wall/window_frames.dm index ab41e769112ee..7921c7dff61f8 100644 --- a/code/game/turfs/closed/wall/window_frames.dm +++ b/code/game/turfs/closed/wall/window_frames.dm @@ -67,20 +67,19 @@ /obj/structure/window_frame/proc/shock(mob/user, shock_chance) if(!has_grille) // no grille? dont shock. return FALSE + if(!underlaying_cable) + return FALSE if(!prob(shock_chance)) return FALSE if(!in_range(src, user))//To prevent TK and mech users from getting shocked return FALSE var/turf/my_turf = get_turf(src) var/obj/structure/cable/underlaying_cable = my_turf.get_cable_node() - if(underlaying_cable) - if(electrocute_mob(user, underlaying_cable, src, 1, TRUE)) - var/datum/effect_system/spark_spread/spark_effect = new /datum/effect_system/spark_spread - spark_effect.set_up(3, 1, src) - spark_effect.start() - return TRUE - else - return FALSE + if(electrocute_mob(user, underlaying_cable, src, 1, TRUE)) + var/datum/effect_system/spark_spread/spark_effect = new /datum/effect_system/spark_spread + spark_effect.set_up(3, 1, src) + spark_effect.start() + return TRUE return FALSE /obj/structure/window_frame/proc/on_entered(datum/source, AM as mob|obj) From 075aa47a7398dcd2f6a07cbfed61eb63b44addaa Mon Sep 17 00:00:00 2001 From: tralezab <40974010+tralezab@users.noreply.github.com> Date: Mon, 20 Feb 2023 14:49:05 -0800 Subject: [PATCH 5/5] try_shock, atom/movable/AM --- code/game/turfs/closed/wall/window_frames.dm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/code/game/turfs/closed/wall/window_frames.dm b/code/game/turfs/closed/wall/window_frames.dm index 7921c7dff61f8..953910e1094e3 100644 --- a/code/game/turfs/closed/wall/window_frames.dm +++ b/code/game/turfs/closed/wall/window_frames.dm @@ -61,10 +61,10 @@ ///Called by the climbable element if you try climb up. Better hope you're well protected against shocks! XD /obj/structure/window_frame/proc/on_try_climb(mob/climber) - shock(climber, 100) + try_shock(climber, 100) ///Gives the user a shock if they get unlucky (Based on shock chance) -/obj/structure/window_frame/proc/shock(mob/user, shock_chance) +/obj/structure/window_frame/proc/try_shock(mob/user, shock_chance) if(!has_grille) // no grille? dont shock. return FALSE if(!underlaying_cable) @@ -82,25 +82,25 @@ return TRUE return FALSE -/obj/structure/window_frame/proc/on_entered(datum/source, AM as mob|obj) +/obj/structure/window_frame/proc/on_entered(datum/source, atom/movable/AM) SIGNAL_HANDLER if(!isliving(AM)) return var/mob/living/potential_victim = AM if(potential_victim.movement_type & (FLOATING|FLYING)) return - shock(potential_victim, 100) + try_shock(potential_victim, 100) /obj/structure/window_frame/attack_animal(mob/user, list/modifiers) . = ..() if(!.) return - if(!shock(user, 70) && !QDELETED(src)) //Last hit still shocks but shouldn't deal damage to the grille + if(!try_shock(user, 70) && !QDELETED(src)) //Last hit still shocks but shouldn't deal damage to the grille take_damage(rand(5,10), BRUTE, MELEE, 1) /obj/structure/window_frame/attack_hulk(mob/living/carbon/human/user) - if(shock(user, 70)) + if(try_shock(user, 70)) return . = ..() @@ -112,19 +112,19 @@ user.do_attack_animation(src, ATTACK_EFFECT_KICK) user.visible_message(span_warning("[user] hits [src]."), null, null, COMBAT_MESSAGE_RANGE) log_combat(user, src, "hit") - if(!shock(user, 70)) + if(!try_shock(user, 70)) take_damage(rand(5,10), BRUTE, MELEE, 1) /obj/structure/window_frame/attack_alien(mob/living/user, list/modifiers) user.do_attack_animation(src) user.changeNext_move(CLICK_CD_MELEE) user.visible_message(span_warning("[user] mangles [src]."), null, null, COMBAT_MESSAGE_RANGE) - if(!shock(user, 70)) + if(!try_shock(user, 70)) take_damage(20, BRUTE, MELEE, 1) /obj/structure/window_frame/wirecutter_act(mob/living/user, obj/item/tool) add_fingerprint(user) - if(shock(user, 100)) + if(try_shock(user, 100)) return if(!has_grille) return @@ -211,7 +211,7 @@ to_chat(user, "You add [stack_name] to [src]") update_appearance() - else if((attacking_item.flags_1 & CONDUCT_1) && shock(user, 70)) + else if((attacking_item.flags_1 & CONDUCT_1) && try_shock(user, 70)) return return ..()