From d6d1f0b31f67507bfb32d5c3446cd8034419a761 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:29:50 +0100 Subject: [PATCH] [MIRROR] [NO GBP]Fixes tesla zaps. [MDB IGNORE] (#24698) * [NO GBP]Fixes tesla zaps. (#79398) ## About The Pull Request Closes #79297 Closes #79312 Due to the new cutoff parameter being added to tesla_zap() (from #78310), and most callers used positional arguments instead of keywords, the zap flags was getting fed the shocked_targets list and maybe other junk. This caused a bunch of unusual phenomena. This is fixed by using keyword arguments. Tesla zaps that use the grid were significantly weaker in terms of damage than they're supposed to be. This was a byproduct of trying to convert everything to joules and removing unnecessary power multipliers. This is fixed by reverting the damage scaling and zap power of zap sources that aren't based on grid. Technically this will cause the zaps from other sources to have less power, but these tend to not be able to put power on grid, so this wouldn't have any change other than what a grounding rod displays. Doesn't really matter. Logs machine explosions from zap_act. Not the most helpful log (would take a lot of effort to add an extra parameter to pass the source), but better than nothing. Probably other stuff I did, lol. ## Why It's Good For The Game Stops zap fuckery. Admins can now find the explosions when a 9GeV engine decides to go haywire or whatever. ## Changelog :cl: fix: Fixes tesla zaps being weird. admin: Logs explosions from explosive zaps. /:cl: * [NO GBP]Fixes tesla zaps. --------- Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com> --- code/datums/mutations/touch.dm | 6 +++--- code/game/machinery/_machinery.dm | 4 ++-- .../objects/effects/anomalies/anomalies_flux.dm | 4 ++-- code/game/objects/obj_defense.dm | 2 +- code/game/objects/structures.dm | 2 +- code/game/objects/structures/grille.dm | 4 ++-- .../abductor/equipment/glands/electric.dm | 2 +- code/modules/antagonists/blob/structures/_blob.dm | 4 ++-- code/modules/clothing/suits/reactive_armour.dm | 4 ++-- code/modules/power/rtg.dm | 2 +- code/modules/power/tesla/coil.dm | 2 +- code/modules/power/tesla/energy_ball.dm | 12 ++++++------ code/modules/projectiles/projectile/energy/tesla.dm | 8 ++++---- code/modules/projectiles/projectile/magic.dm | 6 +++--- .../reagents/chemistry/recipes/pyrotechnics.dm | 13 +++++++------ .../organs/internal/stomach/stomach_ethereal.dm | 2 +- 16 files changed, 39 insertions(+), 38 deletions(-) diff --git a/code/datums/mutations/touch.dm b/code/datums/mutations/touch.dm index 3f798ba52b2..743f2b3fbf8 100644 --- a/code/datums/mutations/touch.dm +++ b/code/datums/mutations/touch.dm @@ -38,7 +38,7 @@ ///This var decides if the spell should chain, dictated by presence of power chromosome var/chain = FALSE ///Affects damage, should do about 1 per limb - var/zap_power = 3e6 + var/zap_power = 7500 ///Range of tesla shock bounces var/zap_range = 7 ///flags that dictate what the tesla shock can interact with, Can only damage mobs, Cannot damage machines or generate energy @@ -60,7 +60,7 @@ span_userdanger("[caster] electrocutes you!"), ) if(chain) - tesla_zap(victim, zap_range, zap_power, zap_flags) + tesla_zap(source = victim, zap_range = zap_range, power = zap_power, cutoff = 1e3, zap_flags = zap_flags) carbon_victim.visible_message(span_danger("An arc of electricity explodes out of [victim]!")) return TRUE @@ -72,7 +72,7 @@ span_userdanger("[caster] electrocutes you!"), ) if(chain) - tesla_zap(victim, zap_range, zap_power, zap_flags) + tesla_zap(source = victim, zap_range = zap_range, power = zap_power, cutoff = 1e3, zap_flags = zap_flags) living_victim.visible_message(span_danger("An arc of electricity explodes out of [victim]!")) return TRUE diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm index 710b5c7ec09..e72c2da00bb 100644 --- a/code/game/machinery/_machinery.dm +++ b/code/game/machinery/_machinery.dm @@ -1130,9 +1130,9 @@ /obj/machinery/zap_act(power, zap_flags) if(prob(85) && (zap_flags & ZAP_MACHINE_EXPLOSIVE) && !(resistance_flags & INDESTRUCTIBLE)) - explosion(src, devastation_range = 1, heavy_impact_range = 2, light_impact_range = 4, flame_range = 2, adminlog = FALSE, smoke = FALSE) + explosion(src, devastation_range = 1, heavy_impact_range = 2, light_impact_range = 4, flame_range = 2, adminlog = TRUE, smoke = FALSE) else if(zap_flags & ZAP_OBJ_DAMAGE) - take_damage(power * 6.25e-7, BURN, ENERGY) + take_damage(power * 2.5e-4, BURN, ENERGY) if(prob(40)) emp_act(EMP_LIGHT) power -= power * 5e-4 diff --git a/code/game/objects/effects/anomalies/anomalies_flux.dm b/code/game/objects/effects/anomalies/anomalies_flux.dm index 2bb3ab28a1a..35b8bc388d7 100644 --- a/code/game/objects/effects/anomalies/anomalies_flux.dm +++ b/code/game/objects/effects/anomalies/anomalies_flux.dm @@ -66,7 +66,7 @@ ///range in whuich we zap var/zap_range = 1 ///strength of the zappy - var/zap_power = 1e6 + var/zap_power = 2500 ///the zappy flags var/zap_flags = ZAP_GENERATES_POWER | ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE @@ -78,7 +78,7 @@ /obj/effect/anomaly/flux/big/anomalyEffect() . = ..() - tesla_zap(src, zap_range, zap_power, zap_flags) + tesla_zap(source = src, zap_range = zap_range, power = zap_power, cutoff = 1e3, zap_flags = zap_flags) /obj/effect/anomaly/flux/big/Bumped(atom/movable/bumpee) . = ..() diff --git a/code/game/objects/obj_defense.dm b/code/game/objects/obj_defense.dm index 7f135fe839c..2a6db83d9d4 100644 --- a/code/game/objects/obj_defense.dm +++ b/code/game/objects/obj_defense.dm @@ -160,7 +160,7 @@ if(has_buckled_mobs()) for(var/m in buckled_mobs) var/mob/living/buckled_mob = m - buckled_mob.electrocute_act((clamp(round(strength * 3.125e-6), 10, 90) + rand(-5, 5)), src, flags = SHOCK_TESLA) + buckled_mob.electrocute_act((clamp(round(strength * 1.25e-3), 10, 90) + rand(-5, 5)), src, flags = SHOCK_TESLA) ///the obj is deconstructed into pieces, whether through careful disassembly or when destroyed. /obj/proc/deconstruct(disassembled = TRUE) diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index ba8623ec4aa..cdc2b2bd5ec 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -63,6 +63,6 @@ /obj/structure/zap_act(power, zap_flags) if(zap_flags & ZAP_OBJ_DAMAGE) - take_damage(power * 1.5625e-7, BURN, "energy") + take_damage(power * 2.5e-4, BURN, "energy") power -= power * 5e-4 //walls take a lot out of ya . = ..() diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 3d68af42dc7..6983dbdac14 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -352,8 +352,8 @@ var/obj/structure/cable/C = T.get_cable_node() if(C) playsound(src, 'sound/magic/lightningshock.ogg', 100, TRUE, extrarange = 5) - tesla_zap(src, 3, C.newavail() * 0.01, ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_MOB_STUN | ZAP_LOW_POWER_GEN | ZAP_ALLOW_DUPLICATES) //Zap for 1/100 of the amount of power. At a million watts in the grid, it will be as powerful as a tesla revolver shot. - C.add_delayedload(C.newavail() * 0.0375) // you can gain up to 3.5 via the 4x upgrades power is halved by the pole so thats 2x then 1X then .5X for 3.5x the 3 bounces shock. + tesla_zap(source = src, zap_range = 3, power = C.newavail() * 0.01, cutoff = 1e3, zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_MOB_STUN | ZAP_LOW_POWER_GEN | ZAP_ALLOW_DUPLICATES) //Zap for 1/100 of the amount of power. At a million watts in the grid, it will be as powerful as a tesla revolver shot. + C.add_delayedload(C.newavail() * 0.0375) // you can gain up to 3.5 via the 4x upgrades power is halved by the pole so thats 2x then 1X then .5X for 3.5x the 3 bounces shock. // What do you mean by this? return ..() /obj/structure/grille/get_dumping_location() diff --git a/code/modules/antagonists/abductor/equipment/glands/electric.dm b/code/modules/antagonists/abductor/equipment/glands/electric.dm index 9c4d47dc337..a3107af0217 100644 --- a/code/modules/antagonists/abductor/equipment/glands/electric.dm +++ b/code/modules/antagonists/abductor/equipment/glands/electric.dm @@ -22,5 +22,5 @@ addtimer(CALLBACK(src, PROC_REF(zap)), rand(30, 100)) /obj/item/organ/internal/heart/gland/electric/proc/zap() - tesla_zap(owner, 4, 3.2e6, ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_MOB_STUN) + tesla_zap(source = owner, zap_range = 4, power = 8e3, cutoff = 1e3, zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_MOB_STUN) playsound(get_turf(owner), 'sound/magic/lightningshock.ogg', 50, TRUE) diff --git a/code/modules/antagonists/blob/structures/_blob.dm b/code/modules/antagonists/blob/structures/_blob.dm index e206d97c26b..324c91ea3a5 100644 --- a/code/modules/antagonists/blob/structures/_blob.dm +++ b/code/modules/antagonists/blob/structures/_blob.dm @@ -227,9 +227,9 @@ /obj/structure/blob/zap_act(power, zap_flags) if(overmind) if(overmind.blobstrain.tesla_reaction(src, power)) - take_damage(power * 3.125e-6, BURN, ENERGY) + take_damage(power * 1.25e-3, BURN, ENERGY) else - take_damage(power * 3.125e-6, BURN, ENERGY) + take_damage(power * 1.25e-3, BURN, ENERGY) power -= power * 2.5e-3 //You don't get to do it for free return ..() //You don't get to do it for free diff --git a/code/modules/clothing/suits/reactive_armour.dm b/code/modules/clothing/suits/reactive_armour.dm index 6c33e287f03..9fec4dbe82b 100644 --- a/code/modules/clothing/suits/reactive_armour.dm +++ b/code/modules/clothing/suits/reactive_armour.dm @@ -226,7 +226,7 @@ emp_message = span_warning("The tesla capacitors beep ominously for a moment.") clothing_traits = list(TRAIT_TESLA_SHOCKIMMUNE) /// How strong are the zaps we give off? - var/zap_power = 1e7 + var/zap_power = 2.5e4 /// How far to the zaps we give off go? var/zap_range = 20 /// What flags do we pass to the zaps we give off? @@ -240,7 +240,7 @@ /obj/item/clothing/suit/armor/reactive/tesla/reactive_activation(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) owner.visible_message(span_danger("[src] blocks [attack_text], sending out arcs of lightning!")) - tesla_zap(owner, zap_range, zap_power, zap_flags) + tesla_zap(source = owner, zap_range = zap_range, power = zap_power, cutoff = 1e3, zap_flags = zap_flags) reactivearmor_cooldown = world.time + reactivearmor_cooldown_duration return TRUE diff --git a/code/modules/power/rtg.dm b/code/modules/power/rtg.dm index 974c2e66737..af48e9c5944 100644 --- a/code/modules/power/rtg.dm +++ b/code/modules/power/rtg.dm @@ -71,7 +71,7 @@ visible_message(span_danger("\The [src] lets out a shower of sparks as it starts to lose stability!"),\ span_hear("You hear a loud electrical crack!")) playsound(src.loc, 'sound/magic/lightningshock.ogg', 100, TRUE, extrarange = 5) - tesla_zap(src, 5, power_gen * 20) + tesla_zap(source = src, zap_range = 5, power = power_gen * 20) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(explosion), src, 2, 3, 4, null, 8), 10 SECONDS) // Not a normal explosion. /obj/machinery/power/rtg/abductor/bullet_act(obj/projectile/Proj) diff --git a/code/modules/power/tesla/coil.dm b/code/modules/power/tesla/coil.dm index 48facb18f02..972c98d4862 100644 --- a/code/modules/power/tesla/coil.dm +++ b/code/modules/power/tesla/coil.dm @@ -116,7 +116,7 @@ power = min(surplus(), power) //Take the smaller of the two add_load(power) playsound(src.loc, 'sound/magic/lightningshock.ogg', zap_sound_volume, TRUE, zap_sound_range) - tesla_zap(src, 10, power, 1e3, zap_flags) + tesla_zap(source = src, zap_range = 10, power = power, cutoff = 1e3, zap_flags = zap_flags) zap_buckle_check(power) /obj/machinery/power/energy_accumulator/grounding_rod diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 9298e46512e..3e0f3baef0d 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -76,7 +76,7 @@ pixel_y = 0 shocked_things.Cut(1, shocked_things.len / 1.3) var/list/shocking_info = list() - tesla_zap(src, 3, TESLA_DEFAULT_POWER, shocked_targets = shocking_info) + tesla_zap(source = src, zap_range = 3, power = TESLA_DEFAULT_POWER, shocked_targets = shocking_info) pixel_x = -32 pixel_y = -32 @@ -84,7 +84,7 @@ var/range = rand(1, clamp(orbiting_balls.len, 2, 3)) var/list/temp_shock = list() //We zap off the main ball instead of ourselves to make things looks proper - tesla_zap(src, range, TESLA_MINI_POWER/7*range, shocked_targets = temp_shock) + tesla_zap(source = src, zap_range = range, power = TESLA_MINI_POWER / 7 * range, shocked_targets = temp_shock) shocking_info += temp_shock shocked_things += shocking_info @@ -334,7 +334,7 @@ var/mob/living/closest_mob = closest_atom ADD_TRAIT(closest_mob, TRAIT_BEING_SHOCKED, WAS_SHOCKED) addtimer(TRAIT_CALLBACK_REMOVE(closest_mob, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS) - var/shock_damage = (zap_flags & ZAP_MOB_DAMAGE) ? (min(round(power/2.4e5), 90) + rand(-5, 5)) : 0 + var/shock_damage = (zap_flags & ZAP_MOB_DAMAGE) ? (min(round(power / 600), 90) + rand(-5, 5)) : 0 closest_mob.electrocute_act(shock_damage, source, 1, SHOCK_TESLA | ((zap_flags & ZAP_MOB_STUN) ? NONE : SHOCK_NOSTUN)) if(issilicon(closest_mob)) var/mob/living/silicon/S = closest_mob @@ -350,11 +350,11 @@ if(prob(20))//I know I know var/list/shocked_copy = shocked_targets.Copy() - tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_copy)//Normally I'd copy here so grounding rods work properly, but it fucks with movement - tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_targets) + tesla_zap(source = closest_atom, zap_range = next_range, power = power * 0.5, cutoff = cutoff, zap_flags = zap_flags, shocked_targets = shocked_copy) + tesla_zap(source = closest_atom, zap_range = next_range, power = power * 0.5, cutoff = cutoff, zap_flags = zap_flags, shocked_targets = shocked_targets) shocked_targets += shocked_copy else - tesla_zap(closest_atom, next_range, power, zap_flags, shocked_targets) + tesla_zap(source = closest_atom, zap_range = next_range, power = power, cutoff = cutoff, zap_flags = zap_flags, shocked_targets = shocked_targets) #undef BIKE #undef COIL diff --git a/code/modules/projectiles/projectile/energy/tesla.dm b/code/modules/projectiles/projectile/energy/tesla.dm index 65b9ba0162e..9dfe043a015 100644 --- a/code/modules/projectiles/projectile/energy/tesla.dm +++ b/code/modules/projectiles/projectile/energy/tesla.dm @@ -5,24 +5,24 @@ damage = 10 //A worse lasergun var/zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_LOW_POWER_GEN var/zap_range = 3 - var/power = 4e6 + var/power = 1e4 /obj/projectile/energy/tesla/on_hit(atom/target, blocked = 0, pierce_hit) . = ..() - tesla_zap(src, zap_range, power, zap_flags) + tesla_zap(source = src, zap_range = zap_range, power = power, cutoff = 1e3, zap_flags = zap_flags) qdel(src) /obj/projectile/energy/tesla/process() . = ..() //Many coders have given their blood for this speed - tesla_zap(src, zap_range, power, zap_flags) + tesla_zap(source = src, zap_range = zap_range, power = power, cutoff = 1e3, zap_flags = zap_flags) /obj/projectile/energy/tesla/revolver name = "energy orb" /obj/projectile/energy/tesla/cannon name = "tesla orb" - power = 8e6 + power = 2e4 damage = 15 //Mech man big /obj/projectile/energy/tesla_cannon diff --git a/code/modules/projectiles/projectile/magic.dm b/code/modules/projectiles/projectile/magic.dm index 7b2d546b668..2f3214d5d90 100644 --- a/code/modules/projectiles/projectile/magic.dm +++ b/code/modules/projectiles/projectile/magic.dm @@ -481,7 +481,7 @@ speed = 0.3 /// The power of the zap itself when it electrocutes someone - var/zap_power = 8e6 + var/zap_power = 2e4 /// The range of the zap itself when it electrocutes someone var/zap_range = 15 /// The flags of the zap itself when it electrocutes someone @@ -496,14 +496,14 @@ /obj/projectile/magic/aoe/lightning/on_hit(atom/target, blocked = 0, pierce_hit) . = ..() - tesla_zap(src, zap_range, zap_power, zap_flags) + tesla_zap(source = src, zap_range = zap_range, power = zap_power, cutoff = 1e3, zap_flags = zap_flags) /obj/projectile/magic/aoe/lightning/Destroy() QDEL_NULL(chain) return ..() /obj/projectile/magic/aoe/lightning/no_zap - zap_power = 4e6 + zap_power = 1e4 zap_range = 4 zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_LOW_POWER_GEN diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm index d49976ac10e..05bc622faa7 100644 --- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm +++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm @@ -542,9 +542,9 @@ reaction_tags = REACTION_TAG_EASY | REACTION_TAG_EXPLOSIVE | REACTION_TAG_DANGEROUS /datum/chemical_reaction/reagent_explosion/teslium_lightning/on_reaction(datum/reagents/holder, datum/equilibrium/reaction, created_volume) - var/T1 = created_volume * 8e3 //100 units : Zap 3 times, with powers 8e5/2e6/4.8e6. Tesla revolvers have a power of 10000 for comparison. - var/T2 = created_volume * 2e4 - var/T3 = created_volume * 4.8e4 + var/T1 = created_volume * 20 //100 units : Zap 3 times, with powers 8e5/2e6/4.8e6. Tesla revolvers have a power of 10000 for comparison. + var/T2 = created_volume * 50 + var/T3 = created_volume * 120 var/added_delay = 0.5 SECONDS if(created_volume >= 75) addtimer(CALLBACK(src, PROC_REF(zappy_zappy), holder, T1), added_delay) @@ -557,10 +557,11 @@ addtimer(CALLBACK(src, PROC_REF(default_explode), holder, created_volume, modifier, strengthdiv), added_delay) /datum/chemical_reaction/reagent_explosion/teslium_lightning/proc/zappy_zappy(datum/reagents/holder, power) - if(QDELETED(holder.my_atom)) + var/atom/holder_atom = holder.my_atom + if(QDELETED(holder_atom)) return - tesla_zap(holder.my_atom, 7, power, zap_flags) - playsound(holder.my_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) + tesla_zap(source = holder_atom, zap_range = 7, power = power, cutoff = 1e3, zap_flags = zap_flags) + playsound(holder_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) /datum/chemical_reaction/reagent_explosion/teslium_lightning/heat required_temp = 474 diff --git a/code/modules/surgery/organs/internal/stomach/stomach_ethereal.dm b/code/modules/surgery/organs/internal/stomach/stomach_ethereal.dm index 4cc8ee404c1..c1632f33329 100644 --- a/code/modules/surgery/organs/internal/stomach/stomach_ethereal.dm +++ b/code/modules/surgery/organs/internal/stomach/stomach_ethereal.dm @@ -92,7 +92,7 @@ playsound(carbon, 'sound/magic/lightningshock.ogg', 100, TRUE, extrarange = 5) carbon.cut_overlay(overcharge) - tesla_zap(carbon, 2, crystal_charge * 1e3, ZAP_OBJ_DAMAGE | ZAP_LOW_POWER_GEN | ZAP_ALLOW_DUPLICATES) + tesla_zap(source = carbon, zap_range = 2, power = crystal_charge * 2.5, cutoff = 1e3, zap_flags = ZAP_OBJ_DAMAGE | ZAP_LOW_POWER_GEN | ZAP_ALLOW_DUPLICATES) adjust_charge(ETHEREAL_CHARGE_FULL - crystal_charge) carbon.visible_message(span_danger("[carbon] violently discharges energy!"), span_warning("You violently discharge energy!"))