proc/orbit(atom/movable/a,atom/movable/b, speed, dist)
spawn() for(var/degrees = 0; 1; degrees += speed)
if(degrees >= 360) degrees -= 360
if(degrees < 0) degrees += 360
if(degrees2 >= 360) degrees2 -= 360
if(degrees2 < 0) degrees2 += 360
var/s = sin(degrees)
var/c = cos(degrees2)
var/nx = round(c * dist + b.x * 32 + b.step_x + b.bound_x + b.bound_width / 2, 1)
var/ny = round(s * dist + b.y * 32 + b.step_y + b.bound_y + b.bound_height / 2, 1)
a.loc = locate(round(nx / 32) + 1, round(ny / 32) + 1, a.z)
a.step_x = nx - a.x * 32 - a.bound_x - a.bound_width / 2
a.step_y = ny - a.y * 32 - a.bound_y - a.bound_height / 2
The problem here is that when you start taking multiple procs and make them sleep(world.tick_lag), they tend to start activating at the same time and cause more load stress than they need to. Or at least this is the conclusion that my experiences have lead to.
My question is how to do this more efficiently. Should I make a list of orbiting objects and put them in a searchable list, making things like speed and degree effects attached variables, thus only ever calling one of these procs for orbital objects, or would searching a list be just as bad?