Initial commit dogtags

This commit is contained in:
SzwedzikPL 2016-03-19 16:17:26 +01:00
parent e96c1a7dc6
commit ca3171a33a
24 changed files with 1564 additions and 0 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 = ""; //@todo
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 = ""; //@todo
};
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 = ""; //@todo
};
};
};
};
class ACE_SelfActions {
class ACE_Equipment {
class ACE_CheckDogtags {
displayName = CSTRING(checkItem);
condition = "true";
statement = "";
insertChildren = QUOTE(_this call DFUNC(addDogtagActions));
};
};
};
};
};

View File

@ -0,0 +1,16 @@
class CfgWeapons {
class ACE_ItemCore;
class InventoryItem_Base_F;
class ACE_dogtag: ACE_ItemCore {
author = ECSTRING(common,ACETeam);
scope = 0;
displayName = CSTRING(itemName);
model = "\A3\weapons_F\ammo\mag_univ.p3d"; //@todo?
//picture = QUOTE(PATHTOF(images\picture.paa)); @todo
class ItemInfo: InventoryItem_Base_F {
mass = 0; //too small to for 1 ?
};
};
ACE_DOGTAGS(ACE_dogtag)
};

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

@ -0,0 +1,50 @@
class RscPicture;
class RscStructuredText;
class RscTitles {
class GVAR(tag) {
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\dogtag.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 = (4 * ((((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.2 * safezoneH;
w = (5.9 * (((safezoneW / safezoneH) min 1.2) / 40));
h = (4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
font = "EtelkaMonospacePro";
class Attributes {
font = "EtelkaMonospacePro";
color = "#FFFFFF";
align = "center";
valign = "middle";
shadow = 1;
shadowColor = "#3f4345";
size = "0.85";
};
};
};
};
};

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 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,10 @@
PREP(addDogtagActions);
PREP(addDogtagItem);
PREP(canCheckDogtag);
PREP(canTakeDogtag);
PREP(checkDogtag);
PREP(checkDogtagItem);
PREP(getDogtagItem);
PREP(sendDogtagData);
PREP(showDogtag);
PREP(takeDogtag);

View File

@ -0,0 +1,6 @@
#include "script_component.hpp"
[QGVAR(showDogtag), DFUNC(showDogtag)] call EFUNC(common,addEventHandler);
[QGVAR(sendDogtagData), DFUNC(sendDogtagData)] call EFUNC(common,addEventHandler);
[QGVAR(getDogtagItem), DFUNC(getDogtagItem)] call EFUNC(common,addEventHandler);
[QGVAR(addDogtagItem), DFUNC(addDogtagItem)] call EFUNC(common,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,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,23 @@
/*
* Author: SzwedzikPl
* Adds dogtag item to unit (triggered by server)
*
* Arguments:
* 0: Item class <STRING>
* 1: Nickname on dogtag <STRING>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_item", "_nickname"];
if(_item == "") exitWith {};
[ace_player, _item] call CBA_fnc_addItem;
private _displayText = format [localize LSTRING(takeDogtagSuccess), _nickname];
[_displayText] call EFUNC(common,displayText);

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

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

View File

@ -0,0 +1,23 @@
/*
* Author: SzwedzikPl
* Checks unit dogtag
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target"];
if(_target getVariable [QGVAR(dogtagTaken), false]) then {
[localize LSTRING(noDogtag)] call EFUNC(common,displayText);
} else {
private _nickname = [_target, false, true] call EFUNC(common,getName);
[QGVAR(showDogtag), [_nickname]] call EFUNC(common,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 EFUNC(common,serverEvent);

View File

@ -0,0 +1,40 @@
/*
* 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 ["_target", "_unit"];
TRACE_2("getDogtagItem",_target,_unit);
private _allDogtags = missionNameSpace getVariable [QGVAR(allDogtags), []];
private _allDogtagNicknames = missionNameSpace getVariable [QGVAR(allDogtagNicknames), []];
private _nextID = count _allDogtags + 1;
if(_nextID > 999) exitWith {};
private _nickname = [_unit, false, true] call EFUNC(common,getName);
private _item = format ["ACE_dogtag_%1", _nextID];
_allDogtags pushBack _item;
_allDogtagNicknames pushBack _nickname;
missionNameSpace setVariable [QGVAR(allDogtags), _allDogtags];
missionNameSpace setVariable [QGVAR(allDogtagNicknames), _allDogtagNicknames];
if(isMultiplayer) then {
[QGVAR(addDogtagItem), [_target], [_item]] call EFUNC(common,targetEvent);
} else {
[QGVAR(addDogtagItem), [_item, _nickname]] call EFUNC(common,localEvent);
};

View File

@ -0,0 +1,30 @@
/*
* Author: SzwedzikPl
* Server: returns to client nickname 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 _allDogtagNicknames = missionNameSpace getVariable [QGVAR(allDogtagNicknames), []];
private _nickname = "";
private _index = _allDogtags find _item;
if(_index >= 0) then {
_nickname = _allDogtagNicknames select _index;
};
[QGVAR(showDogtag), [_target], [_nickname]] call EFUNC(common,targetEvent);

View File

@ -0,0 +1,27 @@
/*
* Author: SzwedzikPL
* Shows dogtag
*
* Arguments:
* 0: Nickname <STRING>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
params ["_nickname"];
if(!hasInterface || {_nickname == ""}) exitWith {};
(QGVAR(tag) call BIS_fnc_rscLayer) cutRsc [QGVAR(tag), "PLAIN", 1, true];
private _display = uiNamespace getvariable [QGVAR(tag), displayNull];
if(isNull _display) exitWith {};
private _control = _display displayCtrl 1001;
_control ctrlSetText _nickname;

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), false]) then {
[localize LSTRING(dogtagAlreadyTaken)] call EFUNC(common,displayText);
} else {
_target setVariable [QGVAR(dogtagTaken), true, true];
[QGVAR(getDogtagItem), [_player, _target]] call EFUNC(common,serverEvent);
};

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Dogtags">
<Key ID="STR_ACE_Dogtags_itemName">
<English>Dog Tag</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Nieśmiertelnik</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_checkItem">
<English>Check Dog Tag</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Sprawdź nieśmiertelnik</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_checkDogtag">
<English>Check</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Sprawdź</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_takeDogtag">
<English>Take</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Zabierz</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_takeDogtagSuccess">
<English>Dogtag taken from %1...</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Zabrałeś nieśmiertelnik %1...</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_noDogtag">
<English>I can't seem to find his dogtag!</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Brak nieśmiertelnika</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
<Key ID="STR_ACE_Dogtags_dogtagAlreadyTaken">
<English>Somebody else has already taken the dogtag...</English>
<German></German>
<French></French>
<Czech></Czech>
<Polish>Ktoś już zabrał ten nieśmiertelnik...</Polish>
<Spanish></Spanish>
<Hungarian></Hungarian>
<Russian></Russian>
<Italian></Italian>
<Portuguese></Portuguese>
</Key>
</Package>
</Project>