[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
🆑
fix: Fixes tesla zaps being weird.
admin: Logs explosions from explosive zaps.
/🆑

* [NO GBP]Fixes tesla zaps.

---------

Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-10-31 10:29:50 -07:00
committed by GitHub
co-authored by Pickle-Coding
parent b2921af343
commit eb75696ae9
16 changed files with 39 additions and 38 deletions
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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
@@ -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)
. = ..()
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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
. = ..()
+2 -2
View File
@@ -359,8 +359,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()
@@ -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)
@@ -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
@@ -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
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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
+6 -6
View File
@@ -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
@@ -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
+3 -3
View File
@@ -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
@@ -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
@@ -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!"))