• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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 39
Joined
Feb 27, 2007
Messages
5,013
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,198
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