• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[vJASS] Some Limits in Arrays Obstructing Initiation

Status
Not open for further replies.
Level 2
Joined
Apr 7, 2008
Messages
19
Hi, I recently got back into WC3 mapping and decided to learn JASS/vJASS.

I decided create a Hero that can be played in a standard melee map (just another Tavern Hero).

Unfortunately, I am coming across a problem that appears to be from some sort of limitation on global arrays.

This is the initiation code I am using to set up space for the abilities of my Hero, the "Inferno Avenger." It is straight-forward. Note that when the limitation obstructs me, the actions sequence does not go to completion (i.e. write "4b" to the screen).
JASS:
function Trig_InitAbilities_Actions takes nothing returns nothing
    // Init Inferno Avenger
    //call BJDebugMsg("1a")
    call OathOfFire_Init()
    //call BJDebugMsg("1b")
    //call BJDebugMsg("2a")
    call FlameStride_Init()
    //call BJDebugMsg("2b")
    //call BJDebugMsg("3a")
    call ExplosiveStrike_Init()
    //call BJDebugMsg("3b")
    //call BJDebugMsg("4a")
    call Conflagration_Init()
    //call BJDebugMsg("4b")
endfunction

//===========================================================================
function InitTrig_InitAbilities takes nothing returns nothing
    set gg_trg_InitAbilities = CreateTrigger(  )
    call TriggerRegisterTimerEvent( gg_trg_InitAbilities, 0.00, false )
    call TriggerAddAction( gg_trg_InitAbilities, function Trig_InitAbilities_Actions )
endfunction

Presently, I am using the following code to put a limit on the array indices so that my initiation code goes to completion. I have included here my own speculation on the limitation in the comments.
JASS:
globals
    // Array limit.
    constant integer C_ARRAYLIMIT = 100
    // Should be 8190 but for some reason that causes inexplicable problems with the InitAbilities' called functions.
    // The real limit with only Inferno Avenger's abilities implemented is 2655. Anything greater prevents InitAbilities from completing.
    // When C_ARRAYLIMIT is set to 100, assuming all Heroes require only approximately that amount, then about 25 Heroes can be made.
    // This is reasoned to be because 100 is <4% of 2655.
    // Somehow, Inferno Avenger is using 5535 unit spaces across 14 arrays (variously int, real, unit, and timer). Each array averages 396 unit spaces.
    // Recalculating: Given 2655 remaining unit spaces, 2655/396 = n, 6 < n < 7. About 6 arrays can be used.
    // Thus, given that Inferno Avenger alone uses 14 arrays, there likely is not enough unit spaces for any more complex Heroes.
endglobals

The functions OathOfFire_Init, FlameStride_Init, ExplosiveStrike_Init, and Conflagration_Init all look roughly the same and they all have roughly the same globals blocks. The globals block and initiation function for OathOfFire_Init follows.
JASS:
    globals
        // properties
        private real rDuration = 8
        private real rInterval = 2
        private real array rDmgCaps // these are initialized in Init
        private real numfx = 5 // number of special effects surrounding target unit
        private real radiusfx = 100 // distance from target unit at which fx appear
        private real radius = 250 // area of effect
        // array
        private unit array uCasters
        private unit array uTargets
        private timer array tTimers // duration
        private timer array tIntervals // intervals within duration
        private integer array iLevels // spell level at moment of casting
        private real array rTargetHP // record of target's hp
        private integer iSize = 0
        // temp storage for messaging in between callbacks
        private unit cb_uCaster
        private real cb_rDmg // damage dealt
    endglobals

    function OathOfFire_Init takes nothing returns nothing
        local integer i  = 0
        // damage caps
        set rDmgCaps[1] = 32
        set rDmgCaps[2] = 64
        set rDmgCaps[3] = 96
        loop // array init
            exitwhen (i == C_ARRAYLIMIT)
            set uCasters[i] = null
            set uTargets[i] = null
            set tTimers[i] = null
            set tIntervals[i] = null
            set i = i + 1
        endloop
    endfunction

Setting C_ARRAYLIMITS to anything above 2655 prevents "4b" from printing to the screen while I debug. Why is this? Do I have too many global arrays? If so, how can I circumvent this problem?
 
Could you post all the script? I think it's hitting the limit op but the only way to make sure is to see the init scripts.
 
Operation limit: you can only do so and so many actions within a thread (here the one started by the timer) before it halts.

You do not necessarily have to pre-inialize whole arrays. Besides that arrays are already null-initialized by wc3, just keep track of what indexes you are currently using and init them when you allocate a new one.
 
Status
Not open for further replies.
Back
Top