I want to make it so that every couple of seconds, a group of units spawn and this group randomly attacks a point within a region and once it reaches the point, I want them to aquire a new point to attack move to.
The problem is this.
I want this trigger to go so that every few seconds, another group is spawned with the same orders, but a different random point to go to I feel like I should have the units be catagorized into unit groups upon creation, and set attack orders to the group itself so that the group moves as a whole but is there a way to create variables via triggers?
cuz for obvious purposes, I can't do this in the editor, Unit group 1, 2,3,4,5,6, etc.....
I want a trigger that can assign each new batch of units to their own unit group, not to an existing one. Doesn't have to be one trigger that does all this, but a series of them. Any ideas?
But that would mean that those points are preset by me and there's a pattern to their movements. I want a repeating trigger to make the unit groups move to random points every few seconds. That's easy though.
The part which I'm trying to figure out is storing it so that there are 10 unit groups floating around the map.
Regular Infantry Groups = (Empty unit group) <Unit Group[10]>
That's the variable Unit group array which I created to store the units in.
This is the trigger which I have right now.
----
Spawn Reg Infantry Wave
Events
Timer - Every 20.0 seconds of Game Time
Local Variables
Conditions
Actions
Unit - Create 7 AI Marine for player 3 at (Position of City AI Barracks [82.50, 94.50]) using default facing (No Options)
Unit - Create 3 AI Marauder for player 3 at (Position of City AI Barracks [85.50, 91.50]) using default facing (No Options)
Unit Group - Add (Created Unit()) to Regular Infantry Groups[((Number of Reg Infantry Groups + 1) mod 10)]
But I also want this trigger to cycle through the array and only add the units to a spot in the array if there are no units in there. So that if there were all 10 units groups running around, and one of them gets wiped out, this trigger would cycle through and create a new batch of units to have them occupy the empty slot.
(Number of Living units in Regular Infantry Groups[((Number of Reg Infantry Groups + 1) mod 10)]) < 5
So the condition would be that if the number of units in the array slot are less than 5, then it'd create a new batch of units and add them to the array slot.
::edit:: ok so that doesn't work, it creates the units, but the units just keep on being created, I get the feeling I'm not calling the array correctly to check for the numbers.
That will only spawn units when there is a group that is either empty or wiped out. (I renamed Regular Infantry Group to RIG so the code would get shorter).
Note that the last action (Add xxx to xxx) should be a action of type "Add Unit Group to Unit Group" and not "Add Unit to Unit Group".
Since you are spawning several units and you want all of them to be added in the group. Maybe you've already done that in your trigger, but to me it seems like you used "Add Unit to Unit Group".
PS: If you don't know the "Break" action - once it is called it work jump out of the current loop and the trigger continues with the actions after the loop.
I created a map for you, this is how I would create a system similar to the one you described if I had to.
When you first look at it it seems pretty complex, but it's way simpler than you think.
I didn't add any comments because everything is self explanatory.
Variables:
hdd_squad - squad struct (Record), containes all the variables a squad should hold;
hdd_squads - hdd_squad array, this is where the squads are placed;
hdd_squadsMaxLength - contains the current max length of the hdd_squads array, messy speedup so loops don't have to iterate that much;
Triggers:
hdd_C_keyDown - calls hdd_createUnits with some predefined parameters;
hdd_R_keyDown - removes everything;
hdd_moveUnits - every 1 second, checks all squads to see if any of them are idle (hdd_squadIsIdle), if a squad is idle it orders all the units in the squad to attack a random point;
Functions/Actions:
hdd_createUnits - creates units at a random point around a point with a delay and calls hdd_addSquad, Creates a thread;
hdd_addSquad - checks the hdd_squads array for an open space and adds the squad there, also selects a commander and adds a textTag;
hdd_squadIsIdle - checks the orders of all the units in a unit group, of none of the units has orders, returns true, the squad is Idle;
I made it in 25 minutes so it may not be the most efficient way to do it or it may contain some bugs.
Map attached to this post.
Also, if you use a large part of this in your published map I wouldn't mind seeing my nickname in some small obscure corner of the credits :)
I want to make it so that every couple of seconds, a group of units spawn and this group randomly attacks a point within a region and once it reaches the point, I want them to aquire a new point to attack move to.
The problem is this.
I want this trigger to go so that every few seconds, another group is spawned with the same orders, but a different random point to go to I feel like I should have the units be catagorized into unit groups upon creation, and set attack orders to the group itself so that the group moves as a whole but is there a way to create variables via triggers?
cuz for obvious purposes, I can't do this in the editor, Unit group 1, 2,3,4,5,6, etc.....
I want a trigger that can assign each new batch of units to their own unit group, not to an existing one. Doesn't have to be one trigger that does all this, but a series of them. Any ideas?
You could just store an array of attack groups, and recycle them as needed.
Sounds like you could just use attack waves tho
You could use this:
It'll queue up the orders and execute them after each other, like shift-clicking.
But that would mean that those points are preset by me and there's a pattern to their movements. I want a repeating trigger to make the unit groups move to random points every few seconds. That's easy though.
The part which I'm trying to figure out is storing it so that there are 10 unit groups floating around the map.
Regular Infantry Groups = (Empty unit group) <Unit Group[10]>
That's the variable Unit group array which I created to store the units in.
This is the trigger which I have right now.
----Spawn Reg Infantry Wave
Events
Local Variables
Conditions
Actions
But I also want this trigger to cycle through the array and only add the units to a spot in the array if there are no units in there. So that if there were all 10 units groups running around, and one of them gets wiped out, this trigger would cycle through and create a new batch of units to have them occupy the empty slot.
Would a condition such as this work?
(Number of Living units in Regular Infantry Groups[((Number of Reg Infantry Groups + 1) mod 10)]) < 5
So the condition would be that if the number of units in the array slot are less than 5, then it'd create a new batch of units and add them to the array slot.
::edit:: ok so that doesn't work, it creates the units, but the units just keep on being created, I get the feeling I'm not calling the array correctly to check for the numbers.
That condition would only check one group for survivors, though.
I think you'll have to do something like that:
That will only spawn units when there is a group that is either empty or wiped out. (I renamed Regular Infantry Group to RIG so the code would get shorter).
Note that the last action (Add xxx to xxx) should be a action of type "Add Unit Group to Unit Group" and not "Add Unit to Unit Group".
Since you are spawning several units and you want all of them to be added in the group. Maybe you've already done that in your trigger, but to me it seems like you used "Add Unit to Unit Group".
PS: If you don't know the "Break" action - once it is called it work jump out of the current loop and the trigger continues with the actions after the loop.
Hello Noodles!
I created a map for you, this is how I would create a system similar to the one you described if I had to. When you first look at it it seems pretty complex, but it's way simpler than you think.
I didn't add any comments because everything is self explanatory.
Variables:
hdd_squad - squad struct (Record), containes all the variables a squad should hold;
hdd_squads - hdd_squad array, this is where the squads are placed;
hdd_squadsMaxLength - contains the current max length of the hdd_squads array, messy speedup so loops don't have to iterate that much;
Triggers:
hdd_C_keyDown - calls hdd_createUnits with some predefined parameters;
hdd_R_keyDown - removes everything;
hdd_moveUnits - every 1 second, checks all squads to see if any of them are idle (hdd_squadIsIdle), if a squad is idle it orders all the units in the squad to attack a random point;
Functions/Actions:
hdd_createUnits - creates units at a random point around a point with a delay and calls hdd_addSquad, Creates a thread;
hdd_addSquad - checks the hdd_squads array for an open space and adds the squad there, also selects a commander and adds a textTag;
hdd_squadIsIdle - checks the orders of all the units in a unit group, of none of the units has orders, returns true, the squad is Idle;
I made it in 25 minutes so it may not be the most efficient way to do it or it may contain some bugs. Map attached to this post.
Also, if you use a large part of this in your published map I wouldn't mind seeing my nickname in some small obscure corner of the credits :)
Thank you VERY much. This was exactly what I was looking for.
And don't worry, I've been keeping a list of people who reply with suggestions in any thread I make, so your name has been noted.