PDA

View Full Version : Auto Move Generated Units


cobracao
09-12-2005, 11:09 AM
In developing a map I wanted to create an area that auto-generated units that once a certain number of units was created they would move to another area (Player starting point) and attack.

I developed one trigger that creates units based on a timer. One of the actions in that trigger calls on a second trigger

The second trigger looks for a condition to determine how many units are in the region. If the condition passes I set it to call another trigger

The third trigger I wanted to select the created units and order them into a players main encampment.

Of course the unit generator works smoothly. However I am unable to get the units to move into the players encampment. I've tried several ways of doing so. Order Group of units in a region to another region. This simply results in any player controlled units moving to the region when they enter.

I've tried setting the trigger to Select All of the units (Select Units for Player 10) and order them to move to point A.

However this simply doesnt appear to work.. Anyone have any ideas, please?

XZminX
09-12-2005, 4:08 PM
Make a unit group variable and call it AttackSquad.
When you create unit add it to that unit group.
When you want to order group to attack ground, use the following:

Unit Group - Pick every unit in AttackSquad and do Unit - Issue picked unit to (1 or 2) Target.

1 is Attack, to attack only units in and near that region
2 is Attack-Move To, to attack anything on their way to the target, including target (if anyone survives)
Target is the region variable that you need to define somewhere before.

This way you dont need region from where you take units and order them to move to certain region. You could do so too, but you need a condition to check if the owner of the unit is not player-controlled and the unit-type is right. I think that Unit Group trick is more efficient and nicer.
Enjoy!

cobracao
09-12-2005, 6:23 PM
Awesome! Thanks for the reply. I am hoping to try that tonight. I think I wasted like 2 hours testing changes trying to get that to work.

I appreciate you taking the time to give me a hand up sir!

-=UPDATE=-
Ok.. Just spent about an hour at it :p

I've got 3 Scripts
Script 1:
Event - Every 5 seconds of game time (Will be longer but for test purposes)
Condition - None
Action -
Unit Create for Player at point;
Unit Group Add Last Created to 'P2AttackGroup';
Trigger Run Script 2;

Script 2:
Event - None
Condition - 'P2AttackGroup' >= 6
Action - Trigger Run Script 3;

Script 3:
Event - None
Condition - None
Action - Unit Group Pick every unit in 'P2AttackGroup' and do (Order group to attack/move to PlayerArea


I've added Floating text into each of the scripts for Debugging Purposes. I list which script is running and the number of units in 'P2AttackGroup'

Script 1 Runs as expected, which is obvious by the amassing troops and lists the correct value for the number of units in the Group

Script 2 Runs as expected based by the creation of floating text within the script, correctly identifying the number of units in the Group

Script 3 is executed as expected by the creation of the floating text within the script, correctly identifying the number of units in the group.

However after the group >6 Scripts 2 and 3 are executed everytime Script 1 runs based on the text display (Group is now consistently greater than 6).

However the units never attack? :`(
I'd be willing to share the current version of my map that I am using to test this ability....

XZminX
09-13-2005, 4:17 PM
Script 2 is not needed, just add in Script 1 instead Trigger - Run Script 2 this:
IF (Number of units in P2AttackGroup > 6) THEN (Trigger - Run Script 3) ELSE (Do Nothing)
Use Unit Group - Pick every unit in P2AttackGroup and do: Unit - Issue picked unit to attack-move to PlayerArea instead Unit Group Pick every unit in 'P2AttackGroup' and do (Order group to attack/move to PlayerArea

Take a look at the script you wrote: Unit Group Pick every unit in 'P2AttackGroup' and do (Order group to attack/move to PlayerArea
You do this: Take your unit group and make a loop taking every unit as itself, so you approach to each unit for itself. You can't give unit a group-type order. That is what you do here: Order group to attack/move to PlayerArea
Correct that and it will be OK.
Also you may consider removing units from unit group because that condition makes no sence in later game.

cobracao
09-13-2005, 4:51 PM
Awesome! I look forward to making the corrections. I can't believe I missed the logic of issuing a group command to a unit...

Well, I am expecting the the Attack Group get decimated by the Player. They are merely for harrassment. Each player will have this harrassment. Mainly as a training point. A player I am working with has a nasty habbit of not working so much on units until he has all his buildings and some tech in place (Be nice he's a kid) :p

So as long as the Attack group is decimated each time there should be no group to select from. If not without additional code I would suspect each time a unit is created the condition should evaluate to true and units will just keeping moving into the player area to join their brethren...

XZminX
09-14-2005, 2:14 PM
I don't follow you there. Do you have a problem still or what?

cobracao
09-14-2005, 6:32 PM
I don't follow you there. Do you have a problem still or what?

Sorry bout that.. Was attempting to answer
Also you may consider removing units from unit group because that condition makes no sence in later game.

I wasnt too worried about removing units from the group...


Anyways, I am sorry, with all your help, which I am grateful for, it still does not appear to be working... :(

Zipsco
09-19-2005, 5:37 AM
Ahh damn it... wrote a long post, saying you had forgotten something, then aften reading again i find it... wow what a good waste of time, anyway... found a few places you might have made some mistakes..: trigger run trigger... there are choices to that one... 1 run trigger without conditions and 1 with conditions... pick the right one.. (the one with conditions) also... you should tend to that trigger with : P2attackgroup <= 6... maybe you just shortend it.. but should look like this : number of units in "P2attackgroup" <= 6.... maybe thats what wrong... else i can find anything that should make it impossible... i have done this a thousand times.. it is usually some little mistake you have overlooked... try reading the triggers through 3 or 4 times without jumping over some you think you did right... thats usually the places the errors is, since you havent checked them!