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

Only works for a single player at a time?

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
  • 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 (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
            • Else - Actions
So here's the rundown of what this is meant to do.

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:
Level 16
Joined
Dec 15, 2011
Messages
1,423
GAITargetUnit[blah] in your first cond is null. Therefore the Then block is not fired and it perhaps causes the issue.

On a side note, you are not clearing group leaks and you should be looping TempInt instead of Integer B. Faster and help you get rid of the excessive line set TempInt = Integer B.

I am not really sure what your issue is though. A bit too muddy (for me at least). Mind elaborating?
 
Level 13
Joined
Oct 16, 2010
Messages
731
  • Generic AI New Target
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • -------- Sets temp unit --------
      • Set TempUnit = (Dying unit)
      • -------- Get player numbers (start) --------
      • For each (Integer B) from 1 to 12, do (Actions)
        • Loop - Actions
          • -------- ------------- --------
          • Set TempInt = (Integer B)
          • -------- Get player numbers (end) --------
          • -------- Check if dying unit is a target of any player --------
          • -------- ------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempUnit Equal to GAITargetUnit[TempInt]
            • Then - Actions
              • -------- If so... --------
              • -------- ------------- --------
              • -------- Set the player with the target (the attacker?) --------
              • Set TempPlayer = (Player(TempInt))
              • -------- Set unit group to find any living structures owned to the target player --------
              • Set TempUnitGroup01 = (Units owned by GAITargetPlayer[TempInt] matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
              • -------- Check to see if any exist --------
              • -------- ------------- --------
              • 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
                  • -------- If so... --------
                  • -------- ------------- --------
                  • -------- Pick a random structure from player to be target --------
                  • Set GAITargetUnit[TempInt] = (Random unit from TempUnitGroup01)
                  • -------- Set point as location of target --------
                  • Set GIATargetPoint[TempInt] = (Position of GAITargetUnit[TempInt])
                  • -------- ------------- --------
                • Else - Actions
                  • -------- If not... --------
                  • -------- ------------- --------
                  • -------- Find all enemies of attacking player --------
                  • Set TempPlayerGroup = (All players matching ((((Matching player) is an enemy of TempPlayer) Equal to True) and (((Matching player) slot status) Equal to Is playing)))
                  • -------- Pick random player to be new target --------
                  • Set GAITargetPlayer[TempInt] = (Random player from TempPlayerGroup)
                  • -------- Set group to all living structures belonging to new target player --------
                  • Set TempUnitGroup01 = (Units owned by GAITargetPlayer[TempInt] matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
                  • -------- Pick random structure to be target --------
                  • Set GAITargetUnit[TempInt] = (Random unit from TempUnitGroup01)
                  • -------- Set point to location of target --------
                  • Set GIATargetPoint[TempInt] = (Position of GAITargetUnit[TempInt])
                  • -------- ------------- --------
              • -------- ------------- --------
              • -------- Below is to use triggers to make them move to the next target instantly (Works fine) --------
              • 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
            • Else - Actions
I've added some comments to see if you can understand what it is all for.

I can change the loop part a bit. But basically where it picks all players (the loop integer) it only seems to end up picking one player with that target... Even when there is no "killing unit" involved with the trigger.

So the issue is that the other players which didn't have their target moved still have their units attack nothing because the target hasn't been moved at all.

Could it work better with a "Pick all players" trigger?
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
You still didn't clean the group. It could cause problems because the units in it remain through the loop and cause subsequent iterations to bug.

Here is what may help. Try putting a line to display debug messages in the ITEs and also display the current loop index. It will help you solve the issue easier.
 
Status
Not open for further replies.
Top