AGM_Attach PRE CBA

This commit is contained in:
jaynus 2015-01-11 10:26:40 -08:00
parent 1e29509b45
commit fa5098b169
10 changed files with 531 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

159
addons/Attach/config.cpp Normal file
View File

@ -0,0 +1,159 @@
class CfgPatches {
class AGM_Attach {
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/";
};
};
class CfgFunctions {
class AGM_Attach {
class AGM_Attach {
file = "AGM_Attach\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 AGM_Attach {
displayName = "$STR_AGM_Attach_AttachDetach";
condition = "[_player, ''] call AGM_Attach_fnc_canAttach";
statement = "[_player] call AGM_Attach_fnc_openAttachUI;";
exceptions[] = {"AGM_Drag_isNotDragging"};
showDisabled = 0;
priority = 5;
icon = "\AGM_Attach\UI\attach_ca.paa";
hotkey = "T";
};
class AGM_Attach_Detach {
displayName = "$STR_AGM_Attach_Detach";
condition = "[_player] call AGM_Attach_fnc_canDetach";
statement = "[_player] call AGM_Attach_fnc_detach";
exceptions[] = {"AGM_Drag_isNotDragging"};
showDisabled = 0;
priority = 5;
icon = "\AGM_Attach\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 = "\AGM_Attach\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;
};
};

View File

@ -0,0 +1,60 @@
/*
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 ["AGM_AttachedItemName", ""] != "") 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 AGM_Core_fnc_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 AGM_Core_fnc_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 AGM_Core_fnc_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 AGM_Core_fnc_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 AGM_Core_fnc_displayTextStructured;
};
default {
if (true) exitWith {};
};
};
// Remove item
_unit removeItem _itemName;
_unit setVariable ["AGM_AttachedItemName", _itemName, true];
_unit setVariable ["AGM_AttachedItem", _attachedItem, true];

View File

@ -0,0 +1,19 @@
/*
* 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 ["AGM_AttachedItemName", ""] == ""} && {_item in (magazines _unit + items _unit + [""])}

View File

@ -0,0 +1,17 @@
/*
* 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 ["AGM_AttachedItemName", ""] != ""}

View File

@ -0,0 +1,63 @@
/*
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 ["AGM_AttachedItemName", ""];
// 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 AGM_Core_fnc_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 "AGM_AttachedItem", _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 "AGM_AttachedItem");
};
// Reset unit variables
_unit setVariable ["AGM_AttachedItemName","", true];
_unit setVariable ["AGM_AttachedItem",nil, true];
// Display message
switch true do {
case (_itemName == "AGM_IR_Strobe_Item") : {
[localize "STR_AGM_Attach_IrStrobe_Detached"] call AGM_Core_fnc_displayTextStructured;
};
case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : {
[localize "STR_AGM_Attach_IrGrenade_Detached"] call AGM_Core_fnc_displayTextStructured;
};
case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : {
[localize "STR_AGM_Attach_Chemlight_Detached"] call AGM_Core_fnc_displayTextStructured;
};
default {
if (true) exitWith {};
};
};

View File

@ -0,0 +1,63 @@
/*
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 AGM_Interaction_fnc_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 AGM_Interaction_fnc_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 AGM_Interaction_fnc_AddSelectableItem;
};
_listed pushBack _x;
};
} forEach _attachables;
[
_actions,
{
[AGM_player, _this] call AGM_Attach_fnc_attach;
call AGM_Interaction_fnc_hideMenu;
},
{
call AGM_Interaction_fnc_hideMenu;
if !(profileNamespace getVariable ["AGM_Interaction_AutoCloseMenu", false]) then {"Default" call AGM_Interaction_fnc_openMenuSelf};
}
] call AGM_Interaction_fnc_openSelectMenu;

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited with tabler - 2014-12-12 -->
<Project name="AGM">
<Package name="Attach">
<Key ID="STR_AGM_Attach_AttachDetach">
<English>Attach item &gt;&gt;</English>
<German>Gegenstand befestigen &gt;&gt;</German>
<Spanish>Acoplar objeto &gt;&gt;</Spanish>
<Polish>Przyczep przedmiot &gt;&gt;</Polish>
<French>Attacher l'objet &gt;&gt;</French>
<Czech>Připnout předmět &gt;&gt;</Czech>
<Portuguese>Acoplar item &gt;&gt;</Portuguese>
<Italian>Attacca l'oggetto &gt;&gt;</Italian>
<Hungarian>Tárgy hozzácsatolása &gt;&gt;</Hungarian>
<Russian>Добавить приспособления</Russian>
</Key>
<Key ID="STR_AGM_Attach_Attach">
<English>Attach</English>
<German>Befestigen</German>
<Spanish>Acoplar</Spanish>
<Polish>Przyczep</Polish>
<French>Attacher</French>
<Czech>Připnout</Czech>
<Portuguese>Acoplar</Portuguese>
<Italian>Attacca</Italian>
<Hungarian>Hozzácsatolás</Hungarian>
<Russian>Присоединить</Russian>
</Key>
<Key ID="STR_AGM_Attach_Detach">
<English>Detach item</English>
<German>Gegenstand entfernen</German>
<Spanish>Quitar objeto</Spanish>
<Polish>Odczep przedmiot</Polish>
<French>Détacher l'objet</French>
<Czech>Odepnout předmět</Czech>
<Portuguese>Separar item</Portuguese>
<Italian>Stacca l'oggetto</Italian>
<Hungarian>Tárgy lecsatolása</Hungarian>
<Russian>Отсоединить</Russian>
</Key>
<Key ID="STR_AGM_Attach_IrStrobe_Attached">
<English>IR Strobe Attached</English>
<German>IR-Stroboskop befestigt</German>
<Spanish>Marcador IR acoplado</Spanish>
<Polish>Przyczepiono stroboskop IR</Polish>
<French>Strobe IR attaché</French>
<Czech>IR Značkovač Připnutý</Czech>
<Portuguese>Marcador IV Acoplado</Portuguese>
<Italian>Strobo IR attaccata</Italian>
<Hungarian>Infravörös jeladó hozzácsatolva</Hungarian>
<Russian>ИК строб присоединён</Russian>
</Key>
<Key ID="STR_AGM_Attach_IrStrobe_Detached">
<English>IR Strobe Detached</English>
<German>IR-Stroboskop entfernt</German>
<Spanish>Marcador IR quitado</Spanish>
<Polish>Odczepiono stroboskop IR</Polish>
<French>Strobe IR détaché</French>
<Czech>IR Značkovač Odepnutý</Czech>
<Portuguese>Marcador IV Separado</Portuguese>
<Italian>Strobo IR staccata</Italian>
<Hungarian>Infravörös jeladó lecsatolva</Hungarian>
<Russian>ИК строб отсоединён</Russian>
</Key>
<Key ID="STR_AGM_Attach_IrGrenade_Attached">
<English>IR Grenade Attached</English>
<German>IR-Granate befestigt</German>
<Spanish>Granada IR acoplada</Spanish>
<Polish>Przyczepiono granat IR</Polish>
<French>Grenade IR attachée</French>
<Czech>IR Granát Připnutý</Czech>
<Portuguese>Granada IV Acoplada</Portuguese>
<Italian>Granata IR attaccata</Italian>
<Hungarian>Infravörös gránát hozzácsatolva</Hungarian>
<Russian>ИК граната присоединена</Russian>
</Key>
<Key ID="STR_AGM_Attach_IrGrenade_Detached">
<English>IR Grenade Detached</English>
<German>IR-Granate entfernt</German>
<Spanish>Granada IR quitada</Spanish>
<Polish>Odczepiono granat IR</Polish>
<French>Grenade IR détachée</French>
<Czech>IR Granát Odepnutý</Czech>
<Portuguese>Granada IV Separada</Portuguese>
<Italian>Granata IR staccata</Italian>
<Hungarian>Infravörös gránát lecsatolva</Hungarian>
<Russian>ИК граната отсоединена</Russian>
</Key>
<Key ID="STR_AGM_Attach_Chemlight_Attached">
<English>Chemlight Attached</English>
<German>Leuchtstab befestigt</German>
<Spanish>Barra de luz acoplada</Spanish>
<Polish>Przyczepiono światło chemiczne</Polish>
<French>Chemlight attaché</French>
<Czech>Chemické světlo Připnuto</Czech>
<Portuguese>Chemlight Acoplada</Portuguese>
<Italian>Chemlight attaccata</Italian>
<Hungarian>Chemlight hozzácsatolva</Hungarian>
<Russian>Химсвет присоединён</Russian>
</Key>
<Key ID="STR_AGM_Attach_Chemlight_Detached">
<English>Chemlight Detached</English>
<German>Leuchtstab entfernt</German>
<Spanish>Barra de luz quitada</Spanish>
<Polish>Odczepiono światło chemiczne</Polish>
<French>Chemlight détaché</French>
<Czech>Chemické světlo Odepnuto</Czech>
<Portuguese>Chemlight Separada</Portuguese>
<Italian>Chemlight staccata</Italian>
<Hungarian>Chemlight hozzácsatolva</Hungarian>
<Russian>Химсвет отсоединён</Russian>
</Key>
<Key ID="STR_AGM_Attach_Inventory_Full">
<English>No inventory space</English>
<German>Kein Platz im Inventar</German>
<Spanish>Sin espacio en inventario</Spanish>
<Polish>Brak miejsca w ekwipunku</Polish>
<French>Pas de place dans l'inventaire</French>
<Czech>Není místo v inventáři</Czech>
<Portuguese>Sem espaço no inventário</Portuguese>
<Italian>Non hai più spazio</Italian>
<Hungarian>Nincs több hely</Hungarian>
<Russian>В инвентаре нет места</Russian>
</Key>
<Key ID="STR_AGM_IrStrobe_Name">
<English>IR Strobe</English>
<German>IR-Stroboskop</German>
<Spanish>Marcador IR</Spanish>
<Polish>Stroboskop IR</Polish>
<French>Strobe IR</French>
<Czech>IR Značkovač</Czech>
<Portuguese>Marcador IV</Portuguese>
<Italian>Strobo IR</Italian>
<Hungarian>Infravörös jeladó</Hungarian>
<Russian>ИК строб</Russian>
</Key>
<Key ID="STR_AGM_IrStrobe_Description">
<English>IR Strobe allows you to signal your position through a pulsating beacon only visible with NVGs.</English>
<German>Das IR-Stroboskop erlaubt es dir deine Position mit einem blinkenden Leuchtfeuer zu signalisieren, welches nur mit Nachtsichtgerät zu erkennen ist.</German>
<Polish>Stroboskop światła podczerwieni umożliwia oznaczenie swojej pozycji pulsacyjnym światłem widocznym tylko przez optykę noktowizyjną i gogle noktowizyjne.</Polish>
<Spanish>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. </Spanish>
<French>Le Strobe IR permet de signaler votre position grace à un clignotement visible par des JVN.</French>
<Czech>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.</Czech>
<Portuguese>O Marcador IV permite que você sinalize sua posição através de um pulso visível somente com equipamento de visão noturna.</Portuguese>
<Italian>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.</Italian>
<Hungarian>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ó.</Hungarian>
<Russian>ИК строб позволяет сигнализировать свое местоположение через пульсирующий маяк, видимый только через ПНВ.</Russian>
</Key>
</Package>
</Project>