I'm having a problem where when your unit dies, it creates a new one right away. It does this for 4 players. It works sometimes, then at other times the trigger will start creating units for you even when your current one is alive. I set it up like this:
I think it might be your condition in the first trigger. Instead of what you have, make the condition "owner of triggering unit == 1". Do that in an If then else for each player.
The problem is that your second trigger, once activated, keeps running every 0.5 seconds, without any conditions. Remove the Event: Timer - Every 0.5 seconds of Game Time from your second trigger, so it only gets activated from the first.
@Pinworm45 & xenrathe: I tried both your ways but it was still spawning units even when you had one already.
@Vicboy: Your way worked, its just that I have no idea how or why it works. Can you explain the logic behind it please? But 1 thing I noticed was that you assigned the Hero variable to already placed units on the map. In mine there are no units previously placed, so I will be unable to do that.
Ah, are you new with triggering? A person coming from WC3 would have known these things.
I didn't use any advanced actions, events or variables. I just added a few simple actions and smart tricks that makes it shorter.
Anyways, here's a guide to that damn trigger. These things you learn can be applied to other triggers.
Variables:
Temporary Integer = Temporary because it should only be used for instant instances. (The ones where it isn't waited to be used) Random Integer = Sets it to 1-4. Absolutely random, and patterns are just coincidence.
Hero[x] = Sets it to the Last Created Unit. x = Player Number. So Hero[1] is the sole unit of Player 1.
Random Unit Type[x] = This is where you set the unit types. Like set Random Unit Type[2] to Zergling. x = Unit types. 1 = Zealot; 2 = Zergling and etc. I suggest you stay with that order.
Zealot, Zergling, Marine, Stalker[x][y] = A boolean (T/F). It's pretty much like your original Zealot, Zergling etc., booleans but compressed into 4 arrays. (Arrays are used to put multiple values into one variable) x = This is where the player number is. y = Unit types and if they're true or false.
For example:
Player 2 is spawned into a Zergling
Zergling is the 2nd word of the variable "Zealot, Zergling, Marine, Stalker[x][y]"
This means that it will set the variable "Temporary Integer" into 1, and then you do the actions below, then after that is completed, it sets the variable into 2, and then uses that number again on the actions below.
If = If the conditions are all positive, then it will do the actions in Then.
Then = The actions inside this only occurs when If is all positive.
Else = The actions inside this only occurs when at least one of the conditions in If is negative.
IF
(Triggeringunit)==Hero[TemporaryInteger]
In other words, this condition is used up 4 times in the run of the trigger.
If, let's say, Hero[4] is TRUE while the others are FALSE, then number 4 is carried over to the THEN actions. It will be known as (Temporary Integer) through the run of the THEN actions.
Sets the variable "Random Integer" to a random number from 1 to 4. This is required. You are setting a variable into one of those 4 numbers. Once this action is completed (the set variable action) then you'll have one non-random value from 4 numbers. Example, the "Random Integer" sets its value into 3. In the whole trigger, the number 3 will be used. NOT a random integer from 1 to 4.
In the Trigger, "Set Variables", you'll notice I had set some of the variables. This is required because there is no other time that these variables will be set into a value, other than in that Trigger.
Okay, so you've placed Unit Type values in the variables in numerical order.
Then you pick a random value in Random Unit Type using the "Random Integer" variable.
Then the current "Temporary Integer" is used to know which player is getting the unit.
Then you'll create a unit of a random unit type for a player in integer form called "Temporary Integer"
If you had a hard time seeing what that meant, just take this example.
....... Create a unit of unit type .......
Variables are...
Random Integer = Number 3 of 1 to 4
Random Unit Type[1] = Zealot
Random Unit Type[2] = Zergling
Random Unit Type[3] = Marine
Random Unit Type[4] = Stalker
Temporary Integer = 2
Remember the Unit variable with arrays called Hero[Array]?
It will set the unit of that player to the Last Created Unit, which happens to be just above this action. (Create Unit For Player action)
Thank You for explaining! Yes, I am new to triggering and have never messed with the WC3 editor. I'm pretty sure I understood most of what you wrote. But 1 problem I'm having; how would I tell if Player 1, 2, 3,or 4 has a certain unit? I was trying to do this:
EDIT: NVM, I figured it out. I'm so stupid >_<, I had totally forgot about the Zealot, Zergling, Marine, Stalker variable when I started making this mouse click trigger. Understand everything now ^_^! Thanks again!
Aight, the ZZMS variable isn't the best idea in a map that keeps on growing but it is the slimmest way to do this.
I think adding more unit types would be simple enough though.
Feel free to use your other concept (Though if you will, I'll show you how to do it properly)
If you are going to use your original concept, expect additional 10 lines of actions for every trigger that will find the player's unit type.
Also, looking back at this, I find it strange that I had written a whole tutorial just for my damn trigger and just for helping you.
Maybe I'm going to be a teacher one day :P
After switching to your concept, I really don't ever want to go back to my old way, lol. I like the simplicity of it and how much easier it is to read now. BTW, you'll make an awesome teacher ^_^!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm having a problem where when your unit dies, it creates a new one right away. It does this for 4 players. It works sometimes, then at other times the trigger will start creating units for you even when your current one is alive. I set it up like this:
Not exactly sure what is wrong with my logic here. Any help would be appreciated. Thank You!
Can I see that other trigger?
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
I'm doing random unit creation from 4 units and spawn in either 1 of 10 spots. This trigger is initially off. Hope this helps a bit o.o!
@Layola:
I think it might be your condition in the first trigger. Instead of what you have, make the condition "owner of triggering unit == 1". Do that in an If then else for each player.
@Layola: Go
The problem is that your second trigger, once activated, keeps running every 0.5 seconds, without any conditions. Remove the Event: Timer - Every 0.5 seconds of Game Time from your second trigger, so it only gets activated from the first.
Your system was a little fat, so I took the liberty to slim it down.
Below is everything that your trigger was. (Except for the Region variables)
Just let me know if you still want help with your triggers.
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
@Pinworm45 & xenrathe: I tried both your ways but it was still spawning units even when you had one already.
@Vicboy: Your way worked, its just that I have no idea how or why it works. Can you explain the logic behind it please? But 1 thing I noticed was that you assigned the Hero variable to already placed units on the map. In mine there are no units previously placed, so I will be unable to do that.
Thank You!
Ah, are you new with triggering? A person coming from WC3 would have known these things.
I didn't use any advanced actions, events or variables. I just added a few simple actions and smart tricks that makes it shorter.
Anyways, here's a guide to that damn trigger. These things you learn can be applied to other triggers.
Variables:
Temporary Integer = Temporary because it should only be used for instant instances. (The ones where it isn't waited to be used)
Random Integer = Sets it to 1-4. Absolutely random, and patterns are just coincidence.
Hero[x] = Sets it to the Last Created Unit.
x = Player Number. So Hero[1] is the sole unit of Player 1.
Random Unit Type[x] = This is where you set the unit types. Like set Random Unit Type[2] to Zergling.
x = Unit types. 1 = Zealot; 2 = Zergling and etc. I suggest you stay with that order.
Zealot, Zergling, Marine, Stalker[x][y] = A boolean (T/F). It's pretty much like your original Zealot, Zergling etc., booleans but compressed into 4 arrays. (Arrays are used to put multiple values into one variable)
x = This is where the player number is.
y = Unit types and if they're true or false.
For example:
Player 2 is spawned into a Zergling
Zergling is the 2nd word of the variable "Zealot, Zergling, Marine, Stalker[x][y]"
Therefore,
Zealot, Zergling, Marine, Stalker[2][1] = False
Zealot, Zergling, Marine, Stalker[2][2] = True
Zealot, Zergling, Marine, Stalker[2][3] = False
Zealot, Zergling, Marine, Stalker[2][4] = False
Actions:
This means that it will set the variable "Temporary Integer" into 1, and then you do the actions below, then after that is completed, it sets the variable into 2, and then uses that number again on the actions below.
If = If the conditions are all positive, then it will do the actions in Then.
Then = The actions inside this only occurs when If is all positive.
Else = The actions inside this only occurs when at least one of the conditions in If is negative.
IF
In other words, this condition is used up 4 times in the run of the trigger.
(Triggering unit) == Hero[1]
(Triggering unit) == Hero[2]
(Triggering unit) == Hero[3]
(Triggering unit) == Hero[4]
If, let's say, Hero[4] is TRUE while the others are FALSE, then number 4 is carried over to the THEN actions. It will be known as (Temporary Integer) through the run of the THEN actions.
THEN
Sets the variable "Random Integer" to a random number from 1 to 4. This is required. You are setting a variable into one of those 4 numbers. Once this action is completed (the set variable action) then you'll have one non-random value from 4 numbers. Example, the "Random Integer" sets its value into 3. In the whole trigger, the number 3 will be used. NOT a random integer from 1 to 4.
In the Trigger, "Set Variables", you'll notice I had set some of the variables. This is required because there is no other time that these variables will be set into a value, other than in that Trigger.
Okay, so you've placed Unit Type values in the variables in numerical order.
Then you pick a random value in Random Unit Type using the "Random Integer" variable.
Then the current "Temporary Integer" is used to know which player is getting the unit.
Then you'll create a unit of a random unit type for a player in integer form called "Temporary Integer"
If you had a hard time seeing what that meant, just take this example.
....... Create a unit of unit type .......
Variables are...
Random Integer = Number 3 of 1 to 4
Random Unit Type[1] = Zealot
Random Unit Type[2] = Zergling
Random Unit Type[3] = Marine
Random Unit Type[4] = Stalker
Temporary Integer = 2
Then...
Random Unit Type[Random Integer] = Marine
This Marine is given to Player 2.
Remember the Unit variable with arrays called Hero[Array]?
It will set the unit of that player to the Last Created Unit, which happens to be just above this action. (Create Unit For Player action)
This one is slightly harder to understand unless you've fully understood how the following works.
For Each Temporary Integer from 1 to 4 and blah blah.
Random Integer = Random integer from 1 to 4
Arrays
Pretty hard to explain so I'll give an example of this:
Variable - Set Zealot, Zergling, Marine, Stalker[2][3] = true
Zealot = 1
Zergling = 2
Marine = 3
Stalker = 4
This means Player 2 has Marine as True.
The actions after this is pretty self explanatory.
Alright, enough typing, time to play PS3.
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
You can either follow that and hopefully understand the mechanics of my trigger one by one or...
Just ask me bit by bit. Your call. I'm getting tired of explaining them further more.
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
Thank You for explaining! Yes, I am new to triggering and have never messed with the WC3 editor. I'm pretty sure I understood most of what you wrote. But 1 problem I'm having; how would I tell if Player 1, 2, 3,or 4 has a certain unit? I was trying to do this:
EDIT: NVM, I figured it out. I'm so stupid >_<, I had totally forgot about the Zealot, Zergling, Marine, Stalker variable when I started making this mouse click trigger. Understand everything now ^_^! Thanks again!
Aight, the ZZMS variable isn't the best idea in a map that keeps on growing but it is the slimmest way to do this.
I think adding more unit types would be simple enough though.
Feel free to use your other concept (Though if you will, I'll show you how to do it properly)
If you are going to use your original concept, expect additional 10 lines of actions for every trigger that will find the player's unit type.
Also, looking back at this, I find it strange that I had written a whole tutorial just for my damn trigger and just for helping you.
Maybe I'm going to be a teacher one day :P
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
After switching to your concept, I really don't ever want to go back to my old way, lol. I like the simplicity of it and how much easier it is to read now. BTW, you'll make an awesome teacher ^_^!