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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top