diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 15a1bdcfb0f..7611e5c980f 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1708,4 +1708,40 @@ var/mob/dview/dview_mob = new see_in_dark = 1e6 -/mob/dview/New() //For whatever reason, if this isn't called, then BYOND will throw a type mismatch runtime when attempting to add this to the mobs list. -Fox \ No newline at end of file +/mob/dview/New() //For whatever reason, if this isn't called, then BYOND will throw a type mismatch runtime when attempting to add this to the mobs list. -Fox + + +//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/proc/orbit(atom/A, radius = 10, clockwise = 1, angle_increment = 15) + if(!istype(A)) + return + orbiting = A + var/angle = 0 + var/matrix/initial_transform = matrix(transform) + spawn + while(orbiting) + loc = orbiting.loc + + angle += angle_increment + + var/matrix/shift = matrix(initial_transform) + shift.Translate(radius,0) + if(clockwise) + shift.Turn(angle) + else + shift.Turn(-angle) + animate(src,transform = shift,2) + + 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 \ No newline at end of file