add function to report a blood type which is fixed to the units name

This commit is contained in:
commy2 2016-06-20 21:50:00 +02:00
parent 6df82aad55
commit c88313221f
3 changed files with 29 additions and 3 deletions

View File

@ -1,5 +1,6 @@
PREP(addDogtagActions);
PREP(addDogtagItem);
PREP(bloodType);
PREP(canCheckDogtag);
PREP(canTakeDogtag);
PREP(checkDogtag);

View File

@ -0,0 +1,24 @@
/*
* Author: commy2
* Reports a blood type depending on the units name.
*
* Arguments:
* 0: Name of a unit <STRING>
*
* Return Value:
* A random blood type <STRING>
*
* Public: No
*/
#include "script_component.hpp"
#define BLOOD_TYPES ["O POS", "O NEG", "A POS", "A NEG", "B POS", "B NEG", "AB POS", "AB NEG"]
params ["_name"];
private _num = 0;
private _count = {_num = _num + _x} count toArray _name;
_num = _num + _count;
BLOOD_TYPES select (_num % count BLOOD_TYPES)

View File

@ -19,13 +19,14 @@ private _dogTagData = _target getVariable QGVAR(dogtagData);
if (!isNil "_dogTagData") exitWith {_dogTagData};
// Create dog tag data once for the unit: nickname, code (eg. 135-13-900) and blood type
private _targetName = [_target, false, true] call EFUNC(common,getName);
private _dogTagData = [
[_target, false, true] call EFUNC(common,getName),
_targetName,
str(floor random 9) + str(floor random 9) + str(floor random 9) + "-" +
str(floor random 9) + str(floor random 9) + "-" +
str(floor random 9) + str(floor random 9) + str(floor random 9),
selectRandom ["O POS", "O NEG", "A POS", "A NEG", "B POS", "B NEG",
"AB POS", "AB NEG"]
_targetName call FUNC(bloodType)
];
// Store it
_target setVariable [QGVAR(dogtagData), _dogTagData, true];