HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

array problems

05-20-2003, 05:47 PM#1
layzie86988
Ok, I'm using UMSWE and GUI triggers and for some reason arrays don't seem to work correctly for me. I have an array of units and each unit in the array is supposed to represent a specific unit for a specific player so unit[1] belongs to player 1. This doesn't seem to work in game, but it works fine when I use separate unit variables for each unit as opposed to using an array. Any thoughts as to why this would be? Any help is appreciated.
05-20-2003, 06:16 PM#2
Starcraftfreak
Actually this should work. Have you assigned the units correctly to the array?
Set Variable: unit[playerindex]=unit
playerindex is the number of the player (1 for Player 1).
But you should be more specific about what you intend to do with the units. Only then I (or others) can tell you if this is an efficient way.
05-20-2003, 07:25 PM#3
layzie86988
Well it turns out that the array thing doesn't appear to be my problem after I tested a little. But now I have a new problem entirely. Here's what I want to do: I have 6 starting locations on my map and a neutral unit placed at each. I want the map to have random starting locations and then when the game starts, I want to give ownership of the unit at each player's starting location to that player, if that makes sense. I thought of checking the unit's position against the initial camera bounds, but the initial camera bounds condition doesn't check agains't which player's initial camera bounds it is. Anyone know how could I do this?
05-20-2003, 07:52 PM#4
MrDoomMaster
The best thing to do is to do a loop that creates a unit at the position of a players' start location.

Here is an example:

For every integer A 1 to 12, do (create 1 (unit type) for (playerindex((integer a))) at (position of (playerindex((integer a))'s start location) facing default building facing degrees


I haven't tested this, but it should work. Make sure that, in player properties, fixed locations are NOT checked!
05-21-2003, 05:21 AM#5
layzie86988
That actually is a good idea, but I forgot to mention that the unit type of the unit I'd want to create is dependent upon where the player actually starts, so what I need is some way to detect where the player starts while the start locations are random. For example, let's say I have 4 towns on my map , each populated by a different race. I want the players to be townsfolk of these towns so in a dwarf town the player would be a dwarf and so on.
05-21-2003, 05:45 AM#6
layzie86988
Now I've got it. I'll just create a dummy unit at the start location and replace it with the proper one after checking a region at the start location. It should work for me. Thanks for helping guys.