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

[Solved] 2D Arrays for a Grid?

Status
Not open for further replies.
Level 2
Joined
Oct 2, 2019
Messages
11
Hello. With all the buzz about Warcraft 3 Reforged, I figured I would try my hand at mapping again. So my issue is that it doesn't seem Warcraft 3's editor supports multidimensional arrays like Starcraft 2 does. Would anyone happen to know if there is a way to simulate a 2d array with a little world editor trickery? What I want to use it for is to detect adjacency between different Regions for the purpose of moving pieces along a 2d game board. I didn't want to have to create a bunch of if/then/else functions since my board has 66 different region squares, and was hoping for a simpler way of going about this. Thanks in advance to whoever can help.
 
Level 2
Joined
Oct 2, 2019
Messages
11
I have read about them while looking for solutions regarding my problem, but I am not sure how I would go about using them. It was sufficient enough to simulate 2d arrays by using [(x-1)*MAX_Y + y].
 
Level 42
Joined
Feb 27, 2007
Messages
5,316
Sure (it’s actually invalid for all 0<=x<MAX_Y), but my presumption was that the OP was using GUI and such users generally index their arrays from 1. The way I wrote it maps indexes starting from x=1 to [1][1]..[1][MAX_Y] rather than x=0 to [0][0]..[0][MAX_Y-1].
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Sure (it’s actually invalid for all 0<=x<MAX_Y), but my presumption was that the OP was using GUI and such users generally index their arrays from 1. The way I wrote it maps indexes starting from x=1 to [1][1]..[1][MAX_Y] rather than x=0 to [0][0]..[0][MAX_Y-1].
Not that any real change would be needed anyway due to JASS arrays being dynamic arrays. At most a few wasted indices at the array start. These would mostly be masked due to how arrays expand in powers of two (according to what people said long ago).
 
Status
Not open for further replies.
Top