• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Capturing a neutral building

Status
Not open for further replies.
I've been using this script for some time but it's not very reliable. Mechanical units don't always trigger it and wards do. It also captures and then an instant later uncaptures sometimes.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • -------- -------------------------------------------------- --------
      • Hashtable - Create a hashtable
      • Set Tower_Hash = (Last created hashtable)
      • -------- -------------------------------------------------- --------
      • -------- Capture distance --------
      • -------- -------------------------------------------------- --------
      • Set Tower_Reals[0] = 256.00
      • -------- -------------------------------------------------- --------
      • Set Towers = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Scout Tower))
      • Unit Group - Pick every unit in Towers and do (Actions)
        • Loop - Actions
          • Trigger - Add to Capture Tower <gen> the event (Unit - A unit comes within Tower_Reals[0] of (Picked unit))
  • Capture Tower
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Close
      • Set Tower_Temp_Loc_1 = (Position of (Triggering unit))
      • Set Tower_Temp_Group_1 = (Units within (Tower_Reals[0] + 32.00) of Tower_Temp_Loc_1 matching ((Unit-type of (Matching unit)) Equal to Scout Tower))
      • Unit Group - Pick every unit in Tower_Temp_Group_1 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 - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
              • Hashtable - Save (Player number of (Owner of (Triggering unit))) as (Key owner) of (Key (Picked unit)) in Tower_Hash
              • Unit Group - Add (Picked unit) to Towers_Owned
              • Trigger - Turn on Lose Tower <gen>
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Tower_Temp_Group_1)
      • Custom script: call RemoveLocation(udg_Tower_Temp_Loc_1)
  • Lose Tower
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Towers_Owned and do (Actions)
        • Loop - Actions
          • Set Tower_Temp_Loc_1 = (Position of (Picked unit))
          • Set Tower_Temp_Group_1 = (Units within Tower_Reals[0] of Tower_Temp_Loc_1 matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Not equal to Scout Tower) and ((((Matching unit) is A structure) Equal to False) and ((Owner of (Matching unit)) Equal t
          • Set Tower_Temp_Group_2 = (Units within Tower_Reals[0] of Tower_Temp_Loc_1 matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Not equal to Scout Tower) and ((((Matching unit) is A structure) Equal to False) and ((Owner of (Matching unit)) Not equ
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Tower_Temp_Group_1 is empty) Equal to True
              • (Tower_Temp_Group_2 is empty) Equal to True
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Towers_Owned
              • Unit - Change ownership of (Picked unit) to Neutral Passive and Change color
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Towers_Owned is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Tower_Temp_Group_1 is empty) Equal to True
                  • (Tower_Temp_Group_2 is empty) Equal to False
                • Then - Actions
                  • Set Tower_Temp_Unit_1 = (Random unit from Tower_Temp_Group_2)
                  • Unit - Change ownership of (Picked unit) to (Owner of Tower_Temp_Unit_1) and Change color
                  • Hashtable - Save (Player number of (Owner of Tower_Temp_Unit_1)) as (Key owner) of (Key (Picked unit)) in Tower_Hash
                • Else - Actions
          • Custom script: call DestroyGroup(udg_Tower_Temp_Group_1)
          • Custom script: call DestroyGroup(udg_Tower_Temp_Group_2)
          • Custom script: call RemoveLocation(udg_Tower_Temp_Loc_1)
 

Attachments

  • Tower_Capture_System.w3x
    19.9 KB · Views: 55
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
The mechanical bug:
The siege engine has larger collision size than the paladin. So it needs longer tolerance than 32 distance units.

The ward bug:
You could add some condition to the trigger, like unit classification, unit is not a summmoned unit.

The capture bug:
The enter the range of tower trigger uses x + y range. The periodic trigger uses x range. Therefore it might not detect the unit that entered the range.

Put the triggers in hidden tags.
 
  • Like
Reactions: Kam
Status
Not open for further replies.
Top