I need to make an income system via trigger editor (Not the data editor).
I want to do a trigger that activate every 30 sec game time.
It will look for each player how many building they have and give + 10 mineral for every building they have.
For example, timer expire. Player one have 4 supply depot, he then get + 40 mineral. Etc.
I've tried several way to do this, and checked on the forums for similar post, but I am not able to make my trigger work.
I would like to have some help from someone that is good with trigger, but in a form of tutorial or at least an image of how the trigger would look like.
Hey! Thanks for the reply, I did it and it worked.
But now I have a new problem that I will explain.
There are some building in the map that a player unit can "cap" . "Capping" require the unit to stay near the building (attached to a region) for 10 sec. After 10 sec, the building will become to the player.
I've made a trigger to do this function and it work in some way. When one of my unit enter the region of the building, i now own him.
But, my problem is that even if I specified a timer for the capping duration, it do not work. And I also want to do that if there is already some units on the region, the "capping" phase can't begin until no unit are attached to the region.
Do you understand my problem? And can someone help me find out a way to resolve this problem?
I think the basic of the trigger would be something like:
Event - Any unit enter region 01 (there is a supply depot on the region that is controlled by a neutral player)
Action - Change ownership of supply depot to player 1
I think that I need to put a "If then Else" condition that specify two things: If 10 sec elapsed, give supply depot to the triggering player. Also, I need to put that If there is some hostile units on the region, the trigger can't activate or is in a pause state.
Starting Cap: Here's how I would do this. Create 1 global boolean variable for each building that can be "capped". This variable will be false if no units are capping the building and true if they are. The trigger that fires when a player enters the building's region will have a condition that the boolean variable associated with this building be false.
Capping Timer: I don't use the built-in timer functions. My recommendation is to use a real variable and call it something like "timer". Set the real variable to the time required to cap. Use a while loop with the condition that the timer be greater than 0 and, in the loop wait, then decrease the timer variable by however long you waited. That's just the timer part. Someone wrote a great guide to using waits, check it out here: "Waits in SC2 - oddities and solutions"
Now you'll need to check to make sure that the player that started capping the building is still in the region. That's easy enough - just use the "Unit In Region" function to check that the player is still in the region. What if the player leaves the building region? Now you need some way to tell the while loop that it should stop because the building was not capped. Use another boolean variable (private). Set it to false if the player leaves the region and, in the condition for your while loop, add a condition that this boolean variable be true. So the condition will be that timer is greater than 0 and boolean variable ("continueCap" ??) be true.
You still need to check if an enemy player has interrupted the cap. You can make use of the same boolean variable to tell the while loop to stop the timer. To check to see if an enemy player has interrupted the cap, use a private unit group variable. After you check to make sure the capping player is still in the region, set the unit group variable to units in region with alliance to player. You can make this as simple or complicated as you want, but the simplest way would be to set the unit group to look for units in the cap region with enemy alliance to the capping player with max amount 1. If the size of the unit group variable, the number of units it found, is more than 0, stop the timer because someone interrupted the cap.
Yup, that works. I can't think of an easily explainable way of consolidating it down to a few triggers/variables in order to scale it up when there are a lot of capping points though.
I've setup a system (for a map I help with) that has 3 capture points, which is why I was able to help here. I use an array of size 3 for each of these points and the variable type is a record that contains a handful of dialog / dialog items and variables. I prefer to create dialogs at map start and just show/hide them instead of dynamically creating them, but I suppose it all depends on the need.
For a lot of capture points, off the top of my head, I would say just do what I am doing and increase the array size. It would be possible to do all this for virtually any number of capture points, even if they changed locations and/or quantity on a game-by-game basis. Thank you for your picture, BTW, aZergBaneling. I was too lazy X_X
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey,
I need to make an income system via trigger editor (Not the data editor).
I want to do a trigger that activate every 30 sec game time.
It will look for each player how many building they have and give + 10 mineral for every building they have.
For example, timer expire. Player one have 4 supply depot, he then get + 40 mineral. Etc.
I've tried several way to do this, and checked on the forums for similar post, but I am not able to make my trigger work.
I would like to have some help from someone that is good with trigger, but in a form of tutorial or at least an image of how the trigger would look like.
Thank you very much!
10 minerals per structure every 30 seconds.
Custom Campaign Initiative | Mapster Community Project: Data Wizards
Starcraft II: Unsung Rebels, a custom campaign for Starcraft II
SC2Saver, a way to create saved games via trigger
Frustrated with the editor and would like answers in real time? Join the SC2Mapster Discord!
Hey! Thanks for the reply, I did it and it worked.
But now I have a new problem that I will explain.
There are some building in the map that a player unit can "cap" . "Capping" require the unit to stay near the building (attached to a region) for 10 sec. After 10 sec, the building will become to the player.
I've made a trigger to do this function and it work in some way. When one of my unit enter the region of the building, i now own him.
But, my problem is that even if I specified a timer for the capping duration, it do not work. And I also want to do that if there is already some units on the region, the "capping" phase can't begin until no unit are attached to the region.
Do you understand my problem? And can someone help me find out a way to resolve this problem?
I think the basic of the trigger would be something like:
Event - Any unit enter region 01 (there is a supply depot on the region that is controlled by a neutral player)
Action - Change ownership of supply depot to player 1
I think that I need to put a "If then Else" condition that specify two things: If 10 sec elapsed, give supply depot to the triggering player. Also, I need to put that If there is some hostile units on the region, the trigger can't activate or is in a pause state.
Anyways, I need help !
In reply to Reason:
Now you'll need to check to make sure that the player that started capping the building is still in the region. That's easy enough - just use the "Unit In Region" function to check that the player is still in the region. What if the player leaves the building region? Now you need some way to tell the while loop that it should stop because the building was not capped. Use another boolean variable (private). Set it to false if the player leaves the region and, in the condition for your while loop, add a condition that this boolean variable be true. So the condition will be that timer is greater than 0 and boolean variable ("continueCap" ??) be true.
You still need to check if an enemy player has interrupted the cap. You can make use of the same boolean variable to tell the while loop to stop the timer. To check to see if an enemy player has interrupted the cap, use a private unit group variable. After you check to make sure the capping player is still in the region, set the unit group variable to units in region with alliance to player. You can make this as simple or complicated as you want, but the simplest way would be to set the unit group to look for units in the cap region with enemy alliance to the capping player with max amount 1. If the size of the unit group variable, the number of units it found, is more than 0, stop the timer because someone interrupted the cap.
In reply to MacMagnus:
Custom Campaign Initiative | Mapster Community Project: Data Wizards
Starcraft II: Unsung Rebels, a custom campaign for Starcraft II
SC2Saver, a way to create saved games via trigger
Frustrated with the editor and would like answers in real time? Join the SC2Mapster Discord!
Wow, Thank you for the answer man !
I will try that soon and give a feedback :)
In reply to aZergBaneling: