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

[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.
 
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].
 
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].
 
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.
Back
Top