Home   Help Search Login Register  

Author Topic: Body Count Script  (Read 1254 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Body Count Script
« 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.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Body Count Script
« Reply #1 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];
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Body Count Script
« Reply #2 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?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Body Count Script
« Reply #3 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). ::)
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)