• 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.

[JASS] arrays in structs

Status
Not open for further replies.
Level 6
Joined
Sep 9, 2006
Messages
92
so heres a bit of my code, i was just wondering if i can just somehow use a dummy array for the 3 dummy units i use, and if so, what the variable would look like

JASS:
private struct data
    static hashtable h = InitHashtable()
    unit c
    integer lvl
    timer tim = CreateTimer()
    real Fx //final position
    real Fy
    unit dummyO //dummy orb unit
    real Dx //dummy's position
    real Dy
    integer PT = PULSE_TIMER
    unit dummy1
    unit dummy2
    
    static method periodic takes nothing returns nothing
        local integer id = GetHandleId(GetExpiredTimer())
        local data this = LoadInteger(.h,id,0)
        local real angle = bj_RADTODEG * Atan2(.Fy - .Dy, .Fx - .Dx)
        local real Tx = (.Dx + DUMMY_OFFSET * Cos(angle * bj_DEGTORAD))
        local real Ty = (.Dy + DUMMY_OFFSET * Sin(angle * bj_DEGTORAD))
        call SetUnitPosition(.dummyO, Tx, Ty)
        if .PT > 0 then
            set .PT = .PT - 1
        else
            set
            //send pulse
            set .PT = PULSE_TIMER
        endif
        if SquareRoot((Tx-.Fx)*(Tx-.Fx)+(Ty-.Fy)*(Ty-.Fy)) < 2. then
            call DestroyTimer(.tim)
            call FlushChildHashtable(.h,id)
            call .destroy(id)
            //end spell
        endif
    endmethod

something like
JASS:
unit dummy[0]
unit dummy[1]
unit dummy[2]
so then i can run a loop for the latter 2 (because they are both firing shockwaves, just at different angles)

edit: gah figured it out.. however if someone could help me with another problem that woudl be great.. i want to find 45 degrees either way from a given travel angle, will the code automatically adjust the angle if its off by 360 degrees or do i do that manually?
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you subtract 45 from a "given travel angle" it will offset its value by 45° in a clockwise direction. If you add 45 to a "given travel angle" it will offset its value by 45° in a counter-clockwise direction.

Other than that I really don't know what you're asking.
 
Status
Not open for further replies.
Top