diff --git a/addons/attach/$PBOPREFIX$ b/addons/attach/$PBOPREFIX$ new file mode 100644 index 0000000000..1e4e48a4ca --- /dev/null +++ b/addons/attach/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\Addons\laser \ No newline at end of file diff --git a/addons/attach/CfgEventHandlers.hpp b/addons/attach/CfgEventHandlers.hpp new file mode 100644 index 0000000000..8af0265fe2 --- /dev/null +++ b/addons/attach/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE( call compile preprocessFileLineNumbers PATHTOF(XEH_preInit.sqf) ); + }; +}; \ No newline at end of file diff --git a/addons/attach/UI/attach_ca.paa b/addons/attach/UI/attach_ca.paa new file mode 100644 index 0000000000..ec545508ba Binary files /dev/null and b/addons/attach/UI/attach_ca.paa differ diff --git a/addons/attach/UI/detach_ca.paa b/addons/attach/UI/detach_ca.paa new file mode 100644 index 0000000000..886c494d90 Binary files /dev/null and b/addons/attach/UI/detach_ca.paa differ diff --git a/addons/attach/UI/irstrobe_item.paa b/addons/attach/UI/irstrobe_item.paa new file mode 100644 index 0000000000..376ea4c906 Binary files /dev/null and b/addons/attach/UI/irstrobe_item.paa differ diff --git a/addons/attach/XEH_preInit.sqf b/addons/attach/XEH_preInit.sqf new file mode 100644 index 0000000000..311aa874ec --- /dev/null +++ b/addons/attach/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +PREPF(attach); +PREPF(canAttach); +PREPF(canDetach); +PREPF(detach); +PREPF(openAttachUI); \ No newline at end of file diff --git a/addons/attach/config.cpp b/addons/attach/config.cpp new file mode 100644 index 0000000000..c5054ebd6e --- /dev/null +++ b/addons/attach/config.cpp @@ -0,0 +1,165 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {"AGM_IR_Strobe_Item"}; + requiredVersion = 0.60; + requiredAddons[] = {AGM_Core, AGM_Interaction}; + version = "0.95"; + versionStr = "0.95"; + versionAr[] = {0,95,0}; + author[] = {"KoffeinFlummi", "eRazeri", "CAA-Picard"}; + authorUrl = "https://github.com/KoffeinFlummi/"; + }; +}; + +#include "CfgEventHandlers.hpp" + +/* +class CfgFunctions { + class ADDON { + class ADDON { + file = PATHTOF(functions); + class attach; + class canAttach; + class canDetach; + class detach; + class openAttachUI; + }; + }; +}; +*/ + +#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ + name = #ITEM; \ + count = COUNT; \ +}; + +class CfgVehicles { + class Man; + class CAManBase: Man { + class AGM_SelfActions { + class AGM_Equipment { + class GVAR(Attach) { + displayName = "$STR_AGM_Attach_AttachDetach"; + condition = QUOTE( [_player, ''] call FUNC(canAttach) ); + statement = QUOTE( [_player] call FUNC(openAttachUI); ); + exceptions[] = {"AGM_Drag_isNotDragging"}; + showDisabled = 0; + priority = 5; + icon = PATHTOF(UI\attach_ca.paa); + hotkey = "T"; + }; + class GVAR(Detach) { + displayName = "$STR_AGM_Attach_Detach"; + condition = QUOTE( [_player] call FUNC(canDetach ); + statement = QUOTE( [_player] call FUNC(detach) ); + exceptions[] = {"AGM_Drag_isNotDragging"}; + showDisabled = 0; + priority = 5; + icon = PATHTOF(UI\detach_ca.paa); + hotkey = "T"; + }; + }; + }; + }; + + class All; + class AGM_IR_Strobe_Effect: All { + scope = 1; + displayName = "IR Strobe"; + model = "\A3\Weapons_F\empty.p3d"; + simulation = "nvmarker"; + + class NVGMarker { + diffuse[] = {0,0,0}; + ambient[] = {0,0,0}; + brightness = 0.004; + name = "pozicni blik"; + drawLight = 1; + drawLightSize = 0.005; + drawLightCenterSize = 0.003; + activeLight = 0; + blinking=1; + dayLight = 0; + onlyInNvg = 1; + useFlare = 0; + }; + side = 7;//-1=NO_SIDE yellow box,3=CIV grey box,4=NEUTRAL yellow box,6=FRIENDLY green box,7=LOGIC no radar signature + accuracy = 1000; + cost = 0; + armor = 500; + threat[] = {0,0,0}; + nameSound = ""; + type = 0; + weapons[] = {}; + magazines[] = {}; + nvTarget = 1; + destrType = "DestructNo"; + brightness = 20; + }; + + class NATO_Box_Base; + class EAST_Box_Base; + class IND_Box_Base; + class FIA_Box_Base_F; + + class Box_NATO_Support_F: NATO_Box_Base { + class TransportItems { + MACRO_ADDITEM(AGM_IR_Strobe_Item,12) + }; + }; + + class Box_East_Support_F: EAST_Box_Base { + class TransportItems { + MACRO_ADDITEM(AGM_IR_Strobe_Item,12) + }; + }; + + class Box_IND_Support_F: IND_Box_Base { + class TransportItems { + MACRO_ADDITEM(AGM_IR_Strobe_Item,12) + }; + }; + + class Box_FIA_Support_F: FIA_Box_Base_F { + class TransportItems { + MACRO_ADDITEM(AGM_IR_Strobe_Item,12) + }; + }; + + class AGM_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(AGM_IR_Strobe_Item,12) + }; + }; +}; + +class CfgWeapons { + class AGM_ItemCore; + class InventoryItem_Base_F; + + class AGM_IR_Strobe_Item: AGM_ItemCore { + displayName = "$STR_AGM_IrStrobe_Name"; + descriptionShort = "$STR_AGM_IrStrobe_Description"; + model = "\A3\weapons_F\ammo\mag_univ.p3d"; + picture = PATHTOF(UI\irstrobe_item.paa); + scope = 2; + AGM_attachable = 1; + class ItemInfo: InventoryItem_Base_F { + mass = 1; + }; + }; +}; + +class CfgMagazines { + class CA_Magazine; + class B_IR_Grenade: CA_Magazine { + AGM_Attachable = 1; + }; + class SmokeShell; + class Chemlight_green: SmokeShell { + AGM_Attachable = 1; + }; +}; diff --git a/addons/attach/functions/fnc_attach.sqf b/addons/attach/functions/fnc_attach.sqf new file mode 100644 index 0000000000..b4cf675096 --- /dev/null +++ b/addons/attach/functions/fnc_attach.sqf @@ -0,0 +1,62 @@ +#include "script_component.hpp" + +/* +Author: eRazeri and CAA-Picard + +Attach an item to the unit + +Arguments: +0: unit +1: Item name + +Return Value: +none +*/ + +private ["_unit", "_itemName", "_attachedItem"]; + +_unit = _this select 0; +_itemName = _this select 1; + +// Check if unit has an attached item +if (_unit getVariable [QGVAR(ItemName), ""] != "") exitWith {}; + +// Check if the unit still has the item +if !((_itemName in items _unit) or (_itemName in magazines _unit)) exitWith {}; + +// Attach item +switch true do { + case (_itemName == "AGM_IR_Strobe_Item") : { + _attachedItem = "AGM_IR_Strobe_Effect" createVehicle [0,0,0]; + _attachedItem attachTo [_unit,[0,-0.11,0.16],"pilot"];//makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri + [localize "STR_AGM_Attach_IrStrobe_Attached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "B_IR_Grenade") : { + _attachedItem = "B_IRStrobe" createVehicle [0,0,0]; + _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; + [localize "STR_AGM_Attach_IrGrenade_Attached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "O_IR_Grenade") : { + _attachedItem = "O_IRStrobe" createVehicle [0,0,0]; + _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; + [localize "STR_AGM_Attach_IrGrenade_Attached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "I_IR_Grenade") : { + _attachedItem = "I_IRStrobe" createVehicle [0,0,0]; + _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; + [localize "STR_AGM_Attach_IrGrenade_Attached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { + _attachedItem = _itemName createVehicle [0,0,0]; + _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; + [localize "STR_AGM_Attach_Chemlight_Attached"] call EFUNC(core,displayTextStructured);; + }; + default { + if (true) exitWith {}; + }; +}; + +// Remove item +_unit removeItem _itemName; +_unit setVariable [QGVAR(ItemName), _itemName, true]; +_unit setVariable [QGVAR(Item), _attachedItem, true]; diff --git a/addons/attach/functions/fnc_canAttach.sqf b/addons/attach/functions/fnc_canAttach.sqf new file mode 100644 index 0000000000..fe5191d7e2 --- /dev/null +++ b/addons/attach/functions/fnc_canAttach.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +/* + * Author: commy2 + * + * Check if a unit can attach a specific item. + * + * Argument: + * 0: Unit that wants to attach the object (Object) + * 1: Name of the attachable item (String) + * + * Return value: + * Boolean (Bool) + */ + +private ["_unit", "_item"]; + +_unit = _this select 0; +_item = _this select 1; + +canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] == ""} && {_item in (magazines _unit + items _unit + [""])} diff --git a/addons/attach/functions/fnc_canDetach.sqf b/addons/attach/functions/fnc_canDetach.sqf new file mode 100644 index 0000000000..3ddfc6c11e --- /dev/null +++ b/addons/attach/functions/fnc_canDetach.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +/* + * Author: commy2 + * + * Check if a unit has an item attached and if it can remove that item. + * + * Argument: + * 0: Unit that wants to detach something (Object) + * + * Return value: + * Boolean (Bool) + */ + +private "_unit"; + +_unit = _this select 0; + +canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] != ""} diff --git a/addons/attach/functions/fnc_detach.sqf b/addons/attach/functions/fnc_detach.sqf new file mode 100644 index 0000000000..415429440b --- /dev/null +++ b/addons/attach/functions/fnc_detach.sqf @@ -0,0 +1,65 @@ +#include "script_component.hpp" + +/* +Author: eRazeri and CAA-Picard + +Detach an item from a unit + +Arguments: +unit + +Return Value: +none +*/ + +private ["_unit", "_itemName", "_count", "_attachedItem"]; + +_unit = _this select 0; +_itemName = _unit getVariable [QGVAR(ItemName), ""]; + +// Check if unit has an attached item +if (_itemName == "") exitWith {}; + +// Add item to inventory +_count = (count items _unit) + (count magazines _unit); +_unit addItem _itemName; +if ((count items _unit) + (count magazines _unit) <= _count) exitWith { + [localize "STR_AGM_Attach_Inventory_Full"] call EFUNC(core,displayTextStructured); +}; + +if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { + // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle + [_unit getVariable QGVAR(Item), _unit] spawn { + _attachedItem = _this select 0; + _unit = _this select 1; + detach _attachedItem; + _attachedItem setPos [getPos _unit select 0, getPos _unit select 1, (getPos _unit select 2) -1000]; + sleep 0.5; + deleteVehicle _attachedItem; + }; +} +else +{ + // Delete attached item + deleteVehicle (_unit getVariable QGVAR(Item)); +}; + +// Reset unit variables +_unit setVariable [QGVAR(ItemName),"", true]; +_unit setVariable [QGVAR(Item),nil, true]; + +// Display message +switch true do { + case (_itemName == "AGM_IR_Strobe_Item") : { + [localize "STR_AGM_Attach_IrStrobe_Detached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : { + [localize "STR_AGM_Attach_IrGrenade_Detached"] call EFUNC(core,displayTextStructured); + }; + case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { + [localize "STR_AGM_Attach_Chemlight_Detached"] call EFUNC(core,displayTextStructured); + }; + default { + if (true) exitWith {}; + }; +}; diff --git a/addons/attach/functions/fnc_openAttachUI.sqf b/addons/attach/functions/fnc_openAttachUI.sqf new file mode 100644 index 0000000000..5af80d2c9e --- /dev/null +++ b/addons/attach/functions/fnc_openAttachUI.sqf @@ -0,0 +1,65 @@ +#include "script_component.hpp" + +/* + Name: AGM_Attach_fnc_openAttachUI + + Author: Garth de Wet (LH) + + Description: + Opens the UI for attaching objects. + + Parameters: + 0: OBJECT - unit + + Returns: + Nothing + + Example: + [player] call AGM_Attach_fnc_openAttachUI; +*/ +private ["_unit", "_actions", "_attachables", "_item"]; +_unit = _this select 0; +_listed = []; +_attachables = magazines _unit; +_actions = [localize "STR_AGM_Attach_AttachDetach", localize "STR_AGM_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu); +{ + if !(_x in _listed) then { + _item = ConfigFile >> "CfgMagazines" >> _x; + if (getNumber (_item >> "AGM_Attachable") == 1) then { + _actions = [ + _actions, + getText(_item >> "displayName"), + getText(_item >> "picture"), + _x + ] call EFUNC(interaction,addSelectableItem); + }; + _listed pushBack _x; + }; +} forEach _attachables; +_attachables = items _unit; +{ + if !(_x in _listed) then { + _item = ConfigFile >> "CfgWeapons" >> _x; + if (getNumber (_item >> "AGM_Attachable") == 1) then { + _actions = [ + _actions, + getText(_item >> "displayName"), + getText(_item >> "picture"), + _x + ] call EFUNC(interaction,addSelectableItem); + }; + _listed pushBack _x; + }; +} forEach _attachables; + +[ + _actions, + { + [AGM_player, _this] call FUNC(attach); + call EFUNC(interaction,hideMenu); + }, + { + call EFUNC(interaction,hideMenu); + if !(profileNamespace getVariable [EQGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; + } +] call EFUNC(interaction,openSelectMenu); diff --git a/addons/attach/script_component.hpp b/addons/attach/script_component.hpp new file mode 100644 index 0000000000..c09a5b97e1 --- /dev/null +++ b/addons/attach/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT attach +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_ATTACH + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_ATTACH + #define DEBUG_SETTINGS DEBUG_SETTINGS_ATTACH +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/attach/stringtable.xml b/addons/attach/stringtable.xml new file mode 100644 index 0000000000..895dff95c7 --- /dev/null +++ b/addons/attach/stringtable.xml @@ -0,0 +1,150 @@ + + + + + + Attach item >> + Gegenstand befestigen >> + Acoplar objeto >> + Przyczep przedmiot >> + Attacher l'objet >> + Připnout předmět >> + Acoplar item >> + Attacca l'oggetto >> + Tárgy hozzácsatolása >> + Добавить приспособления + + + Attach + Befestigen + Acoplar + Przyczep + Attacher + Připnout + Acoplar + Attacca + Hozzácsatolás + Присоединить + + + Detach item + Gegenstand entfernen + Quitar objeto + Odczep przedmiot + Détacher l'objet + Odepnout předmět + Separar item + Stacca l'oggetto + Tárgy lecsatolása + Отсоединить + + + IR Strobe Attached + IR-Stroboskop befestigt + Marcador IR acoplado + Przyczepiono stroboskop IR + Strobe IR attaché + IR Značkovač Připnutý + Marcador IV Acoplado + Strobo IR attaccata + Infravörös jeladó hozzácsatolva + ИК строб присоединён + + + IR Strobe Detached + IR-Stroboskop entfernt + Marcador IR quitado + Odczepiono stroboskop IR + Strobe IR détaché + IR Značkovač Odepnutý + Marcador IV Separado + Strobo IR staccata + Infravörös jeladó lecsatolva + ИК строб отсоединён + + + IR Grenade Attached + IR-Granate befestigt + Granada IR acoplada + Przyczepiono granat IR + Grenade IR attachée + IR Granát Připnutý + Granada IV Acoplada + Granata IR attaccata + Infravörös gránát hozzácsatolva + ИК граната присоединена + + + IR Grenade Detached + IR-Granate entfernt + Granada IR quitada + Odczepiono granat IR + Grenade IR détachée + IR Granát Odepnutý + Granada IV Separada + Granata IR staccata + Infravörös gránát lecsatolva + ИК граната отсоединена + + + Chemlight Attached + Leuchtstab befestigt + Barra de luz acoplada + Przyczepiono światło chemiczne + Chemlight attaché + Chemické světlo Připnuto + Chemlight Acoplada + Chemlight attaccata + Chemlight hozzácsatolva + Химсвет присоединён + + + Chemlight Detached + Leuchtstab entfernt + Barra de luz quitada + Odczepiono światło chemiczne + Chemlight détaché + Chemické světlo Odepnuto + Chemlight Separada + Chemlight staccata + Chemlight hozzácsatolva + Химсвет отсоединён + + + No inventory space + Kein Platz im Inventar + Sin espacio en inventario + Brak miejsca w ekwipunku + Pas de place dans l'inventaire + Není místo v inventáři + Sem espaço no inventário + Non hai più spazio + Nincs több hely + В инвентаре нет места + + + IR Strobe + IR-Stroboskop + Marcador IR + Stroboskop IR + Strobe IR + IR Značkovač + Marcador IV + Strobo IR + Infravörös jeladó + ИК строб + + + IR Strobe allows you to signal your position through a pulsating beacon only visible with NVGs. + Das IR-Stroboskop erlaubt es dir deine Position mit einem blinkenden Leuchtfeuer zu signalisieren, welches nur mit Nachtsichtgerät zu erkennen ist. + Stroboskop światła podczerwieni umożliwia oznaczenie swojej pozycji pulsacyjnym światłem widocznym tylko przez optykę noktowizyjną i gogle noktowizyjne. + El Marcador IR permite señalizar su posisición a través de una baliza visible solo a través de dispositivos de visión nocturna. + Le Strobe IR permet de signaler votre position grace à un clignotement visible par des JVN. + IR Značkovač je Infračerveně zářící stroboskop umožňující signalizaci vaší pozice díky blikajícímu světlu, které je vidět pouze při užití noktovizoru. + O Marcador IV permite que você sinalize sua posição através de um pulso visível somente com equipamento de visão noturna. + La Strobo IR è una luce stroboscopica che ti permette di segnalare la tua posizione grazie all'emissione di impulsi ad infrarossi visibili solo con i visori notturni. + Az infravörös jeladóval megjelölheted a helyzetedet úgy, hogy annak pulzáló fénye csak éjjellátó készülékkel látható. + ИК строб позволяет сигнализировать свое местоположение через пульсирующий маяк, видимый только через ПНВ. + + + \ No newline at end of file