diff --git a/code/__HELPERS/matrices.dm b/code/__HELPERS/matrices.dm index 31e6c444d1a..94668321c60 100644 --- a/code/__HELPERS/matrices.dm +++ b/code/__HELPERS/matrices.dm @@ -3,15 +3,24 @@ Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT -/atom/proc/SpinAnimation(speed = 10, loops = -1) - var/matrix/m120 = matrix(transform) - m120.Turn(120) - var/matrix/m240 = matrix(transform) - m240.Turn(240) - var/matrix/m360 = matrix(transform) - speed /= 3 //Gives us 3 equal time segments for our three turns. - //Why not one turn? Because byond will see that the start and finish are the same place and do nothing - //Why not two turns? Because byond will do a flip instead of a turn - animate(src, transform = m120, time = speed, loops) - animate(transform = m240, time = speed) - animate(transform = m360, time = speed) \ No newline at end of file +/atom/proc/SpinAnimation(speed = 10, loops = -1, clockwise = 1, segments = 3) + if(!segments) + return + var/segment = 360/segments + if(!clockwise) + segment = -segment + var/list/matrices = list() + for(var/i in 1 to segments-1) + var/matrix/M = matrix(transform) + M.Turn(segment*i) + matrices += M + var/matrix/last = matrix(transform) + matrices += last + + speed /= segments + + animate(src, transform = matrices[1], time = speed, loops) + for(var/i in 2 to segments) //2 because 1 is covered above + animate(transform = matrices[i], time = speed) + //doesn't have an object argument because this is "Stacking" with the animate call above + //3 billion% intentional diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 7a7213b12bf..e37ca4bfb52 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1665,40 +1665,63 @@ var/mob/dview/dview_mob = new return 1 return 0 -//ORBITS -/atom/movable/var/atom/orbiting = null //This is just so you can stop an orbit. //orbit() can run without it (swap orbiting for A) //but then you can never stop it and that's just silly. +/atom/movable/var/atom/orbiting = null -/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = 1, angle_increment = 15) +//A: atom to orbit +//radius: range to orbit at, radius of the circle formed by orbiting +//clockwise: whether you orbit clockwise or anti clockwise +//rotation_speed: how fast to rotate +//rotation_segments: the resolution of the orbit circle, less = a more block circle, this can be used to produce hexagons (6 segments) triangles (3 segments), and so on, 36 is the best default. +//pre_rotation: Chooses to rotate src 90 degress towards the orbit dir (clockwise/anticlockwise), useful for things to go "head first" like ghosts +//lockinorbit: Forces src to always be on A's turf, otherwise the orbit cancels when src gets too far away (eg: ghosts) + +/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lockinorbit = FALSE) if(!istype(A)) return + + if(orbiting) + stop_orbit() + orbiting = A - var/angle = 0 var/matrix/initial_transform = matrix(transform) - spawn - while(orbiting) - loc = orbiting.loc + var/lastloc = loc - angle += angle_increment + //Head first! + if(pre_rotation) + var/matrix/M = matrix(transform) + var/pre_rot = 90 + if(!clockwise) + pre_rot = -90 + M.Turn(pre_rot) + transform = M - var/matrix/shift = matrix(initial_transform) - shift.Translate(radius,0) - if(clockwise) - shift.Turn(angle) - else - shift.Turn(-angle) - animate(src,transform = shift,2) + var/matrix/shift = matrix(transform) + shift.Translate(0,radius) + transform = shift + + SpinAnimation(rotation_speed, -1, clockwise, rotation_segments) + + //we stack the orbits up client side, so we can assign this back to normal server side without it breaking the orbit + transform = initial_transform + while(orbiting && orbiting == A && A.loc) + var/targetloc = get_turf(A) + if(!lockinorbit && loc != lastloc && loc != targetloc) + break + loc = targetloc + lastloc = loc + sleep(0.6) + + if (orbiting == A) //make sure we haven't started orbiting something else. + orbiting = null + SpinAnimation(0,0) - sleep(0.6) //the effect breaks above 0.6 delay - animate(src,transform = initial_transform,2) /atom/movable/proc/stop_orbit() - if(orbiting) - loc = get_turf(orbiting) - orbiting = null + orbiting = null //Centers an image. //Requires: diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index bf7e324d0bf..11bc2dc3084 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -264,7 +264,7 @@ a { /obj/proc/tesla_act(var/power) being_shocked = 1 - var/power_bounced = power / 2 + var/power_bounced = power / 1.3 tesla_zap(src, 5, power_bounced) spawn(10) being_shocked = 0 diff --git a/code/modules/power/tesla/coil.dm b/code/modules/power/tesla/coil.dm index 67fa8523436..c7509b94242 100644 --- a/code/modules/power/tesla/coil.dm +++ b/code/modules/power/tesla/coil.dm @@ -42,6 +42,7 @@ var/power_produced = power / power_loss add_avail(power_produced*input_power_multiplier) flick("coilhit", src) + playsound(src.loc, 'sound/magic/LightningShock.ogg', 100, 1, extrarange = 5) tesla_zap(src, 5, power_produced) spawn(10) being_shocked = 0 diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 6f8aa7b524e..f1af4c5f66f 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -40,15 +40,16 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics, if(!is_orbiting) handle_energy() var/amount_to_move = 2 + orbiting_balls.len * 2 + var/what_does_the_scouter_say_about_the_balls_power_level = (TESLA_DEFAULT_POWER + (TESLA_MINI_POWER * orbiting_balls.len)) move_the_basket_ball(amount_to_move) pixel_x = 0 pixel_y = 0 - tesla_zap(src, 7, TESLA_DEFAULT_POWER) + playsound(src.loc, 'sound/magic/lightningbolt.ogg', 100, 1, extrarange = 5) + tesla_zap(src, 7, what_does_the_scouter_say_about_the_balls_power_level) pixel_x = -32 pixel_y = -32 energy += rand(1,3) // ensure it generates energy without needing to be blasted by the PA too much due to its size, and that a tesla engine will always get bigger over time else - tesla_zap(src, 7, TESLA_MINI_POWER) energy = 0 // ensure we dont have miniballs of miniballs return @@ -67,17 +68,19 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics, /obj/singularity/energy_ball/proc/handle_energy() if(energy >= 300) - energy = 0 - var/obj/singularity/energy_ball/EB = new(loc) - orbiting_balls.Add(EB) - EB.transform *= pick(0.3,0.4,0.5,0.6,0.7) - EB.is_orbiting = 1 - var/icon/I = icon(icon,icon_state,dir) + energy -= 300 + playsound(src.loc, 'sound/magic/lightning_chargeup.ogg', 100, 1, extrarange = 5) + spawn(100) + var/obj/singularity/energy_ball/EB = new(loc) + orbiting_balls.Add(EB) + EB.transform *= pick(0.3,0.4,0.5,0.6,0.7) + EB.is_orbiting = 1 + var/icon/I = icon(icon,icon_state,dir) - var/orbitsize = (I.Width()+I.Height())*pick(0.5,0.6,0.7) - orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25) - spawn(1) - EB.orbit(src,orbitsize, pick(FALSE,TRUE), rand(10,25), pick(3,4,5,6,36)) + var/orbitsize = (I.Width()+I.Height())*pick(0.5,0.6,0.7) + orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25) + spawn(1) + EB.orbit(src,orbitsize, pick(FALSE,TRUE), rand(10,25), pick(3,4,5,6,36)) @@ -110,7 +113,7 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics, return closest_atom /proc/tesla_zap(var/atom/source, zap_range = 3, power) - if(power < 1000) + if(power < 500) return var/list/tesla_coils = list() var/list/grounding_rods = list() @@ -176,6 +179,9 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics, if(istype(L, /mob/living/silicon)) var/mob/living/silicon/S = L S.emp_act(2) + tesla_zap(S, 7, power / 1.5) // metallic folks bounce it further + else + tesla_zap(L, 5, power / 1.5) return if(!closest_atom) closest_atom = get_closest_atom(/obj/machinery, potential_machine_zaps, source) diff --git a/sound/magic/LightningShock.ogg b/sound/magic/LightningShock.ogg new file mode 100644 index 00000000000..341a2934d6b Binary files /dev/null and b/sound/magic/LightningShock.ogg differ diff --git a/sound/magic/lightning_chargeup.ogg b/sound/magic/lightning_chargeup.ogg new file mode 100644 index 00000000000..0af44495024 Binary files /dev/null and b/sound/magic/lightning_chargeup.ogg differ diff --git a/sound/magic/lightningbolt.ogg b/sound/magic/lightningbolt.ogg new file mode 100644 index 00000000000..e5f6a5731ad Binary files /dev/null and b/sound/magic/lightningbolt.ogg differ