Sorry to bother you guys, but I've been kind of stumped on this one. What I want my trigger to do exactly is generate 3 minerals every 5 seconds to player X so long as he is the only player in region Y. If multiple players are in the region no one is awarded minerals, and If' you lose control of the hill, your minerals stop increasing.
I've tried several attempts at mimicing triggers in the wiki but none seem to fit properly.
Thanks in advance
check is your region correct, unit type, are player groups correctly set (meaning are players in them) and are those towers really change the owner and most important is your event firing
Make sure you have an appropriate event for your trigger. Alternatively, you can cause the trigger to run on a loop and execute it from another trigger.
don't want to criticize as is correct in a way but if i know there's no more to do and target condition of given task fails at some point "Skip remaining actions" is good way to skip unnecessary processing. You should at least use break statement although i'm not sure how it behaves nested inside 'repeat forever'
Think of theoretical situation in this case where you have 5000 units. It would still run even when it's already known it won't do anything after for example unit number 3
Thanks for your criticisms (I mean it.) You're right, there should be a break in there to keep it from checking every unit in the region once it's determined that more than 1 player own a unit there. I've used nested breaks before and they work just fine.
It's probably more efficient to use a repeating loop rather than firing the actions using events though because of how SC2 processes events. If you have too many events firing at once there is a noticeable drop in performance, but if you have several threads running at once the performance drop is negligible. Of course, if you have a ridiculous number of threads running then it might not be better, though in most cases that will never happen.
EDIT: I've modified the trigger to include the break.
hey im also looking to do pretty much exactly the same thing but i dont understand they way in which the actions have been written here with 'if' 'when' and 'then' etc. i also dont have any player groups...i dont think
what i want should hopefully be less complex, i currently have it so that when a player occupies the region, they are given 2 mins every second for each unit that is there so it looks like this:
Events:
Unit - Any Unit Enters Region 001
Actions:
v General - Repeat (Actions) forever
v Actions:
General - Wait 1.0 Game Time seconds
Player - Modify player (Owner of (Triggering unit)) Minerals: add 2
problem is this means when a player enters the region and leaves, its still adding minerals until the other player takes over, i was hoping it would be possible to have:
Repeat Until - Player leaves region
but i seem to be out of luck on that one as far as i can see, any help would be fantastic
Your lazy ;/ Here you have 2 very efficient neat done for you functions and yet you say you don't get it, because you didn't even read it.
No one mentioned any player groups here
This can't be less complex. Its very simple already
you create unit group containing any units in YOUR REGION (its even in caps)
in case of BasharTeg's solution you create Boolean variable initially set to "True" which is like "Yes" which later in code checks to add minerals
you check is created group not empty
if it's not empty, means there are some units in it, you save owner of first unit from this group to 'p' as "PLAYER" (first because it doesn't matter, and if there are more than 1 its still ok. In any case unit number 1 will be always there if group is not empty)
you check if any of the other units in this group belong to other player than player 'p', meaning there are 2 or more units which are not of the same player
if yes, there are 2 units of different player you skip the rest, or as in case of BasharTeg's solution, you set your Boolean variable to "False" which is like "No"
At this point, if it's not skipped, you add minerals to the player 'p' you saved before because it turns out only his units are in region, and if your Boolean variable is "False" you do nothing. No minerals, no more code to run.
im not being lazy (maybe my code was but as i dont really know what im doing yet thats probably why) and i did read it, as i said im new to this so i dont have the knowledge to just read those lines of code and instantly know exactly how to create them.
i have managed to copy the code now but as endorphyne1 said, it doesnt seem to be doing anything, which is why i said about not having player groups, incase that was what was stopping it work
Sorry to bother you guys, but I've been kind of stumped on this one. What I want my trigger to do exactly is generate 3 minerals every 5 seconds to player X so long as he is the only player in region Y. If multiple players are in the region no one is awarded minerals, and If' you lose control of the hill, your minerals stop increasing.
I've tried several attempts at mimicing triggers in the wiki but none seem to fit properly. Thanks in advance
Note that modify minerals is below pick each unit, not inside
I copied your trigger exactly as shown and still nothing happens. >.<
Not sure if there's more I need to write or if I missed something
check is your region correct, unit type, are player groups correctly set (meaning are players in them) and are those towers really change the owner and most important is your event firing
Really small room for errors here
Make sure you have an appropriate event for your trigger. Alternatively, you can cause the trigger to run on a loop and execute it from another trigger.
Here's how I would run the trigger:
don't want to criticize as is correct in a way but if i know there's no more to do and target condition of given task fails at some point "Skip remaining actions" is good way to skip unnecessary processing. You should at least use break statement although i'm not sure how it behaves nested inside 'repeat forever'
Think of theoretical situation in this case where you have 5000 units. It would still run even when it's already known it won't do anything after for example unit number 3
@Nerfpl: Go
Thanks for your criticisms (I mean it.) You're right, there should be a break in there to keep it from checking every unit in the region once it's determined that more than 1 player own a unit there. I've used nested breaks before and they work just fine.
It's probably more efficient to use a repeating loop rather than firing the actions using events though because of how SC2 processes events. If you have too many events firing at once there is a noticeable drop in performance, but if you have several threads running at once the performance drop is negligible. Of course, if you have a ridiculous number of threads running then it might not be better, though in most cases that will never happen.
EDIT: I've modified the trigger to include the break.
hey im also looking to do pretty much exactly the same thing but i dont understand they way in which the actions have been written here with 'if' 'when' and 'then' etc. i also dont have any player groups...i dont think
what i want should hopefully be less complex, i currently have it so that when a player occupies the region, they are given 2 mins every second for each unit that is there so it looks like this:
Events: Unit - Any Unit Enters Region 001
Actions: v General - Repeat (Actions) forever v Actions: General - Wait 1.0 Game Time seconds Player - Modify player (Owner of (Triggering unit)) Minerals: add 2
problem is this means when a player enters the region and leaves, its still adding minerals until the other player takes over, i was hoping it would be possible to have: Repeat Until - Player leaves region
but i seem to be out of luck on that one as far as i can see, any help would be fantastic
thanks
Your lazy ;/ Here you have 2 very efficient neat done for you functions and yet you say you don't get it, because you didn't even read it.
im not being lazy (maybe my code was but as i dont really know what im doing yet thats probably why) and i did read it, as i said im new to this so i dont have the knowledge to just read those lines of code and instantly know exactly how to create them.
i have managed to copy the code now but as endorphyne1 said, it doesnt seem to be doing anything, which is why i said about not having player groups, incase that was what was stopping it work
damn those avatars ! ^^
check the map and don't tell me it won't work