Jambird 10 Posted May 26, 2013 Hi, I'm pretty new to scripting or anything of that nature and I need to know the easiest way to make it so the mission ends after 25 blufor casualties have been sustained. I have looked around endlessly for threads for this with no luck. I already have base respawning on so I just need to know how I can make it so after the above amount of casualties have been sustained the mission ends (failure). Thanks! :cool: Share this post Link to post Share on other sites
Joe98 92 Posted May 27, 2013 If you search, some people have asked: "How can I get a mission to end if there are 2 or less enemy remaining on the map?" In your trigger amend the given answer to read "......only X number of friendlies on the map" Share this post Link to post Share on other sites
Jambird 10 Posted May 27, 2013 (edited) If you search, some people have asked: "How can I get a mission to end if there are 2 or less enemy remaining on the map?"In your trigger amend the given answer to read "......only X number of friendlies on the map" But I have respawning on, so that won't work will it? Also, if this helps or not, there will be about 25-40 people playing this mission from my group, all on Blufor. :) Edited May 27, 2013 by Jambird Share this post Link to post Share on other sites
Silderoy 1 Posted May 27, 2013 (edited) that might work, not tested though: create a file called "casualtiesCheck.sqf". inside put the following: _deadbluefor = 0; while {true} do { { if ((side _x == west) && (getdammage _x == 1)) then { _deadbluefor = _deadbluefor + 1; }; } forEach playableUnits; sleep 2; }; then in your init.sqf put this: null = [] execVM "casualtiesCheck.sqf"; and it the end "lose" trigger, write in the Cond field:\ _deadbluefor = 25; Edited May 27, 2013 by Silderoy Share this post Link to post Share on other sites
Jambird 10 Posted May 27, 2013 that might work, not tested though:create a file called "casualtiesCheck.sqf". inside put the following: _deadbluefor = 0; while {true} do { { if ((side _x == west) && (getdammage _x == 1)) then { _deadbluefor = _deadbluefor + 1; }; } forEach playableUnits; sleep 2; }; then in your init.sqf put this: null = [] execVM "casualtiesCheck.sqf"; and it the end "lose" trigger, write in the Cond field:\ _deadbluefor = 25; I'll try it now! Thanks :D ---------- Post added at 12:10 ---------- Previous post was at 11:37 ---------- that might work, not tested though:create a file called "casualtiesCheck.sqf". inside put the following: _deadbluefor = 0; while {true} do { { if ((side _x == west) && (getdammage _x == 1)) then { _deadbluefor = _deadbluefor + 1; }; } forEach playableUnits; sleep 2; }; then in your init.sqf put this: null = [] execVM "casualtiesCheck.sqf"; and it the end "lose" trigger, write in the Cond field:\ _deadbluefor = 25; Okay I tried it, unfortunately it did not work :( I'll tell you what I did to make sure I did nothing wrong: I created the casualtiesCheck.sqf with notepad and placed it in the mission folder with mission.sqm and description.ext etc, copied and pasted that code you put up there into it. I opened up the init.sqf that I had from other attempts and pasted the code you asked me to put in there I opened up Arma 2 oa and but a end #3 trigger down and put "_deadbluefor = 25;" in it. That's all I did with the trigger, nothing else. I did not set who could activate it or anything. Share this post Link to post Share on other sites
Silderoy 1 Posted May 27, 2013 (edited) ok my bad, stupid mistake, change "_deadbluefor" to "DEADBLUEFOR", without the _. both on the script and in the trigger. and make sure its in the Cond field and not the On Act. so delete anything from the casualtiesCheck.sqf, and paste this into it: DEADBLUEFOR = 0; while {true} do { { if ((side _x == west) && (!alive _x)) then { DEADBLUEFOR = DEADBLUEFOR + 1; hint format ["causualties: %1", DEADBLUEFOR]; }; } forEach playableUnits; sleep 2; }; now it should hint you the number of casualties every time a bluefor unit dies. Edited May 28, 2013 by Silderoy Share this post Link to post Share on other sites
Jambird 10 Posted May 27, 2013 ok my bad, stupid mistake, change "_deadbluefor" to "DEADBLUEFOR", without the _. both on the script and in the trigger. and make sure its in the Cond field and not the On Act.so delete anything from the casualtiesCheck.sqf, and paste this into it: DEADBLUEFOR = 0; while {true} do { { if ((side _x == west) && (getdammage _x == 1)) then { DEADBLUEFOR = DEADBLUEFOR + 1; hint format ["causualties: %1", DEADBLUEFOR]; }; } forEach playableUnits; sleep 2; }; now it should hint you the number of casualties every time a bluefor unit dies. Still nothing! :( I don't know if this might be the cause, but the name of the mission in game does not match the name of the mission folder. The mission folder has percentages and things in, while the actual name of the mission in game does not! I'll show you a screenshot: I did rename the mission through the "intel" option, I'm not sure how that effects the folder. Share this post Link to post Share on other sites
Silderoy 1 Posted May 27, 2013 you have the percents because you had spaces in the ingame name. arma files cannot have spaces, so their "name" for a space is %20... about the script, is it showing the hints or nothing? Share this post Link to post Share on other sites
Jambird 10 Posted May 27, 2013 you have the percents because you had spaces in the ingame name. arma files cannot have spaces, so their "name" for a space is %20...about the script, is it showing the hints or nothing? No, nothing at all :( Share this post Link to post Share on other sites
Silderoy 1 Posted May 28, 2013 (edited) ok to check whats working and whats not, put that into the causaltiesCheck.sqf: DEADBLUEFOR = 0; hint "script is running"; sleep 1; while {true} do { hint "'while' loop started"; sleep 1; { hint "'forEach' loop started"; sleep 1; if (side _x == west) then { hint "unit is bluefor"; sleep 1; if (!alive _x) then { hint "unit is dead"; sleep 1; DEADBLUEFOR = DEADBLUEFOR + 1; hint "casualty saved"; }; }; } forEach playableUnits; hint "'foreEach' loop finished"; sleep 2; }; now it should have alot of hints. tell me which hint you see and which you do not, what is the last hint you can see. Edited May 28, 2013 by Silderoy Share this post Link to post Share on other sites
Jambird 10 Posted May 28, 2013 It keeps saying "unit is blufor " "'for each' loop started" over and over again. I killed some Blufor ai, no effect. Share this post Link to post Share on other sites
Silderoy 1 Posted May 28, 2013 the problem over here is that when a unit dies, it becomes a civilian, and leaves its group. Im trying to find a way to get it but an the moment no luck... Share this post Link to post Share on other sites
comp_uter15776 1 Posted May 28, 2013 Sounds tedious, and I'm not exactly a 1337 scripting pr0, but could you not individually name them and then check how many are alive, and if it's above a certain number the game continues, if not it ends? Just my 2p Regards, Comp_uter15776 Share this post Link to post Share on other sites
Silderoy 1 Posted May 28, 2013 (edited) Sounds tedious, and I'm not exactly a 1337 scripting pr0, but could you not individually name them and then check how many are alive, and if it's above a certain number the game continues, if not it ends?Just my 2p Regards, Comp_uter15776 if he have spawn, it wont work. and if I got it right then he have... EDIT: But, you got me an idea! name all of the bluefor units. something like b1,b2,b3,b4,b5,b6.... now in the casualtiesCheck.sqf put this: DEADBLUEFOR = 0; _blueForUnits = [b1,b2,b3,b4,b5,b6...]; while {true} do { { if (!alive _x) then { DEADBLUEFOR = DEADBLUEFOR + 1; hint "casualty detected"; sleep 1; hint format ["casualties: %1", DEADBLUEFOR]; }; } forEach _blueForUnits; sleep 2; }; in _blueForUnits put all the names of the bluefor units. :p if that one doesnt work I think you can make it with Event Handlers. to do that get the following code into the casualtiesCheck.sqf, but only if the above doesnt work: DEADBLUEFOR = 0; _blueForUnits = [b1,b2,b3,b4,b5,b6...]; while {true} do { { _x addMPEventHandler ["MPKilled", {DEADBLUEFOR = DEADBLUEFOR + 1}]; waituntil {!alive _x}; waituntil {alive _x}; } forEach _blueForUnits; sleep 1; }; Edited May 28, 2013 by Silderoy Share this post Link to post Share on other sites
Jambird 10 Posted May 29, 2013 Alright, doing it now! :) Share this post Link to post Share on other sites
ixenocider 10 Posted May 31, 2013 ok to check whats working and whats not, put that into the causaltiesCheck.sqf: DEADBLUEFOR = 0; hint "script is running"; sleep 1; while {true} do { hint "'while' loop started"; sleep 1; { hint "'forEach' loop started"; sleep 1; if (side _x == west) then { hint "unit is bluefor"; sleep 1; if (!alive _x) then { hint "unit is dead"; sleep 1; DEADBLUEFOR = DEADBLUEFOR + 1; hint "casualty saved"; }; }; } forEach playableUnits; hint "'foreEach' loop finished"; sleep 2; }; now it should have alot of hints. tell me which hint you see and which you do not, what is the last hint you can see. I tried this out. It never reaches "unit is blufor." I believe it has to do with the if (side _x == east) part but I am not too sure. Share this post Link to post Share on other sites
PlacidPaul 11 Posted May 31, 2013 Just to point out, if your making a mission that doesn't have respawns, just put this in a trigger west countSide allunits <= your number I know it doesn't really apply to OP, but it might to someone else. Share this post Link to post Share on other sites
Silderoy 1 Posted May 31, 2013 I tried this out. It never reaches "unit is blufor." I believe it has to do with the if (side _x == east) part but I am not too sure. it has nothing to do with east, because he is interested in bluefor only... Share this post Link to post Share on other sites