diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 2a223184ccf..32b70c13cd1 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -674,7 +674,7 @@ Turf and target are seperate in case you want to teleport some distance from a t else return get_step(ref, base_dir) -/proc/do_mob(mob/user , mob/target, time = 30, numticks = 5, stealth = 0) //This is quite an ugly solution but i refuse to use the old request system. +/proc/do_mob(mob/user , mob/target, time = 30, numticks = 5, uninterruptible = 0) //This is quite an ugly solution but i refuse to use the old request system. if(!user || !target) return 0 if(numticks == 0) @@ -693,7 +693,7 @@ Turf and target are seperate in case you want to teleport some distance from a t if(user && user.client) user.client.images -= progbar return 0 - if ( user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying ) + if (!uninterruptible && (user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying )) if(user && user.client) user.client.images -= progbar return 0 diff --git a/code/datums/spells/lightning.dm b/code/datums/spells/lightning.dm index 54d0a3378b7..3fbefee6c16 100644 --- a/code/datums/spells/lightning.dm +++ b/code/datums/spells/lightning.dm @@ -10,7 +10,7 @@ cooldown_min = 30 selection_type = "view" random_target = 1 - var/energy = 0 + var/start_time = 0 var/ready = 0 var/image/halo = null var/sound/Snd // so far only way i can think of to stop a sound, thank MSO for the idea. @@ -18,7 +18,7 @@ action_icon_state = "lightning" /obj/effect/proc_holder/spell/targeted/lightning/Click() - if(!ready && energy==0) + if(!ready && start_time==0) if(cast_check()) StartChargeup() else @@ -33,16 +33,14 @@ halo = image("icon"='icons/effects/effects.dmi',"icon_state" ="electricity","layer" = EFFECTS_LAYER) user.overlays.Add(halo) playsound(get_turf(usr), Snd, 50, 0) - spawn(0) - while(ready) - energy++ - if(energy >= 100 && ready) - Discharge() - sleep(1) + start_time = world.time + if(do_mob(user,user,100,uninterruptible=1)) + if(ready) + Discharge() /obj/effect/proc_holder/spell/targeted/lightning/proc/Reset(mob/user = usr) ready = 0 - energy = 0 + start_time = 0 if(halo) user.overlays.Remove(halo) @@ -72,26 +70,18 @@ playsound(get_turf(usr), 'sound/magic/lightningbolt.ogg', 50, 1) user.Beam(target,icon_state="lightning",icon='icons/effects/effects.dmi',time=5) - switch(energy) - if(1 to 25) - target.electrocute_act(10,"Lightning Bolt") - playsound(get_turf(target), 'sound/magic/LightningShock.ogg', 50, 1, -1) - if(25 to 75) - target.electrocute_act(25,"Lightning Bolt") - playsound(get_turf(target), 'sound/magic/LightningShock.ogg', 50, 1, -1) - if(75 to 100) - //CHAIN LIGHTNING - Bolt(user,target,energy,user) + var/energy = min(world.time - start_time,100) + Bolt(user,target,max(15,energy/2),5,user) //5 bounces for energy/2 burn Reset(user) -/obj/effect/proc_holder/spell/targeted/lightning/proc/Bolt(mob/origin,mob/target,bolt_energy,mob/user = usr) +/obj/effect/proc_holder/spell/targeted/lightning/proc/Bolt(mob/origin,mob/target,bolt_energy,bounces,mob/user = usr) origin.Beam(target,icon_state="lightning",icon='icons/effects/effects.dmi',time=5) var/mob/living/carbon/current = target - if(bolt_energy < 75) - current.electrocute_act(25,"Lightning Bolt") + if(bounces < 1) + current.electrocute_act(bolt_energy,"Lightning Bolt",safety=1) playsound(get_turf(current), 'sound/magic/LightningShock.ogg', 50, 1, -1) else - current.electrocute_act(25,"Lightning Bolt") + current.electrocute_act(bolt_energy,"Lightning Bolt",safety=1) playsound(get_turf(current), 'sound/magic/LightningShock.ogg', 50, 1, -1) var/list/possible_targets = new for(var/mob/living/M in view_or_range(range,target,"view")) @@ -102,4 +92,4 @@ return var/mob/living/next = pick(possible_targets) if(next) - Bolt(current,next,bolt_energy-6,user) // 5 max bounces \ No newline at end of file + Bolt(current,next,bolt_energy,bounces-1,user) \ No newline at end of file diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 46fb3469ab3..472e92fdecd 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -376,7 +376,7 @@ Sorry Giacom. Please don't be mad :( return 0 -/mob/living/proc/electrocute_act(shock_damage, obj/source, siemens_coeff = 1.0) +/mob/living/proc/electrocute_act(shock_damage, obj/source, siemens_coeff = 1.0, safety = 0) return 0 //only carbon liveforms have this proc /mob/living/emp_act(severity)