Clan TMMM
Would you like to react to this message? Create an account in a few clicks or log in to continue.


The official site of Clan TMMM
 
HomeHomeSearchLatest imagesRegisterLog in


Latest topics
» Kevkevqaz is back
vJASS help I_icon_minitimeby Eat_bacon_daily Wed Feb 22, 2023 7:22 pm

» Hey whats up
vJASS help I_icon_minitimeby seankly Tue Feb 04, 2020 10:32 pm

» Gotta click fast - WC3 Mazing #mildlyinteresting
vJASS help I_icon_minitimeby hoffmann Wed Jun 21, 2017 10:28 pm

» I'm getting married and you guys are invited
vJASS help I_icon_minitimeby Achilles.42 Wed Sep 07, 2016 11:00 am

» Server Photo Album 1
vJASS help I_icon_minitimeby Pat1487 Sat Aug 06, 2016 5:28 pm

» Legacy of The Void Beta
vJASS help I_icon_minitimeby Achilles.42 Sun Oct 18, 2015 3:21 am

» Hey guys!!!
vJASS help I_icon_minitimeby Eat_bacon_daily Fri Oct 16, 2015 11:20 pm

SC2 Links
SC2 Challenge/Tourney Info

Official SC2 Forums

SC2 Curse

SC2Mapster

Team Liquid

SC2 Replayed

SC2 Strategy
WC3 Links
Clan_TMMM[Host] Info

WC3 Challenge/Tourny Rules

Epicwar
Poll
What game does everyone play now?
Starcraft 2
vJASS help I_vote_lcap26%vJASS help I_vote_rcap
 26% [ 8 ]
Warcraft 3
vJASS help I_vote_lcap35%vJASS help I_vote_rcap
 35% [ 11 ]
League of Legends
vJASS help I_vote_lcap19%vJASS help I_vote_rcap
 19% [ 6 ]
World of Warcraft
vJASS help I_vote_lcap0%vJASS help I_vote_rcap
 0% [ 0 ]
Diablo 2
vJASS help I_vote_lcap0%vJASS help I_vote_rcap
 0% [ 0 ]
No games at all
vJASS help I_vote_lcap10%vJASS help I_vote_rcap
 10% [ 3 ]
Other game not listed
vJASS help I_vote_lcap10%vJASS help I_vote_rcap
 10% [ 3 ]
Total Votes : 31
Transparency

 

 vJASS help

Go down 
3 posters
AuthorMessage
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: vJASS help   vJASS help I_icon_minitimeTue Apr 12, 2011 2:57 am

I'm learning how to use vJASS and I could use a few tips n stuff. unfortunately i cant actually test it cuz jngp is a fickle whore.

like is having this. before all my struct member vars necessary?
or just as good is: did i do this completely wrong?

also is using periodic event ok or should i learn how to use something called timerutils?

Code:
public struct Wheel

    private unit mycenterunit                  private real mydegreesbetweenspokes
    private integer myspokeunitID              private real mydistbetweenspokeunits
    private integer mynumspokes                private real myangularvelocity
    private integer myspokelength              private real myzheight
    private hashtable myunits                  private player myowner

    public method getMyUnits takes nothing returns hashtable
        return this.myunits
    endmethod

    private method rotatewheel takes nothing returns nothing
        //represents the current spoke out of the total number of spokes
        local integer i = 1
        //represents the current unit in a particular spoke
        local integer j = 1
        loop
        exitwhen i > this.mynumspokes
            local real newangle = i*this.mydegreesbetweenspokes + .03*this.myangularvelocity
            loop
            exitwhen j > this.myspokelength
                //used to reduce function calls
                local real distfromcenter = j*this.mydistbetweenspokeunits
                //determines the x position of the unit to be created based on the position of the center unit
                local real x = (call GetUnitX (this.mycenterunit)) + distfromcenter*(call CosBJ(newangle))
                //same as x but for y position
                local real y = (call GetUnitY (this.mycenterunit)) + distfromcenter*(call SinBJ(newangle))
                //the optional z value for wavy wisp wheels
                //creates a temporary unit var to represent the current unit in the wheel
                local unit tempunit = call LoadUnitHandle(this.myunits, i, j)
                //offset the current unit to its next position in the circle
                call SetUnitX(tempunit, x)
                call SetUnitY(tempunit, y)
                call SetUnitFlyHeight(tempunit, (this.myzheight * (call SinBJ(newangle))), 0) //sets the units fly height to be a sin wave with rate 0... idk what rate is
                //go to next unit in spoke
                set j = j + 1
            endloop
            //go to next spoke in wheel
            set i = i + 1
        endloop
        //go to next iteration of wheel
        //while any real number is valid as a degree, keeping it within ~360 helps keep everything under control
        local real timecalc = .03 * this.myangularvelocity
        if (this.mydegreesbetweenspokes > 360 + timecalc) then
        set this.mydegreesbetweenspokes = this.mydegreesbetweenspokes + timecalc
        else
        set this.mydegreesbetweenspokes = this.mydegreesbetweenspokes - (360 + timecalc)
        endif
    endmethod

    private method createwheel takes nothing returns hashtable
        //represents the current spoke out of the total number of spokes
        local integer i = 1
        //represents the current unit in a particular spoke
        local integer j = 1
        //used to store all the units in a individual spoke per index
        local hashtable units = InitHashtable()   
        loop
        exitwhen i > this.mynumspokes
            loop
            exitwhen j > this.myspokelength
                //used to reduce function calls
                local real degbetween = i*this.mydegreesbetweenspokes
                local real distbetween = j*this.mydistbetweenspokeunits
                //determines the x position of the unit to be created based on the position of the center unit
                local real x = (call GetUnitX (this.mycenterunit)) + distbetween*(call CosBJ(degbetween))
                //same as x but for y position
                local real y = (call GetUnitY (this.mycenterunit)) + distbetween*(call SinBJ(degbetween))
                //creates a unit of designated type for designated player in wheel format around a designated center unit (facing 0 degrees on creation)
                unit tempunit = call CreateUnit(this.myowner, this.myspokeunitID, x, y, 0)
                //saves a pointer to the unit in the hashtable units giving its spoke as i and position in spoke as j
                call SaveUnitHandle(units, i, j, tempunit)
                set j = j + 1
            endloop
            set i = i + 1
        endloop
   
        return units
    endmethod

    public method destroyWheel takes nothing returns nothing
        call this.destroy()
    endmethod

    method onDestroy takes nothing returns nothing //what happens when the struct as the struct is destroyed by .destroy()
        local integer i = 1 //current spoke
        local integer j = 1 //current unit in spoke
        loop
        exitwhen i > this.mynumspokes
            loop
            exitwhen j > this.myspokelength
                call RemoveUnit(LoadUnitHandle(this.myunits, i, j)) //loops through all units in wheel besides the center and removes them from the game. The center unit is kept alive.
                set j = j + 1
            endloop
            FlushChildHashtable(this.myunits, i) //not sure about the best way to clear up a hash, I think this clears all the units ids from a spoke, but i'm not sure
        endloop   
    endmethod

    static method create takes unit centerunit, integer spokeunitID, integer numspokes, integer spokelength, real degreesbetweenspokes, real distbetweenspokeunits, real radialvelocity, real zheight, player owner returns Wheel
        local Wheel new = Wheel.allocate()
        new.mycenterunit = centerunit              new.mydegreesbetweenspokes = degreesbetweenspokes
        new.myspokeunitID = spokeunitID            new.mydistbetweenspokeunits = distbetweenspokeunits
        new.mynumspokes = numspokes                new.myangularvelocity = radialvelocity
        new.myspokelength = spokelength            new.myzheight = zheight
        new.myowner = owner
        mywisps = new.createwheel
        call TriggerRegisterTimerEventPeriodic(new.rotatewheel, .03)
        return new
    endmethod
endstruct

displays slightly better here

update: i reinstalled everything and now my ive got ze jngp
i'm guessing syntax checker is what u use to find errors, unfortunately its giving a sytax erroron my struct declaration
ie sytax error line 1: struct Wheel
I'm almost positive thats how its supposed to be declared... maybe i did something wrong with the vjass compiler
or maybe i put this in the wrong spot (atm its in the map header)

i dont have the slightest clue where im supposed to place jass stuff. how smart is the compiler? do i need functions to go in a certain order based on use or can i declare anything anywhere like in java?
Back to top Go down
Pat1487
Moderator
Moderator
Pat1487



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeTue Apr 12, 2011 1:54 pm

Ignore the syntax checker, it doesnt take vjass into consideration
When you save the map jasshelper is called and it will give you the right errors, 1 at a time, it's kindve annoying like that, you may have to save it more then once before jasshelper will do anything
And it wont do anything if you use test map

The jasshelper in newgen is old, update it to this: http://www.wc3c.net/showthread.php?t=88142

Also change those locals to privates (dont do it to all of them, wait until the compiler tells so you can see when your supposed to use locals)
Separate the variable declarations so that its 1 per line (i know i said whitespace doesnt matter, but varible declarations are always 1 per line unless they are the same type, and thats only for certain languages)
Line 12 on pastebin should be endmethod but its right in the code tag you posted here

And you cant declare and set a variable in a loop
Code:
loop
        exitwhen i > this.mynumspokes
                local real newangle = i*this.mydegreesbetweenspokes + .03*this.myangularvelocity
Is wrong, you did it more then once, im just using this instance as an example
It should be soemthing like:
Code:
local real newangle
            loop
            exitwhen i > this.mynumspokes
                    set newangle = i*this.mydegreesbetweenspokes + .03*this.myangularvelocity


As for what order to declare stuff in, it doesnt matter as long as you dont call it before youve declared it and unless its a method, but you put all the methods in the right places i think
And your going to need a trigger for that periodic event to work, ive actually never tried it like that, so i dont know if it wil work but im pretty sure it wont
But dont worry about that until you get to it while fixing the other errors
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeTue Apr 12, 2011 3:53 pm

tyyyy
oh thats good to know (about only declare at start of meth/func/struct)

unfortunately i cant debug this because whenever i try to save anything with vjass it'll bring up the jasshelper bar (only if there are errors) but will freeze halfway through and the only way to unfreeze it is to close jasshelper.
also weird (and maybe related) is that i cant save a map with vjass regularly - i have to enable debug mode to do it or else it'll do that thing where if you try to play the map it lets you join but then kicks you right away.

take 2 on the code though

Code:
public struct Wheel

    private unit mycenterunit                  private real mydegreesbetweenspokes
    private integer myspokeunitID              private real mydistbetweenspokeunits
    private integer mynumspokes                private real myangularvelocity
    private integer myspokelength              private real myzheight
    private hashtable myunits                  private player myowner

    public method getMyUnits takes nothing returns hashtable
        return this.myunits
    endmethod

    private method rotatewheel takes nothing returns nothing
        //represents the current spoke out of the total number of spokes
        local integer i = 1
        //represents the current unit in a particular spoke
        local integer j = 1
        local real distfromcenter, newangle, x, y
        local unit tempunit
        local real timecalc = .03 * this.myangularvelocity
        loop
        exitwhen i > this.mynumspokes
            set newangle = i*this.mydegreesbetweenspokes + .03*this.myangularvelocity
            loop
            exitwhen j > this.myspokelength
                //used to reduce function calls
                set distfromcenter = j*this.mydistbetweenspokeunits
                //determines the x position of the unit to be created based on the position of the center unit
                set x = (call GetUnitX (this.mycenterunit)) + distfromcenter*(call CosBJ(newangle))
                //same as x but for y position
                set y = (call GetUnitY (this.mycenterunit)) + distfromcenter*(call SinBJ(newangle))
                //the optional z value for wavy wisp wheels
                //creates a temporary unit var to represent the current unit in the wheel
                set tempunit = call LoadUnitHandle(this.myunits, i, j)
                //offset the current unit to its next position in the circle
                call SetUnitX(tempunit, x)
                call SetUnitY(tempunit, y)
                call SetUnitFlyHeight(tempunit, (this.myzheight * (call SinBJ(newangle))), 0) //sets the units fly height to be a sin wave with rate 0... idk what rate is
                //go to next unit in spoke
                set j = j + 1
            endloop
            //go to next spoke in wheel
            set i = i + 1
        endloop
        //go to next iteration of wheel
        //while any real number is valid as a degree, keeping it within ~360 helps keep everything under control
        if (this.mydegreesbetweenspokes > 360 + timecalc) then
        set this.mydegreesbetweenspokes = this.mydegreesbetweenspokes + timecalc
        else
        set this.mydegreesbetweenspokes = this.mydegreesbetweenspokes - 360 //this might need to be 360 + timecalc instead of 360, but I don't think so
        endif
    endmethod

    private method createwheel takes nothing returns hashtable
        //represents the current spoke out of the total number of spokes
        local integer i = 1
        //represents the current unit in a particular spoke
        local integer j = 1
        //used to store all the units in a individual spoke per index
        local hashtable units = InitHashtable()   
        local real degbetween, distbetween, x, y
        loop
        exitwhen i > this.mynumspokes
            loop
            exitwhen j > this.myspokelength
                //used to reduce function calls
                set degbetween = i*this.mydegreesbetweenspokes
                set distbetween = j*this.mydistbetweenspokeunits
                //determines the x position of the unit to be created based on the position of the center unit
                set x = (call GetUnitX (this.mycenterunit)) + distbetween*(call CosBJ(degbetween))
                //same as x but for y position
                set y = (call GetUnitY (this.mycenterunit)) + distbetween*(call SinBJ(degbetween))
                //creates a unit of designated type for designated player in wheel format around a designated center unit (facing 0 degrees on creation)
                unit tempunit = call CreateUnit(this.myowner, this.myspokeunitID, x, y, 0)
                //saves a pointer to the unit in the hashtable units giving its spoke as i and position in spoke as j
                call SaveUnitHandle(units, i, j, tempunit)
                set j = j + 1
            endloop
            set i = i + 1
        endloop   
        return units
    endmethod

    public method destroyWheel takes nothing returns nothing
        call this.destroy()
    endmethod

    method onDestroy takes nothing returns nothing //what happens when the struct as the struct is destroyed by .destroy()
        local integer i = 1 //current spoke
        local integer j = 1 //current unit in spoke
        loop
        exitwhen i > this.mynumspokes
            loop
            exitwhen j > this.myspokelength
                call RemoveUnit(LoadUnitHandle(this.myunits, i, j)) //loops through all units in wheel besides the center and removes them from the game. The center unit is kept alive.
                set j = j + 1
            endloop
            FlushChildHashtable(this.myunits, i) //not sure about the best way to clear up a hash, I think this clears all the units ids from a spoke, but i'm not sure
        endloop   
    endmethod

    static method create takes unit centerunit, integer spokeunitID, integer numspokes, integer spokelength, real degreesbetweenspokes, real distbetweenspokeunits, real radialvelocity, real zheight, player owner returns Wheel
        local Wheel new = Wheel.allocate()
        new.mycenterunit = centerunit              new.mydegreesbetweenspokes = degreesbetweenspokes
        new.myspokeunitID = spokeunitID            new.mydistbetweenspokeunits = distbetweenspokeunits
        new.mynumspokes = numspokes                new.myangularvelocity = radialvelocity
        new.myspokelength = spokelength            new.myzheight = zheight
        new.myowner = owner
        mywisps = new.createwheel
        call TriggerRegisterTimerEventPeriodic(new.rotatewheel, .03)
        return new
    endmethod
endstruct

http://pastebin.com/1Aj8irqa
Back to top Go down
Pat1487
Moderator
Moderator
Pat1487



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeTue Apr 12, 2011 4:16 pm

debug mode and enable should be the only to things checked for jass helper, if its freezing you might have something else checked thats conflicting with it

Also did you update jasshelper?
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeTue Apr 12, 2011 7:53 pm

http://pastebin.com/Y7pWEUjE

the problem is in:

function s__Wheel_startWheel takes integer this,integer newwheel returns nothing
call TriggerRegisterTimerEventPeriodic(s__Wheel_rotatewheel(newwheel), .03)
endfunction

originally it looks like:

private method startWheel takes Wheel newwheel returns nothing
call TriggerRegisterTimerEventPeriodic(newwheel.rotatewheel(), .03)
endmethod

called from the constructor with:
call newwheel.startWheel(newwheel)

the error is
cannot convert nothing to trigger


I also tried

private method startWheel takes nothing returns nothing
call TriggerRegisterTimerEventPeriodic(rotatewheel(), .03)
endmethod

but that had the same error at the same place
Back to top Go down
Pat1487
Moderator
Moderator
Pat1487



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 11:50 am

TriggerRegisterTimerEventPeriodic() is for triggers (and one of the worst names for a native function)

Triggers need to have an action and event registered to them
TriggerRegisterTimerEventPeriodic(trigger, real) registers the event, the function for registering the event depends on the event you want
TriggerAddAction(trigger, function) registers the action
VJass may let you do TriggerAddAction(trigger, struct)

You need something like this:

Code:
local trigger TTT = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(TTT,.03)
call TriggerAddAction(TTT, newwheel.rotatewheel())

Actually i dont think vJass will let that work because of add action, try it first
But if it doesnt work try: call TriggerAddAction(TTT, function s__Wheel_rotatewheel(newwheel))
Or whatever it gets translated into

You may have to put local trigger TTT = GetTriggeringTrigger() in the rotatewheel method
But don't until the compiler says something about it, or if it isnt working in game
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 1:52 pm

it cant be newwheel.rotatewheel() because rotatewheel returns nothing
i guess if it could return itself as a action that would work but I don't know how to do that, and i feel like there's a better way

like does jass have some sort of lambda expression or a way of passing unevaluated methods?

i tried the other suggestions (except for the triggeringtrigger thing, i didnt understand that bit at all) the thing with function out front sounded promising but it got a syntax error saying unexpected ( or something like that. i tried switching function with method but that didnt work either.
Back to top Go down
Pat1487
Moderator
Moderator
Pat1487



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 2:34 pm

Why does rotatewheel have to return anything?
Isnt that rotating the wheel and what you were trying to do

TTT is the current trigger thats running
Triggeringtrigger is referencing it
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 2:38 pm

i agree it shouldn't return anything, but when you do
call TriggerAddAction(TTT, newwheel.rotatewheel())
the compiler is doing
newwheel.rotatewheel() which returns nothing
so really its trying to do
call TriggerAddAction(TTT, )

i thought saying function newwheel.rotatewheel() would tell the compiler that its a pointer to the function not to actually do the function, but it still didnt like that.

and oh ok that makes sense
Back to top Go down
Pat1487
Moderator
Moderator
Pat1487



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 2:40 pm

I told you what to do if it didnt work like that

Pat1487 wrote:
But if it doesnt work try: call TriggerAddAction(TTT, function s__Wheel_rotatewheel(newwheel))

I think its supposed to be s_Wheel_rotatewheel(newwheel)) and the extra _ is a typo in your post, but im not sure
And TTT is just a name, call it w/e you want
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeWed Apr 13, 2011 2:42 pm

I did try that

it didnt work,
i said that too

it says:
Syntax error, unexpected (
also it is supposed to be two _'s
i don't understand either
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeSun Jun 05, 2011 10:37 pm

Code:
static method create takes takes unit centerunit, integer spokeunitID, integer numspokes, integer spokelength, real degreesbetween, real distbetween, real angvelocity, real zheight, player powner returns Wheel
        local Wheel newwheel = Wheel.allocate()
       
        local integer i = 0
        local integer j = 0
       
        local real deg
        local real dist
        local real x
        local real y
        local real r
       
        local unit u
       
        set newwheel.center = centerunit
        set newwheel.unitID = spokeunitID
        set newwheel.nSpoke = numspokes
        set newwheel.nSpokeLength = spokelength
        set newwheel.degBetween = degreesbetween
        set newwheel.distBetween = distbetween
        set newwheel.angVelocity = angvelocity
        set newwheel.zHeight = zheight
        set newwheel.owner = powner
       
        set newwheel.units = InitHashtable()
       
        loop
        exitwhen i > nSpoke
            set deg = i*degBetween
            set r = deg * 180 / bj_PI
           
            loop
            exitwhen j > nSpokeLength
                set dist = j*distBetween
                set x = call GetUnitX(this.center) + Cos(r) * dist
                set y = call GetUnitY(this.center) + Sin(r) * dist
               
                set u = call CreateUnit(this.owner, unitID, x, y, 0)
                call SaveUnitHandle(units, i, j, u)
               
                set j = j + 1
            endloop
           
            set i = i + 1
        endloop
       
        set u = null
        return newwheel
    endmethod

so i'm taking another stab at this because i thought i understood how to do stuff better and i wanted a quick n easy way to make wheels in my map

but im running into an incredibly unhelpful error (ty JASS helper...)
naturally its on the very first line i posted
method create must return Wheel

i tried a few things hoping it was some random syntax problem. it needs to be static, and it cant return nothing (specifically it really does have to return a Wheel)
the name of the struct is Wheel, so that much makes sense

I completely agree that it should return a wheel, but im 99% sure it is returning a wheel

thoughts?
Back to top Go down
AmAzIn[G]232
Corporal
Corporal
AmAzIn[G]232



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeSun Jun 05, 2011 11:18 pm

War3 is terrible for map making, give up.
Back to top Go down
Serenity09
Moderator
Moderator
Serenity09



vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitimeMon Jun 06, 2011 10:37 am

oh herp derp

Code:
static method create takes takes
might just be the problem

on the other hand, wtf vjass why couldnt you have just said something like syntax error or unexpected type "takes"
Back to top Go down
Sponsored content





vJASS help Empty
PostSubject: Re: vJASS help   vJASS help I_icon_minitime

Back to top Go down
 
vJASS help
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Clan TMMM :: Warcraft 3 :: WC3 Tutorials and Help-
Jump to: