How to make units ignore attacking a unit with a specific buff?

Level 15
Joined
Jul 19, 2007
Messages
855
As the title says I want units with a specific buff to be unable to be attacked but how? Currenly I use to order attacking units to Stop everytime they are trying to attack the units with the specific buff but the attacking unit will just stand there and do nothing because it keeps trying to attack the unit with the specific buff but is ordered to Stop until the specific buff is gone. Is there any other way to do this? So the units just ignoring attack the units with the specific buff and keep attacking other units instead?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Damn World Editor really lacks of trigger options... Well it was worth asking anyway ^^
This doesn't account for everything but it's a good start:
  • Attack Prevention
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Avatar) Equal to True
    • Actions
      • Set VariableSet AtkPrev_Attacker = (Attacking unit)
      • Set VariableSet AtkPrev_Owner = (Owner of AtkPrev_Attacker)
      • Set VariableSet AtkPrev_Point = (Position of AtkPrev_Attacker)
      • Set VariableSet AtkPrev_Group = (Units within ((Unit: AtkPrev_Attacker's Weapon Real Field: Attack Range ('ua1m') at Index:0) + 256.00) of AtkPrev_Point.)
      • Unit Group - Remove (Attacked unit) from AtkPrev_Group.
      • -------- --------
      • -------- Filter out unwanted targets from the group --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AtkPrev_Attacker is Able to attack flying units) Equal to False
        • Then - Actions
          • -------- Can only attack Ground --------
          • Unit Group - Pick every unit in AtkPrev_Group and do (Actions)
            • Loop - Actions
              • Set VariableSet AtkPrev_Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (AtkPrev_Target belongs to an enemy of AtkPrev_Owner.) Equal to True
                  • (AtkPrev_Target is alive) Equal to True
                  • (AtkPrev_Target is A ground unit) Equal to True
                  • (AtkPrev_Target is invulnerable) Equal to False
                • Then - Actions
                  • -------- Keep valid targets in the group! --------
                • Else - Actions
                  • Unit Group - Remove AtkPrev_Target from AtkPrev_Group.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AtkPrev_Attacker is Able to attack ground units) Equal to False
            • Then - Actions
              • -------- Can only attack Air --------
              • Unit Group - Pick every unit in AtkPrev_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet AtkPrev_Target = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AtkPrev_Target belongs to an enemy of AtkPrev_Owner.) Equal to True
                      • (AtkPrev_Target is alive) Equal to True
                      • (AtkPrev_Target is A flying unit) Equal to True
                      • (AtkPrev_Target is invulnerable) Equal to False
                    • Then - Actions
                      • -------- Keep valid targets in the group! --------
                    • Else - Actions
                      • Unit Group - Remove AtkPrev_Target from AtkPrev_Group.
            • Else - Actions
              • -------- Can attack both Ground + Air --------
              • Unit Group - Pick every unit in AtkPrev_Group and do (Actions)
                • Loop - Actions
                  • Set VariableSet AtkPrev_Target = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AtkPrev_Target belongs to an enemy of AtkPrev_Owner.) Equal to True
                      • (AtkPrev_Target is alive) Equal to True
                      • (AtkPrev_Target is invulnerable) Equal to False
                    • Then - Actions
                      • -------- Keep valid targets in the group! --------
                    • Else - Actions
                      • Unit Group - Remove AtkPrev_Target from AtkPrev_Group.
      • -------- --------
      • -------- If the unit group is empty then this will be set to "No unit" --------
      • Set VariableSet AtkPrev_Target = (Random unit from AtkPrev_Group)
      • -------- --------
      • -------- Clean up memory leaks --------
      • Custom script: call RemoveLocation( udg_AtkPrev_Point )
      • Custom script: call DestroyGroup( udg_AtkPrev_Group )
      • -------- --------
      • -------- Either find a new target or cancel the attack --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AtkPrev_Target Not equal to No unit
        • Then - Actions
          • Unit - Order AtkPrev_Attacker to Attack AtkPrev_Target
        • Else - Actions
          • Unit - Order AtkPrev_Attacker to Stop.
 

Attachments

  • Attack Prevention 1.w3m
    20 KB · Views: 1
Top