• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Lumber/mine harvest loop

Status
Not open for further replies.
Level 22
Joined
Nov 20, 2005
Messages
1,221
I need a trigger that, in sequence:

-Trains a peon(ok i can make it)
-Get him to chop onto a tree-region(ok again)
-After a tree-region has been depleted(by the peon), THAT specific peon harvesting it has to move to another specific tree-region
-If that peon gets killed, train another peon that follow the same region of where the previous peon was chopping.

And automatically(based on this trigger) another trigger with the same function with gold mines.
So, after a mine goes off, another mine must be selected for new harvest, and killed peons going to it must be retrained and go where the new mine is.
Thanks for the help.
 
Level 2
Joined
Jun 12, 2006
Messages
13
For the mine, you could try setting a variable to the mine you want. Then when it's done, you set it to another mine. When a peon dies, you create a new one and then issue order to mine at the variabled mine or something.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
Would this work as the trigger to train more peons when some die?
PeonGroup is a Unit Group type variable

View attachment 16927

Nah, i've set up an infinite loop of peasant training, limiting first the cpu's peasant training to a fixed number, so that automatically when a peasant dies, another one is immediately being trained.
So the matter would be to assign to the newly trained peasant the same job the previous one was doing.

Let me know for the tree trigger. That's the most important, for now.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
ok i got the idea(after so long). Sorry for the double post but i need to bring this thread back to the top so everyone can read that MAYBE the Memory Leak problem is over.
This is the trigger for new regions of trees to harvest, correct me if it's wrong. I should check for the memory leak also:

(wait, i'll copy triggers)

  • Event:
  • A destructibile within "FIRST TREE AREA" dies
  • Actions:
  • Set TREES +1
  • Event:
  • A destructibile within "SECOND TREE AREA" dies
  • Actions:
  • Set TREES2 +1
  • Event:
  • A destructibile within "THIRD TREE AREA" dies
  • Actions:
  • Set TREES3 +1
  • Event:
  • Mine X is dead
  • Actions:
  • Set Newmine = +1
(These up above are triggers to count the number of trees chopped down so that at certain quantity a new variable will be set and chopper peons will automatically go to the new trees region)

So:

  • Event:
  • TREES = 21
  • Actions:
  • wait 0.10 seconds
  • Unit group - pick every unit in "choppers" and do(unit - order picked unit to chop(random destructibile in SECOND TREE AREA)
  • Set TREEREGION +1(this will come in use later, when a "chopper" dies)
  • Event:
  • TREES2 = 63
  • Actions:
  • wait 0.10 seconds
  • Unit group - pick every unit in "choppers" and do(unit - order picked unit to chop(random destructibile in THIRD TREE AREA)
  • Set TREEREGION +1(this will come in use later, when a "chopper" dies)
  • Event:
  • TREES3 = 28
  • Actions:
  • wait 0.10 seconds
  • Unit group - pick every unit in "choppers" and do(unit - order picked unit to chop(random destructibile in FOURTH TREE AREA)
  • Set TREEREGION +1(this will come in use later, when a "chopper" dies)
Now, retraining triggers:

  • Event:
  • A unit is dead
  • Conditions:
  • unit type of triggering unit = to Peon
  • triggering unit = random unit from "miners"
  • Owner of triggering unit is P2
  • Actions:
  • wait 1.00 seconds
  • unit group - order units of type "Town hall" to build a peon
  • wait 15.00 seconds(training time)
  • unit group - add trained unit to "miners"
  • wait 0.50 game seconds
  • if newmine = 0 then do Unit order trained unit to chop mine x else do if newmine = 1 then do unit order trained unit to chop mine y else do nothing
  • Event:
  • A unit is dead
  • Conditions:
  • unit type of triggering unit = to Peon
  • triggering unit = random unit from "choppers"
  • Owner of triggering unit is P2
  • Actions:
  • wait 1.00 seconds
  • unit group - order units of type "Town hall" to build a peon
  • wait 15.00 seconds(training time)
  • unit group - add trained unit to "choppers"
  • wait 0.50 game seconds
  • if TREEREGION = 1 then do Unit order trained unit to chop random destructibile in FIRST TREE AREA else do if TREEREGION = 2
    • then do unit order trained unit to chop random destructibile in SECOND TREE AREA else do if TREEREGION = 3
  • then do Unit order trained unit to chop random destructibile in THIRD TREE AREA else do if TREEREGION = 4
    • then do Unit order trained unit to chop random destructibile in FOURTH TREE AREA else do nothing

These are triggers used for the loop chopping in new tree areas. Are them right?? Let me know, PEONS DOES NOT RESPOND WHEN THE FIRST TREE REGION IS DEPLETED!

updated, look above.
 
Last edited by a moderator:
Level 22
Joined
Nov 20, 2005
Messages
1,221
mmm it works now but it still leaks.
Do i have to put that code EVERY TIME is shown below "unit group", or just when i do

  • Event:
  • TREES = 21
  • Actions:
  • wait 0.10 seconds
  • Custom script blablabla
  • Unit group - pick every unit in "choppers" and do(unit - order picked unit to chop(random destructibile in SECOND TREE AREA)
  • Set TREEREGION +1
Like this, right?

But if i do(because i DID):

  • Event:
  • Conditions:
  • Actions:
  • Unit group - Add "peon1" to "choppers"
  • Unit group - Add "peon2" to "miners"
  • Unit group - Order "Town hall" to train peon
  • comment: and so on...various references
Then? :( , where does the code need to be put, if there are so many references to unit group?
 
Level 11
Joined
Aug 25, 2006
Messages
971
What are you guys talking about? You should only set that variable if you want all units the group to be erased. If hes using a global variable then it only leaks if he stops using the global variable and never uses it again. So in short, the code does not leak.

Keep your code the way it was.

You need it when: You create a unit group and then want to create a new group or your never going to use the previous group again.

Will when do you 'create' a group?
Whenever you use the 'pick all units in' it creates a group. When you add a unit to the group it does not create a new group unless there is no group in existence yet.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
What are you guys talking about? You should only set that variable if you want all units the group to be erased. If hes using a global variable then it only leaks if he stops using the global variable and never uses it again. So in short, the code does not leak.

Keep your code the way it was.

You need it when: You create a unit group and then want to create a new group or your never going to use the previous group again.

Will when do you 'create' a group?
Whenever you use the 'pick all units in' it creates a group. When you add a unit to the group it does not create a new group unless there is no group in existence yet.


I know aren't "unit group" triggers that leak. It's just something i changed once, and "bum" it leaks! But now i can't find where is the leak problem. There are so many triggers in my map i feel lost now if i'm going to search.
At least i have a backup copy of it.
I know i should not do it, but maybe if i post the map someone could find the leak for me, and fix it.
Tell me what to do.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Leaks don't cause freezes, unless your leaks are SUPER massive! Messed up triggering causes freezes. I'll look into it presently.

Ok found the problem.
What the #*@^ is this?
  • selection swindle
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • Selection - Remove (Random unit from (Random ((Number of units in (Units currently selected by Player 1 (Red))) - 4) units from (Units currently selected by Player 1 (Red)))) from selection for Player 1 (Red)
Its under the category "Exclusive stuff of Warcraft"

Delete/disable that trigger and it works fine.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
lol, ye, maybe was really that :O
let's see, "THIS PROJECT" i'm working on FORCE the player to select only 4 units at once. It seems however, that you can always select more than 4 units before the trigger auto-deselect. This may cause clewer players to fast select and fast "area-attack" whole groups of units.
the initial time was "every 0.10" but i turned it to 0.00 hoping that it will be more faster in deselecting than before.
I remember i set it, but i've completely forgot it. XD Thanks for the point.
Have you noticed that every time you train a peon, the peon goes toward enemy base? Why? This was something inside "AI del livello corrente"(something mistaken in "create FTM or ARC" maybe) certainly, where enemy SOLDIERS have to get to location in order to gather for strikes. I haven't found a way to fix that, though. :(

EDIT(tried the map with seconds fixage): ahhhhhh :D it's fine now. You got rep, wd4!
 
Last edited:
Level 22
Joined
Nov 20, 2005
Messages
1,221
lol, it was for me a timing to deselect units right in time before the player can imput the command! Ok, i've already fixed it at 0.05 cuz i saw a little little bit of leak after i've set it to 0.01. Now it should work fine.
However, i think that the main priority now it's to stay focused on that DAMNED tree-region trigger.
As you see, in "Ai del livello corrente" there are various trigger named "integer TREE" etc. and "FIRST TREE AREA DOWN" and so on.
Those trigger have to manage the AI peasant work on resources. I've marked various tree areas around their village, and their chopping order. See if it's right. If not, fix it: It's the main topic. :p
 
Level 11
Joined
Aug 25, 2006
Messages
971
Sorry, I haven't got a lot of time right at this moment. But I found that at least two triggers are screwing up. I got this with war3err. (About 20 seconds into the game, I pressed escape at beginning)

Check out the variable it mentions. Freeing a group is great, but freeing it twice is bad (possible thread crash) Of course if after you freed it you made another group and stored it in the same variable, its ok to free it again. But it apparently you freed a unit group twice without making a new one.
 

Attachments

  • WC3ScrnShot_112907_061711_01.jpg
    WC3ScrnShot_112907_061711_01.jpg
    118.8 KB · Views: 67
Level 22
Joined
Nov 20, 2005
Messages
1,221
Check out the variable it mentions. Freeing a group is great, but freeing it twice is bad (possible thread crash) Of course if after you freed it you made another group and stored it in the same variable, its ok to free it again. But it apparently you freed a unit group twice without making a new one.

I can't understand this part. O_O
I'll check out that variable.

EDIT: maybe i found why newly trained peons or enemy peasants go to the upper right and bottom left corner.
It's a trigger to make other kind of unit move to those locations:

  • Events:
  • A unit enters (entire map)
  • Conditions:
  • Or - Any (conditions) are true <<-----------------
  • - Owner of triggering unit = P2
  • - Unit type of triggering unit = ######
  • - Var1 = FALSE
  • - Var2 = FALSE
  • Actions:
  • If random integer between 1 and 2 = 1 then do order entering unit to attack - go "regionx" else if random integer between 1 and 2 = 2 then do
  • order entering unit to attack - go "regiony"
As we see, only by training units, that type of unit go in issued locations, because the function "Or - any (conditions) are true" take notice of the Var1 and Var2, both false at the beginning.

EDIT:
Ok, there was another small problem again but is fixed.
Under the triggers "make cleric NORTH(and SOUTH) move only" change the voices in conditions and actions from "entering" to "triggering".
Keep focusing on the loop trigger now!
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
I'm a bit lost, what loop trigger?
Tell me the following:
Where is it?
Whats it supposed to do?
What is it doing?

Do you mean the trigger for the selection thing?
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
Forgive me, i thought it was a routine now:
The loop trigger is what the main topic talks about: Lumber/mine harvest loop.
It's not a single trigger, but a chain of triggers that must act one after another so that the whole thing can work.
Is located under "IA del livello corrente" on voices "Integer TREE/TREE2/TREE3" these are variables set up to check if tree areas are still alive: i've counted every tree in each area and fixed a number so that when a certain number of dead destructibiles is reached, another tree region start from being chopped by AI peasant.
"Integer MINE" does the same but for gold mines that AI harvest.
"FIRST/SECOND/THIRD AREA DOWN" are triggers that SHOULD(because they don't work, and that's why i need your help) issue AI peasants to get to new tree areas.
Then, at last, the most important triggers(still following to the previous ones):
Under "AI build/repair/harvest management" folder you find:
"Loop create miners" & "loop create choppers"
These triggers give the AI town hall the command to TRAIN other peasants when one(from "choppers" or "miners" unit groups) dies.
The gui script then has to send these peasants where the PREVIOUS one of the same u.group was working(so i call it "loop")
I mean, if the dying peasant(choppers) was in tree region 2, then the new recruited one must go to chop trees in trees region 2. If the dying peasant(miners) was harvesting mine #2, then the new recruited one must go to harvest mine #2. It's clear now? :)
 
Level 11
Joined
Aug 25, 2006
Messages
971
Crystal. Unfortunitly I have to catch the bus in about 5 minutes so I can't do it this morning. I will do it when I get home. (I will be late) Oh, can you post the newest version of the map? Because if you've found any other glitches it would be nice for me to have those fixes so I don't spend time on things you already found.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
you got it all right. :)

here's the UPDATED version ^^

P.S. The better way to solve the problem(at my advice) is to create a separate map and test any trigger concerning this topic in there, with a more simple detail(e.g. paste four clouds of trees, with a central town hall and 1 peasant). Else do as you wish. :)
 

Attachments

  • TerzoOrchi.w3x
    419.4 KB · Views: 32
Level 11
Joined
Aug 25, 2006
Messages
971
Ok I solved the lumber. Besides fixing it I made two modifications you may want to remove. The first was I set the goldmine to only have 200 gold. And I made trees have only 1 hp. This is so I could rapidly test the effects of my modifications. I only tested the first 3 tree areas. (Remember to make back ups of your map!)
 

Attachments

  • TerzoOrchi.w3x
    418.8 KB · Views: 32
Level 22
Joined
Nov 20, 2005
Messages
1,221
Good, i'll test it later. You got a PM. ;)

EDIT: I now tried it outside the campaign editor: trees trigg it's ok, but the "mine" one is not working: the mine blows up and peasants stay there.
Besides, i have an idea. Since the choppers tends to go in the rear of the 2nd region, make him chop in the front part first, or at least tell me how to do it. I could make that peasant chop in front first. Then, if and when he possibly dies, the new recruited one shall go to "random destructibile in region". I think i can make it by myself. I'll post later the adjusted trigger. So let me know when you fix the trigger about the mine.

EDIT2: I've set up regions where peasant has to chop first, now it's ok. I could set the same script you used for trees peasant to miners, so that i can fix the other trigger too. I'll let you know.
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
Today I'm extremely busy. I doubt I'll find the time I need to fix the gold mine triggers today. If I do it won't be for at least 6 or 7 hours. Let me know if you get what you want out of the lumber. I'll help you as soon as I can.

PS. The snow is funny.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
The lumber is OK. I'm trying to fix the mine one but the BEST i have is only 1 peasant from unit group "miners" go to the next mine, the other ones, in every case i give them "add ordered unit(cuz i make AI ORDER them to harvest), trained unit(because their Townh trains them) to "miners"" don't go!!!!
I EVEN created a region where peasants took place right after being trained from the TH and thus adding entering units(in that region) of type Peasant to "miners" but nothing again! Help me :_(((((((
 
Level 11
Joined
Aug 25, 2006
Messages
971
Ok here we go. This is better, but not super good. Try it out and tell me what you think. It works.. mostly. I'm really not very good at AI. Did i mention my mom knows Italian? Crazy coincidence.
 

Attachments

  • TerzoOrchi.w3x
    422.9 KB · Views: 45
Level 22
Joined
Nov 20, 2005
Messages
1,221
hey you were wrong with something telling me inside trigger: AI hasn't to build town halls away; the max they can have is their own one and if it's destroyed they'll rebuild it.
I find confusing your trigger system, but i have one last idea to make everything work properly. I'll let you know, stay tuned. :p

EDIT: The last idea doesn't work, but lol i have a further INSANE idea: i'm a madman, sorry :p Maybe this time it'll work.

P.S. If you want to know more about the whole project i'm building(this map is only a part of it), you can contact me via msn telling me first a password i'll write you on to a PM i'm sending to you now, so that i'm sure it's you.
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
I don't understand what I did that was so confusing? I took the one that already existed and modified it slightly. Then I made another trigger to update the unitgroup. What don't you understand? I'll explain it.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
trigger that force the construction of a new town hall.
However i can't mindly connect at the moment all of those changement you did.
But hey i have to test this insane idea. Stay tuned for a while.....

EDIT: YEEEEEEEESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS!!!!!!!!!!!!!!! IT WORRRRRRRRKKKKKSSSSSSSSSSSSSSSSSSSSSSS!!!!

ehm, maybe before singing victory i should test peasant respawn, even if i think that is over now. Then i'll tell in what consists this MANIAC idea!
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
I hope you read the comments I left you about the peasent respawns! Its important...
I'm glad you got it to work, but I don't see what was wrong with the way I did it. I even based it 80% off of what you already had.
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
i made a more efficent way. Listen to this and you'll get crazy :D
Under the Campaign editor i've COPIED the "peasant" unit, and gave it a "editor tooltip" or whatever you call it, "gold" so that i see it "Peasant (gold)". Then i did the same with the copied unit, so "Peasant (lumber)". By replacing the chopper peasant with the peasant (lumber) i could easily assign command to him and Peasant (gold) ones. The most efficent way without leaks! ^^ isn't it? What do you think about?
 
Level 11
Joined
Aug 25, 2006
Messages
971
Will not really... When you refered to the unitgroup variable it was great. Now that your refering to Unit group Units of type(Peasant(gold)) it leaks. It leaks bad. Only variables don't leak.

However don't give up yet! Even though I'm pretty sure the way I did it had it covered your method can still work!
Still use the variable. Make a trigger that (1) Destroys the unit group in the variable. (2) Repicks all units of that type and puts them into the variable.

Also constantly replacing peasants with different types is rather inefficient. Another thing; I'm pretty sure the ability 'Call to Arms' of higher level town halls won't work on non-original peasants unless you make one version of it for each type of peasant.

The way my trigger worked was when a unit was ordered to do anything to a goldmine, the unit was a peasant, and it was owned by the computer player; the trigger would add that unit to the gold miner group.

*I hope I didn't shoot down your idea*
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
Also constantly replacing peasants with different types is rather inefficient. Another thing; I'm pretty sure the ability 'Call to Arms' of higher level town halls won't work on non-original peasants unless you make one version of it for each type of peasant.

It's unnecessary: "call to arms" is not enabled. ^^

I'll let you know if leaks. It doesnt' leak for the first time i tried the way.

EDIT: ........................doesn't work for the respawn -_- but WAIT UP :p i forgot to set a specific triggers for unit ENTERING the map. I'll tell results briefly.

EDIT2: it doesn't work neither -_- but i have a last trumpcard.

EDIT3: wait up wait up! a disattention in a "condition" string.............ok, it works fine now. But choppers don't respawn: maybe something is wrong there also. I'll check it........

EDIT4: aaaahhhh :D everything is OK!! huu :p it was though, but at the end i made it! ^^

I've built a trigger that sends peasants of any type to their assigned areas, by detecting first unit "entering entire map" of the specified type. On another side, i removed a couple of actions under a trigger that detected if a certain type of peasant died, then recruit the same unit type. This wasn't working because in the same trigger another action had to send newly trained peasant to locations used by the killed one. So i removed this last action an built the trigger "unit entering entire map". It wasn't working with the chopper peasant when i said "maybe something is wrong" because in the "custom data" section i didn't set the human town hall to be able of training "Peasant (lumber)" :p so, voila!
I tried many times to kill peasant working on to mine or peasant working on to lumber: everyone is trained again and get to his previous activity. So everything is clear and does NOT leak at all! ^^
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
Gj. I'm glad you sorted all that out. Have fun and good luck in your further ventures! I'll try to be an active member of these forums until SC2 comes out. So if you need me you know where I am, lol.
 
Status
Not open for further replies.
Top