Merge pull request #3962 from acemod/dogtags

Dogtags
This commit is contained in:
Glowbal 2016-06-29 22:19:02 +02:00 committed by GitHub
commit cd08e00c71
35 changed files with 1750 additions and 1 deletions

View File

@ -0,0 +1,15 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,43 @@
class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_Actions {
class ACE_MainActions {
class ACE_Dogtag {
displayName = CSTRING(itemName);
condition = "";
statement = "";
showDisabled = 0;
priority = 3;
icon = QPATHTOF(data\dogtag_icon_ca.paa);
class ACE_CheckDogtag {
displayName = CSTRING(checkDogtag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canCheckDogtag));
statement = QUOTE([ARR_2(_player,_target)] call FUNC(checkDogtag));
showDisabled = 0;
priority = 3;
icon = QPATHTOF(data\dogtag_icon_ca.paa);
};
class ACE_TakeDogtag {
displayName = CSTRING(takeDogtag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeDogtag));
statement = QUOTE([ARR_2(_player,_target)] call FUNC(takeDogtag));
showDisabled = 0;
priority = 3;
icon = QPATHTOF(data\dogtag_icon_ca.paa);
};
};
};
};
class ACE_SelfActions {
class ACE_Equipment {
class ACE_CheckDogtags {
displayName = CSTRING(checkItem);
condition = "true";
statement = "";
insertChildren = QUOTE(_this call DFUNC(addDogtagActions));
};
};
};
};
};

File diff suppressed because it is too large Load Diff

72
addons/dogtags/Dogtag.hpp Normal file
View File

@ -0,0 +1,72 @@
class RscPicture;
class RscStructuredText;
class RscTitles {
class GVAR(singleTag) {
idd = -1;
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(tag)),_this select 0)]);
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(tag)),nil)]);
movingEnable = false;
duration = 5;
fadeIn = 0.2;
fadeOut = 0.2;
class controls {
class background: RscPicture {
idc = 1000;
text = QUOTE(PATHTOF(data\dogtagSingle.paa));
sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
x = ((safezoneX + safezoneW) - (10 * (((safezoneW / safezoneH) min 1.2) / 40)) - 2.9 * (((safezoneW / safezoneH) min 1.2) / 40));
y = safeZoneY + 0.175 * safezoneH;
w = (8 * (((safezoneW / safezoneH) min 1.2) / 40));
h = (8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
font = "EtelkaMonospacePro";
};
class nickname: RscStructuredText {
idc = 1001;
text = "";
sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
x = ((safezoneX + safezoneW) - (8.4 * (((safezoneW / safezoneH) min 1.2) / 40)) - 2.9 * (((safezoneW / safezoneH) min 1.2) / 40));
y = safeZoneY + 0.24 * safezoneH;
w = (5.9 * (((safezoneW / safezoneH) min 1.2) / 40));
h = (3 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
font = "RobotoCondensed";
class Attributes {
font = "RobotoCondensed";
color = "#EEEEEE";
align = "left";
valign = "middle";
shadow = 2;
shadowColor = "#3f4345";
size = "0.80";
};
};
};
};
class GVAR(doubleTag): GVAR(singleTag) {
idd = -1;
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(tag)),_this select 0)]);
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(tag)),nil)]);
class controls: controls {
class background: background {
text = QUOTE(PATHTOF(data\dogtagDouble.paa));
};
class nickname: nickname {
class Attributes: Attributes {
font = "RobotoCondensed";
color = "#EEEEEE";
align = "left";
valign = "middle";
shadow = 2;
shadowColor = "#3f4345";
size = "0.80";
};
};
};
};
};

11
addons/dogtags/README.md Normal file
View File

@ -0,0 +1,11 @@
ace_dogtags
==========
Adds options to check and take dog tag from dead or unconscious units
## Maintainers
The people responsible for merging changes to this component or answering potential questions.
- [SzwedzikPL](https://github.com/SzwedzikPL)

View File

@ -0,0 +1,13 @@
PREP(addDogtagActions);
PREP(addDogtagItem);
PREP(bloodType);
PREP(canCheckDogtag);
PREP(canTakeDogtag);
PREP(checkDogtag);
PREP(checkDogtagItem);
PREP(getDogtagData);
PREP(getDogtagItem);
PREP(sendDogtagData);
PREP(showDogtag);
PREP(ssn);
PREP(takeDogtag);

View File

@ -0,0 +1,45 @@
#include "script_component.hpp"
[QGVAR(showDogtag), DFUNC(showDogtag)] call CBA_fnc_addEventHandler;
[QGVAR(sendDogtagData), DFUNC(sendDogtagData)] call CBA_fnc_addEventHandler;
[QGVAR(getDogtagItem), DFUNC(getDogtagItem)] call CBA_fnc_addEventHandler;
[QGVAR(addDogtagItem), DFUNC(addDogtagItem)] call CBA_fnc_addEventHandler;
//Add actions and event handlers only if ace_medical is loaded
// - Adding actions via config would create a dependency
if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then {
if (hasInterface) then {
private _checkTagAction = [
"ACE_CheckDogtag",
format ["%1: %2", localize LSTRING(itemName), localize LSTRING(checkDogtag)],
QPATHTOF(data\dogtag_icon_ca.paa),
{[_player,_target] call FUNC(checkDogtag)},
{!isNil {_target getVariable QGVAR(dogtagData)}}
] call ace_interact_menu_fnc_createAction;
["ACE_bodyBagObject", 0, ["ACE_MainActions"], _checkTagAction] call EFUNC(interact_menu,addActionToClass);
private _takeTagAction = [
"ACE_TakeDogtag",
format ["%1: %2", localize LSTRING(itemName), localize LSTRING(takeDogtag)],
QPATHTOF(data\dogtag_icon_ca.paa),
{[_player,_target] call FUNC(takeDogtag)},
{(!isNil {_target getVariable QGVAR(dogtagData)}) && {((_target getVariable [QGVAR(dogtagTaken), objNull]) != _target)}}
] call ace_interact_menu_fnc_createAction;
["ACE_bodyBagObject", 0, ["ACE_MainActions"], _takeTagAction] call EFUNC(interact_menu,addActionToClass);
};
if (isServer) then {
["ace_placedInBodyBag", {
params ["_target", "_bodyBag"];
TRACE_2("ace_placedInBodyBag eh",_target,_bodyBag);
private _dogTagData = [_target] call FUNC(getDogtagData);
_bodyBag setVariable [QGVAR(dogtagData), _dogTagData, true];
if ((_target getVariable [QGVAR(dogtagTaken), objNull]) == _target) then {
_bodyBag setVariable [QGVAR(dogtagTaken), _bodyBag, true];
};
}] call CBA_fnc_addEventHandler;
};
};

View File

@ -0,0 +1,7 @@
#include "script_component.hpp"
ADDON = false;
#include "XEH_PREP.hpp"
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

18
addons/dogtags/config.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"SzwedzikPL"};
authorUrl = "https://github.com/SzwedzikPL/";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgWeapons.hpp"
#include "CfgVehicles.hpp"
#include "Dogtag.hpp"

Binary file not shown.

View File

@ -0,0 +1,82 @@
class StageTI {
texture = "a3\data_f\default_glass_ti_ca.paa";
};
ambient[] = {1,1,1,1};
diffuse[] = {1,1,1,1};
forcedDiffuse[] = {0,0,0,0};
emmisive[] = {0,0,0,1};
specular[] = {0.3,0.3,0.3,1};
specularPower = 50;
PixelShaderID = "Super";
VertexShaderID = "Super";
class Stage1 {
texture = "z\ace\addons\dogtags\data\dogtag_nohq.paa";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage2 {
texture = "#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage3 {
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage4 {
texture = "#(argb,8,8,3)color(1,1,1,1,AS)";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage5 {
texture = "#(argb,8,8,3)color(0,0.6,1,1,SMDI)";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage6 {
texture = "#(ai,32,128,1)fresnel(0.85,0.36)";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};
class Stage7 {
useWorldEnvMap = "true";
texture = "a3\data_f\env_interier_car_ca.paa";
uvSource = "tex";
class uvTransform {
aside[] = {1,0,0};
up[] = {0,1,0};
dir[] = {0,0,1};
pos[] = {0,0,0};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
class CfgSkeletons {
class Default {
isDiscrete = 1;
skeletonInherit = "";
skeletonBones[] = {};
};
};
class CfgModels {
class Default {
sectionsInherit = "";
sections[] = {""};
skeletonName = "Default";
};
class ace_dogtag: Default {};
};

View File

@ -0,0 +1,40 @@
/*
* Author: SzwedzikPL
* Creates one action per dogtag.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Children actions <ARRAY>
*
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_player"];
//Get all dogtags and their ids
private _unitDogtags = [];
private _unitDogtagIDs = [];
{
private _id = getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(tagID));
if (_id > 0) then {
_unitDogtags pushBack _x;
_unitDogtagIDs pushBack _id;
};
} forEach items _player;
//Create action children for all dogtags
private _actions = [];
{
private _tagID = _unitDogtagIDs select _forEachIndex;
private _displayName = format ["%1 #%2", getText (configFile >> "CfgWeapons" >> _x >> "displayName"), _tagID];
private _picture = getText (configFile >> "CfgWeapons" >> _x >> "picture");
private _action = [_x, _displayName, _picture, {_this call FUNC(checkDogtagItem)}, {true}, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _player];
} forEach _unitDogtags;
_actions

View File

@ -0,0 +1,24 @@
/*
* Author: SzwedzikPL
* Adds dogtag item to unit (triggered by server)
*
* Arguments:
* 0: Item class <STRING>
* 1: Dogtag data <ARRAY>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_item", "_dogtagData"];
if (_item == "") exitWith {};
[ace_player, _item] call CBA_fnc_addItem;
_dogtagData params ["_nickName"];
private _displayText = format [localize LSTRING(takeDogtagSuccess), _nickName];
[_displayText] call EFUNC(common,displayText);

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

@ -0,0 +1,20 @@
/*
* Author: SzwedzikPL
* Checks if dogtag can be checked.
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* True if dogtag can be checked <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target"];
if (isNull _target) exitWith {false};
(!alive _target) || {_target getVariable ["ACE_isUnconscious", false]}

View File

@ -0,0 +1,20 @@
/*
* Author: SzwedzikPL
* Checks if dogtag can be taken.
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* True if dogtag can be taken <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target"];
if (isNull _target) exitWith {false};
(!alive _target) || {_target getVariable ["ACE_isUnconscious", false]}

View File

@ -0,0 +1,21 @@
/*
* Author: SzwedzikPL
* Checks unit dogtag
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target"];
private _doubleTags = (_target getVariable [QGVAR(dogtagTaken), objNull]) != _target;
private _dogTagData = [_target] call FUNC(getDogTagData);
[QGVAR(showDogtag), [_dogTagData, _doubleTags]] call CBA_fnc_localEvent;

View File

@ -0,0 +1,19 @@
/*
* Author: SzwedzikPL
* Check dogtag self menu action
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
* 2: Item class <STRING>
*
* Return Value:
* Mone
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target", "_item"];
[QGVAR(sendDogtagData), [_player, _item]] call CBA_fnc_serverEvent;

View File

@ -0,0 +1,31 @@
/*
* Author: esteldunedain
* Get unit dogtag data
*
* Arguments:
* 0: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_target"];
// Check if the data was already created
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 = [
_targetName,
_targetName call FUNC(ssn),
_targetName call FUNC(bloodType)
];
// Store it
_target setVariable [QGVAR(dogtagData), _dogTagData, true];
_dogTagData

View File

@ -0,0 +1,36 @@
/*
* Author: SzwedzikPL
* Server: creates new dogtag item and send it to client
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
if(!isServer) exitWith {};
params ["_player", "_target"];
TRACE_2("getDogtagItem",_player,_target);
private _allDogtags = missionNamespace getVariable [QGVAR(allDogtags), []];
private _allDogtagDatas = missionNamespace getVariable [QGVAR(allDogtagDatas), []];
private _nextID = count _allDogtags + 1;
if (_nextID > 999) exitWith {ACE_LOGERROR("Ran out of IDs");};
private _dogTagData = [_target] call FUNC(getDogTagData);
private _item = format ["ACE_dogtag_%1", _nextID];
_allDogtags pushBack _item;
_allDogtagDatas pushBack _dogTagData;
missionNamespace setVariable [QGVAR(allDogtags), _allDogtags];
missionNamespace setVariable [QGVAR(allDogtagDatas), _allDogtagDatas];
[QGVAR(addDogtagItem), [_item, _dogTagData], [_player]] call CBA_fnc_targetEvent;

View File

@ -0,0 +1,30 @@
/*
* Author: SzwedzikPL
* Server: returns to client data on given dogtag
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
if(!isServer) exitWith {};
params ["_target", "_item"];
TRACE_2("sendDogtagData",_target,_item);
private _allDogtags = missionNameSpace getVariable [QGVAR(allDogtags), []];
private _allDogtagDatas = missionNameSpace getVariable [QGVAR(allDogtagDatas), []];
private _dogtagData = [];
private _index = _allDogtags find _item;
if (_index >= 0) then {
_dogtagData = _allDogtagDatas select _index;
};
[QGVAR(showDogtag), [_dogtagData], [_target]] call CBA_fnc_targetEvent;

View File

@ -0,0 +1,32 @@
/*
* Author: SzwedzikPL
* Shows dogtag
*
* Arguments:
* 0: Dog tag data <ARRAY>
* 1: Display as double tag <BOOLEAN>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
params ["_dogtagData", ["_doubleTags", false, [false]]];
if (!hasInterface || {_dogtagData isEqualTo []}) exitWith {};
if (_doubleTags) then {
(QGVAR(tag) call BIS_fnc_rscLayer) cutRsc [QGVAR(doubleTag), "PLAIN", 1, true];
} else {
(QGVAR(tag) call BIS_fnc_rscLayer) cutRsc [QGVAR(singleTag), "PLAIN", 1, true];
};
private _display = uiNamespace getvariable [QGVAR(tag), displayNull];
if(isNull _display) exitWith {};
private _control = _display displayCtrl 1001;
_dogtagData params ["_nickName", "_code", "_bloodType"];
_control ctrlSetStructuredText parseText format ["%1<br/>%2<br/>%3", toUpper _nickName, _code, _bloodType];

View File

@ -0,0 +1,31 @@
/*
* Author: SilentSpike
* Reports a social security number generated from the units name.
*
* Arguments:
* 0: Name of a unit <STRING>
*
* Return Value:
* A random three/two/four format social security number <STRING>
*
* Public: No
*/
#include "script_component.hpp"
params ["_name"];
private _length = count _name;
private _chars = toArray _name;
// For short names, reuse characters
if (_length < 9) then {
// Iterates every second character, swapping odd/even with each loop
for [{_i = 0},{_i < 2*(9 - _length)},{_i = _i + 2}] do {
_chars pushBack (_chars select floor((_i + (_i/_length % 2)) % _length));
};
};
// Offset array slice for long names to make generation more unique
private _slice = [0, _length % 9] select (_length > 9);
private _nums = (_chars select [_slice, 9]) apply { _x % 10 };
([_nums select [0,3],_nums select [3,2], _nums select [5,4]] apply { _x joinString "" }) joinString "-"

View File

@ -0,0 +1,24 @@
/*
* Author: SzwedzikPL
* If dogtag is not already taken triggers event on server
* If dogtag already taken displays info about it
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target"];
if ((_target getVariable [QGVAR(dogtagTaken), objNull]) == _target) then {
[localize LSTRING(dogtagAlreadyTaken)] call EFUNC(common,displayText);
} else {
_target setVariable [QGVAR(dogtagTaken), _target, true];
[QGVAR(getDogtagItem), [_player, _target]] call CBA_fnc_serverEvent;
};

View File

@ -0,0 +1 @@
#include "\z\ace\addons\dogtags\script_component.hpp"

View File

@ -0,0 +1,17 @@
#define COMPONENT dogtags
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define CBA_DEBUG_SYNCHRONOUS
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_DOGTAGS
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_DOGTAGS
#define DEBUG_SETTINGS DEBUG_SETTINGS_DOGTAGS
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Dogtags">
<Key ID="STR_ACE_Dogtags_itemName">
<English>Dog Tag</English>
<Polish>Nieśmiertelnik</Polish>
</Key>
<Key ID="STR_ACE_Dogtags_checkItem">
<English>Check Dog Tag</English>
<Polish>Sprawdź nieśmiertelnik</Polish>
</Key>
<Key ID="STR_ACE_Dogtags_checkDogtag">
<English>Check</English>
<Polish>Sprawdź</Polish>
</Key>
<Key ID="STR_ACE_Dogtags_takeDogtag">
<English>Take</English>
<Polish>Zabierz</Polish>
</Key>
<Key ID="STR_ACE_Dogtags_takeDogtagSuccess">
<English>Dogtag taken from %1...</English>
<Polish>Zabrałeś nieśmiertelnik %1...</Polish>
</Key>
<Key ID="STR_ACE_Dogtags_dogtagAlreadyTaken">
<English>Somebody else has already taken the dogtag...</English>
<Polish>Ktoś już zabrał ten nieśmiertelnik...</Polish>
</Key>
</Package>
</Project>

View File

@ -27,7 +27,7 @@ if (isNil QGVAR(bodiesToDelete)) then {GVAR(bodiesToDelete) = [];};
GVAR(bodiesToDelete) pushBack _target;
// Start up a loop to wait for bodies to be free to delete
if ((count GVAR(bodiesToDelete)) > 0) then {
if ((count GVAR(bodiesToDelete)) == 1) then {
[] call FUNC(bodyCleanupLoop);
};