From e38417cebea4ae6e37fc13d10964316b3deb051f Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Thu, 31 Dec 2015 17:28:27 -0500 Subject: [PATCH] Electrocution Refactor+Electric Reagents --- code/datums/spells/lightning.dm | 4 +- .../shadowling/shadowling_abilities.dm | 5 +- code/modules/mob/living/carbon/carbon.dm | 59 ++++++++----------- .../mob/living/carbon/human/examine.dm | 3 + code/modules/mob/living/carbon/human/human.dm | 27 +++++---- .../mob/living/carbon/human/species/golem.dm | 2 +- .../living/carbon/human/species/species.dm | 2 + code/modules/mob/living/living_defense.dm | 2 +- .../living/simple_animal/bot_swarm/swarmer.dm | 3 +- .../revenant/revenant_abilities.dm | 2 +- code/modules/reagents/newchem/pyro.dm | 18 ++++++ code/modules/reagents/newchem/toxins.dm | 34 +++++++++++ 12 files changed, 106 insertions(+), 55 deletions(-) diff --git a/code/datums/spells/lightning.dm b/code/datums/spells/lightning.dm index 37804317b69..e99261aa8bd 100644 --- a/code/datums/spells/lightning.dm +++ b/code/datums/spells/lightning.dm @@ -74,10 +74,10 @@ obj/effect/proc_holder/spell/targeted/lightning/proc/Reset(mob/user = usr) origin.Beam(target,icon_state="lightning[rand(1,12)]",icon='icons/effects/effects.dmi',time=5) var/mob/living/carbon/current = target if(bounces < 1) - current.electrocute_act(bolt_energy,"Lightning Bolt", def_zone = "chest") + current.electrocute_act(bolt_energy,"Lightning Bolt",safety=1) playsound(get_turf(current), 'sound/machines/defib_zap.ogg', 50, 1, -1) else - current.electrocute_act(bolt_energy,"Lightning Bolt", def_zone = "chest") + current.electrocute_act(bolt_energy,"Lightning Bolt",safety=1) playsound(get_turf(current), 'sound/machines/defib_zap.ogg', 50, 1, -1) var/list/possible_targets = new for(var/mob/living/M in view_or_range(range,target,"view")) diff --git a/code/game/gamemodes/shadowling/shadowling_abilities.dm b/code/game/gamemodes/shadowling/shadowling_abilities.dm index d6f5f2e47fc..f4186557627 100644 --- a/code/game/gamemodes/shadowling/shadowling_abilities.dm +++ b/code/game/gamemodes/shadowling/shadowling_abilities.dm @@ -706,8 +706,9 @@ datum/reagent/shadowling_blindness_smoke/on_mob_life(var/mob/living/M as mob) if(is_shadow_or_thrall(target)) continue target << "You are struck by a bolt of lightning!" - playsound(target, 'sound/effects/eleczap.ogg', 50, 1) - target.electrocute_act(80, "lightning bolt", def_zone = "chest") + playsound(target, 'sound/magic/LightningShock.ogg', 50, 1) + target.Weaken(8) + target.take_organ_damage(0,50) usr.Beam(target,icon_state="red_lightning",icon='icons/effects/effects.dmi',time=1) /obj/effect/proc_holder/spell/targeted/shadowlingAscendantTransmit diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 0d4985009cb..8c9ffd8400e 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -114,8 +114,7 @@ mob/living return return -/mob/living/carbon/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/def_zone = null,var/override = 0, tesla_shock = 0) - +/mob/living/carbon/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, override = 0, tesla_shock = 0) if(status_flags & GODMODE) //godmode return 0 if(NO_SHOCK in mutations) //shockproof @@ -124,42 +123,32 @@ mob/living shock_damage *= siemens_coeff if(shock_damage<1 && !override) return 0 - - src.apply_damage(shock_damage, BURN, def_zone, used_weapon="Electrocution") - - if(heart_attack && prob(25)) - heart_attack = 0 - playsound(loc, "sparks", 50, 1, -1) - if (shock_damage < 10) - src.visible_message( - "\red [src] was mildly shocked by the [source].", \ - "\red You feel a mild shock course through your body.", \ - "\red You hear a light zapping." \ - ) - jitteriness += (rand(2,4))//mostly for the swarmer trap - do_jitter_animation(jitteriness) - if (shock_damage > 10) - if (shock_damage < 200) - src.visible_message( - "\red [src] was shocked by the [source]!", \ - "\red You feel a powerful shock course through your body!", \ - "\red You hear a heavy electrical crack." \ - ) - jitteriness += 1000 //High numbers for violent convulsions - do_jitter_animation(jitteriness) - stuttering += 2 + 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) + //src.burn_skin(shock_damage) + //src.adjustFireLoss(shock_damage) //burn_skin will do this for us + //src.updatehealth() + visible_message( + "[src] was shocked by \the [source]!", \ + "You feel a powerful shock coursing through your body!", \ + "You hear a heavy electrical crack." \ + ) + jitteriness += 1000 //High numbers for violent convulsions + do_jitter_animation(jitteriness) + stuttering += 2 + if(!tesla_shock || (tesla_shock && siemens_coeff > 0.5)) + Stun(2) + spawn(20) + jitteriness = max(jitteriness - 990, 10) //Still jittery, but vastly less if(!tesla_shock || (tesla_shock && siemens_coeff > 0.5)) - Stun(2) - spawn(20) - jitteriness = max(jitteriness - 990, 10) //Still jittery, but vastly less - if(!tesla_shock || (tesla_shock && siemens_coeff > 0.5)) - Stun(3) - Weaken(3) + Stun(3) + Weaken(3) if (shock_damage > 200) src.visible_message( - "\red [src] was arc flashed by the [source]!", \ - "\red The [source] arc flashes and electrocutes you!", \ - "\red You hear a lightning-like crack!" \ + "[src] was arc flashed by the [source]!", \ + "The [source] arc flashes and electrocutes you!", \ + "You hear a lightning-like crack!" \ ) playsound(loc, "sound/effects/eleczap.ogg", 50, 1, -1) explosion(src.loc,-1,0,2,2) diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 15761fb3421..f0e30751fc7 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -245,6 +245,9 @@ else msg += "[t_He] [t_is] quite chubby.\n" + if(reagents.has_reagent("teslium")) + msg += "[t_He] is emitting a gentle blue glow!\n" + msg += "" if(getBrainLoss() >= 60) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 01325c240eb..badfb8268e8 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -742,19 +742,11 @@ //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(var/shock_damage, var/obj/source, var/base_siemens_coeff = 1.0, var/def_zone = null,var/override = 0, tesla_shock = 0) - +/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 - - if (!def_zone) - def_zone = pick("l_hand", "r_hand") - - var/obj/item/organ/external/affected_organ = get_organ(check_zone(def_zone)) - var/siemens_coeff = base_siemens_coeff * get_siemens_coefficient_organ(affected_organ) - if(tesla_shock) var/total_coeff = 1 if(gloves) @@ -766,8 +758,21 @@ if(S.siemens_coefficient <= 0) total_coeff -= 0.95 siemens_coeff = total_coeff - - return ..(shock_damage, source, siemens_coeff, def_zone, override, tesla_shock) + 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(species) + species_siemens_coeff = species.siemens_coeff + siemens_coeff = gloves_siemens_coeff * species_siemens_coeff + if(heart_attack) + if(shock_damage * siemens_coeff >= 1 && prob(25)) + heart_attack = 0 + if(stat == CONSCIOUS) + src << "You feel your heart beating again!" + . = ..(shock_damage,source,siemens_coeff,safety,override,tesla_shock) /mob/living/carbon/human/Topic(href, href_list) diff --git a/code/modules/mob/living/carbon/human/species/golem.dm b/code/modules/mob/living/carbon/human/species/golem.dm index aaa073879fb..ae11d2e8746 100644 --- a/code/modules/mob/living/carbon/human/species/golem.dm +++ b/code/modules/mob/living/carbon/human/species/golem.dm @@ -12,7 +12,7 @@ blood_color = "#515573" flesh_color = "#137E8F" - + siemens_coeff = 0 has_organ = list( "brain" = /obj/item/organ/brain/golem diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index 6cff7f5f7a0..f1fbf8c8299 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -42,6 +42,8 @@ var/passive_temp_gain = 0 //IS_SYNTHETIC species will gain this much temperature every second var/reagent_tag //Used for metabolizing reagents. + var/siemens_coeff = 1 //base electrocution coefficient + var/darksight = 2 var/hazard_high_pressure = HAZARD_HIGH_PRESSURE // Dangerously high pressure. var/warning_high_pressure = WARNING_HIGH_PRESSURE // High pressure warning. diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index a62229d9c5b..4c1780e34d0 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -65,7 +65,7 @@ apply_damage(P.damage, P.damage_type, def_zone, armor) return P.on_hit(src, armor, def_zone) -/mob/living/proc/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/def_zone = null, tesla_shock = 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/emp_act(severity) diff --git a/code/modules/mob/living/simple_animal/bot_swarm/swarmer.dm b/code/modules/mob/living/simple_animal/bot_swarm/swarmer.dm index e04147a7c77..16c20f1cd36 100644 --- a/code/modules/mob/living/simple_animal/bot_swarm/swarmer.dm +++ b/code/modules/mob/living/simple_animal/bot_swarm/swarmer.dm @@ -434,8 +434,7 @@ var/mob/living/L = AM if(!istype(L, /mob/living/simple_animal/hostile/swarmer)) playsound(loc,'sound/effects/snap.ogg',50, 1, -1) - L.Stun(1) //i am doing this here instead of electrocute act - L.electrocute_act(0, src, 1, "l_foot", 1) + L.electrocute_act(0, src, 1, 1) if(isrobot(L) || L.isSynthetic()) L.Weaken(5) qdel(src) diff --git a/code/modules/mob/living/simple_animal/revenant/revenant_abilities.dm b/code/modules/mob/living/simple_animal/revenant/revenant_abilities.dm index 02f231d7f73..29b58c981ab 100644 --- a/code/modules/mob/living/simple_animal/revenant/revenant_abilities.dm +++ b/code/modules/mob/living/simple_animal/revenant/revenant_abilities.dm @@ -105,7 +105,7 @@ if(M == user) return M.Beam(L,icon_state="purple_lightning",icon='icons/effects/effects.dmi',time=5) - M.electrocute_act(shock_damage, "[L.name]") + M.electrocute_act(shock_damage, "[L.name]", safety=1) var/datum/effect/system/spark_spread/z = new /datum/effect/system/spark_spread/ z.set_up(4, 0, M) z.start() diff --git a/code/modules/reagents/newchem/pyro.dm b/code/modules/reagents/newchem/pyro.dm index cb915f9a4c2..57a49b079f8 100644 --- a/code/modules/reagents/newchem/pyro.dm +++ b/code/modules/reagents/newchem/pyro.dm @@ -608,3 +608,21 @@ datum/reagent/firefighting_foam/reaction_obj(var/obj/O, var/volume) var/location = get_turf(holder.my_atom) explosion(location,0,0,3) return + +/datum/chemical_reaction/shock_explosion + name = "shock_explosion" + id = "shock_explosion" + result = null + required_reagents = list("teslium" = 5, "uranium" = 5) //uranium to this so it can't be spammed like no tomorrow without mining help. + result_amount = 1 + mix_message = "The reaction releases an electrical blast!" + mix_sound = 'sound/magic/lightningbolt.ogg' + +/datum/chemical_reaction/shock_explosion/on_reaction(var/datum/reagents/holder, var/created_volume) + var/turf/T = get_turf(holder.my_atom) + for(var/mob/living/carbon/C in view(6, 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(1, "electrical blast") + holder.del_reagent("teslium") //Clear all remaining Teslium and Uranium, but leave all other reagents untouched. + holder.del_reagent("uranium") + return diff --git a/code/modules/reagents/newchem/toxins.dm b/code/modules/reagents/newchem/toxins.dm index 99a500c601a..d71be25ca55 100644 --- a/code/modules/reagents/newchem/toxins.dm +++ b/code/modules/reagents/newchem/toxins.dm @@ -745,3 +745,37 @@ datum/reagent/ants/on_mob_life(var/mob/living/M as mob) M.adjustBruteLoss(2) ..() return + +/datum/reagent/teslium //Teslium. Causes periodic shocks, and makes shocks against the target much more effective. + name = "Teslium" + id = "teslium" + description = "An unstable, electrically-charged metallic slurry. Increases the conductance of living things." + reagent_state = LIQUID + color = "#20324D" //RGB: 32, 50, 77 + metabolization_rate = 0.2 + var/shock_timer = 0 + +/datum/reagent/teslium/on_mob_life(mob/living/M) + 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 + playsound(M, "sparks", 50, 1) + ..() + +/datum/chemical_reaction/teslium + name = "Teslium" + id = "teslium" + result = "teslium" + required_reagents = list("plasma" = 1, "silver" = 1, "blackpowder" = 1) + result_amount = 3 + mix_message = "A jet of sparks flies from the mixture as it merges into a flickering slurry." + min_temp = 400 + mix_sound = null + +/datum/chemical_reaction/teslium/on_reaction(var/datum/reagents/holder, var/created_volume) + var/location = get_turf(holder.my_atom) + var/datum/effect/system/spark_spread/s = new /datum/effect/system/spark_spread + s.set_up(6, 1, location) + s.start() + return \ No newline at end of file