Keeping units together - Alternative to Unit Leaves Region... Why won't this work?

NuQ

Member
Reaction score
8
I have a watchman type unit that is supposed to wander, but obviously not too far away from the town it is guarding... I didnt want to have to create a bunch of regions and then move them to the position of the watchmen everytime one is trained... so i gave the town hall an aura and had it check to see if the unit had the buff when it was given an order. if it didnt it would order the unit to return to the town hall... but it doesn't work. here is the trigger:

Trigger:
  • Herding
    • Events
      • Unit - A unit Begins channeling an ability
      • Unit - A unit Begins casting an ability
      • Unit - A unit Starts the effect of an ability
      • Unit - A unit Finishes casting an ability
      • Unit - A unit Stops casting an ability
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Watchman
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has buff Home ) Equal to True
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Set CustomValue = (Custom value of (Triggering unit))
          • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A town-hall-type unit) Equal to True) and ((Custom value of (Matching unit)) Equal to CustomValue)))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Set TempPoint = (Position of (Picked unit))
              • Unit - Order (Triggering unit) to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_TempGroup)


each unit is assigned a custom value when it is created, the custom value assigns it to which town it was created at, and is unique to each town. so all the custom value stuff is a way of refferencing each town hall. any clues why this won't work?

Edit: Shura has pointed out the infinite loop problem caused by the "Unit is issued an order targeting a point(move) event. that's just there as a relic of when I've tried changing triggering unit to ordered unit, casting unit, etc, to try to get it to detect when the wander ability is used. which just isn't happening. if i can't get this configuration to work, is there another way to keep wandering units in a general area (other than creating a region and a specific unit leaves region event)
 

Shura

New Member
Reaction score
45
Wouldn't that trigger cause an infinite loop? You order the unit to move to the point, which fires the trigger, which loops? So wouldn't it crash the game?
 

NuQ

Member
Reaction score
8
The loop only fires once for each unit as it is picked, doesn't it? and since there is only one unit in the playable map area that is a town hall type unit, with the same custom value as the triggering unit, it should only fire once.
 

Shura

New Member
Reaction score
45
I'm referring to the fact your ordering a unit to move in your trigger. This would cause your trigger to fire, which would cause your unit to be ordered to move again, which would cause the trigger to fire etc. If your map doesn't crash when this trigger should run, then the unit is never being ordered to move.
 

NuQ

Member
Reaction score
8
It would only order the unit to move until it was back in the aura and wouldn't be all that different from a user spamming the move command on the same location (ie, yes, its a spam, but the unit continues to move while being spammed.) at least, thats the intention...
 

Shura

New Member
Reaction score
45
The moment the trigger orders the unit to move, it fires, which loops instantly. This crashes the game.
Trigger:
  • trigger
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to Move To (Center of (Playable map area))

You could try this if you wanted to. This trigger would crash the game once a unit is issued as order targeting a point.
Anyway, the point is, the unit is never being issued its order, which means there's a problem somewhere before that point in your trigger. You will also need to turn off the trigger, and then turn it on again when ordering the unit to move.
 

NuQ

Member
Reaction score
8
Theres got to be a way of keeping units together other than using pre-defined regions. bah.
 

Shura

New Member
Reaction score
45
Your trigger should work. You should go check to confirm the units are being given correct custom values. Then put in actions that display messages in your code at different places, to confirm that the code reaches the point where it displays the message.
 

Wratox1

Member
Reaction score
22
there is an ability called wander, its normally used on critters to make them run around in the forest, add that ability to your watchman;)
 

NuQ

Member
Reaction score
8
I have given them wander... The problem is they wander too, far eventually, and i want to order them to return home. No matter what i do i can't get it to detect when the wander ability is sued (unit begins casting an ability, unit begins effect of an ability, etc, nothing seems to pick up on it.)

@Shura: I know the custom value association thing is working because of this, here is the code to respawn the peasants if they die... using the same way of refering to their "home" town hall.

Trigger:
  • Spawn Peasants
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Peasant Dummy
    • Actions
      • Set CustomValue = (Custom value of (Dying unit))
      • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A town-hall-type unit) Equal to True) and ((Custom value of (Matching unit)) Equal to CustomValue)))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • Set RandomValue = (Random integer number between 1 and 7)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 1
            • Then - Actions
              • Unit - Create 1 Peasant (Mil) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 2
            • Then - Actions
              • Unit - Create 1 Peasant (Mil) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 3
            • Then - Actions
              • Unit - Create 1 Peasant (Mil) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 4
            • Then - Actions
              • Unit - Create 1 Peasant (Arc) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 5
            • Then - Actions
              • Unit - Create 1 Peasant (Arc) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 6
            • Then - Actions
              • Unit - Create 1 Villager (Female) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomValue Equal to 7
            • Then - Actions
              • Unit - Create 1 Villager (Female) for (Owner of (Picked unit)) at TempPoint facing Default building facing degrees
              • Unit - Set the custom value of (Last created unit) to CustomValue
              • AI - Ignore (Last created unit)'s guard position
            • Else - Actions
              • Do nothing
          • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_TempGroup)


And that works, the peasants respawn at the village their were killed/first spawned at, without any problems(no duplicates at other town halls, either)

Initially i wanted it to just detect the wander ability when used, if it doesnt have buff, send back to town hall but i can't even get it to run the trigger in the first place. :confused:

I might jsut break down and create a hundred regions to be moved in the event one of these "watchmen" is created...
 

Shura

New Member
Reaction score
45
Why don't you try something like this?
Trigger:
  • test
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Watchman) and (((Matching unit) has buff Home) Equal to False))) and do (Actions)
        • Loop - Actions
          • Set Temp_Unit = (Picked unit)
          • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A town-hall-type unit) Equal to True) and ((Custom value of (Matching unit)) Equal to (Custom value of (Picked unit))))) and do (Actions)
            • Loop - Actions
              • Unit - Order Temp_Unit to Move To (Position of (Picked unit))

You would need to clean the leaks yourself.
 

NuQ

Member
Reaction score
8
I tried doing a periodic event at sundown and sunrise, but it lags signifigantly when called and some of the units weren't being ordered to move for as much 2 hours of game time later than they should have been. i've of course done the "unit leaves region" thing which responded perfectly without any lag... but the whole point of this pursuit is to find another way of doing that.

here's an example of some of the weirder things i've tried.

Trigger:
  • Watchmen
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Watchman
    • Actions
      • Trigger - Add to Herding Test <gen> the event (Unit - A unit leaves (Region centered at (Position of (Trained unit)) with size (500.00, 500.00)))


and then here is the actual trigger that event is added to...

Trigger:
  • Herding Test
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Leaving unit)) Equal to Watchmen
        • Then - Actions
          • Set CustomValue = (Custom value of (Leaving unit))
          • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A town-hall-type unit) Equal to True) and ((Custom value of (Matching unit)) Equal to CustomValue)))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Set TempPoint = (Position of (Picked unit))
              • Unit - Order (Leaving unit) to Move To TempPoint
        • Else - Actions
          • Do nothing


Obviously it would leak if it worked in the first place... but just an example of some of the crazy things i've tried, all in the name of being lazy i guess.

Edit: Using the "(Region centered at (Position of (Trained unit)) with size (500.00, 500.00)))" thing works ifyou're using it in "Random point in region" move orders, but it doesnt seem to actually create a region that endures and can be used for "unit leaves region." :(
 
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