We are currently using the "stupid worker AI" trigger from BW which works as follows: As soon as a worker tries to harvest a mineral field, IF the field is occupied it will automatically try to find a new open field.
This makes workers less effective but makes over-saturation almost never max out.
In BroodWar however, it seemed that workers would not act this way if all mineral fields were being harvested as they tried to harvest. Then they would simply wait until the current harvester was done. This is what I want to try to add to a test map and see how the eco pans out. To be more spesific:
Can someone tell me how to make a trigger which does the following:
When a harvester tries to harvest and occupied mineral field it waits for its turn by that mineral field ONLY IF all the other mineral fields are being harvested the exact moment it is "checking" if the current field is open for harvest. It will move to another field by default if there is another mineral field open in our mod, so that trigger should not be needed.
Was that clear? I know absolutely nothing about triggers so the best for me is just to make a new map with only these triggers in them and send it to me so I can copy them over. You can use my email: [email protected]
The best way to learn is to try it yourself. I'm not entirely sure why you're having a problem though... I think the AI in SC2 already does what you're describing with workers. But, just in case it doesn't...
What you will need is the right combination of an event and conditional branches. I'm not entirely sure how harvesting works as an ability, but making an event which checks to see if the harvest ability has been activated by a unit might be a good place to start. Otherwise, you might have to use a loop, checking the current status of all workers in the map.
From there, your conditional branches (under actions) should check to see if <targeted mineral field is occupied>. If false, order the worker to harvest the target mineral field. If true, run another conditional branch, checking if all nearby mineral fields are occupied. If true, order the worker to harvest the target mineral field, if false, order the worker to harvest an unoccupied mineral field.
Allow me to elaborate on how SC2 mining works and what I want to try for Starbow.
SC2: The mining time for SC2 allows for "paring", but this is no more than mining when the field is open for it since one worker will be done by the time the second gets there. Now here is the important part (and I did some testing): If worker A is going to mine from a mineral field occupied by worker B, it will do one of two things. It will wait until worker B is done if worker be is soon done (I do not have the exact values but I think it is less than a second), OR it wil try to find an open mineral patch if worker B has more than that time left to mine.
What I want: I want workers to try another patch regardless of how much time worker B has left. (Which we already have implemented). But I also want to add that worker A stays by the patch if all the other patches are occupied at the moment it checks if the patch by worker B has been occupied. If that made any sense....
So this will be a trigger which overrides the trigger we already have if a certain condition is fulfilled.
Let me add some more here. And I really hope someone can help me.
We already have triggers in Starbow making workers automatically try to find a new patch if one is currently occupied. All that should be needed is to put that behaviour as part of an "if" loop.
If no other patches are open (not sure how to make that) then wait by the patch, else goto open patch.
You can look at the triggers by opening the "Starbow HoTS Final" map from the EU server at the editor. It's version 1.64 or so that is the latest.
Here is a quick mockup of something in Pseudocode. This is not REAL code, but if you translate it into code, it should work.
Workers will, when told to mine, check to see if a Mineral Patch is occupied by another worker (this is done by changing the mineral patch's custom value at position 0 to 1). SCVs will avoid using this mineral patch if it is already targeted by another SCV. Now, if there are no open patches, the SCV will just go with its original target.
The Trigger below is to reset the Custom Value of the mineral patch once it has been either Successfully mined, or mining has been canceled for whatever reason.
Trig 1, setting min patches to 0
Any unit uses gather at cancel stage
Any unit uses gather at complete stage
Triggering ability unit target is mineral field
Set triggering ability unit target custom value 0 to 0
Trig 2, setting min patches to 1
Any unit uses gather at harvest stage
Triggering ability unit target is mineral field
Set triggering ability unit target custom value 0 to 1
Now for the order trigger
Any unit uses gather at wait at resource stage
Any unit uses gather at approach resource stage
Unit - order (triggering unit) to (gather targettiing (random any unit from (units in (region(position of (triggering unit)), radius 10) owned by player any matching exluded: missile, dead hidden with at most any amount) with custom value 0 = 0))) (replace existing orders)
In theory this should get workers to try harvesting from a different mineral patch if that mineral patch is empty and the current one being harvested from is not.
Try to confirm that the custom value of the Mineral Patches is indeed 1 while an SCV is targeted on it, and 0 when no SCV is. I would do this by using SendActorMessageToUnit to the Minerals (to SetTintColor to a red) and removing the visual when the SCV's have ended mining on it (ClearTint). Or, you could run TextMessage to print out a message for visual feedback.
You may potentially have to add Any unit uses gather at execute stage to get the second trigger to fire.
Thanks! I'll try this.
If the problem is that the workers don't bounce, my initial thought is that patches are simply not properly gaining custom value 0 = 0 to signify they are open for business.
Hello!
I am helping work on the SC2 mod named Starbow. You can read more about it here: www.teamliquid.net/forum/viewmessage.php?topic_id=304955
We are currently using the "stupid worker AI" trigger from BW which works as follows: As soon as a worker tries to harvest a mineral field, IF the field is occupied it will automatically try to find a new open field.
This makes workers less effective but makes over-saturation almost never max out.
In BroodWar however, it seemed that workers would not act this way if all mineral fields were being harvested as they tried to harvest. Then they would simply wait until the current harvester was done. This is what I want to try to add to a test map and see how the eco pans out. To be more spesific:
Can someone tell me how to make a trigger which does the following:
When a harvester tries to harvest and occupied mineral field it waits for its turn by that mineral field ONLY IF all the other mineral fields are being harvested the exact moment it is "checking" if the current field is open for harvest. It will move to another field by default if there is another mineral field open in our mod, so that trigger should not be needed.
Was that clear? I know absolutely nothing about triggers so the best for me is just to make a new map with only these triggers in them and send it to me so I can copy them over. You can use my email: [email protected]
Cheers!
The best way to learn is to try it yourself. I'm not entirely sure why you're having a problem though... I think the AI in SC2 already does what you're describing with workers. But, just in case it doesn't...
What you will need is the right combination of an event and conditional branches. I'm not entirely sure how harvesting works as an ability, but making an event which checks to see if the harvest ability has been activated by a unit might be a good place to start. Otherwise, you might have to use a loop, checking the current status of all workers in the map.
From there, your conditional branches (under actions) should check to see if <targeted mineral field is occupied>. If false, order the worker to harvest the target mineral field. If true, run another conditional branch, checking if all nearby mineral fields are occupied. If true, order the worker to harvest the target mineral field, if false, order the worker to harvest an unoccupied mineral field.
That should get you started.
Allow me to elaborate on how SC2 mining works and what I want to try for Starbow.
SC2: The mining time for SC2 allows for "paring", but this is no more than mining when the field is open for it since one worker will be done by the time the second gets there. Now here is the important part (and I did some testing): If worker A is going to mine from a mineral field occupied by worker B, it will do one of two things. It will wait until worker B is done if worker be is soon done (I do not have the exact values but I think it is less than a second), OR it wil try to find an open mineral patch if worker B has more than that time left to mine.
What I want: I want workers to try another patch regardless of how much time worker B has left. (Which we already have implemented). But I also want to add that worker A stays by the patch if all the other patches are occupied at the moment it checks if the patch by worker B has been occupied. If that made any sense....
So this will be a trigger which overrides the trigger we already have if a certain condition is fulfilled.
Let me add some more here. And I really hope someone can help me.
We already have triggers in Starbow making workers automatically try to find a new patch if one is currently occupied. All that should be needed is to put that behaviour as part of an "if" loop.
If no other patches are open (not sure how to make that) then wait by the patch, else goto open patch.
You can look at the triggers by opening the "Starbow HoTS Final" map from the EU server at the editor. It's version 1.64 or so that is the latest.
Here is a quick mockup of something in Pseudocode. This is not REAL code, but if you translate it into code, it should work.
Workers will, when told to mine, check to see if a Mineral Patch is occupied by another worker (this is done by changing the mineral patch's custom value at position 0 to 1). SCVs will avoid using this mineral patch if it is already targeted by another SCV. Now, if there are no open patches, the SCV will just go with its original target.
The Trigger below is to reset the Custom Value of the mineral patch once it has been either Successfully mined, or mining has been canceled for whatever reason.
You will have to add some more to the code to get it to work flawlessly, but this is a good starting point.
Good Luck
Thanks a lot geru!
I'll have to look closer at it and learn some triggers....
If someone wants to translate this to actual triggers in a map I'd be very happy!
I'm having trouble getting it to work.
Here is the current setup.
Trig 1, setting min patches to 0 Any unit uses gather at cancel stage Any unit uses gather at complete stage
Triggering ability unit target is mineral field
Set triggering ability unit target custom value 0 to 0
Trig 2, setting min patches to 1 Any unit uses gather at harvest stage
Triggering ability unit target is mineral field
Set triggering ability unit target custom value 0 to 1
Now for the order trigger Any unit uses gather at wait at resource stage Any unit uses gather at approach resource stage
Unit - order (triggering unit) to (gather targettiing (random any unit from (units in (region(position of (triggering unit)), radius 10) owned by player any matching exluded: missile, dead hidden with at most any amount) with custom value 0 = 0))) (replace existing orders)
In theory this should get workers to try harvesting from a different mineral patch if that mineral patch is empty and the current one being harvested from is not.
It isn't bouncing workers though.
@decemberscalm: Go
Try to confirm that the custom value of the Mineral Patches is indeed 1 while an SCV is targeted on it, and 0 when no SCV is. I would do this by using SendActorMessageToUnit to the Minerals (to SetTintColor to a red) and removing the visual when the SCV's have ended mining on it (ClearTint). Or, you could run TextMessage to print out a message for visual feedback.
You may potentially have to add Any unit uses gather at execute stage to get the second trigger to fire.
Thanks! I'll try this. If the problem is that the workers don't bounce, my initial thought is that patches are simply not properly gaining custom value 0 = 0 to signify they are open for business.
Problem solved! Thanks for all the help!