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

Weird unit group array problem

Status
Not open for further replies.
Level 2
Joined
Dec 8, 2005
Messages
14
I ran into a rather strange problem related to unit groups. Here's what Im trying to accomplish:

In my map,barracks are used to control small unit groups, that I call "squads".Each barracks has 1 squad assigned to.When a unit dies from the squad,the barracks it belonged to automatically respawns it, and sends it to the rally point. Both the barracks, and the units they control are given an "ID" integer which is stored in the units' custom value. The triggers that do this work perfectly.

Now I want to add ability buttons to the barracks that enable them to order their squads to retreat, move to the rally point, or attack-move to it. To do this, a trigger adds each squad member to a unit group variable upon being spawned.
So what happens is that when a unit is created, it is given a custom value equal to the custom value of the barracks, and it is added to a unit group array with the index being the ID (custom value) of the barracks.

When I tested this in-game, the whole thing appeared to work well with the first barracks I built.
Then any new barracks I built were bugged. They spawn and respawn their units, but the squads don't get added to unit groups.
What could be wrong?

Here are my triggers:

This gives the ID to the barracks that is built

Barracks
Events
Unit - A unit Finishes construction
Conditions
(Unit-type of (Triggering unit)) Equal to Barracks
Actions
Unit - Add Summon Army to (Constructed structure)
Set BarracksCounter = (BarracksCounter + 1)
Set ID_BuildBarrack = BarracksCounter
Set Barrack[ID_BuildBarrack] = (Constructed structure)
Unit - Set the custom value of (Constructed structure) to ID_BuildBarrack

This gives ID to spawned units, adds them to a group, and sends them to attack

Summoned unit attack order
Events
Unit - A unit Spawns a summoned unit
Conditions
((Owner of (Triggering unit)) controller) Not equal to Computer
((Unit-type of (Summoned unit)) Equal to Warrior) or ((Unit-type of (Summoned unit)) Equal to Lava Elemental (Level 1))
Actions
Unit - Set the custom value of (Summoned unit) to (Custom value of (Summoning unit))
Unit Group - Add (Summoned unit) to Squad[(Custom value of (Summoning unit))]
Unit - Order (Summoned unit) to Attack-Move To (Rally-Point of (Summoning unit) as a point)
Selection - Select Squad[(Custom value of (Summoning unit))]

Help would be appreciated.

Never mind,I found the sorce of the problem.I left the size of the unit group array 1, so only 1 groups could be created.In fact, I thought that size would mean the dimensions of an array...
Changed it, works now.
 
Status
Not open for further replies.
Top