Event - Every 1.00 seconds of game time
Set TempGroup = all units in playable map
Pick all units in TempGroup
If unit is first type then
Set picked unit = U1
If unit is unit type of other type then
Set picked unit = U2
If owner of U1 is an enemy of U2 then
Set Loc1 = position of U1
Set Loc2 = position of U2
Set Distance from Loc1 to Loc2 = D
If D is less than 800 then
Set T = T+1
Else then
Set T = 0
If T = 60 then
Remove 60 gold from owner of U2
Add 60 gold to owner of U1
Set T = 0
RemoveLocations Loc1 and Loc2
Destroy Unit Group
Someone will certainly point out that this will only work if there is only one of each unit in the game. I didn't want to get into that first because it is a bit complex and I wanted to get you the basics of running a check once.
To account for multiple units of either type and possibly owned by multiple players you will need to index them. One way to do this might be with an integer array.
So you would create an integer variable (i). Then set i = i +1, so that we count ever time this function runs. Then Set Picked unit = U1
. That way we have all picked units of type 1 labeled with variables. Then do the same with i2. Set i2 = i2 + 1. Then Set U2[i2] = picked unit. Then you would need to check each integer i against each interger i2 for distance. We can do this by looping. You would use a loop functions command. So for each (integer A) from 0 to i do the following: For each integer B from 0 to i2 do the following. Then we do this part:
If owner of U1 is an enemy of U2 then
Set Loc1[Integer A] = position of U1[integer A]
Set Loc2[integer B] = position of U2[integer B]
Set Distance from Loc1[Integer A] to Loc2[integer B] = D
If D is less than 800 then
Now we know all units of type 1 in range with a unit of type 2
All that is left is counting to 60 for each set. We need a new index for this.
Let's call it 'm' for match. But we don't want to overwrite it each time.
We want a match to stay a match until the go more than the distance apart.
set m = (
Set T[m] = T[m] + 1
Else then
Set T[m] = 0
If T[m] = 60 then
Remove 60 gold from owner of U2[integer A]
Add 60 gold to owner of U1[integer B]
Set T[m] = 0
Remove Locations Loc1[integer A] and Loc2[integer B]
Destroy Unit Group
Nope I lost it. I can't think of how to index it exactly. I'm sorry. Someone can fill in the rest. This is the basic idea though.
Another way might be to use the event "A unit comes within 800 of a unit"
Then check for types. Then start the time. If it reaches 60 then swap the gold.
If the units get farther away than 800 turn off the timer and reset.
When I say timer, I mean a looping trigger dynamically indexed for time, not an actual timer.
Pick every unit in the map with condition that the picked unit is your unit type, i think that's possible.
It is possible but it creates a non-removable leak. Just pick all units and only do actions for picked units of type.