• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Orbit Trigger

Status
Not open for further replies.
Level 13
Joined
Sep 24, 2007
Messages
1,023
i was wondering if anyone could show me how ot create an orbit trigger
a sun would be the center of one of the orbits (notice the word a and one i need more then one orbit in the map) well the planets orbit the sun in a circle and i would also need it so moons orbit the orbiting planets i would also need it to make a space station orbit the planet if this is impossible just tell me and if its possible plz show me how
 
Level 4
Joined
Mar 15, 2008
Messages
71
you could use the sphere ability by editing it in unit editor...but I think it can consist up to 6 sphere's at once...so you should make more sphere abilities...
Don't know If that's what you are looking for
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If you'll want to create it with triggers, the only way I could think of is with vJass and structs (or Jass with a lot of game cache and a big head ace).

This won't be playable though. For example, you won't be able to use the space station because it requires you to instantly move all the units invlolved (stars/buildings/whatever) very fast which doesn't allow you to give them orders.

I will test if you can give orders with a unit instantly moving like this, brb.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Phew what was wrong with the Hive ? :razz:

Anyway, conclusions from testing:

  • You cannot move buildings
  • You can move units
  • You cannot move buildings that are set to units via the Building boolean
  • You can move units that are set to buildings via the Building boolean
  • When moving a unit-based building you CAN order it to produce units

Therefor, make a unit, change it to be a building via the "States - Is a Building" and then add whatever you want to it.

Both of the moving functions (SetUnitX/Y, SetUnitPosition) work for this.
Didn't check the SetUnitPositionLoc but I guess it would work aswell.
 
Level 9
Joined
Nov 17, 2004
Messages
277
I experimented with a solar system once. It is doable to have the planets orbit by moving them a little bit every few seconds with the trigger "move to point with polar offset". However, there are a few problems. Firstly, it looks jumpy, and worse, you would have to take into account units near the planets when they move, or things orbitting the planets. So it can be done, but it doesn't look that great or function well. Hope that helps.
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
a friend of mine gave me this he said it worked also he said it would need to be edited for the orbit of planet to work also the trigger doesnt work or me the planet just disappears
  • movement trigger
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit - Move Planet near sun 0002 <gen> instantly to ((Position of Sun 0001 <gen>) offset by (Distance between (Position of Sun 0001 <gen>) and (Position of Planet near sun 0002 <gen>)) towards ((Angle from (Position of Sun 0001 <gen>) to (Position of Planet near sun 0002 <gen>)) + 3.00) degrees), facing Default building facing degrees
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
I doubt anyone except lord PipeDream would be able to recreate a system of this caliber with correct physics.

Otherwise, yeah you can always just make crappy rotations using polar coordinates. But think about collisions. What would happen if two planets (or objects, for that matter) collide? What happens if a meteor passes by? Should it be attracted by the most dense entity? What about revolution, rotation speed, centripetal/fugal force, 2 dimensional or 3 dimensional, ETC...
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
well if two planets colide they will both be destroyed maybe leaving an astrodie feild in its wake if a planet and a smaller objct hit the bigger one wins more dense objects have more gravitational pull so more dense more stuff would go around it


should i repost this in the jass section or would some1 make the jass trigger for me?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I made this nice funny system today.

It lets you to create anywhere you want a "main planet", which simulates the sun, and "moon planets" which can be any other planet.
Basically the only difference between them is that a Main planet doesn't move in circles.

When you create them, you give them values like this:
function MainCreate takes real x, real y, real angle, real rotationspeed, real size, integer model, integer pnum returns nothing

x,y is the coordinates the planet is created at, angle is the starting face angle, rotationspeed is the speed it rotates (not MOVE, planets rotate around themselves), size is the size of the model, model is the model Rawcode, for example: 'h000', pnum is the owner number, for example 0 = red.

function MoonCreate takes planet p, real distance, real angle, real rotationspeed, real circlingspeed, real size, integer model, integer pnum returns nothing

planet p is the "father" of this moon which is the planet it will circle around, distance is the distance from the moon to its father, angle is the starting angle between the father and the moon, rotationspeed is the speed it rotates around itself, circlingspeed is the speed it circles its father, size is the size, model is the model, pnum is the owner.

The speed (rotationspeed, circlingspeed) works based on seconds, so if you put 1, it will do it in 1 second.

You can set planets properties after they were created with this functions
function SetRotationSpeed takes planet p, real rotationspeed returns nothing function SetDistance takes planet p, real distance returns nothing function SetCirclingSpeed takes planet p, real circlingspeed returns nothing function SetSize takes planet p, real size returns nothing function SetOwner takes planet p, integer pnum returns nothing


Im trying to make a DestroyPlanet function (destroys the planet and all its moons) but I just can't seem to make it work good :S

Examples on using this with GUI:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call MainCreate( 1000, 1000, 50, 8, 2, 'h000', 0)
      • Custom script: call MoonCreate( PLANET[0], 300, 20, 4, 4, 1.5, 'h000', 0 )
      • Custom script: call MoonCreate( PLANET[1], 80, 80, 4, 1, .8, 'h000', 0 )

Give me some suggestions if you want more stuff in it.
I thought of allowing to give names to each planet you make and then you can get it by that name, I will see if it is worth the trouble.

Here is the result (its not smooth only because of the gif):
 

Attachments

  • Planets.gif
    Planets.gif
    2.2 MB · Views: 226
Level 29
Joined
Jul 29, 2007
Messages
5,174
is there anyway you could put this into the map because it seems a bit hard to create

It requires vJass which requires JNGP (Jass New Gen Pack), so if you don't have it, get it here.
Other then that, to implant it you only need to copy the code to any trigger, no need renaming or anything like that.
Warning! If you use vJass in your map you will not be able to open it with a World Editor without JNGP.

Please give me more suggestions on add-ons though, I feel like it needs more stuff in it :p
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
whats jngp???? and with vjass i tohught i heard somewhere you could incress the map size past 256 is that true what about a black hole forming every once and a while and then that transposts the solor system to another part of the galaxy and having this black hole pull everything around it and then teleport it to the other place
also maybe some comets that have an oval orbit so they might hit something an astroid belt
also i was going to have more then one planet and more then one sun would this trigger work for all that??
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
whats jngp???? and with vjass i tohught i heard somewhere you could incress the map size past 256 is that true

JNGP is a pack of some nice programs made for the World Editor.
It hacks the World Editor and allows you to do a lot of extra things (almost everything is for Jass, a bit for the object editor).
It doesn't CHANGE the editor and therefor, no you can't increase map size.

what about a black hole forming every once and a while and then that transposts the solor system to another part of the galaxy and having this black hole pull everything around it and then teleport it to the other place

Sounds kinda hard to me, ill try it though.

also maybe some comets that have an oval orbit so they might hit something an astroid belt

Didn't get this (need to learn some more english :<).

also i was going to have more then one planet and more then one sun would this trigger work for all that??

Of course, as you saw in the GUI example I made only 1 Main planet and 2 Moon planets, you can make as many as you like though.

I wanted to make the name system so you can easily refer to a planet, including the fact that their variables might change (I think, or its another bug in the DestroyPlanet, need to check it), this seems a necessity to me.
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
you are aweare of the astroid belt between mars and planet earth maybe make more of those and also have comets which travel at high speeds and have an ovel shaped orbit that causes it to at one point in its orbit be very far form the sun and during another point in the orbit be very close to the sun
 
Level 4
Joined
Mar 2, 2008
Messages
83
you are aweare of the astroid belt between mars and planet earth maybe make more of those and also have comets which travel at high speeds and have an ovel shaped orbit that causes it to at one point in its orbit be very far form the sun and during another point in the orbit be very close to the sun


Epic Fail

sol-syst-frontpage.jpg
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
It didn't slow down, it went back because it recorded a bit more then a lap.

I implanted Comets, I think they work fine but need some more testing.

I'm now trying to add some physic stuff but I truly suck at it and don't understand a but of it, so if someone who does can pm me ill be glad.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
I felt like working on a system for this yesterday. It effectively simulates revolution and stuff, not rotation yet. What's cool is it adjusts to the amount of objects relative to their properties in real-time. I only made it in 2D because I felt that 3D would be unnecessary in this sort of system. I'm just trying to find a formula that would allow perfectly circular orbit...
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
In my thingy you can make Main planets where ever you want, by giving the X and Y coordinates you want.
You can then attach Moon planets to them if you want.

Guess ill stop working on it though, HINDY will pwn me anyway :<

In case you want it, here it is (the Comets are a bit buggy).

JASS:
               library Wolf

globals
    planet array PLANET
    comet array COMET
    integer PCOUNT = 0
    integer CCOUNT = 0
    timer PTIMER = CreateTimer()
    timer CTIMER = CreateTimer()
    string array PNAME
    string array CNAME
    constant integer MAX_FOLLOW = 5 // change this to change the maximum number of instances following the commet
endglobals
                                        
            struct planet
                unit self
                unit father
                real distance
                real rotationspeed
                real circlingspeed
                real angle
                string name
            endstruct
            struct comet
                unit self
                unit array follow[MAX_FOLLOW]
                integer countfollow
                real speed
                real angle
                string name
            endstruct

function CometDestroy takes comet c returns nothing
    local integer i = 0
    loop
        exitwhen i > c.countfollow
        call RemoveUnit(c.follow[i])
        set i = i + 1
    endloop
    call RemoveUnit(c.self)
    call c.destroy()
endfunction
function OutofMap takes real x, real y returns boolean
    if x < GetCameraBoundMinX() or x > GetCameraBoundMaxX() or y < GetCameraBoundMinY() or y > GetCameraBoundMaxY() then
        return true
    endif
    return false
endfunction
function MoveComets takes nothing returns nothing
    local comet c
    local integer i = 0
    local integer int = 0
    local unit u
    local unit un
    loop
        exitwhen i > CCOUNT
        set c = COMET[i]
        set u = c.self
        call SetUnitX(u, GetUnitX(u) + c.speed / 25 * Cos(c.angle * bj_DEGTORAD))
        call SetUnitY(u, GetUnitY(u) + c.speed / 25 * Sin(c.angle * bj_DEGTORAD))
        if OutofMap(GetUnitX(u), GetUnitY(u)) then
            call CometDestroy(c)
        endif
        loop
            exitwhen int > c.countfollow
            set un = c.follow[int]
            call SetUnitX(un, GetUnitX(un) + c.speed / 25 * Cos(c.angle * bj_DEGTORAD))
            call SetUnitY(un, GetUnitY(un) + c.speed / 25 * Sin(c.angle * bj_DEGTORAD))
            set int = int + 1
        endloop
        set u = null
        set i = i + 1
    endloop
    if CCOUNT == 0 then
        call PauseTimer(CTIMER)
    endif
endfunction
function MovePlanets takes nothing returns nothing
    local planet p
    local integer i = 0
    loop
        exitwhen i > PCOUNT
        set p = PLANET[i]
        set p.angle = p.angle + p.circlingspeed
        call SetUnitX(p.self, GetUnitX(p.father) + p.distance * Cos(p.angle * bj_DEGTORAD))
        call SetUnitY(p.self, GetUnitY(p.father) + p.distance * Sin(p.angle * bj_DEGTORAD))
        call SetUnitFacing(p.self, GetUnitFacing(p.self) + p.rotationspeed)
        set i = i + 1
    endloop
    if PCOUNT == 0 then
        call PauseTimer(PTIMER)
    endif
endfunction
function MainCreate takes real x, real y, real angle, real rotationspeed, real size, integer model, integer pnum returns nothing
    local planet mainplanet = planet.create()
    local unit u = CreateUnit(Player(pnum), model, x, y, angle)
    call SetUnitScale(u, size, size, size)
    set mainplanet.self = u
    set mainplanet.rotationspeed = 14.4 * rotationspeed
    set mainplanet.angle = angle
    set PCOUNT = PCOUNT + 1
    set PLANET[PCOUNT - 1] = mainplanet
    if PCOUNT - 1 == 0 then  
        call TimerStart(PTIMER, 0.04, true, function MovePlanets)
    endif
    set u = null
endfunction
function MoonCreate takes planet p, real distance, real angle, real rotationspeed, real circlingspeed, real size, integer model, integer pnum returns nothing
    local planet moon = planet.create()
    local unit u = CreateUnit(Player(pnum), model, GetUnitX(p.self) + distance * Cos(angle * bj_DEGTORAD), GetUnitY(p.self) + distance * Sin(angle * bj_DEGTORAD), 0)
    if p == null then
        call BJDebugMsg("Error: planet p is null")
    endif
    call SetUnitScale(u, size, size, size)
    set moon.self = u
    set moon.father = p.self
    set moon.distance = distance
    set moon.rotationspeed = 14.4 * rotationspeed
    set moon.circlingspeed = 14.4 * circlingspeed
    set moon.angle = angle
    set PCOUNT = PCOUNT + 1
    set PLANET[PCOUNT - 1] = moon
    set u = null
endfunction
function DestroyPlanet takes planet d returns nothing
    local planet p
    local integer i = 0
    loop
        exitwhen i > PCOUNT
        set p = PLANET[i]
        if p.father == d.self then
            set PLANET[PCOUNT] = PLANET[PCOUNT-1]
            set PCOUNT = PCOUNT -1
            call KillUnit(p.self)
            call p.destroy()
        endif
        set i = i + 1
    endloop
    set PLANET[PCOUNT] = PLANET[PCOUNT-1]
    set PCOUNT = PCOUNT -1
    call KillUnit(d.self)
    call d.destroy()
endfunction
function CometCreate takes real x, real y, real angle, real speed, real size, integer model, integer pnum, integer fnumber, real fdistance returns nothing
    local comet c = comet.create()
    local unit u = CreateUnit(Player(pnum), model, x, y, angle)
    local unit follow
    local integer i = 1
    loop
        exitwhen i > fnumber
        set follow = CreateUnit(Player(pnum), model, x - fdistance * i * Cos(angle * bj_DEGTORAD), y - fdistance * i * Sin(angle * bj_DEGTORAD), angle)
        call SetUnitVertexColor(follow, 100, 100, 100, 100 * -i)
        call SetUnitScale(follow, 100 - 10 * i, 100 - 10 * i, 100 - 10 * i)
        set c.follow[c.countfollow] = follow
        set c.countfollow = c.countfollow + 1
        set c.follow[c.countfollow - 1] = follow
        set i = i + 1
    endloop
    set c.self = u
    set c.speed = speed
    set c.angle = angle
    call SetUnitScale(u, size, size, size)
    if CCOUNT == 0 then
        call TimerStart(CTIMER, 0.04, true, function MoveComets)
    endif
    set CCOUNT = CCOUNT + 1
    set COMET[CCOUNT - 1] = c
    set u = null
endfunction

//===================== Helper functions =======================
function LastCreatedPlanet takes nothing returns planet
    return PLANET[PCOUNT - 1]
endfunction
function LastCreatedComet takes nothing returns comet
    return COMET[CCOUNT - 1]
endfunction
//===================== Setting planet properties functions =======================
function SetPlanetName takes planet p, string s returns nothing
    set p.name = s
endfunction
function SetPlanetRotationSpeed takes planet p, real rotationspeed returns nothing
    set p.rotationspeed = rotationspeed
endfunction
function SetPlanetDistance takes planet p, real distance returns nothing
    set p.distance = distance
endfunction
function SetPlanetCirclingSpeed takes planet p, real circlingspeed returns nothing
    set p.circlingspeed = circlingspeed
endfunction
function SetPlanetSize takes planet p, real size returns nothing
    call SetUnitScale(p.self, size, size, size)
endfunction
function SetPlanetOwner takes planet p, integer pnum returns nothing
    call SetUnitOwner(p.self, Player(pnum), true)
endfunction
//===================== Setting comet properties functions =======================
function SetCometName takes comet c, string s returns nothing
    set c.name = s
endfunction
function SetCometSpeed takes comet c, real s returns nothing
    set c.speed = s
endfunction
function SetCometSize takes comet c, real size returns nothing
    call SetUnitScale(c.self, size, size, size)
endfunction
function SetCometOwner takes comet c, integer pnum returns nothing
    call SetUnitOwner(c.self, Player(pnum), true)
endfunction   

                                        endlibrary


I added as you can see LastCreatedPlanet/Commet.

So now its a lot easier to refer to planets you have just created.
Example:
  • Custom script: call MainCreate( 1000, 1000, 50, 8, 2, 'h000', 0)
  • Custom script: call MoonCreate( LastCreatedPlanet(), 300, 20, 4, 4, 1.5, 'h000', 0 )
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
K ill explain again.

This system is made of three parts.

Main planets
which act like the sun - planets that circle around themselves but don't move.
Moon planets which act like any other planet - they circle around themselves and also around their "father" planet.
Comets which are a bit buggy and not looking good are just what they are...

Now you wish to make a solar system.
For that you'll need firstly to create a Main planet as the sun, then create for it as many Moon planets as you want (example: Earth is a moon planet which has the Moon as ITS Moon planet).

In the video example I made a Main planet, a Moon planet for the Main, and a Moon planet for the Moon planet.

Now to create them, simply follow what is in the function

function MainCreate takes real x, real y, real angle, real rotationspeed, real size, integer model, integer pnum returns nothing [function MoonCreate takes planet p, real distance, real angle, real rotationspeed, real circlingspeed, real size, integer model, integer pnum returns nothing function CometCreate takes real x, real y, real angle, real speed, real size, integer model, integer pnum, integer fnumber, real fdistance returns nothing

Every time you want to call one of this functions, you will use a custom script, make it like this call Function_Name(parameters).

This means that to create a Main planet for example, you will need to give it a x,y coordinates, the angle the planet will face upon creation, the rotation speed (the speed it turns around itself), size of the model, the model Rawcode, and the player that owns the planet.

Now to explain all the parameters:
  • x - real value, the x part of the location where the planet will be created.
  • y - real value, the Y part of the location where the planet will be created.
  • angle - real value, the angle that the object will be facing upon creation.
  • planet p - planet value, the planet which this Moon planet will circle around.
  • rotation speed - real value, the speed (in seconds) at which the planet will rotate around itself.
  • distance - real value, the distance at which a Moon planet will be created from its father planet.
  • circling speed - real value, the speed (in seconds) at which the planet will circle around its father planet.
  • size - real value, the size of the model (same as in the object editor)
  • model - integer value, the raw code of the model, for example: 'h000'.
  • pnum - integer value, the owner of the object (remember that players in Jass start at 0 and not at 1).
  • fnumber - integer value, the number of the following units (to make a comet look like a comet), if you want more then 5 followers, change this line constant integer MAX_FOLLOW = 5 to whatever number you want.
  • fdistance - real value, the distance between each follower.

Now to set stats after creation, use this functions
function SetPlanetName takes planet p, string s returns nothing function SetPlanetRotationSpeed takes planet p, real rotationspeed returns nothing function SetPlanetDistance takes planet p, real distance returns nothing function SetPlanetCirclingSpeed takes planet p, real circlingspeed returns nothing function SetPlanetSize takes planet p, real size returns nothing function SetPlanetOwner takes planet p, integer pnum returns nothing function SetCometName takes comet c, string s returns nothing function SetCometSpeed takes comet c, real s returns nothing function SetCometSize takes comet c, real size returns nothing function SetCometOwner takes comet c, integer pnum returns nothing


To get the last created Planet/Comet, use this functions
function LastCreatedPlanet takes nothing returns planet function LastCreatedComet takes nothing returns comet


So now, lets say we want to create the a sun, two planets that will circle around the sun, and one moon for each one of this planets.
The code will be something like this:
  • Actions
    • Custom script: call MainCreate( 1000, 1000, 50, 8, 2, 'h000', 0)
    • Custom script: call MoonCreate( LastCreatedPlanet, 300, 20, 4, 4, 1.5, 'h000', 0 )
    • Custom script: call MoonCreate( LastCreatedPlanet, 80, 80, 4, 1, .8, 'h000', 0 )
    • Custom script: call MoonCreate( PLANET[0], 500, 180, 2, 2, 4, 'h000', 0 )
    • Custom script: call MoonCreate( LastCreatedPlanet, 50, 320, 1, 4, 1, 'h000', 0 )
The third one needed PLANET[0] because the last created planet wasn't the sun, it was the first planet's moon.
Whenever you create a planet, its real name is PLANET[Integer+1], starting by the first planet which is PLANET[0].

I would have made a name system but since HINDY is gonna pwn me anyway I stopped.
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
wait your goign to be able to capture these tihngs right?????? also will player made object be able to circle this?

and I HAVE NO CLUE HOW TO PUT THIS IN is there any possible way that you would put it in the map?
 
Last edited:
Status
Not open for further replies.
Top