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

How do i make a condition that only works with allies?

Status
Not open for further replies.
Level 2
Joined
Dec 30, 2011
Messages
13
This is the trigger

  • Shipyard wea
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Capture distance --------
      • -------- -------------------------------------------------- --------
      • Set Shipyard_Real[1] = 200.00
      • -------- -------------------------------------------------- --------
      • Set Shipyard[1] = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Shipyard))
      • Unit Group - Pick every unit in Shipyard[1] and do (Actions)
        • Loop - Actions
          • Trigger - Add to Shipyard return1 <gen> the event (Unit - A unit comes within Shipyard_Real[1] of (Picked unit))
  • Shipyard return1
    • Events
    • Conditions
    • Actions
      • Set Shipyard_Loc_1[1] = (Position of (Triggering unit))
      • Set Shipyard_Group_1[1] = (Units within (Shipyard_Real[1] + 25.00) of Shipyard_Loc_1[1] matching ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))
      • Unit Group - Pick every unit in Shipyard_Group_1[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to 10.00
              • (Unit-type of (Picked unit)) Equal to Transport Ship
            • Then - Actions
              • Player - Add 2 to (Owner of (Picked unit)) Current gold
              • Unit - Set mana of (Picked unit) to 0.00
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Shipyard_Group_1[1])
      • Custom script: call RemoveLocation(udg_Shipyard_Loc_1[1])
 
Level 2
Joined
Dec 30, 2011
Messages
13
I did it before but didnt work cuz the trigger works picking the unit in range and the boolean select this unit only and no the buildig to get closer
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
Then you need to change it to be periodic, if more than one unit arrives in range then there will be issues.
Try this?

Hold on, i'm having issues lol.

Edit:
Here we are, attached are the trigger files if you want to import.

  • Start
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Set VariableSet Shipyard_A_Index = (Shipyard_A_Index + 1)
              • Set VariableSet Shipyard_B_Unit[Shipyard_A_Index] = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Shipyard_A_Index Equal to 1
                • Then - Actions
                  • Trigger - Turn on Periodic <gen>
                • Else - Actions
            • Else - Actions
  • Periodic
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Shipyard_A_Loop) from 1 to Shipyard_A_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Shipyard_B_Unit[Shipyard_A_Loop] is alive) Equal to True
            • Then - Actions
              • Set VariableSet Shipyard_P[1] = (Position of Shipyard_B_Unit[Shipyard_A_Loop])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of Shipyard_B_Unit[Shipyard_A_Loop]) Equal to 10.00
                • Then - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units within 225.00 of Shipyard_P[1].) and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Mana of Shipyard_B_Unit[Shipyard_A_Loop]) Equal to 10.00
                          • (Unit-type of (Picked unit)) Equal to Guard Tower
                        • Then - Actions
                          • Unit - Set mana of Shipyard_B_Unit[Shipyard_A_Loop] to 0.00
                          • Special Effect - Create a special effect attached to the chest of Shipyard_B_Unit[Shipyard_A_Loop] using Abilities\Spells\Other\Transmute\GoldBottleMissile.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Player - Add 2 to (Owner of (Picked unit)).Current gold
                        • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Shipyard_P[1])
            • Else - Actions
              • Set VariableSet Shipyard_A_Loop = (Shipyard_A_Loop - 1)
              • Set VariableSet Shipyard_A_Index = (Shipyard_A_Index - 1)
              • Set VariableSet Shipyard_B_Unit[Shipyard_A_Loop] = Shipyard_B_Unit[Shipyard_A_Index]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Shipyard_A_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 

Attachments

  • Shipyard triggers.wtg
    4.4 KB · Views: 38
Last edited:
Level 2
Joined
Dec 30, 2011
Messages
13
What do you wanna do? Because there exists a boolean called "<Your unit> is belongs to a ally/enemy of <Your player>"

X unit enter in range of 225 of shipyard and have 10 mana then give 2 gold and set mana to 0
entering unit in range of 225 of shipyard is an enemy of owner of shipyard then do nothing

Something like that
Then you need to change it to be periodic, if more than one unit arrives in range then there will be issues.
Try this?

Hold on, i'm having issues lol.

Edit:
Here we are, attached are the trigger files if you want to import.

  • Start
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Set VariableSet Shipyard_A_Index = (Shipyard_A_Index + 1)
              • Set VariableSet Shipyard_B_Unit[Shipyard_A_Index] = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Shipyard_A_Index Equal to 1
                • Then - Actions
                  • Trigger - Turn on Periodic <gen>
                • Else - Actions
            • Else - Actions
  • Periodic
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Shipyard_A_Loop) from 1 to Shipyard_A_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Shipyard_B_Unit[Shipyard_A_Loop] is alive) Equal to True
            • Then - Actions
              • Set VariableSet Shipyard_P[1] = (Position of Shipyard_B_Unit[Shipyard_A_Loop])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of Shipyard_B_Unit[Shipyard_A_Loop]) Equal to 10.00
                • Then - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units within 225.00 of Shipyard_P[1].) and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Mana of Shipyard_B_Unit[Shipyard_A_Loop]) Equal to 10.00
                          • (Unit-type of (Picked unit)) Equal to Guard Tower
                        • Then - Actions
                          • Unit - Set mana of Shipyard_B_Unit[Shipyard_A_Loop] to 0.00
                          • Special Effect - Create a special effect attached to the chest of Shipyard_B_Unit[Shipyard_A_Loop] using Abilities\Spells\Other\Transmute\GoldBottleMissile.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Player - Add 2 to (Owner of (Picked unit)).Current gold
                        • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Shipyard_P[1])
            • Else - Actions
              • Set VariableSet Shipyard_A_Loop = (Shipyard_A_Loop - 1)
              • Set VariableSet Shipyard_A_Index = (Shipyard_A_Index - 1)
              • Set VariableSet Shipyard_B_Unit[Shipyard_A_Loop] = Shipyard_B_Unit[Shipyard_A_Index]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Shipyard_A_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions

That trigger still have the thing that can be used by the enemy, idk how to do that only works for you and allies xD
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
I realize something:
  • Shipyard return1
    • Events
    • Conditions
      • (Unit-Type of (Triggering unit)) Equal to Transport Ship
      • (Mana of (Triggering unit)) Equal to 10.00
    • Actions
    • Set Temp_Unit = (Triggering unit) "To increase the efficiency"
    • Set Shipyard_Loc_1[1] = (Position of Temp_Unit)
    • Set Shipyard_Group_1[1] = (Units within (Shipyard_Real[1] + 25.00) of Shipyard_Loc_1[1] matching ((Owner of (Matching unit)) Equal to (Owner of Temp_Unit)) and ((Unit-Type of (Matching unit)) Equal to Shipyard))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Shipyard_Group_1[1] is empty) Equal to False
      • Then - Actions
        • Player - Add 2 to (Owner of Temp_Unit) Current gold
        • Unit - Set mana of Temp_Unit to 0.00
      • Else - Actions
    • Custom script: call DestroyGroup(udg_Shipyard_Group_1[1])
    • Custom script: call RemoveLocation(udg_Shipyard_Loc_1[1])
Will work for what do you want
 
Status
Not open for further replies.
Top