Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dogtags #3600

Closed
wants to merge 10 commits into from
Closed

Dogtags #3600

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions addons/dogtags/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
43 changes: 43 additions & 0 deletions addons/dogtags/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
};
};
};
16 changes: 16 additions & 0 deletions addons/dogtags/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -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 changes: 50 additions & 0 deletions addons/dogtags/Dogtag.hpp
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions addons/dogtags/README.md
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions addons/dogtags/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREP(addDogtagActions);
PREP(addDogtagItem);
PREP(canCheckDogtag);
PREP(canTakeDogtag);
PREP(checkDogtag);
PREP(checkDogtagItem);
PREP(getDogtagItem);
PREP(sendDogtagData);
PREP(showDogtag);
PREP(takeDogtag);
6 changes: 6 additions & 0 deletions addons/dogtags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -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);
7 changes: 7 additions & 0 deletions addons/dogtags/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "script_component.hpp"

ADDON = false;

#include "XEH_PREP.hpp"

ADDON = true;
3 changes: 3 additions & 0 deletions addons/dogtags/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
18 changes: 18 additions & 0 deletions addons/dogtags/config.cpp
Original file line number Diff line number Diff line change
@@ -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 added addons/dogtags/data/dogtag.paa
Binary file not shown.
40 changes: 40 additions & 0 deletions addons/dogtags/functions/fnc_addDogtagActions.sqf
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushBack

};
} 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
23 changes: 23 additions & 0 deletions addons/dogtags/functions/fnc_addDogtagItem.sqf
Original file line number Diff line number Diff line change
@@ -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 {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (


[ace_player, _item] call CBA_fnc_addItem;

private _displayText = format [localize LSTRING(takeDogtagSuccess), _nickname];
[_displayText] call EFUNC(common,displayText);
20 changes: 20 additions & 0 deletions addons/dogtags/functions/fnc_canCheckDogtag.sqf
Original file line number Diff line number Diff line change
@@ -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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


!alive _target
20 changes: 20 additions & 0 deletions addons/dogtags/functions/fnc_canTakeDogtag.sqf
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions addons/dogtags/functions/fnc_checkDogtag.sqf
Original file line number Diff line number Diff line change
@@ -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);
};
19 changes: 19 additions & 0 deletions addons/dogtags/functions/fnc_checkDogtagItem.sqf
Original file line number Diff line number Diff line change
@@ -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);
40 changes: 40 additions & 0 deletions addons/dogtags/functions/fnc_getDogtagItem.sqf
Original file line number Diff line number Diff line change
@@ -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);
};
Loading