Merge pull request #11285 from Fox-McCloud/elecrocution-refactor

Refactors Electrocution
This commit is contained in:
variableundefined
2019-04-16 19:47:42 +08:00
committed by GitHub
31 changed files with 158 additions and 143 deletions

View File

@@ -1878,7 +1878,7 @@
var/logmsg = null
switch(punishment)
if("Lightning bolt")
M.electrocute_act(5, "Lightning Bolt", safety=1)
M.electrocute_act(5, "Lightning Bolt", safety = TRUE, override = TRUE)
playsound(get_turf(M), 'sound/magic/lightningshock.ogg', 50, 1, -1)
M.adjustFireLoss(75)
M.Weaken(5)

View File

@@ -234,14 +234,14 @@
/datum/plant_gene/trait/cell_charge/on_slip(obj/item/reagent_containers/food/snacks/grown/G, mob/living/carbon/C)
var/power = G.seed.potency*rate
if(prob(power))
C.electrocute_act(round(power), G, 1, 1)
C.electrocute_act(round(power), G, 1, TRUE)
/datum/plant_gene/trait/cell_charge/on_squash(obj/item/reagent_containers/food/snacks/grown/G, atom/target)
if(iscarbon(target))
if(isliving(target))
var/mob/living/carbon/C = target
var/power = G.seed.potency*rate
if(prob(power))
C.electrocute_act(round(power), G, 1, 1)
C.electrocute_act(round(power), G, 1, TRUE)
/datum/plant_gene/trait/cell_charge/on_consume(obj/item/reagent_containers/food/snacks/grown/G, mob/living/carbon/target)
if(!G.reagents.total_volume)

View File

@@ -134,43 +134,48 @@
M.forceMove(get_turf(src))
visible_message("<span class='danger'>[M] bursts out of [src]!</span>")
/mob/living/carbon/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, override = 0, tesla_shock = 0)
/mob/living/carbon/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
SEND_SIGNAL(src, COMSIG_LIVING_ELECTROCUTE_ACT, shock_damage)
if(status_flags & GODMODE) //godmode
return 0
return FALSE
if(NO_SHOCK in mutations) //shockproof
return 0
return FALSE
if(tesla_shock && tesla_ignore)
return FALSE
shock_damage *= siemens_coeff
if(shock_damage<1 && !override)
return 0
if(dna && dna.species)
shock_damage *= dna.species.siemens_coeff
if(shock_damage < 1 && !override)
return FALSE
if(reagents.has_reagent("teslium"))
shock_damage *= 1.5 //If the mob has teslium in their body, shocks are 50% more damaging!
take_overall_damage(0,shock_damage, TRUE, used_weapon = "Electrocution")
shock_internal_organs(shock_damage)
if(illusion)
adjustStaminaLoss(shock_damage)
else
take_overall_damage(0, shock_damage, TRUE, used_weapon = "Electrocution")
shock_internal_organs(shock_damage)
visible_message(
"<span class='danger'>[src] was shocked by \the [source]!</span>", \
"<span class='userdanger'>You feel a powerful shock coursing through your body!</span>", \
"<span class='italics'>You hear a heavy electrical crack.</span>" \
)
"<span class='danger'>[src] was shocked by \the [source]!</span>",
"<span class='userdanger'>You feel a powerful shock coursing through your body!</span>",
"<span class='italics'>You hear a heavy electrical crack.</span>")
AdjustJitter(1000) //High numbers for violent convulsions
do_jitter_animation(jitteriness)
AdjustStuttering(2)
if(!tesla_shock || (tesla_shock && siemens_coeff > 0.5))
if((!tesla_shock || (tesla_shock && siemens_coeff > 0.5)) && stun)
Stun(2)
spawn(20)
AdjustJitter(-1000, bound_lower = 10) //Still jittery, but vastly less
if(!tesla_shock || (tesla_shock && siemens_coeff > 0.5))
if((!tesla_shock || (tesla_shock && siemens_coeff > 0.5)) && stun)
Stun(3)
Weaken(3)
if(shock_damage > 200)
src.visible_message(
"<span class='danger'>[src] was arc flashed by the [source]!</span>", \
"<span class='userdanger'>The [source] arc flashes and electrocutes you!</span>", \
"<span class='italics'>You hear a lightning-like crack!</span>" \
)
"<span class='danger'>[src] was arc flashed by the [source]!</span>",
"<span class='userdanger'>The [source] arc flashes and electrocutes you!</span>",
"<span class='italics'>You hear a lightning-like crack!</span>")
playsound(loc, 'sound/effects/eleczap.ogg', 50, 1, -1)
explosion(src.loc,-1,0,2,2)
explosion(loc, -1, 0, 2, 2)
if(override)
return override
else

View File

@@ -551,13 +551,8 @@
dna.species.update_sight(src)
//Removed the horrible safety parameter. It was only being used by ninja code anyways.
//Now checks siemens_coefficient of the affected area by default
/mob/living/carbon/human/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = 0, override = 0, tesla_shock = 0)
if(status_flags & GODMODE) //godmode
return 0
if(NO_SHOCK in mutations) //shockproof
return 0
//Added a safety check in case you want to shock a human mob directly through electrocute_act.
/mob/living/carbon/human/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
if(tesla_shock)
var/total_coeff = 1
if(gloves)
@@ -575,20 +570,18 @@
siemens_coeff = 0
else if(!safety)
var/gloves_siemens_coeff = 1
var/species_siemens_coeff = 1
if(gloves)
var/obj/item/clothing/gloves/G = gloves
gloves_siemens_coeff = G.siemens_coefficient
if(dna.species)
species_siemens_coeff = dna.species.siemens_coeff
siemens_coeff = gloves_siemens_coeff * species_siemens_coeff
if(undergoing_cardiac_arrest())
siemens_coeff = gloves_siemens_coeff
if(undergoing_cardiac_arrest() && !illusion)
if(shock_damage * siemens_coeff >= 1 && prob(25))
set_heartattack(FALSE)
if(stat == CONSCIOUS)
to_chat(src, "<span class='notice'>You feel your heart beating again!</span>")
. = ..()
dna.species.spec_electrocute_act(src, shock_damage, source, siemens_coeff, safety, override, tesla_shock, illusion, stun)
. = ..(shock_damage, source, siemens_coeff, safety, override, tesla_shock, illusion, stun)
/mob/living/carbon/human/Topic(href, href_list)
if(!usr.stat && usr.canmove && !usr.restrained() && in_range(src, usr))

View File

@@ -309,6 +309,9 @@
/datum/species/proc/handle_death(mob/living/carbon/human/H) //Handles any species-specific death events (such as dionaea nymph spawns).
return
/datum/species/proc/spec_electrocute_act(mob/living/carbon/human/H, shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
return
/datum/species/proc/help(mob/living/carbon/human/user, mob/living/carbon/human/target, datum/martial_art/attacker_style)
if(attacker_style && attacker_style.help_act(user, target))//adminfu only...
return TRUE

View File

@@ -55,8 +55,22 @@
/mob/living/proc/check_projectile_dismemberment(obj/item/projectile/P, def_zone)
return 0
/mob/living/proc/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = 0, tesla_shock = 0)
return 0 //only carbon liveforms have this proc
/mob/living/proc/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
SEND_SIGNAL(src, COMSIG_LIVING_ELECTROCUTE_ACT, shock_damage)
if(status_flags & GODMODE) //godmode
return FALSE
if(NO_SHOCK in mutations) //shockproof
return FALSE
if(tesla_shock && tesla_ignore)
return FALSE
if(shock_damage > 0)
if(!illusion)
adjustFireLoss(shock_damage)
visible_message(
"<span class='danger'>[src] was shocked by \the [source]!</span>",
"<span class='userdanger'>You feel a powerful shock coursing through your body!</span>",
"<span class='italics'>You hear a heavy electrical crack.</span>")
return shock_damage
/mob/living/emp_act(severity)
var/list/L = src.get_contents()

View File

@@ -71,6 +71,9 @@
/mob/living/silicon/drop_item()
return
/mob/living/silicon/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
return FALSE //So borgs they don't die trying to fix wiring
/mob/living/silicon/emp_act(severity)
switch(severity)
if(1)

View File

@@ -85,6 +85,9 @@
/mob/living/simple_animal/hostile/construct/narsie_act()
return
/mob/living/simple_animal/hostile/construct/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE)
return FALSE
/////////////////Juggernaut///////////////

View File

@@ -142,7 +142,7 @@
return
/mob/living/simple_animal/hostile/floor_cluwne/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = 0, tesla_shock = 0, illusion = 0, stun = TRUE)//prevents runtimes with machine fuckery
/mob/living/simple_animal/hostile/floor_cluwne/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = FALSE, override = FALSE, tesla_shock = FALSE, illusion = FALSE, stun = TRUE) //prevents runtimes with machine fuckery
return FALSE

View File

@@ -49,6 +49,7 @@
anchored = 1
use_power = NO_POWER_USE
req_access = list(access_engine_equip)
siemens_strength = 1
var/spooky=0
var/area/area
var/areastring = null
@@ -535,7 +536,7 @@
if(C.amount >= 10 && !terminal && opened && has_electronics != 2)
var/turf/T = get_turf(src)
var/obj/structure/cable/N = T.get_cable_node()
if(prob(50) && electrocute_mob(usr, N, N))
if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE))
do_sparks(5, 1, src)
return
C.use(10)
@@ -1237,13 +1238,13 @@
if(prob(5))
var/list/shock_mobs = list()
for(var/C in view(get_turf(src), 5)) //We only want to shock a single random mob in range, not every one.
if(iscarbon(C))
shock_mobs +=C
if(isliving(C))
shock_mobs += C
if(shock_mobs.len)
var/mob/living/carbon/S = pick(shock_mobs)
S.electrocute_act(rand(5,25), "electrical arc")
playsound(get_turf(S), 'sound/effects/eleczap.ogg', 75, 1)
Beam(S,icon_state="lightning[rand(1,12)]",icon='icons/effects/effects.dmi',time=5)
var/mob/living/L = pick(shock_mobs)
L.electrocute_act(rand(5, 25), "electrical arc")
playsound(get_turf(L), 'sound/effects/eleczap.ogg', 75, 1)
Beam(L, icon_state = "lightning[rand(1, 12)]", icon = 'icons/effects/effects.dmi', time = 5)
else // no cell, switch everything off

View File

@@ -191,14 +191,14 @@ By design, d1 is the smallest direction and d2 is the highest
src.add_fingerprint(user)
// shock the user with probability prb
/obj/structure/cable/proc/shock(mob/user, prb, var/siemens_coeff = 1.0)
/obj/structure/cable/proc/shock(mob/user, prb, siemens_coeff = 1)
if(!prob(prb))
return 0
return FALSE
if(electrocute_mob(user, powernet, src, siemens_coeff))
do_sparks(5, 1, src)
return 1
return TRUE
else
return 0
return FALSE
//explosion handling
/obj/structure/cable/ex_act(severity)

View File

@@ -162,23 +162,10 @@
ex_act(EXPLODE_DEVASTATE)
/obj/item/stock_parts/cell/proc/get_electrocute_damage()
switch(charge)
if(5000000 to INFINITY)
return min(rand(200, 300),rand(200, 300))
if(4000000 to 5000000 - 1)
return min(rand(80, 180),rand(80, 180))
if(1000000 to 4000000 - 1)
return min(rand(50, 160),rand(50, 160))
if(200000 to 1000000 - 1)
return min(rand(25, 80),rand(25, 80))
if(100000 to 200000 - 1)//Ave powernet
return min(rand(20, 60),rand(20, 60))
if(50000 to 100000 - 1)
return min(rand(15, 40),rand(15, 40))
if(1000 to 50000 - 1)
return min(rand(10, 20),rand(10, 20))
else
return 0
if(charge >= 1000)
return Clamp(20 + round(charge / 25000), 20, 195) + rand(-5, 5)
else
return 0
// Cell variants
/obj/item/stock_parts/cell/empty/New()

View File

@@ -353,7 +353,7 @@
M.show_message("[user.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
if(on && (W.flags & CONDUCT))
if(prob(12))
electrocute_mob(user, get_area(src), src, 0.3)
electrocute_mob(user, get_area(src), src, 0.3, TRUE)
broken()
else
@@ -387,7 +387,7 @@
if(has_power() && (W.flags & CONDUCT))
do_sparks(3, 1, src)
if(prob(75))
electrocute_mob(user, get_area(src), src, rand(0.7,1.0))
electrocute_mob(user, get_area(src), src, rand(0.7, 1), TRUE)
// returns whether this light has power

View File

@@ -298,34 +298,37 @@
//power_source is a source of electricity, can be powercell, area, apc, cable, powernet or null
//source is an object caused electrocuting (airlock, grille, etc)
//No animations will be performed by this proc.
/proc/electrocute_mob(mob/living/carbon/M as mob, var/power_source, var/obj/source, var/siemens_coeff = 1.0)
/proc/electrocute_mob(mob/living/M, power_source, obj/source, siemens_coeff = 1, dist_check = FALSE)
if(!istype(M))
return 0
return FALSE
if(istype(M.loc,/obj/mecha))
return 0 //feckin mechs are dumb
return FALSE //feckin mechs are dumb
if(dist_check)
if(!in_range(source, M))
return FALSE
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(H.gloves)
var/obj/item/clothing/gloves/G = H.gloves
if(G.siemens_coefficient == 0)
return 0 //to avoid spamming with insulated glvoes on
return FALSE //to avoid spamming with insulated glvoes on
var/area/source_area
if(istype(power_source,/area))
if(istype(power_source, /area))
source_area = power_source
power_source = source_area.get_apc()
if(istype(power_source,/obj/structure/cable))
if(istype(power_source, /obj/structure/cable))
var/obj/structure/cable/Cable = power_source
power_source = Cable.powernet
var/datum/powernet/PN
var/obj/item/stock_parts/cell/cell
if(istype(power_source,/datum/powernet))
if(istype(power_source, /datum/powernet))
PN = power_source
else if(istype(power_source,/obj/item/stock_parts/cell))
cell = power_source
else if(istype(power_source,/obj/machinery/power/apc))
else if(istype(power_source, /obj/machinery/power/apc))
var/obj/machinery/power/apc/apc = power_source
cell = apc.cell
if(apc.terminal)
@@ -344,7 +347,7 @@
if(cell)
cell_damage = cell.get_electrocute_damage()
var/shock_damage = 0
if(PN_damage>=cell_damage)
if(PN_damage >= cell_damage)
power_source = PN
shock_damage = PN_damage
else

View File

@@ -128,23 +128,10 @@
newavail = 0
/datum/powernet/proc/get_electrocute_damage()
switch(avail)
if(5000000 to INFINITY)
return min(rand(200,300),rand(200,300))
if(4000000 to 5000000)
return min(rand(80,180),rand(80,180))
if(1000000 to 4000000)
return min(rand(50,160),rand(50,160))
if(200000 to 1000000)
return min(rand(25,80),rand(25,80))
if(100000 to 200000)//Ave powernet
return min(rand(20,60),rand(20,60))
if(50000 to 100000)
return min(rand(15,40),rand(15,40))
if(1000 to 50000)
return min(rand(10,20),rand(10,20))
else
return 0
if(avail >= 1000)
return Clamp(20 + round(avail / 25000), 20, 195) + rand(-5, 5)
else
return 0
////////////////////////////////////////////////
// Misc.

View File

@@ -78,7 +78,7 @@
if(isliving(user))
var/shock_damage = min(rand(30,40),rand(30,40))
if(iscarbon(user))
if(isliving(user) && !issilicon(user))
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)

View File

@@ -183,7 +183,7 @@
playsound(src.loc, I.usesound, 50, 1)
if(do_after(user, 50 * I.toolspeed, target = src))
if(prob(50) && electrocute_mob(usr, terminal.powernet, terminal)) //animate the electrocution if uncautious and unlucky
if(prob(50) && electrocute_mob(usr, terminal.powernet, terminal, 1, TRUE)) //animate the electrocution if uncautious and unlucky
do_sparks(5, 1, src)
return
@@ -320,7 +320,7 @@
if(do_after(user, 50, target = src))
var/turf/T = get_turf(user)
var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one
if(prob(50) && electrocute_mob(user, N, N)) //animate the electrocution if uncautious and unlucky
if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE)) //animate the electrocution if uncautious and unlucky
do_sparks(5, 1, src)
return

View File

@@ -115,6 +115,16 @@
/obj/singularity/energy_ball/Bumped(atom/A)
dust_mobs(A)
/obj/singularity/energy_ball/attack_tk(mob/user)
if(iscarbon(user))
var/mob/living/carbon/C = user
to_chat(C, "<span class='userdanger'>That was a shockingly dumb idea.</span>")
var/obj/item/organ/internal/brain/B = C.get_int_organ(/obj/item/organ/internal/brain)
C.ghostize(0)
if(B)
B.remove(C)
qdel(B)
/obj/singularity/energy_ball/orbit(obj/singularity/energy_ball/target)
if(istype(target))
target.orbiting_balls += src
@@ -130,6 +140,10 @@
qdel(src)
/obj/singularity/energy_ball/proc/dust_mobs(atom/A)
if(isliving(A))
var/mob/living/L = A
if(L.incorporeal_move || L.status_flags & GODMODE)
return
if(!iscarbon(A))
return
for(var/obj/machinery/power/grounding_rod/GR in orange(src, 2))
@@ -155,7 +169,6 @@
var/static/blacklisted_tesla_types = typecacheof(list(/obj/machinery/atmospherics,
/obj/machinery/power/emitter,
/obj/machinery/field/generator,
/mob/living/simple_animal,
/obj/machinery/particle_accelerator/control_box,
/obj/structure/particle_accelerator/fuel_chamber,
/obj/structure/particle_accelerator/particle_emitter/center,
@@ -165,6 +178,9 @@
/obj/structure/particle_accelerator/end_cap,
/obj/machinery/field/containment,
/obj/structure/disposalpipe,
/obj/structure/disposaloutlet,
/obj/machinery/disposal/deliveryChute,
/obj/machinery/camera,
/obj/structure/sign,
/obj/machinery/gateway,
/obj/structure/grille,
@@ -255,7 +271,7 @@
else if(closest_mob)
var/shock_damage = Clamp(round(power/400), 10, 90) + rand(-5, 5)
closest_mob.electrocute_act(shock_damage, source, 1, tesla_shock = 1)
closest_mob.electrocute_act(shock_damage, source, 1, tesla_shock = TRUE)
if(issilicon(closest_mob))
var/mob/living/silicon/S = closest_mob
if(stun_mobs)

View File

@@ -1171,6 +1171,6 @@
shock_timer++
if(shock_timer >= rand(5,30)) //Random shocks are wildly unpredictable
shock_timer = 0
M.electrocute_act(rand(5,20), "Teslium in their body", 1, 1) //Override because it's caused from INSIDE of you
M.electrocute_act(rand(5, 20), "Teslium in their body", 1, TRUE) //Override because it's caused from INSIDE of you
playsound(M, "sparks", 50, 1)
return ..()

View File

@@ -376,9 +376,9 @@
/datum/chemical_reaction/shock_explosion/on_reaction(datum/reagents/holder, created_volume)
var/turf/T = get_turf(holder.my_atom)
for(var/mob/living/carbon/C in view(min(8, round(created_volume * 2)), T))
C.Beam(T,icon_state="lightning[rand(1,12)]",icon='icons/effects/effects.dmi',time=5) //What? Why are we beaming from the mob to the turf? Turf to mob generates really odd results.
C.electrocute_act(3.5, "electrical blast")
for(var/mob/living/L in view(min(8, round(created_volume * 2)), T))
L.Beam(T, icon_state = "lightning[rand(1, 12)]", icon = 'icons/effects/effects.dmi', time = 5) //What? Why are we beaming from the mob to the turf? Turf to mob generates really odd results.
L.electrocute_act(3.5, "electrical blast")
holder.del_reagent("teslium") //Clear all remaining Teslium and Uranium, but leave all other reagents untouched.
holder.del_reagent("uranium")