OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: The-Architect on 20 Jul 2008, 00:09:43

Title: Body Count Script
Post by: The-Architect on 20 Jul 2008, 00:09:43
How would I go about creating a body count script.

Something that would appear at the end of a mission, preferably in a radio message, telling the player how many bad guys had been killed in the mission.
Title: Re: Body Count Script
Post by: Spooner on 20 Jul 2008, 15:00:49
I would place a massive trigger, which covered all OPFOR:
Activation: OPFOR PRESENT ONCE
Code: (OnAct) [Select]
{ [_x] execVM "addDeathCounter.sqf" } forEach thisList; totalEnemies = count thisList

(if you add more OPFOR during the mission, then you'd have to run addDeathCounter.sqf for each of them too).

Code: (addDeathCounter.sqf) [Select]
_enemy = _this select 0;

if (isNil "numKilled") then { numKilled = 0 };

_enemy addEventHandler ["KILLED", {
    numKilled = numKilled + 1;
}];

I don't know how you end your mission, so I can't help you with knowing when to use this (sadly, you can't put dynamic text into the debriefing):
Code: [Select]
[playerSide, "HQ"] sideChat format ["Well done, %1! You neutralised %2 OPFOR out of %3.", name player, numKilled, totalEnemies];
Title: Re: Body Count Script
Post by: The-Architect on 20 Jul 2008, 23:11:29
I don't know how to use .sqf files. I'm a bit retarded like that.

Also, didn't there used to be a bit of syntax you could put into a radio message that gave a number. The % symbol maybe?
Title: Re: Body Count Script
Post by: Spooner on 21 Jul 2008, 00:57:25
Well, you don't actually need to use the sqf file in this example. Just create it in notepad and copy in the text! Here it is in SQS if it makes your life bearable ;P
Code: (trigger on act) [Select]
{ [_x] exec "addDeathCounter.sqs" } forEach thisList; totalEnemies = count thisList

Code: (addDeathCounter.sqs) [Select]
_enemy = _this select 0

? isNil "numKilled" : numKilled = 0

_enemy addEventHandler ["KILLED", {numKilled = numKilled + 1;}]

Erm, I used the % syntax in the format command for the final message (last code snippet in previous post). ::)