Okay so I'm having some trouble "HasUnitInRegion" condition definition.
You suggested...
"For Each Unit (u) in (Units in Region (MyRegion)) Do"
but the closest thing I could figure out was...
"Unit Group - For each unit u in (Any units in Win Region owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) do (Actions)"
Do I have to create a condition definition for "UnitsInRegion" as well?
In any event, the result has been a defeat for the player even if they have units in the region. What am I missing?
Thats the right function you found. I just shortened it. The entire any player and exluded stuff is standard.
It should actually work.
Can you show us the code you have right now? Including the HasAUnitInRegion Condition definition in particular.
@James7285: Go
You're sulotion should work, but its takes some more memory space than mine.
SouLCarveRR's suggenstion is right. "Number of units in region matching conditions" is an integer return type function. So you need to look into integer functions to find it.
What I do is set up a trigger for each set of variables that = and end game sequence.
So say if timer runs out and player 1 has so many units in region 1 and player 1 has more than 50 minerals, then fade out instantly, kill all units, create a bunker for player 1, and then set default melee options.
You can maybe do something similar.
I don't know though. I'm just into hard core basics done awesome.
No offense but that solution is very poor.
It will always just be a black screen upon both victory and defeat.
It doesn't allow you to set up what victory or defeat looks like.
For instance in my map, upon defeat I zoom out the camera and let the player see his base overrun by enemies. There is also a transmission saying stuff like "this is our doom".
And if the player wants to, he can press "return to game" and see what status it was in before he lost.
All of these things are not possible with your solution. Victory and defeat will both look boring.
Well and for the Sudden death I would advise this:
Trigger: Sudden Death (Initially OFF!)
Events:
Any Unit Leaves MyRegion
Any Unit Dies
Condition:
Local Variables:
p: integer
winner: integer
foundOne: boolean
Action:
For Each Player (p) in (All Players) Do
- if (HasAUnitInRegion(p))
- - then if(foundOne)
- - - then skip remaining actions
- - - else set winner = p; set foundOne = true
- - else
VictoryFunction(winner)
::::::::::::::::::::::::::::::::::
Then in the Placeholder it should say:
Turn Trigger (Sudden Death) On.
A little History:
In the Warcraft editor, the entire scripting was done with triggers and such. But there was a script language called "Jass" and each trigger function called a corresponding function in "jass". At some point in time, as a mapper you were given the choise wheter you want to use the trigger editor's "pseudo-code" or actual jass code. I have little doubt that it will be the same for GE at some point. So if you are more the typing kind of guy, just sit back.
Enough History.
I take from your post that you do have some scripting experience. That's good.
The Trigger editor basicly works the same way as any programming language for the most part.
There are different kinds of functions. All Functions can take parameters and have local variables.
There's things called "Action Definitions" These are basically sub-functions. They perform a squence of actions.
Then there's "Condition Definitions" Those are basically functions with the return type "boolean". These can be use as conditions.
Then there's Triggers. Those are your scripts connection to the game.
Trigger have Events, Conditons and actions. Simply put, if the event starts and the conditions are met, the actions are fired.
That's enough for now, getting weary xD
So on to the problem.
If we forget about sudden death for now its easy:
I dont care how you set up your data system. But you will obviously need a variable for the timer.
Var MyTimer:timer
Var MyRegion:Region
Trigger: Main Round
Event: Timer MyTimer expires
Condition:
Local Variables:
p: integer
winner: integer
foundOne: boolean
Action:
For Each Player (p) in (All Players) Do
- if (HasAUnitInRegion(p))
- - then if(foundOne) /* if we found one and now found annother, means theres no winner yet */
- - - then < Sudden Death Placeholder >; Skip Remaining Actions
- - - else set winner = p; set foundOne = true
- - else
/* (End Loop) <- the end will be obvious in the editor */
/* if we get to this point, we have a winner */
VictoryFunction(winner)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Condition Definition: HasAUnitInRegion
Parameters: p: integer
Local Variables: u: Unit
Actions:
For Each Unit (u) in (Units in Region (MyRegion)) Do
- if (Owner of (u)) == p
- - then Return true
- - else
/* (End Loop) <- the end will be obvious in the editor */
return false
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Action Definition: VictoryFunction
Parameters: winner: integer
Local Variables: p: integer
Actions:
For Each Player (p) in (All Players) Do
- if (p == winner)
- - then End Game For (p) in Victory (.....)
- - else End Game For (p) in Defeat (.....)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Normally I'd explain stuff but I think you get this as a scripter. When you have that, we'll care about sudden death. No more time to write right now.
Thats the right function you found. I just shortened it. The entire any player and exluded stuff is standard.
It should actually work.
Can you show us the code you have right now? Including the HasAUnitInRegion Condition definition in particular.
@James7285: Go You're sulotion should work, but its takes some more memory space than mine.
SouLCarveRR's suggenstion is right. "Number of units in region matching conditions" is an integer return type function. So you need to look into integer functions to find it.
No offense but that solution is very poor.
It will always just be a black screen upon both victory and defeat.
It doesn't allow you to set up what victory or defeat looks like.
For instance in my map, upon defeat I zoom out the camera and let the player see his base overrun by enemies. There is also a transmission saying stuff like "this is our doom".
And if the player wants to, he can press "return to game" and see what status it was in before he lost.
All of these things are not possible with your solution. Victory and defeat will both look boring.
@zenasprime: Go
Well and for the Sudden death I would advise this:
Trigger: Sudden Death (Initially OFF!)
Events:
Any Unit Leaves MyRegion
Any Unit Dies
Condition:
Local Variables:
p: integer
winner: integer
foundOne: boolean
Action:
For Each Player (p) in (All Players) Do
- if (HasAUnitInRegion(p))
- - then if(foundOne)
- - - then skip remaining actions
- - - else set winner = p; set foundOne = true
- - else
VictoryFunction(winner)
::::::::::::::::::::::::::::::::::
Then in the Placeholder it should say:
Turn Trigger (Sudden Death) On.
@zenasprime: Go
A little History:
In the Warcraft editor, the entire scripting was done with triggers and such. But there was a script language called "Jass" and each trigger function called a corresponding function in "jass". At some point in time, as a mapper you were given the choise wheter you want to use the trigger editor's "pseudo-code" or actual jass code. I have little doubt that it will be the same for GE at some point. So if you are more the typing kind of guy, just sit back.
Enough History.
I take from your post that you do have some scripting experience. That's good.
The Trigger editor basicly works the same way as any programming language for the most part.
There are different kinds of functions. All Functions can take parameters and have local variables.
There's things called "Action Definitions" These are basically sub-functions. They perform a squence of actions.
Then there's "Condition Definitions" Those are basically functions with the return type "boolean". These can be use as conditions.
Then there's Triggers. Those are your scripts connection to the game.
Trigger have Events, Conditons and actions. Simply put, if the event starts and the conditions are met, the actions are fired.
That's enough for now, getting weary xD
So on to the problem.
If we forget about sudden death for now its easy:
I dont care how you set up your data system. But you will obviously need a variable for the timer.
Var MyTimer:timer
Var MyRegion:Region
Trigger: Main Round
Event: Timer MyTimer expires
Condition:
Local Variables:
p: integer
winner: integer
foundOne: boolean
Action:
For Each Player (p) in (All Players) Do
- if (HasAUnitInRegion(p))
- - then if(foundOne) /* if we found one and now found annother, means theres no winner yet */
- - - then < Sudden Death Placeholder >; Skip Remaining Actions
- - - else set winner = p; set foundOne = true
- - else
/* (End Loop) <- the end will be obvious in the editor */
/* if we get to this point, we have a winner */
VictoryFunction(winner)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Condition Definition: HasAUnitInRegion
Parameters: p: integer
Local Variables: u: Unit
Actions:
For Each Unit (u) in (Units in Region (MyRegion)) Do
- if (Owner of (u)) == p
- - then Return true
- - else
/* (End Loop) <- the end will be obvious in the editor */
return false
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Action Definition: VictoryFunction
Parameters: winner: integer
Local Variables: p: integer
Actions:
For Each Player (p) in (All Players) Do
- if (p == winner)
- - then End Game For (p) in Victory (.....)
- - else End Game For (p) in Defeat (.....)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Normally I'd explain stuff but I think you get this as a scripter. When you have that, we'll care about sudden death. No more time to write right now.