Jump to content
Sign in to follow this  
Ice_Rhino

Mission Fail if numbers of dead reached

Recommended Posts

I have a four man team that moves through a village. I want the mission to fail if two members of that team get killed. The members of the team are called blu_diver_1a to 1d.

I was thinking about a variable type thing that increments on a team member death and then when equal to 2. Only thing is I do not know how to implement such a thing

Any ideas?

Toni

IR

Share this post


Link to post
Share on other sites

Haven't tried if it works but this is what you're looking for, someone better can probably fix the counting if it doesn't work.

[color="#FF8040"][color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]isServer[/b][/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#006400"][i]//Run only on server/ host side[/i][/color]
[color="#1874CD"]_players[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]alive[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]count[/b][/color] [color="#191970"][b]playableUnits[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//Get the amount of alive playable units[/i][/color]
[color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#1874CD"]_players[/color] [color="#8B3E2F"][b]<[/b][/color] [color="#FF0000"]3[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//When the amount goes below 3, execute below code[/i][/color]
[color="#006400"][i]//Also can do: waitUntil {_players == 2};[/i][/color]
[color="#191970"][b]endMission[/b][/color] [color="#7A7A7A"]"END1"[/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//End the mission with "END1"[/i][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Share this post


Link to post
Share on other sites

It would be very similar to how Larrow dis this for you: http://forums.bistudio.com/showthread.php?183405-Trigger-not-working-on-deaths-of-AI

Except you would do something along the lines of:


while (true) do {

{

(!alive _x)
}count [unit names here] >=2;

};

I am probably missing a thing or two, but doing this from my phone :p so just trying my best.

And it seems we are building whatever scenario you are working on for you...at least that's how I feel, a lot of these things already have threads on then, you may have to search for a bit, but they are out there...

EDIT:I was ninjad... btw, but you will still need the while loop to keep it checking for alive players.

Edited by JShock

Share this post


Link to post
Share on other sites
...but you will still need the while loop to keep it checking for alive players.

Do you even waitUntil bro. It IS a loop.

Share this post


Link to post
Share on other sites

Thanks for the ongoing information, not sure how to implement it though to be honest. Is there a way to create a variable, say DeadDivers, and then on the death of a specific unit, it will

Initial Information - DeadDivers = 0

Then on each death of certain unit it would be

DeadDivers = DeadDivers +1

I could then have a trigger that fires on the DeadDivers = 2

Thanks

Toni

IR

Share this post


Link to post
Share on other sites

add this on the units

this addEventHandler ["Killed",{
 if (isNil "DeadDivers") then {DeadDivers = 0};
 DeadDivers = DeadDivers + 1;
 publicVariable "DeadDivers";
}];

Share this post


Link to post
Share on other sites

Hi Cuel,

I have put the code in the units as you suggested and it accepted it without error. I then created a trigger with condition of

DeadDivers = 2

and a hint on ACT just saying "DeadDivers Limit Reached"

I killed two of the team with the code but nothing happened. What am I missing here?

---------- Post added at 19:49 ---------- Previous post was at 19:14 ----------

Sorted it, I need to use

DeadDivers == 2

Thanks to all for your help and especially Cuel.

Share this post


Link to post
Share on other sites

You could just strap my code a bit and then put it in a trigger too...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×