Events:
Timer - every 5.0 seconds of Game Time (select "Periodic Event" for the event type) Conditions:
(Number of Living units in (Any units in (Mineral Region 1) owned by player 1 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) >= 1 Actions:
Player - modify player 1 Minerals: Add 10
Then, if you want more than one player to be able to get minerals, you'd need a separate trigger for each player.
You could just put a condition in which a region contains a certain unit, and the possessor of that unit receives the minerals. That's about it.
And of course, remove the entering unit event.
OK, try this: Instead of multiple regions, add more than one shape to the same region (they don't have to be touching)
Then use something like the trigger I posted above, but copy it for each player. A little harder, but more efficient, would be to have a "for each player" loop that checks to see if the player has a unit in the region and then adds minerals.
From the Looks of it, you are new to scripting. I suggest you go down to the resources section and check out the tutorials. There are a lot of good resources on this forum.
That being said... I am going to guess at a few clarifications, if they are wrong then my solution may not work... but from the sounds of it, you want to have a region in which, every 5 seconds of game time, the game checks to see if a player has a unit in it. This unit can be of any type and the player can have any number of units in it. If the player has at least one unit of any type within this region, they get a certain ammount of minerals. It does not matter if they have one or twenty units in the region, they get a fixed ammount of resources. Then you want to have multiple regions that behave like this. If the player has units in multiple of these regions, they then get the resources for each region they have a unit it, regardless of how many units are in each one... (i.e. a player has one unit in regionA, three units in regionC, and thirteen units in regionF, they would get three times the resources)
IF this is the case... You will need something as follows...
Global Variable(type: region, array): RegionArrayForResources (put ALL your regions in this variable array)
Global Variable(type: interger): TotalNumberOfRegionsMinusOne
Count: 1 NOTE: This can be Any Amount, I just set it to 1 to stop after we find at least 1 unit)
Opperator: >
Value: 0
Then:
Modify Player Property
Player: 1
Property: Minerals
Operation: Add
Value: 10
Now if you want this to work for multiple players, you need to add a "pick each player" loop between the For-Each and the If-Then-Else and change the player index to arithmetic: picked player - 1
If a lot of this doesn't make sense, I really suggest you go look at the tutorials. Solusions to problems like this can seem simple, and end up being quite convoluted. There might be a shorter "cheatier" way to do this, but it most likely will result in buggy behavior down the road.
Glad I could help :) do me a favor and edit the title of your thread with [Resolved] both so people know it's fixed, and so if people are looking for a solution they know one is here :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Okay I have most of the trigger set up, theres just one problem, I have to enter, leave and reenter in order to get the constant income.
Region 1
Events
Timer - Elapsed time is 5.0 Game Time seconds
Unit - Any Unit Enters Mineral Region 1
Local Variables
Conditions
Actions
Player - Modify player (Triggering player) Minerals: Add 10
Try this:
Events:
Timer - every 5.0 seconds of Game Time (select "Periodic Event" for the event type)
Conditions:
(Number of Living units in (Any units in (Mineral Region 1) owned by player 1 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) >= 1
Actions:
Player - modify player 1 Minerals: Add 10
Then, if you want more than one player to be able to get minerals, you'd need a separate trigger for each player.
You could just put a condition in which a region contains a certain unit, and the possessor of that unit receives the minerals. That's about it. And of course, remove the entering unit event.
Yes but I need this to work for multiple regions, and I need it to work for any unit they bring into it.
OK, try this: Instead of multiple regions, add more than one shape to the same region (they don't have to be touching)
Then use something like the trigger I posted above, but copy it for each player. A little harder, but more efficient, would be to have a "for each player" loop that checks to see if the player has a unit in the region and then adds minerals.
From the Looks of it, you are new to scripting. I suggest you go down to the resources section and check out the tutorials. There are a lot of good resources on this forum.
That being said... I am going to guess at a few clarifications, if they are wrong then my solution may not work... but from the sounds of it, you want to have a region in which, every 5 seconds of game time, the game checks to see if a player has a unit in it. This unit can be of any type and the player can have any number of units in it. If the player has at least one unit of any type within this region, they get a certain ammount of minerals. It does not matter if they have one or twenty units in the region, they get a fixed ammount of resources. Then you want to have multiple regions that behave like this. If the player has units in multiple of these regions, they then get the resources for each region they have a unit it, regardless of how many units are in each one... (i.e. a player has one unit in regionA, three units in regionC, and thirteen units in regionF, they would get three times the resources)
IF this is the case... You will need something as follows...
Global Variable(type: region, array): RegionArrayForResources (put ALL your regions in this variable array) Global Variable(type: interger): TotalNumberOfRegionsMinusOne
Trigger: GivePlayersResources
Now if you want this to work for multiple players, you need to add a "pick each player" loop between the For-Each and the If-Then-Else and change the player index to arithmetic: picked player - 1
If a lot of this doesn't make sense, I really suggest you go look at the tutorials. Solusions to problems like this can seem simple, and end up being quite convoluted. There might be a shorter "cheatier" way to do this, but it most likely will result in buggy behavior down the road.
Thanks! thats exactly what I wanted!
Oh and Yes I am new to Sc2 and Warcraft 3s scripting.
Glad I could help :) do me a favor and edit the title of your thread with [Resolved] both so people know it's fixed, and so if people are looking for a solution they know one is here :)