AIDS (array) structs + array variables

luorax

Invasion in Duskwood
Reaction score
67
Okay, I have a question:
How can I use array variables in a sruct which extends array? I have an AIDS struct which contains various datas about the questgiver units, and I need array members in it. I'm using two struct to achieve it, but what's your opinion? I don't want to use dynamic arrays, because their limitations.

This is a part of my script:

JASS:
    private struct QuestGiverData 
        effect array SFX[12]
        private method onDestroy takes nothing returns nothing
            local integer li = 0
            loop
                exitwhen li > 11
                call DestroyEffect(.SFX[li])
                set .SFX[li] = null
                set li = li + 1
            endloop
        endmethod
    endstruct
    
    private struct QuestGiverStruct extends array
        readonly QuestGiverData Data
        method AIDS_onCreate takes nothing returns nothing
            set .Data = QuestGiverData.create()
        endmethod
        static method AIDS_filter takes unit u returns boolean
            return GetOwningPlayer(u) == QUEST_PLAYER_1 or GetOwningPlayer(u) == QUEST_PLAYER_2
        endmethod
        method AIDS_onDestroy takes nothing returns nothing
            call .Data.destroy()
        endmethod
        //! runtextmacro AIDS()
    endstruct


But what else should I do to improve it?
 

Romek

Super Moderator
Reaction score
963
Yes, [13] should be [12]. I assume that's a typo.
Use [12, XYZ] to increase the instance rate of that array. Replace XYZ with the number of array indices to be taken up by the variable. You should use a multiple of 8190, though it doesn't really matter.
The instance limit will be XYZ/12.
 

luorax

Invasion in Duskwood
Reaction score
67
Okay, this is how my struct looks like now:

JASS:
type QuestGiverData extends effect array [12]
    
    private struct QuestGiverStruct extends array
        readonly QuestGiverData Data
        method AIDS_onCreate takes nothing returns nothing
            set .Data = QuestGiverData.create()
        endmethod
        static method AIDS_filter takes unit u returns boolean
            return GetOwningPlayer(u) == QUEST_PLAYER_1 or GetOwningPlayer(u) == QUEST_PLAYER_2
        endmethod
        method AIDS_onDestroy takes nothing returns nothing
            local integer li = 0
            loop
                exitwhen li > 11
                call DestroyEffect(.Data[li])
                set .Data[li] = null
                set li = li + 1
            endloop
            call .Data.destroy()
        endmethod
        //! runtextmacro AIDS()
    endstruct


Also, thanks + rep to everyone.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top