Unit Gives Uniy Gold Gives Player Gold

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
It's perfectly possible to put a "pick every unit" loop inside another "pick every unit" loop.
But, obviously, the "Picked unit" in the inner loop will be different from the "Picked unit" in the outer loop.


"Set <whatever>Group = units of type" isn't needed.
You already have two triggers that fill in those groups as the units are created.


The "player" loop is not needed.
Simply remember the position and the owner of the "picked unit" in the first loop,
and compare that player to the owner of the "picked unit" in the second loop.
If both are the same and the distances are "close enough" or not, then ... do something.
 
I

IKilledKEnny

Guest
AceHart, would this work:

Code:
Untitled Trigger 004
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in GathererGroup and do (Actions)
            Loop - Actions
                Set GathererPoint = (Position of (Picked unit))
                Set GoldPlayer = (Owner of (Picked unit))
                Unit Group - Pick every unit in ResourcesWagonGroup 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 GoldPlayer
                            Then - Actions
                                Set ResourcesWagonPoint = (Position of (Picked unit))
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Distance between GathererPoint and ResourcesWagonPoint) Less than or equal to 70.00
                                    Then - Actions
                                        Game - Display to (All players) the text: done
                                        Player - Add -10 to GoldPlayer Current gold
                                    Else - Actions
                            Else - Actions

Edit: Just tested it, doesn't work, WHY? :(
 
S

Sunny_D

Guest
i made a trigger that works:

CarrierUnitGroup: You add all trained carriers into this unit group
GoldUnitGroup: You add all trained Gold Gatherers into this unit group
TempUnit and TempUnit2: are unit variables
TempPoint and TempPoint2: are point variables
Custom Values: when a gatherer has gold, then set its custom value to 50

Code:
check range
    Events
        Time - Every 0.50 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in CarrierUnitGroup and do (Actions)
            Loop - Actions
                Set TempUnit = (Picked unit)
                Set TempPoint = (Position of TempUnit)
                Unit Group - Pick every unit in GoldUnitGroup and do (Actions)
                    Loop - Actions
                        Set TempUnit2 = (Picked unit)
                        Set TempPoint2 = (Position of (Picked unit))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Distance between TempPoint and TempPoint2) Less than or equal to 256.00
                                (Custom value of TempUnit2) Equal to 50
                            Then - Actions
                                ----- Your actions: Give Gold, maybe Floating Text above unit, whatever -----
                                Unit - Set the custom value of TempUnit2 to 100
                            Else - Actions
                        Custom script: call RemoveLocation (udg_TempPoint2)
                Custom script: call RemoveLocation (udg_TempPoint)

yea, think that one should work now! ;)
 
I

IKilledKEnny

Guest
Just a quick question before trying that Trigger.

Why did you do this condition:

Code:
(Custom value of TempUnit2) Equal to 50

And why this action:

Code:
Unit - Set the custom value of TempUnit2 to 100
 
S

Sunny_D

Guest
look in the description above:

every time a peasant would have gathered gold, then you set its custom value to 50 (or whatever other number, 50 was random)

if he delievered the gold, you set its custom value to any other number but 50 (i have choosen 100 because its the editor-standart) so you get gold only once. you can set the custom value to 50 again, if he gathered gold again. :)

note: in the sample map i made it - for testing issues - that you can set the custom value by a chat command ;)

oh forgot to enter the condition that its the same player... (just enter "Owner of TempUnit = Owner of TempUnit2" as condition right below (custom value equal to....) in the inner if-then-else ;)
 
I

IKilledKEnny

Guest
Ok I did a little testing and found out that the bolded line doesn't work.

Code:
Untitled Trigger 001
    Events
        [B]Unit - A unit Begins casting an ability[/B]
    Conditions
        (Ability being cast) Equal to Mine (Stone & Gold) 
    Actions
        Unit Group - Add (Triggering unit) to GathererGroup
        Game - Display to (All players) the text: done num1

The ability is just like harvest gold and lumber I just changed the name, what's wrong?
 
S

Sunny_D

Guest
well, as far as i know the gathering button triggers an order not an ability ;)

so i think you would need a trigger with issue-order... so... something like that below... but im not 100% sure though...


Code:
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Issued order) Equal to Harvest
    Actions

and btw: in case you want use that with my previous trigger... add the units to the unit group "Gatherer Group" when they are trained... and change the custom value to 50 when they have gold. :)
 
I

IKilledKEnny

Guest
Yup. :)

Now just to be sure 100% that I didn't manage to destroy everything again here is the new Trigger, tell me if it's good/bad :D

Code:
Untitled Trigger 001
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Ability being cast) Equal to Mine (Stone & Gold) 
    Actions
        Unit Group - Add (Triggering unit) to GathererGroup
        Game - Display to (All players) the text: done num1

lol it took 4 pages to get the answer ^^.
 
I

IKilledKEnny

Guest
Never mind, I'm stupid, it's not right, I can't find
Code:
(Issued order) Equal to Harvest
Is it in boleen or where?
 
I

IKilledKEnny

Guest
Oh ok thanks, but I guess this theard is going to be a little longer becuase, how do I define harvest? Didn't find anything about abilities there. So sorry about my being so 'newb'.
 
I

IKilledKEnny

Guest
Wow, just, WOW it still doesn't work!!

Code:
Untitled Trigger 001
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Unit-type of (Triggering unit)) Equal to Gatherer
    Actions
        Unit Group - Add (Triggering unit) to GathererGroup
        Unit - Set the custom value of (Triggering unit) to 1
        Game - Display to (All players) the text: done num1

Code:
Untitled Trigger 002
    Events
        Unit - A unit Finishes training a unit
    Conditions
        (Unit-type of (Trained unit)) Equal to Resources Wagon
    Actions
        Unit Group - Add (Trained unit) to ResourcesWagonGroup
        Game - Display to (All players) the text: done num2

Code:
Untitled Trigger 004
    Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in GathererGroup and do (Actions)
            Loop - Actions
                Set GoldUnit = (Picked unit)
                Set GathererPoint = (Position of GoldUnit)
                Unit Group - Pick every unit in ResourcesWagonGroup and do (Actions)
                    Loop - Actions
                        Set GoldUnit2 = (Picked unit)
                        Set ResourcesWagonPoint = (Position of GoldUnit2)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Distance between GathererPoint and ResourcesWagonPoint) Less than or equal to 75.00
                                (Custom value of GoldUnit) Equal to 1
                            Then - Actions
                                Game - Display to (All players) the text: done num3
                                Unit - Set the custom value of GoldUnit to 2
                                Custom script:   call RemoveLocation (udg_ResourcesWagonPoint)
                                Custom script:   call RemoveLocation (udg_GathererPoint)
                            Else - Actions

I give up.... Unless someone can tell me why it doesn't work....
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Custom script: call RemoveLocation (udg_GathererPoint)

This comes way too early.
It should happen once the inner loop is done.

And, what's the point of that custom value?
It's always 1 anyway.


Add an extra variable, of type player.
Set GoldPlayer = Owner of (Picked unit)
to be put near "Set GoldUnit =".

And replace the custom value test with
Owner of (GoldUnit2) equal to GoldPlayer


> Unit - A unit Is issued an order targeting an object

Are you actually giving it an order?
I thought it should happen just from walking nearby?

Also, 75 is not much of a distance...
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top