--g_rotatesundirection = {} local speed = 0.4 local radius = 1300 local pos = {} local ang = {} local origin = {} local tspeed = 0 local gotOrigin = false function _rotatesundirection_init(e) end -- Main Function function _rotatesundirection_main(e) CollisionOff(e) if not gotOrigin then PositionObject(g_Entity[e].obj, 0, radius*0.75, g_Entity[e].z) tspeed = 90 origin.x, origin.y, origin.z = g_PlayerPosX, g_PlayerPosY, g_PlayerPosZ gotOrigin = true end ydir = (0-AngleToPoint(e,origin.x,origin.z)) xdir = (math.sin(math.rad(180-ydir))*100) zdir = (math.cos(math.rad(180-ydir))*100) pos.y = g_Entity[e].y - 600 ydir = (pos.y / radius) * 90 SetSunDirection( xdir, ydir, zdir ) --now circle the sun tspeed = tspeed + speed local offset = tspeed * (math.pi / 180) --Converting Degrees To Radians pos.x = origin.x + radius * math.cos(offset) -- Position The Orbiter Along x-axis pos.y = origin.y + radius * 0.75 * math.sin(offset) -- Position The Orbiter Along y-axis pos.z = g_Entity[e].z PositionObject(g_Entity[e]['obj'],pos.x,pos.y,pos.z) RotateToCamera(e) --PromptLocal(e,ang.x.." "..ang.y.." "..ang.z) end -- Exit Function function _rotatesundirection_exit(e) SetSunDirection(5,10,5) end function AngleToPoint(e,x,z) local destx = x - g_Entity[e]['x'] local destz = z - g_Entity[e]['z'] local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle < 1 then angle = angle + 360 elseif angle > 360 then angle = angle - 360 end --SetRotation(e,0,angle,0) return angle end