Hello everyone! I started a map just to screw around with textures and stuff (to get the feel) while on the phone, and I turned it into the most horrible short mission EVER. I know all this background info isn't exactly necessary, but I try to provide a helpful amount of info when asking questions.
I have a small plateau in the center of the map where a small group of bad guys has some form of insidious encampment (screwing around with doodads). Your small force of soldiers has to march up to that plateau and massacre them! YAY! I have an objective that correctly displays at the top of the screen just for this and a region that encompasses almost the entirety of the plateau.
How I have this set up is:
A unit group "Alavus Foundation" that has the 4 marines and 1 war pig that I set up using Map -> Object Groups -> Unit Groups (not a variable)
A Boolean variable of the value "Unit Group is Dead" (for the sake of the post, called x)
A trigger that looks roughly like: EVENT Unit is killed CONDITIONS x = true ACTIONS Mark Objective
I did some debugging and here's what I came up with:
The objective CAN be marked (just never when I want it to be)
With my new system (the above) and some fancy leaderboards, I can see that the variable initializes to FALSE and the unit group contains 5 units.
As I kill units, the number in the unit group does NOT go down, and the variable does NOT switch to TRUE after killing all the units in the unit group, therefor the objective does NOT get marked.
I guess my question is, do Boolean variables not set to constant that can change based on game events update themselves, and if not what is the easiest way to update the boolean when all units in the region are dead (and if I can check for that MYSELF, why use the variable as a middle man unless I want to update multiple triggers?)
--------
EDIT:
I think I solved my own problem. I'm not sure if it will work, but for those who come after and have the same issue, I set this variable as GLOBAL. If I set the variable as local to a trigger with event = unit is killed, it should recheck ever time a unit dies, and finally, when all units in unit group are dead, meet the condition and perform the action.
The logic is, by re-doing the trigger every time a unit dies, the variable should re-initialize with whatever value holds true for "Unit Group is Dead" after trigger unit died.
An event is triggered the moment the event given occurs.
The comparison you place inside the condition area are the conditions that have to be met in order to run the actions below it.
the world "variable" is as the name implies, it is a container label that has data which varies on what you set it to.
As your edit notes, there are two different scopes for variables. variables created within an event will only be retained during the instance of that event. If that same trigger is ran multiple times, the variable contained within it would have multiple entities of itself with different values.
With how you wanted to call your boolean ("Unit Group is Dead"), I assume you want to check if all units are dead. This isn't really an area you need to use a variable. Here's how you can perhaps achieve what you're after:
Inside your Unit is Killed Event noted above, remove the condition x = true. Add a new condition as follows:
Value 1: Change from Owner of Unit to Number of Units in Unit Group
A new red area will appear below Value, called Unit Group. Double click that and set it to the unit group you created before.
Double click Value 2: Change this to 0. Now press OK to exit out.
Now this is a condition that checks how many units are alive in your unit group, and once it equals 0 (they're all dead), it will run the actions.
Wow, Xackery, awesome response. That seems like a really simple, clean way to do it, and gives me ideas on how to do other things in the future.
For some reason, my idea worked. I think this is essentially because, let's say, unit 4 of 5 was killed, so the trigger ran. It created itself a nice copy of the variable which evaluated "false", the actions didn't run, and the whole thing was scrapped. Then, the last unit is killed, it creates a new variable that evaluates to "true", and the events run.
I also forgot to mention that "Unit Group is Dead" is indeed a type of boolean in itself, not something modified. It's just under the "Unit" category of "functions", and it essentially runs the comparison you mentioned every time it is created. Since it is neatly destroyed when it evaluates to false, it is free to create itself as many times as necessary until it says "true," like a Do Until loop.
Oh yeah, I also neglected to bring up the fact that I took 2 semesters of Visual Basic my Sophomore year of high school. Not exactly the most USEFUL language ever, but the only one we offered and certainly enough to mess with a few things anywhere.
On a side note, this editor is totally frustrating, but I think that just makes it more satisfying to use the more you learn about it.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello everyone! I started a map just to screw around with textures and stuff (to get the feel) while on the phone, and I turned it into the most horrible short mission EVER. I know all this background info isn't exactly necessary, but I try to provide a helpful amount of info when asking questions.
I have a small plateau in the center of the map where a small group of bad guys has some form of insidious encampment (screwing around with doodads). Your small force of soldiers has to march up to that plateau and massacre them! YAY! I have an objective that correctly displays at the top of the screen just for this and a region that encompasses almost the entirety of the plateau.
How I have this set up is:
A unit group "Alavus Foundation" that has the 4 marines and 1 war pig that I set up using Map -> Object Groups -> Unit Groups (not a variable)
A Boolean variable of the value "Unit Group is Dead" (for the sake of the post, called x)
A trigger that looks roughly like: EVENT Unit is killed CONDITIONS x = true ACTIONS Mark Objective
I did some debugging and here's what I came up with:
The objective CAN be marked (just never when I want it to be)
With my new system (the above) and some fancy leaderboards, I can see that the variable initializes to FALSE and the unit group contains 5 units.
As I kill units, the number in the unit group does NOT go down, and the variable does NOT switch to TRUE after killing all the units in the unit group, therefor the objective does NOT get marked.
I guess my question is, do Boolean variables not set to constant that can change based on game events update themselves, and if not what is the easiest way to update the boolean when all units in the region are dead (and if I can check for that MYSELF, why use the variable as a middle man unless I want to update multiple triggers?)
--------EDIT:
I think I solved my own problem. I'm not sure if it will work, but for those who come after and have the same issue, I set this variable as GLOBAL. If I set the variable as local to a trigger with event = unit is killed, it should recheck ever time a unit dies, and finally, when all units in unit group are dead, meet the condition and perform the action.
The logic is, by re-doing the trigger every time a unit dies, the variable should re-initialize with whatever value holds true for "Unit Group is Dead" after trigger unit died.
Here's some tips:
With how you wanted to call your boolean ("Unit Group is Dead"), I assume you want to check if all units are dead. This isn't really an area you need to use a variable. Here's how you can perhaps achieve what you're after:
Inside your Unit is Killed Event noted above, remove the condition x = true. Add a new condition as follows: Value 1: Change from Owner of Unit to Number of Units in Unit Group A new red area will appear below Value, called Unit Group. Double click that and set it to the unit group you created before. Double click Value 2: Change this to 0. Now press OK to exit out.
Now this is a condition that checks how many units are alive in your unit group, and once it equals 0 (they're all dead), it will run the actions.
Good luck. :)
Wow, Xackery, awesome response. That seems like a really simple, clean way to do it, and gives me ideas on how to do other things in the future.
For some reason, my idea worked. I think this is essentially because, let's say, unit 4 of 5 was killed, so the trigger ran. It created itself a nice copy of the variable which evaluated "false", the actions didn't run, and the whole thing was scrapped. Then, the last unit is killed, it creates a new variable that evaluates to "true", and the events run.
I also forgot to mention that "Unit Group is Dead" is indeed a type of boolean in itself, not something modified. It's just under the "Unit" category of "functions", and it essentially runs the comparison you mentioned every time it is created. Since it is neatly destroyed when it evaluates to false, it is free to create itself as many times as necessary until it says "true," like a Do Until loop.
Oh yeah, I also neglected to bring up the fact that I took 2 semesters of Visual Basic my Sophomore year of high school. Not exactly the most USEFUL language ever, but the only one we offered and certainly enough to mess with a few things anywhere.
On a side note, this editor is totally frustrating, but I think that just makes it more satisfying to use the more you learn about it.