Skip to content

Commit

Permalink
Merge pull request lizardqueenlexi#166 from CapybaraExtravagante/grill
Browse files Browse the repository at this point in the history
Adds grille functionality to wall frames
  • Loading branch information
tralezab authored Feb 20, 2023
2 parents f3d6f11 + 075aa47 commit 7b91eb1
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 33 deletions.
8 changes: 7 additions & 1 deletion code/datums/elements/climbable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -69,6 +73,8 @@
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(QDELETED(climbed_thing)) //Checking if structure has been destroyed
return
Expand Down
138 changes: 106 additions & 32 deletions code/game/turfs/closed/wall/window_frames.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@
. = ..()

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)

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)
Expand All @@ -55,6 +60,102 @@

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)
try_shock(climber, 100)

///Gives the user a shock if they get unlucky (Based on 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)
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(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, atom/movable/AM)
SIGNAL_HANDLER
if(!isliving(AM))
return
var/mob/living/potential_victim = AM
if(potential_victim.movement_type & (FLOATING|FLYING))
return
try_shock(potential_victim, 100)


/obj/structure/window_frame/attack_animal(mob/user, list/modifiers)
. = ..()
if(!.)
return
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(try_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(!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(!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(try_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, "<span class='notice'>You cut the grille on [src].</span>")
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
Expand Down Expand Up @@ -93,38 +194,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, "<span class='notice'>You cut the grille on [src].</span>")

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()

Expand All @@ -141,6 +212,9 @@
to_chat(user, "<span class='notice'>You add [stack_name] to [src]")
update_appearance()

else if((attacking_item.flags_1 & CONDUCT_1) && try_shock(user, 70))
return

return ..()

/obj/structure/window_frame/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = NONE)
Expand Down

0 comments on commit 7b91eb1

Please sign in to comment.