ID:1554647
 
(See the best response by Kaiochao.)
Problem description:

What I am aiming to do is make an object/multiple objects circle, orbit basically, in a circle pattern around a player constantly until they choose to make them stop and then they would be deleted.

So for instance I use the move and they start orbiting around me and if I start walking then they would keep orbiting around me but when I use the move again they go away. Also if the objects hit a person or say another object it would get deleted and the person would be damaged, if it hits an object then it would just be deleted, same with a dense turf.

How would I go about coding this? I believe using animate() could help achieve this but i'm not to sure how it should be involved.
Best response
You could use animate(), but since you need collision detection, they could desynchronize (since animations are client-side and collisions -- which use the physical, not apparent, position of the particle -- are not).

This requires trigonometry and a time loop. The position of an orbiter can be found using the polar coordinates: (Distance, Angle), where Distance is constant (for a circle) and Angle changes at a constant rate over time.

Polar coordinates can easily be converted to Rectangular coordinates. This formula can be found through Google.

If you are using pixel movement, you'll need a way to set the pixel position of the particle relative to the player that it's orbiting. I would do it this way (using my "absolute positions" library but the concept is there):
mob
var tmp/obj/orbiter/orbiter

verb/toggle_orbiter()
if(orbiter)
orbiter.loc = null
orbiter = null
else
var obj/orbiter/new_orbiter = new (loc)
orbiter = new_orbiter
while(orbiter == new_orbiter && orbiter.loc)
orbiter.Tick(src)
sleep world.tick_lag

obj/orbiter
var tmp/angle = 0 // the current angle
var speed = 2 // how much the angle changes per tick
var radius = 24 // distance from the center of the orbit

icon = // etc.
icon_state = //etc.
bounds = "15,15 to 16,16" // center 2x2 of a 32x32 icon
density = TRUE

proc/Tick(atom/Center) // happens every frame
SetCenter(Center.Cx(), Center.Cy(), Center.z)
Project(radius, angle)
angle += speed

Bump(atom/A)
world << "Bumped [A]"
loc = null

(warning: untested)
Thank you for the reply, i'll try it out and see how it goes.
When I compiled I got 2 errors for undefined procs for SetCenter and Project.

I also got 2 bad proc errors for Center.Cx(), and Center.Cy()
are those two meant to be like that? Or should that be Center.Cx and Center.Cy

And no I am not doing this in pixel movement, the object will be orbiting in tiles around the center, so tile based movement. If pixel movement would be better for this though I could use it.
You have to download this and then check it under the Libs in your DM obj tree list.
Oh I see thank you.
Alright I tested it out and it compiled fine but when I went to test it out I got some runtime errors. But before I get to those, it seems movement was messed up a bit, when I go to move my character it's like a jump ahead one tile with no icon movement change inbetween after that it seems fine, the same thing happens to other mobs on the map.

runtime error: Cannot read null.loc
proc name: toggle orbiter (/mob/verb/toggle_orbiter)
source file: Testing.dm,2313
usr: Twist (/mob)
src: Twist (/mob)
call stack:
Twist (/mob): toggle orbiter()


That line would be
                sleep world.tick_lag


Edit: It seems this error only occurs in specific areas, those areas being places where moves normally aren't allowed, it will even happen if say i'm right under that area. So...

X = Area, O = Me

XXX
XOX = Error Happens
XXX

XXX
XXX = Error Happens
XXX
O

XOX
XXX = Error does not happen
XXX

XXX
XXX O = Error Does not happen
XXX

So basically i'm guessing it happens because the object is
being created in that specific area.

Edit 2: Forgot to mention this but it seems that if the object is in the in spot where I am walking so say i'm walking west and its rotation is over there right now, It makes me walk extremely slow, is this because the object is dense? And if so how would I stop this from happening while still keeping it for what it needs to do.