Skip to content

Commit

Permalink
walks now ignores cable shocks + more refactores?
Browse files Browse the repository at this point in the history
  • Loading branch information
larentoun committed Oct 29, 2023
1 parent 7a8ad76 commit a9f6245
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions modular_ss220/wire_splicing/wiresplicing.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#define MAX_MESSINESS 10

/obj/effect/spawner/wire_splicing
name = "wiring splicing spawner"
icon = 'modular_ss220/wire_splicing/structures_spawners.dmi'
icon_state = "wire_splicing"

/obj/effect/spawner/wire_splicing/Initialize()
. = ..()
new/obj/structure/wire_splicing(get_turf(src))
new /obj/structure/wire_splicing(get_turf(src))
return INITIALIZE_HINT_QDEL

/obj/effect/spawner/wire_splicing/thirty //70% chance to be nothing
name = "wiring splicing spawner 30%"

/obj/effect/spawner/wire_splicing/thirty/Initialize(mapload)
if (prob(70))
if(prob(70))
return INITIALIZE_HINT_QDEL
. = ..()

Expand All @@ -29,16 +31,14 @@

/obj/structure/wire_splicing/Initialize(mapload)
. = ..()
messiness = rand (1,10)
icon_state = "wire_splicing[messiness]"

messiness = rand(1, MAX_MESSINESS)
update_icon(UPDATE_ICON_STATE)

//At messiness of 2 or below, triggering when walking on a catwalk is impossible
//Above that it becomes possible, so we will change the layer to make it poke through catwalks
if (messiness > 2)
layer = LOW_OBJ_LAYER // I wont do such stuff on splicing "reinforcement". Take it as nasty feature


//Wire splice can only exist on a cable. Lets try to place it in a good location
if (locate(/obj/structure/cable) in get_turf(src)) //if we're already in a good location, no problem!
return
Expand Down Expand Up @@ -90,64 +90,68 @@

loc = pick(candidates)

/obj/structure/wire_splicing/update_icon_state()
icon_state = "wire_splicing[messiness]"

/obj/structure/wire_splicing/examine(mob/user)
. = ..()
. += span_warning("It has [messiness] wire[messiness > 1?"s":""] dangling around.")
. += span_warning("It has [messiness] wire[messiness > 1 ? "s" : ""] dangling around.")

/obj/structure/wire_splicing/Crossed(atom/movable/AM, oldloc)
. = ..()
if(isliving(AM))
var/mob/living/crosser = AM
if(HAS_TRAIT(crosser, TRAIT_FLOORED)) // No exploiting the stunned target
return
//var/turf/T = get_turf(src)
var/chance_to_shock = messiness * 10
/*
var/turf/T = get_turf(src)
if(locate(/obj/structure/catwalk) in T)
chance_to_shock -= 20
*/
shock(crosser, chance_to_shock)
shock(AM, chance_to_shock)

/obj/structure/wire_splicing/proc/shock(mob/user, prb, siemens_coeff = 1)
if(!in_range(src, user))//To prevent TK and mech users from getting shocked
return FALSE
/obj/structure/wire_splicing/proc/shock(mob/living/user, prb, siemens_coeff = 1)
. = FALSE
if(!in_range(src, user)) //To prevent TK and mech users from getting shocked
return
if(user.m_intent == MOVE_INTENT_WALK) // Walk slowly to step over
return
if(!prob(prb))
return FALSE
return
var/turf/T = get_turf(src)
var/obj/structure/cable/C = locate(/obj/structure/cable) in T
if(!C)
return FALSE
if (electrocute_mob(user, C.powernet, src, siemens_coeff))
return
if(electrocute_mob(user, C.powernet, src, siemens_coeff))
do_sparks(5, TRUE, src)
return TRUE
else
return FALSE
. = TRUE

/obj/structure/wire_splicing/wirecutter_act(mob/living/user, obj/item/I)
if(I.use_tool(src, user, 2 SECONDS, volume = 50))
if (shock(user, 50))
return
. = TRUE
user.visible_message("[user] cuts the splicing.", span_notice("You cut the splicing."))
investigate_log(" was cut by [key_name(usr)] in [AREACOORD(src)]")
qdel(src)
. = TRUE
if(!I.use_tool(src, user, 2 SECONDS, volume = I.tool_volume))
return
if(shock(user, 50))
return
user.visible_message(span_notice("[user] cuts the splicing."), span_notice("You cut the splicing."))
investigate_log(" was cut by [key_name(usr)] in [AREACOORD(src)]")
qdel(src)

/obj/structure/wire_splicing/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/stack/cable_coil) && user.a_intent == INTENT_HARM)
var/obj/item/stack/cable_coil/coil = I
if(coil.get_amount() >= 1)
reinforce(user, coil)
reinforce(user, coil)
return
. = ..()

/obj/structure/wire_splicing/proc/reinforce(mob/user, obj/item/stack/cable_coil/coil)
if(messiness >= 10)
if(messiness >= MAX_MESSINESS)
to_chat(user, span_warning("You can't seem to jam more cable into the splicing!"))
return
if(!do_after(user, 2 SECONDS, src))
if(!do_after(user, 2 SECONDS, target = src, progress = TRUE))
return
messiness = min(messiness + 1, 10)
investigate_log("wire splicing was reinforced to [messiness] by [key_name(usr)] in [AREACOORD(src)]")
if(messiness >= MAX_MESSINESS)
return
messiness = min(messiness + 1, MAX_MESSINESS)
coil.use(1)
if(messiness < 10 && coil.get_amount() >= 1)
reinforce(user, coil)
update_icon(UPDATE_ICON_STATE)
investigate_log("wire splicing was reinforced to [messiness] by [key_name(usr)] in [AREACOORD(src)]")

#undef MAX_MESSINESS

0 comments on commit a9f6245

Please sign in to comment.