-
Generic AI New Target
-
Events
- Unit - A unit Dies
- Conditions
-
Actions
- Set TempUnit = (Dying unit)
-
For each (Integer B) from 1 to 12, do (Actions)
-
Loop - Actions
- Set TempInt = (Integer B)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempUnit Equal to GAITargetUnit[TempInt]
-
Then - Actions
- Game - Display to (All players) the text: 1
- Set TempPlayer = (Player(TempInt))
- Set TempUnitGroup01 = (Units owned by GAITargetPlayer[TempInt] matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in TempUnitGroup01) Greater than or equal to 1
-
Then - Actions
- Set GAITargetUnit[TempInt] = (Random unit from TempUnitGroup01)
- Set GIATargetPoint[TempInt] = (Position of GAITargetUnit[TempInt])
- Cinematic - Ping minimap for (All players) at GIATargetPoint[TempInt] for 1.00 seconds
- Game - Display to (All players) the text: TeamAllive
-
Else - Actions
- Set TempPlayerGroup = (All players matching ((((Matching player) is an enemy of TempPlayer) Equal to True) and (((Matching player) slot status) Equal to Is playing)))
- Set GAITargetPlayer[TempInt] = (Random player from TempPlayerGroup)
- Set TempUnitGroup01 = (Units owned by GAITargetPlayer[TempInt] matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
- Set GAITargetUnit[TempInt] = (Random unit from TempUnitGroup01)
- Set GIATargetPoint[TempInt] = (Position of GAITargetUnit[TempInt])
- Cinematic - Ping minimap for (All players) at GIATargetPoint[TempInt] for 1.00 seconds
- Game - Display to (All players) the text: TeamDead
- Set TempPlayerGroup = (All players matching ((((Matching player) is an enemy of TempPlayer) Equal to True) and ((((Matching player) slot status) Equal to Is playing) and (((Player number of (Matching player)) Greater than or equal to 1) and ((Player number of (Matching player)) Le
- Set GAITargetPlayer[TempInt] = (Random player from TempPlayerGroup)
- Set TempUnitGroup01 = (Units owned by GAITargetPlayer[TempInt] matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
- Set GAITargetUnit[TempInt] = (Random unit from TempUnitGroup01)
- Set GIATargetPoint[TempInt] = (Position of GAITargetUnit[TempInt])
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempPlayer Equal to Player 11 (Dark Green)
-
Then - Actions
- Trigger - Run Imperial Move Units <gen> (checking conditions)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempPlayer Equal to Player 12 (Brown)
-
Then - Actions
- Trigger - Run Haradrim Move Units <gen> (checking conditions)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (TempPlayer is in AIAttilia) Equal to True
-
Then - Actions
- Trigger - Run Attilia Move Units <gen> (checking conditions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
Events
It's for an AI system and they each have a target player, unit and point. The idea is that they will attack this unit till it is destroyed (the unit being a structure) but to get there they use an attack move to the point, which is set to be the location of the unit.
The tricky part is that if the unit is destroyed and there are still other structures belonging to the same player then they will simply switch to a different target unit and make the point be the location of that instead. But if the player has no more structures (defeat) then they will switch player and find a completely new unit to attack to.
The error comes in the fact that there will be a max of 11 AI's at one point (would be 12 but there's no free spaces so there has to be a player in the game) and they can have the same target.
The part which doesn't work is when the target unit is destroyed (no matter if the player is defeated or not) it will only work for a single player, the player which killed it, even though I haven't used a "Killing unit" response anywhere.
So any ideas??
-----------------------
Now moved to Triggers and Scripts
Last edited: