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

Siege Engine Capturing Trigger

Status
Not open for further replies.
Level 12
Joined
May 9, 2009
Messages
735
I want to make a trigger where siege engines (catapults, meat wagons etc.) change ownership depending on what units are around them.

Only neutral passive siege engines can change ownership and siege engines with no units around them at all (not counting other siege engines and buildings) turn neutral passive.

I can't find an event that would go about to accomplish this. The "a unit comes within range" event is useless and when it is added from another trigger it becomes impossible to alter conditions as they would be targeting either 'the last created unit' or whatever value of a variable that inevitably will have to changed with each siege engine on the field.

Is there are trigger I could make using "periodic event" event and some condition to achieve my goals?
 
Level 12
Joined
May 9, 2009
Messages
735
But what exactly would YOURUNIT be? The only options available in the 'position of unit' are event responses and in this case the event is periodic. You can create a variable, but since the unit variable, which is the only kind this field shows as selectable, can only be set to the same event responses you have to select from to begin with the endeavor is pointless.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Firstly, put all siege engines in a unit group. Let's call it SiegeUnits.

Now in your periodic trigger (every 1 sec should be fine), pick every unit in SiegeUnits.
- If picked unit is owned by neutral passive, set a new unit group variable to nearby player-owned units. If this group isn't empty, change ownership of picked unit to random unit from this group.
- If picked unit is owned by a player, set a new unit group variable to nearby units owned by that player. If the group is empty, change ownership of picked unit to neutral.
 
Level 12
Joined
May 9, 2009
Messages
735
Looks like it's working but the only problem is getting the right fields for the 'units in range of SiegeUnitVariable owned by player'. I could only find the 'units in range and comparison' field that was relevant but 'triggering unit = player' doesn't take into account the units within the range and thus I cannot make units in range and owned by the player thing.
 
Level 12
Joined
May 9, 2009
Messages
735
  • WHAT Copy 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SiegeUnits and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Neutral Passive
            • Then - Actions
              • Unit Group - Add all units of (Units within 250.00 of (Position of (Picked unit))) to AnyUnitsAtAll
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (AnyUnitsAtAll is empty) Equal to False
                • Then - Actions
                  • Unit - Change ownership of (Picked unit) to (Owner of (Random unit from AnyUnitsAtAll)) and Change color
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Unit Group - Add all units of (Units within 250.00 of (Position of (Picked unit)) matching (((Picked unit) is Mechanical) Equal to False)) to PlayerOwnedUnits
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PlayerOwnedUnits is empty) Equal to True
                • Then - Actions
                  • Unit - Change ownership of (Picked unit) to Neutral Passive and Change color
                • Else - Actions
                  • Do nothing
This is what I got and it gives me results but strange ones. The ownership of all the units belonging to the SiegeUnits group keeps on altering between player red and neutral passive. If I add the same condition to the alteration from the neutral to player owned the siege engine just stays passive forever. If I changed picked unit to matched unit in the comparisons nothing happens. If I use the "owner of unit = owner of unit" nothing happens.

It seems the siege engine counts itself when picking the units around it, but it doesn't explain why it ignores the non-mechanical units standing next to it and still goes passive. Is there something dreadfully wrong with the trigger or did I frame it in the wrong way?
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
The capture trigger would look like this:

  • Periodic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SiegeUnit and do (Actions)
        • Loop - Actions
          • Set Siege_u = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of Siege_u) Equal to Neutral Passive
            • Then - Actions
              • Unit Group - Pick every unit in (Units within 250.00 of (Position of Siege_u)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SiegeUnit) Equal to False
                      • (Owner of (Picked unit)) Not equal to Neutral Passive
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to temp_g
                    • Else - Actions
              • Unit - Change ownership of Siege_u to (Owner of (Random unit from temp_g)) and Change color
              • Custom script: call DestroyGroup(udg_temp_g)
            • Else - Actions
The problem when I tested was that yellow was getting it all the time, but I think its the random not working properly testing alone?
 
Level 12
Joined
May 9, 2009
Messages
735
The capture trigger would look like this:

  • Periodic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SiegeUnit and do (Actions)
        • Loop - Actions
          • Set Siege_u = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of Siege_u) Equal to Neutral Passive
            • Then - Actions
              • Unit Group - Pick every unit in (Units within 250.00 of (Position of Siege_u)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SiegeUnit) Equal to False
                      • (Owner of (Picked unit)) Not equal to Neutral Passive
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to temp_g
                    • Else - Actions
              • Unit - Change ownership of Siege_u to (Owner of (Random unit from temp_g)) and Change color
              • Custom script: call DestroyGroup(udg_temp_g)
            • Else - Actions
The problem when I tested was that yellow was getting it all the time, but I think its the random not working properly testing alone?

It's working out but only for the first change. After the same unit becomes passive for the second time it goes automatically back to the player no matter who is nearby. Although I am sure that is because I couldn't recreate the custom text bit, how exactly can I do that?
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
if u press add new action, then "c" you will get add comment, if you press c again it will apear, "script code". If you dont destroy or emty the group u will keep adding units to it and the random selection will chose from a bigger pool of units. You can use this instead:
  • Unit Group - Remove all units from temp_g
Changed it for you, I'm not sure it will work and have no time to improve this atm. Will maybe redo it later today. But this should work ok.

  • Periodic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SiegeUnit and do (Actions)
        • Loop - Actions
          • Set Siege_u = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of Siege_u) Equal to Neutral Passive
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup=true
              • Unit Group - Pick every unit in (Units within 250.00 of (Position of Siege_u)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SiegeUnit) Equal to False
                      • (Owner of (Picked unit)) Not equal to Neutral Passive
                    • Then - Actions
                      • Set temp_u = (Picked unit)
                      • Unit Group - Add temp_u to temp_g
                    • Else - Actions
              • Unit - Change ownership of Siege_u to (Owner of (Random unit from temp_g)) and Change color
              • Unit Group - Remove all units from temp_g
            • Else - Actions
              • -------- Look For Own Units --------
              • Custom script: set bj_wantDestroyGroup=true
              • Unit Group - Pick every unit in (Units within 250.00 of (Position of Siege_u)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SiegeUnit) Equal to False
                      • (Owner of Siege_u) Equal to (Owner of (Picked unit))
                    • Then - Actions
                      • Set temp_count = (temp_count + 1)
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • temp_count Equal to 0
                • Then - Actions
                  • Unit - Change ownership of Siege_u to Neutral Passive and Change color
                • Else - Actions
                  • Set temp_count = 0
 
Last edited:
Level 12
Joined
May 9, 2009
Messages
735
After more testing with the trigger it seems the conditions OwnerOfSiegeUn = OwnerOfPickedUnit doesn't work. When enemies charge the siege engines and slaughter the units next to them so they can take control of the engines the engine does not turn passive until all of those units back off, until there are no units belonging both to the owner of engine and to the other players.

This is a nasty bug so I removed the condition OwnerOfSiegeUnit = Neutral Passive. That way charging enemies will be able to capture the siege engines quickly and with a bigger probability the more of them are next to the engines.
 
Status
Not open for further replies.
Top