Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Woodpeckersam

How to: Count Civillian Casualty and lower score based on how many end of mission

Recommended Posts

Hiya all! As the title says :D

I am wondering how this is possible? I've been trying a couple of scripts out and they dont seem to work.

Basically throughout the whole mission i would need a script that constantly loop, checking if any civillian units have died. When one of the civillians have died, i would to +1 to a variable... lets say...

civii = 0; //At the start
_count = forEach Units trigTown; //Name of trigger to check

if (countSide Civii < _count) //If every 1 Civillian dies do the following
{
 civii + 1;
};

I cannot seem to work out the logic with current codes for this script... I haven't tested it... so i know that it dont work at all

Ok so then at the end of the mission i would like some text to pop up to say...

If the player kills no civilians then say the following:

Congratulations! You killed no Civilians!

If the player kills at least 1 Civilians then say the following:

You killed %% amount of Civilians, your points have been deducted by %% points.

Is there a way to do this?

edit:

Oops thats quite a dodgy title for this thread haha

Edited by WoodyUK

Share this post


Link to post
Share on other sites

So i am assuming that this code will work in the trigger activation, provided that the trigger is set to Civilians Present and Repeatedly.

{_x addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]} foreach units thislist;

How would i grab the variable from the trigger then do some maths and total it up at the end of the mission?

would i need to do this..

_count = count civ_casualties;
_score = _count * 20;
_total = score Player;

if (_count == 0) then
{
 titleText ["Well done! You have killed"+_count+"Civilians! Congratulations", "PLAIN"]
}
else if (_count > 0) then
{
 titleText ["You have killed"+_count+"Civilians! Your score will be lowered by"+_score+"percent", "PLAIN"]
 player addScore _total - _score;
};

Can you correct me if this is totally wrong please?

Edited by WoodyUK

Share this post


Link to post
Share on other sites

The variable is typo'd in the first bit: civ_casaulties :P

Otherwise looks good. When I do it I add it to each civilian's init field, but it should work in a trigger like that as well.

Edited by fatty86
A few typos myself....

Share this post


Link to post
Share on other sites

Thanks for te speedy response :D

I got a feeling that inputting variables into titletext is different from the way I did it. Haven't tested it though, however I'll research into that myself :D

Thanks!

---------- Post added at 03:59 AM ---------- Previous post was at 03:38 AM ----------

titleText [format["Well done! You have killed"%_count" Civilians! Congratulations",]];

Sorry to be a nuisance but is this right?

Share this post


Link to post
Share on other sites
titleText [format["Well done! You have killed %1 civilians! Congratulations!", _count], "PLAIN"];

Share this post


Link to post
Share on other sites

AI often dies in buildings due to not enough room, on OA rocks, falls down from ladders or roofs, gets road killed by enemies, etc.

Hence I recommend to put in a check to the killed-Eventhandler, that makes sure it was one of your own people who killed the resp. civilian:

{_x addeventhandler ["killed",{if(side (_this select 1) == west) then {civ_casaulties = civ_casaulties + 1}}]} foreach units thislist;

(or "side (_this select 1) == east" depending on the faction you are playing)

Share this post


Link to post
Share on other sites

Sorry i was out all day today.... but... thanks for your help guys :D

Actually theres not a problem with that at all Bon, as these civilians are out in the open, not in buildings :D But thanks for that cos it will actually helps! :D

So this works, how do i lower the score of the unit?

"_total" minus "_score"

_total = gets the current score of the player

_count = how many civilians got killed.

_score = score changes every time you kill a Civilian by "_count * 20" then lowers the score by getting the current score of the unit then taking away "_score".

Edited by WoodyUK

Share this post


Link to post
Share on other sites

Try this:

_civscore = _count * 20;

player addScore -_civscore;

May need to change "player" to correct name if this is for multiplayer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×