• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Orbit Trigger

Status
Not open for further replies.
Level 29
Joined
Jul 29, 2007
Messages
5,174
Well a rawcode is the "real" name of an object in the object editor (units, abilities, doodads, upgrades, everything).

Rawcodes are made from four letters/numbers.

To see rawcodes, press Ctrl+D in the object editor.

Now if a jass code requires you to put a rawcode, you'll need to put it inside (don't know name in english lol) '' (NOT "").

So for example, the first custom ability in a map will be 'A000'.
 
Level 13
Joined
Sep 24, 2007
Messages
1,023
well i made the code tihng planet when i made the custom unit then i put it in the trigger editor and this came up

[function MoonCreate takes planet p, 20 distance, 2 angle, 15 rotationspeed, 300 circlingspeed, 1 size, h001 model, 11 pnum returns nothing//===========================================================================

and it said
line 94 : Syntax error
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Ok I added a name value.
Now you can set a planet's name and get a planet with its name.

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
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, string name 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 mainplanet.name = name
    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, string name 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 moon.name = name
    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
function GetPlanetByName takes string name returns planet
    local planet p
    local integer i = 0
    loop
        exitwhen i > PCOUNT
        set p = PLANET[i]
        if p.name == name then
            exitwhen true
        endif
        set i = i + 1
    endloop
    return p
endfunction
//===================== Setting planet properties functions =======================
function SetPlanetName takes planet p, string name, string s returns nothing
    local planet pla
    if name == "" and p != null then
        set p.name = s
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        set pla.name = s
    else
        call BJDebugMsg("planet value or name not found")
    endif
endfunction
function SetPlanetRotationSpeed takes planet p, string name, real rotationspeed returns nothing
    local planet pla
    if name == "" and p != null then
        set p.rotationspeed = rotationspeed
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        set pla.rotationspeed = rotationspeed
    else
        call BJDebugMsg("planet value or name not found")
    endif
endfunction
function SetPlanetDistance takes planet p, string name, real distance returns nothing
    local planet pla
    if name == "" and p != null then
        set p.distance = distance
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        set pla.distance = distance
    else
        call BJDebugMsg("planet value or name not found")
    endif
endfunction
function SetPlanetCirclingSpeed takes planet p, string name, real circlingspeed returns nothing
    local planet pla
    if name == "" and p != null then
        set p.circlingspeed = circlingspeed
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        set pla.circlingspeed = circlingspeed
    else
        call BJDebugMsg("planet value or name not found")
    endif
endfunction
function SetPlanetSize takes planet p, string name, real size returns nothing
    local planet pla
    if name == "" and p != null then
        call SetUnitScale(p.self, size, size, size)
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        call SetUnitScale(pla.self, size, size, size)
    else
        call BJDebugMsg("planet value or name not found")
    endif
endfunction
function SetPlanetOwner takes planet p, string name, integer pnum returns nothing
    local planet pla
    if name == "" and p != null then
        call SetUnitOwner(p.self, Player(pnum), true)
    elseif p == null and name != "" then
        set pla = GetPlanetByName(name)
        call SetUnitOwner(pla.self, Player(pnum), true)
    else
        call BJDebugMsg("planet value or name not found")
    endif
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


For example
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call MainCreate(1000, 1000, 10, 15, 2.5, 'h000', 0, "sun")
      • Custom script: call MoonCreate(GetPlanetByName("sun"), 500, 40, 7, 10, 1, 'h000', 0, "moon1")
      • Custom script: call MoonCreate(GetPlanetByName("moon1"), 100, 230, 4, 6, .5, 'h000', 0, "moon2")
The first one creates a main planet called "sun", the second one creates a moon for sun called moon1, and the third one creates a moon for moon1 called moon2.
 
Last edited:
Level 7
Joined
Dec 8, 2005
Messages
319
so are you trying to make a space game? and if so then you might want to think about being able to move on a Y scale... i remeber seeing a swimming spell that someone made... it would give it some depth to the game... just a thought.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
so are you trying to make a space game? and if so then you might want to think about being able to move on a Y scale... i remeber seeing a swimming spell that someone made... it would give it some depth to the game... just a thought.

Making that with real physics (and with the owning RtC of course) will be awesomely hard.

Well anyway, guess ill just stop upgrading this since Gallin or anyone else in this forum don't even know Jass :S
 
Level 12
Joined
Jul 11, 2007
Messages
642
GhostWolf, very nice system, but by making it vJASS, you made it only for Windows. I'm afraid that program is in a format that can only be downloaded for windows (possibly linx(or however you spell it(sorry))). I'd recommend you try to make a demo one WITHOUT using vJASS for the few of the mac users in the world (enunciation on the me). That will attract (however much larger(1 or 10)) an audience... larger.... by a little.

Now for a suggestion. I'd recommend you make a demo map with everything already in it (even imports for regular planets).

You want to know why I'm interested? Because I made this system and got yelled at, screamed at, and "Ignored"... well... this is the real deal for making our solar system. It isn't liked because our asteroid belt is well... huge... and I used a laggy model, appoligise!
One a (typical) windows, yes it does run only 15-30 fps, but on my mac it does run 80-120 so those numbers are relative.

To do others systems, it would be easiest to mod Wolf's. And don't give up, it's not a bad idea.
'

Actually, GhostWolf, what do you say if we combine our systems? We could (together) make the ultimate orbiting system!

(I apologies for all the wonderful parentheses)

-supermj
 
Level 29
Joined
Jul 29, 2007
Messages
5,174

I'm sorry but I'm not planning on stopping using vJass. It will make my code to work SO much slower.
Instead of a lot of integers and a one nice global timer, I will need to use tons of H2I and tons of local timers, so sorry but, no.

Anyway, there's not much point in making this altogether, as most of the people here can't even work with Jass.
 
Status
Not open for further replies.
Top