HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Question: Array/Region point Assignment.

04-21-2004, 12:49 PM#1
Quantos
Background: I have been working on a map that incorporates a 10x10 grid with regions representing each. These Grids are simply named like a chessboard. (A1-A10, B1-B10, ect..) I incorporated an Array with 100 variables, to hold all the information.

Information and how it's used: Each square holds a value of "production points" you initially build a "house" there that holds up to 4 workers. (based on orc burrow) When a unit enters or leaves this building... it changes the production points of that region.

So basics, Production points for Region A1 = Worker units in house located within Region A1

Basic Question: Since I have 100 regions to work with, I found after looking a little through JASS sections that this would fit this task better I think. I have C++ backgrounds, but I'm not used to the natives of JASS. Could someone help me figure this out.. or send me an example that I could work from? I had issues finding this issue in the forum so far.

Also, if it's easy to code in triggers, please, reserve the naive idiot comments and just let me know how to do it *smiles* Thanks a lot in advance :)
04-22-2004, 07:36 AM#2
Vidstige
Eh, I can't really understand your question. Do you ask how to set up the regions, how to check the regions production points, or? If you have a background in C++ you are probably better of coding Jass than GUI. :> If your question is if you should try to do it in GUI or in Jass, I suggest that you use the gui to learn which native you need to use. Try creating your triggers with the GUI and then convert it to Jass and refine it.

With other words, use the GUI until you get annoyed with it, then do your triggers in custom text, but use the GUI to learn which natives you can use (or check jass.sourceforge.net, or the files: common.j and Blizzard.j). Good luck!
04-27-2004, 03:40 AM#3
Quantos
Thanks for the input... reclarifying what I'm asking.

I want to assign a "production point" variable to each single region. So A1 could have "4" A2 could have "1" and so on. The numbers are between 0-4.

So far, I found that doing it in the trigger method would involve about 100 triggers... I was wondering if anyone could think of an easy way of doing a single Jazz trigger to work with a 100 variable array.

And work with actually assigning the variable slots to regions. If it involves renaming my regions, that's fine. I'm just having issues and want to see if I have a short version of doing it before I put 100 triggers in the loading of the file.

Side note: Thank you so much for the link, that helps a ton
04-27-2004, 12:50 PM#4
Cubasis
Hmm, while i'm not 100% sure what you want/need, it sounds like you're trying to be able to attach a property to a ....rect (region).

Well, you are kinda lucky becouse just lately KaTTaNa came up with a great set of functions that allow you to do this. http://kattana.users.whitehat.dk/viewfunc.php?id=252

Usage: call SetHandleInt( MyRectVariable, "<SumName>", Value )

So, if you wanted to store 3 in the rect stored in udg_TempRect under the name "Value", you'd do this:

call SetHandleInt( udg_TempRect, "Value", 3 )

and to get it back, you'd do this:

set udg_TempInteger = GetHandleInt( udg_TempRect, "Value" )

Hope this helps.

Cubasis
04-29-2004, 04:13 AM#5
Quantos
After looking at this a bit, I think this code will help greatly! It's good enough to be of great notes, kudos to you :)

This post, I'm going to try and do three things:

1. Be sure I know how to handle this code and use it in my map.

//Original Code
call SetHandleInt( udg_TempRect, "Value", 3 ) // Store 3 in udg_tempRect under name "Value"
set udg_TempInteger = GetHandleInt( udg_TempRect, "Value" ) // to get it back


So, to set it up for a variable array, it should be as simple as this if I'm correct: (Using terms that I'd use in game)

Set Region "A1" Total Production Point = 0
call SetHandleInt( udg_RectA1, "TotalProduction", 0 )

Put Production point stored above in Array Index that refers to same Region.
set udg_intProduction[1] = GetHandleInt( udg_RectA1, "TotalProduction")

(Note: more I think of this, I don't know if I need the code)

2. State what I want to do in a format that can be easily converted to code

1- A worker builds "Housing" (Building which holds up to four workers)
2- Worker enter "Housing" = Total Production Point +1 for Region which "Housing" exists
3- Worker leaves building = Total Production Point -1 for Region which "Housing" exists

-NOTE: Each area can have other buildings to create resources, example: Crop house, Mining Camp, Lumber Shack.

4- Owner of "Housing" in region clicks "add production" ability on resource building = Available Production Point -1 for Region which "Housing" exists
5- Owner of "Housing in region clicks "remove production" ability on resource building = Available Production Point +1 for region which "Housing" exists.

............................................................................................
Notes: After writing it out like that, I don't know specifically if that above code is needed, cause this should be achievable without such code I think... but how can I work this idea into a single JASS trigger.... Man, maybe sleep will help me see this better in the morning...

3. Pray that people like yourself will help me understand if it's better to do as a simple single JASS trigger.. or if I need to make a GUI trigger for each region.. 100 triggers is a harder thing for the DL/game to handle.


So cheers to the third one
05-12-2004, 08:53 PM#6
Aiursrage2k
The easiest solution would to have to a series of arrays. A rect array, an integer array, two trigger arrays, a unit array (these arrays are all paralllel!)
, and a single integer

First populate your rect array with the your regions, give each trigger the event unit enters a region, with the condition entering unit is a structure. Now give the trigger an triggeraction.

When this triggeraction is called iterate through the trigger array until you find a match to the triggering trigger, take its index. You may wish to set a check to see if the entering unit is the only structure in the region. Set the entering unit to the unitArray[idx]. Now attach another trigger onto that unit, using events unit enters burrow and unit leaves burrow. Tack on another trigger action.

When this action is called, iterate using the second trigger array to find the index. Then change the integer array, and thats it. Easy as pi. Or if you hate globals use the cache...
05-13-2004, 03:06 PM#7
Quantos
*goes off searching in other threads to help himself understand this post fully. THEN he will make a responce after he tries to learn some of the lingo himself.*
05-13-2004, 10:22 PM#8
Quantos
After much agony of trying to decyfer how to do this with JASS in particular, when learning it, and trying to look in the array tutorials, and not finding one that specifically helps me with this, I felt tha tI should ask questions dealing with the answer. I understand that People expirienced in JASS should typically be here.. but all JASS coders have to start somewhere.



Quote:
Originally Posted by Aiursrage2k
The easiest solution would to have to a series of arrays. A rect array, an integer array, two trigger arrays, a unit array (these arrays are all paralllel!), and a single integer

I understand how they can be parrallel, but You don't specify why each is used.. or what specific part you are refering to. Thus my first confuzzlement

Quote:
Originally Posted by Aiursrage2k
First populate your rect array with the your regions, give each trigger the event unit enters a region, with the condition entering unit is a structure. Now give the trigger an triggeraction.

*nods* Understood, so far, I have to find out what command to "give the trigger a trigger actions" but I'm sure I could find this out.

Quote:
Originally Posted by Aiursrage2k
When this triggeraction is called iterate through the trigger array until you find a match to the triggering trigger, take its index. You may wish to set a check to see if the entering unit is the only structure in the region. Set the entering unit to the unitArray[idx]. Now attach another trigger onto that unit, using events unit enters burrow and unit leaves burrow. Tack on another trigger action.

*blinks blankly* Triggeraction is refering to above paragraph, aka structure being built. "Iterate through the trigger array" Which one.. there are two. And what do the trigger array's hold exactly. "Until you find a match to triggering trigger" So go through the trigger array, which is probably a collection of specific triggers, and look for a match. *nods blankly* I need a slightly amount of clarification here.. probably cause I don't understand the trigger array fully.

Quote:
Originally Posted by Aiursrage2k
When this action is called, iterate using the second trigger array to find the index. Then change the integer array, and thats it. Easy as pi. Or if you hate globals use the cache...

After this point, I assume the integer array is the production point value. I personally think, I feel the problem is that you didn't declare what each array holds or is for. Cause That's the primary confusion, is what is needed for what.. and why. Also how to set up such a JASS trigger to do so.

I VERY MUCH do appreciate your help... I just wish I was more skilled with JASS triggers to be able to take what you gave me and pull it together. If it was C or C++ I'd work with pointers and whatnot to pull this all together, make rects be assigned to the values and whatnot. But JASS...er.... *laughs* help?