Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes tesla zaps. #367

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/datums/mutations/touch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/effects/anomalies/anomalies_flux.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/obj_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
. = ..()
4 changes: 2 additions & 2 deletions code/game/objects/structures/grille.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions code/modules/antagonists/blob/structures/_blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions code/modules/clothing/suits/reactive_armour.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/rtg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/tesla/coil.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions code/modules/power/tesla/energy_ball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
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
for (var/ball in orbiting_balls)
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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions code/modules/projectiles/projectile/energy/tesla.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions code/modules/projectiles/projectile/magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions code/modules/reagents/chemistry/recipes/pyrotechnics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!"))

Expand Down
Loading