Using a unit from a spell to another spell?

Gwafu

Active Member
Reaction score
12
Warning: Long Triggers (What was the hide/spoiler tags again?)

Gather Part
Trigger:
  • Right Click
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Multiple ConditionsAnd - All (Conditions) are true
        • Conditions
          • (Issued order) Equal to (==) (Order(smart))
          • (Unit-type of (Target unit of issued order)) Equal to (==) Gold Mine
          • (Unit-type of (Triggering unit)) Equal to (==) Peasant
          • (Custom value of (Triggering unit)) Equal to (==) 0
    • Actions
      • Custom script: call IssueTargetOrder( GetTriggerUnit(), "harvest", GetOrderTargetUnit() )

Trigger:
  • Harvest Gather
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Gather
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Harvest_Index_Size Equal to (==) 0
        • Then - Actions
          • Trigger - Turn on Harvest Loop <gen>
        • Else - Actions
      • Set Harvest_Index_Size = (Harvest_Index_Size + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Harvest_Index_Size Greater than (>) Harvest_Index_maxSize
          • Then - Actions
            • Set Harvest_Index[Harvest_Index_Size] = Harvest_Index_Size
            • Set Harvest_Index_maxSize = Harvest_Index_Size
          • Else - Actions
      • Set Harvest_TempInt = Harvest_Index[Harvest_Index_Size]
      • Set Harvest_Unit[Harvest_TempInt] = (Triggering unit)
      • Set Harvest_Loc[Harvest_TempInt] = (Position of Harvest_Unit[Harvest_TempInt])
      • Set Harvest_Dur[Harvest_TempInt] = 2.00
      • Wait 0.01 seconds
      • Unit - Hide Harvest_Unit[Harvest_TempInt]
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TimeCheck Equal to (==) True
          • Then - Actions
            • Visibility - Create an initially Enabled visibility modifier for (Owner of Harvest_Unit[Harvest_TempInt]) emitting Visibility from Harvest_Loc[Harvest_TempInt] to a radius of 800.00
          • Else - Actions
            • Visibility - Create an initially Enabled visibility modifier for (Owner of Harvest_Unit[Harvest_TempInt]) emitting Visibility from Harvest_Loc[Harvest_TempInt] to a radius of 600.00
      • Set Harvest_Vis[Harvest_TempInt] = (Last created visibility modifier)
      • Unit - Pause Harvest_Unit[Harvest_TempInt]
      • Animation - Add the gold animation tag to Harvest_Unit[Harvest_TempInt]

Trigger:
  • Harvest Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer Harvest_Loop) from 1 to Harvest_Index_Size, do (Actions)
        • Loop - Actions
          • Set Harvest_TempInt = Harvest_Index[Harvest_Loop]
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Harvest_Dur[Harvest_TempInt] Greater than (>) 0.00
              • Then - Actions
                • Set Harvest_Dur[Harvest_TempInt] = (Harvest_Dur[Harvest_TempInt] - 0.03)
              • Else - Actions
                • Unit - Unhide Harvest_Unit[Harvest_TempInt]
                • Visibility - Destroy Harvest_Vis[Harvest_TempInt]
                • Unit - Unpause Harvest_Unit[Harvest_TempInt]
                • Unit - Set the custom value of Harvest_Unit[Harvest_TempInt] to 1
                • Set Harvest_TempUG = (Units owned by (Owner of Harvest_Unit[Harvest_TempInt]) of type Town Hall)
                • Set Harvest_Distance = 1000000000.00
                • Unit Group - Pick every unit in Harvest_TempUG and do (Actions)
                  • Loop - Actions
                    • Set Harvest_TempLoc = (Position of (Picked unit))
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Distance between Harvest_Loc[Harvest_TempInt] and Harvest_TempLoc) Less than or equal to (<=) Harvest_Distance
                        • Then - Actions
                          • Set Harvest_TempUnit = (Picked unit)
                          • Set Harvest_Distance = (Distance between Harvest_Loc[Harvest_TempInt] and Harvest_TempLoc)
                        • Else - Actions
                • Unit - Remove Gather from Harvest_Unit[Harvest_TempInt]
                • Unit - Add Return Resource to Harvest_Unit[Harvest_TempInt]
                • Unit - Order Harvest_Unit[Harvest_TempInt] to Right-Click Harvest_TempUnit
                • Custom script: call RemoveLocation(udg_Harvest_Loc[udg_Harvest_TempInt])
                • Custom script: call RemoveLocation(udg_Harvest_TempLoc)
                • Custom script: call DestroyGroup(udg_Harvest_TempUG)
                • -------- blah blah blah --------
                • -------- blah blah blah --------
                • Set Harvest_Index[Harvest_Loop] = Harvest_Index[Harvest_Index_Size]
                • Set Harvest_Index[Harvest_Index_Size] = Harvest_TempInt
                • Set Harvest_Index_Size = (Harvest_Index_Size - 1)
                • Set Harvest_Loop = (Harvest_Loop - 1)
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Harvest_Index_Size Equal to (==) 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Return Part
Trigger:
  • Right Click Copy
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Multiple ConditionsAnd - All (Conditions) are true
        • Conditions
          • (Issued order) Equal to (==) (Order(smart))
            • Multiple ConditionsOr - Any (Conditions) are true
              • Conditions
                • (Unit-type of (Target unit of issued order)) Equal to (==) Town Hall
                • (Unit-type of (Target unit of issued order)) Equal to (==) Keep
                • (Unit-type of (Target unit of issued order)) Equal to (==) Castle
          • (Unit-type of (Triggering unit)) Equal to (==) Peasant
            • Multiple ConditionsOr - Any (Conditions) are true
              • Conditions
                • (Custom value of (Triggering unit)) Equal to (==) 1
                • (Custom value of (Triggering unit)) Equal to (==) 2
    • Actions
      • Custom script: call IssueTargetOrder( GetTriggerUnit(), "returnresources", GetOrderTargetUnit() )

Trigger:
  • Return Execute
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Return Resource
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Return_Index_Size Equal to (==) 0
        • Then - Actions
          • Trigger - Turn on Return Loop <gen>
        • Else - Actions
      • Set Return_Index_Size = (Return_Index_Size + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Return_Index_Size Greater than (>) Return_Index_maxSize
          • Then - Actions
            • Set Return_Index[Return_Index_Size] = Return_Index_Size
            • Set Return_Index_maxSize = Return_Index_Size
          • Else - Actions
      • Set Return_TempInt = Return_Index[Return_Index_Size]
      • Set Return_Unit[Return_TempInt] = (Triggering unit)
      • Set Return_Loc[Return_TempInt] = (Position of Return_Unit[Return_TempInt])
      • Set Return_Dur[Return_TempInt] = 2.00
      • Wait 0.01 seconds
      • Unit - Hide Return_Unit[Return_TempInt]
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TimeCheck Equal to (==) True
          • Then - Actions
            • Visibility - Create an initially Enabled visibility modifier for (Owner of Return_Unit[Return_TempInt]) emitting Visibility from Return_Loc[Return_TempInt] to a radius of 800.00
          • Else - Actions
            • Visibility - Create an initially Enabled visibility modifier for (Owner of Return_Unit[Return_TempInt]) emitting Visibility from Return_Loc[Return_TempInt] to a radius of 600.00
      • Set Return_Vis[Return_TempInt] = (Last created visibility modifier)
      • Unit - Pause Return_Unit[Return_TempInt]
      • Animation - Remove the gold animation tag to Return_Unit[Return_TempInt]
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of Return_Unit[Return_TempInt]) Equal to (==) 1
          • Then - Actions
            • Set Build_Resource[1] = (Build_Resource[1] + 100)
            • Multiboard - Set the text for Build_Multiboard[1] item in column 1, row 1 to (String(Build_Resource[1]))
            • Floating Text - Create floating text that reads +100 at Return_Loc[Return_TempInt] with Z offset 20.00, using font size 12.50, color (100.00%, 100.00%, 25.00%), and 0.00% transparency
            • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
            • Floating Text - Change (Last created floating text): Disable permanence
            • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
            • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Else - Actions

Trigger:
  • Return Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer Return_Loop) from 1 to Return_Index_Size, do (Actions)
        • Loop - Actions
          • Set Return_TempInt = Return_Index[Return_Loop]
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Return_Dur[Return_TempInt] Greater than (>) 0.00
              • Then - Actions
                • Set Return_Dur[Return_TempInt] = (Return_Dur[Return_TempInt] - 0.04)
              • Else - Actions
                • Unit - Unhide Return_Unit[Return_TempInt]
                • Visibility - Destroy Return_Vis[Return_TempInt]
                • Unit - Unpause Return_Unit[Return_TempInt]
                • Unit - Set the custom value of Return_Unit[Return_TempInt] to 0
                • Unit - Remove Return Resource to Return_Unit[Return_TempInt]
                • Unit - Add Gather from Return_Unit[Return_TempInt]
                • ------Add order here-------
                • Set Return_Index[Return_Loop] = Return_Index[Return_Index_Size]
                • Set Return_Index[Return_Index_Size] = Return_TempInt
                • Set Return_Index_Size = (Return_Index_Size - 1)
                • Set Return_Loop = (Return_Loop - 1)
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Return_Index_Size Equal to (==) 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions

Okay, before saying "WTF is this shit?" I'll explain. These two trigger "groups" are parts of a custom gold harvesting system. The Gather group controls the "Go to Gold Mine" and the Return group controls the "Go to nearest Town Hall".

The Gather and Return Resource abilities are based on unit-targeting Channel. The custom values stores what kind of resource the peasant is carrying.

In the Gather Loop, it detects the nearest Town Hall.

The problem? I was gonna order the peasant to go the Gold Mine he went from (In the Return Loop), but I can't check it. Any help?

Thanks in advance!
~Gwafu aka supertoinkz
 

NeuroToxin

New Member
Reaction score
46
You're asking how to detect the gold mine he came from?
If you are, I'd suggest something like finding what the gold mines unit type is, well, ordering him to turn around then head the way he came from, as when they mine gold they take the best route, straight towards it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top