Hi there, what I'm trying to do is create a trigger, so when 10 hostiles die, the game ends in victory for the player. The thing is there are about 75 hostiles on the map, but the player only needs to kill 10 to win, sort of like in the "In Utter Darkness" mission in the Wings of Liberty Campaign, where the player needs to kill a certain amount of Zerg before he dies. Sadly I can't find the trigger on how this works in that map's file, so I need help from the community. If you know of a way to make the trigger that I want, please share.
Can you tell me how you setup the killcount variables? I'm getting an error and it fails to compile my scripts, and it has to be something with the way I'm setting up my variables.
Here is the trigger:
trigger1
Events
Unit - Any Unit dies
Local Variables
Conditions
(Owner of (Triggering unit)) == 15
Actions
Variable - Set killcount[(Triggering player)] = KillCount[(Triggering player)][(+ (1))]
General - If (Conditions) then do (Actions) else do (Actions)
If
killcount[(Triggering player)] >= 10
Then
Game - End game in Victory for player 1 (Show dialogs, Show score screen)
Else
Oh OK I fixed that problem, but now when I test the map, it says that there is an error with the trigger in that the array is over and that there are elements after the array.
Yes, you are right. And because the hostile player is 15, that is the number that is being put into the array, and the array most likely does not go to 15, creating that error. That should fix it.
I'm still getting that same error.
Here is my trigger:
trigger1
Events
Unit - Any Unit dies
Local Variables
Conditions
(Owner of (Triggering unit)) == 15
(Owner of (Killing unit)) == 1
Actions
Variable - Set killcount[(Triggering player)] = killcount[(+ (1))]
General - If (Conditions) then do (Actions) else do (Actions)
If
killcount[(Triggering player)] >= 10
Then
Game - End game in Victory for player 1 (Show dialogs, Show score screen)
Else
Hi there, what I'm trying to do is create a trigger, so when 10 hostiles die, the game ends in victory for the player. The thing is there are about 75 hostiles on the map, but the player only needs to kill 10 to win, sort of like in the "In Utter Darkness" mission in the Wings of Liberty Campaign, where the player needs to kill a certain amount of Zerg before he dies. Sadly I can't find the trigger on how this works in that map's file, so I need help from the community. If you know of a way to make the trigger that I want, please share.
Thank you and have a nice day.
You will probably need something like this. KillCount is a global variable which you will have to define as an Integer Array.
@Ardnived: Go
Can you tell me how you setup the killcount variables? I'm getting an error and it fails to compile my scripts, and it has to be something with the way I'm setting up my variables.
Here is the trigger:
trigger1 Events Unit - Any Unit dies Local Variables Conditions (Owner of (Triggering unit)) == 15 Actions Variable - Set killcount[(Triggering player)] = KillCount[(Triggering player)][(+ (1))] General - If (Conditions) then do (Actions) else do (Actions) If killcount[(Triggering player)] >= 10 Then Game - End game in Victory for player 1 (Show dialogs, Show score screen) Else
@benmenftw: Go
Oh yes and the error says "expecting a return value."
@benmenftw: Go
Oh OK I fixed that problem, but now when I test the map, it says that there is an error with the trigger in that the array is over and that there are elements after the array.
@benmenftw: Go
(controller of (triggering player)) is the for the player of the unit who is dead you need Owner of killing unit i think
@Usernameisntworkingright: Go
Yes, you are right. And because the hostile player is 15, that is the number that is being put into the array, and the array most likely does not go to 15, creating that error. That should fix it.
Great to be back and part of the community again!
@TacoManStan
I'm still getting that same error.
Here is my trigger:
trigger1
Events
Unit - Any Unit dies
Local Variables
Conditions
(Owner of (Triggering unit)) == 15
(Owner of (Killing unit)) == 1
Actions
Variable - Set killcount[(Triggering player)] = killcount[(+ (1))]
General - If (Conditions) then do (Actions) else do (Actions)
If
killcount[(Triggering player)] >= 10
Then
Game - End game in Victory for player 1 (Show dialogs, Show score screen)
Else
@benmenftw:
Any ideas?
Uhh, first and foremost
This doesn't make sense. With what you have above you are setting the player's KillCount to be the same as the player above him. What you want is.
Use the Arithmetic (Not the Multiple one), get the player's KillCount and add one.
However. As it appears that you have only 1 human player (Who is player one), you don't need to use an array at all.
@Ardnived:
So should I should just get rid of the set variable or turn off arrays in the variable page of the killcount variable?
@benmenftw:
By the way I can't find out how to get the + 1) at the end of the variable in the set variable action, mine currently looks like:
Variable - Set killcount[(Triggering player)] = KillCount[(Triggering player)][(0 + 1)]
@benmenftw: Go
Make a Variable, integer, doesnt matter what the name is but ill call it "nUnit" and set the intial value to 1 make a trigger
Add a "wait" command to the Then part if you want to delay the victory a bit before the game ends
@Kalithumos:
Thank you so much! It worked!