HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Global Struct Arrays?

03-27-2008, 04:01 AM#1
TEC_Ghost
So I'm wanting to use Structs as a reference for my units, I've got a class setup like this...

Collapse JASS:
library Classes

struct Fighter
    integer X
    integer Y
    integer Z
    unit    Unit
    string  name
    real    damage = 25
    real    life = 300
    integer    strength = 7
    integer    agility = 4
    integer    inteligence = 2 
    integer level
    real    armor
    integer speed
    integer mana = 100
    string array inventory[6]
    integer attackrange
    real critchance = .3
    real critdamage = 1.0
    boolean hasAttacked
    boolean hasMoved
    boolean hasFaced

endstruct


endlibrary

And I'm wanting to make a Global Struct Array so that I can apply store these to be referenced to the unit and changed later. But I've only seen structs referenced as Locals, is there a way to set this up to use them as an array so they can be used all game?
03-27-2008, 04:06 AM#2
Vexorian
Can't you just try it?
03-27-2008, 05:18 AM#3
Ammorth
Collapse JASS:
globals
    Fighter array MyFighters
endglobals

function Init takes nothing returns nothing
    set MyFighters[0] = Fighter.create()
    set MyFighters[1] = Fighter.create()
endfunction
03-27-2008, 12:52 PM#4
TEC_Ghost
Quote:
Originally Posted by Vexorian
Can't you just try it?

Sorry, shoulda mentioned I did, I tried by doing this...

Collapse JASS:
globals
Fighter PlayerFighter[255]
endglobals

function Setup_Actions takes nothing returns nothing

    set udg_hero = gg_unit_Hpal_0003
    
    call SetUnitUserData( udg_hero, 1 )
    
    set PlayerFighter[GetUnitUserData(udg_hero)] = Fighter.create()
endfunction

Thanks Ammorth, seems I was just a bit off!
03-27-2008, 01:00 PM#5
Malf
I don't even think that compiles correctly, since you don't have an array right after Fighter
03-27-2008, 01:20 PM#6
Captain Griffen
All JASS arrays are sized at 8191; you can't init them for any other size.
03-27-2008, 01:38 PM#7
Vexorian
In vJass, you can.
03-27-2008, 10:50 PM#8
TEC_Ghost
Quote:
Originally Posted by Malf
I don't even think that compiles correctly, since you don't have an array right after Fighter

Ya, that was my problem, Ammorth directed me the right way.

I've been switching back and forth between vjass and C++ so I keep getting shit confused lol
03-27-2008, 11:52 PM#9
TheSecretArts
Quote:
Originally Posted by Vexorian
In vJass, you can.

woah really! You've just made my day Vex.
03-28-2008, 01:39 AM#10
Salbrismind
Quote:
Originally Posted by Vexorian
In vJass, you can.

Would I lower number really make a difference?
03-28-2008, 02:31 AM#11
Vexorian
I wrote about that stuff in the manual.
03-28-2008, 02:54 AM#12
TEC_Ghost
Quote:
Originally Posted by TheSecretarts
woah really! You've just made my day Vex.

http://wc3campaigns.net/vexorian/jas...html#storarray