Formating and Headers

This commit is contained in:
PabstMirror 2015-02-01 14:56:19 -06:00
parent 8ceb2aabc1
commit fa002b4db6
14 changed files with 406 additions and 392 deletions

View File

@ -1 +1 @@
z\ace\Addons\laser z\ace\Addons\attach

View File

@ -1,5 +1,5 @@
class Extended_PreInit_EventHandlers { class Extended_PreInit_EventHandlers {
class ADDON { class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_preInit) ); init = QUOTE( call COMPILE_FILE(XEH_preInit) );
}; };
}; };

View File

@ -1,10 +1,10 @@
class CfgMagazines { class CfgMagazines {
class CA_Magazine; class CA_Magazine;
class B_IR_Grenade: CA_Magazine { class B_IR_Grenade: CA_Magazine {
ACE_Attachable = 1; ACE_Attachable = 1;
}; };
class SmokeShell; class SmokeShell;
class Chemlight_green: SmokeShell { class Chemlight_green: SmokeShell {
ACE_Attachable = 1; ACE_Attachable = 1;
}; };
}; };

View File

@ -1,147 +1,147 @@
#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ #define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \
name = #ITEM; \ name = #ITEM; \
count = COUNT; \ count = COUNT; \
}; };
#define MACRO_ATTACHTOVEHICLE \ #define MACRO_ATTACHTOVEHICLE \
class ACE_Actions { \ class ACE_Actions { \
class GVAR(AttachVehicle) { \ class GVAR(AttachVehicle) { \
displayName = "$STR_ACE_Attach_AttachDetach"; \ displayName = "$STR_ACE_Attach_AttachDetach"; \
condition = QUOTE(([ARR_3(_player, _target, '')] call FUNC(canAttach))); \ condition = QUOTE(([ARR_3(_player, _target, '')] call FUNC(canAttach))); \
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(openAttachUI);); \ statement = QUOTE( [ARR_2(_player, _target)] call FUNC(openAttachUI);); \
exceptions[] = {"ACE_Drag_isNotDragging"}; \ exceptions[] = {"ACE_Drag_isNotDragging"}; \
showDisabled = 0; \ showDisabled = 0; \
priority = 0; \ priority = 0; \
icon = PATHTOF(UI\attach_ca.paa); \ icon = PATHTOF(UI\attach_ca.paa); \
distance = 4; \ distance = 4; \
}; \ }; \
class GVAR(DetachVehicle) { \ class GVAR(DetachVehicle) { \
displayName = "$STR_ACE_Attach_Detach"; \ displayName = "$STR_ACE_Attach_Detach"; \
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canDetach))); \ condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canDetach))); \
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(detach) ); \ statement = QUOTE( [ARR_2(_player, _target)] call FUNC(detach) ); \
exceptions[] = {"ACE_Drag_isNotDragging"}; \ exceptions[] = {"ACE_Drag_isNotDragging"}; \
showDisabled = 0; \ showDisabled = 0; \
priority = 0; \ priority = 0; \
icon = PATHTOF(UI\detach_ca.paa); \ icon = PATHTOF(UI\detach_ca.paa); \
distance = 4; \ distance = 4; \
}; \ }; \
}; };
class CfgVehicles { class CfgVehicles {
class LandVehicle; class LandVehicle;
class Car: LandVehicle { class Car: LandVehicle {
MACRO_ATTACHTOVEHICLE MACRO_ATTACHTOVEHICLE
}; };
class Tank: LandVehicle { class Tank: LandVehicle {
MACRO_ATTACHTOVEHICLE MACRO_ATTACHTOVEHICLE
}; };
class Air; class Air;
class Helicopter: Air { class Helicopter: Air {
MACRO_ATTACHTOVEHICLE MACRO_ATTACHTOVEHICLE
}; };
class Plane: Air { class Plane: Air {
MACRO_ATTACHTOVEHICLE MACRO_ATTACHTOVEHICLE
}; };
class Ship; class Ship;
class Ship_F: Ship { class Ship_F: Ship {
MACRO_ATTACHTOVEHICLE MACRO_ATTACHTOVEHICLE
}; };
class Man; class Man;
class CAManBase: Man { class CAManBase: Man {
class ACE_SelfActions { class ACE_SelfActions {
class ACE_Equipment { class ACE_Equipment {
class GVAR(Attach) { class GVAR(Attach) {
displayName = "$STR_ACE_Attach_AttachDetach"; displayName = "$STR_ACE_Attach_AttachDetach";
condition = QUOTE(([ARR_3(_player, _player, '')] call FUNC(canAttach))); condition = QUOTE(([ARR_3(_player, _player, '')] call FUNC(canAttach)));
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(openAttachUI); ); statement = QUOTE( [ARR_2(_player, _player)] call FUNC(openAttachUI); );
exceptions[] = {"ACE_Drag_isNotDragging"}; exceptions[] = {"ACE_Drag_isNotDragging"};
showDisabled = 0; showDisabled = 0;
priority = 5; priority = 5;
icon = PATHTOF(UI\attach_ca.paa); icon = PATHTOF(UI\attach_ca.paa);
hotkey = "T"; hotkey = "T";
};
class GVAR(Detach) {
displayName = "$STR_ACE_Attach_Detach";
condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canDetach)));
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(detach) );
exceptions[] = {"ACE_Drag_isNotDragging"};
showDisabled = 0;
priority = 5;
icon = PATHTOF(UI\detach_ca.paa);
hotkey = "T";
};
};
}; };
class GVAR(Detach) { };
displayName = "$STR_ACE_Attach_Detach";
condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canDetach))); class All;
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(detach) ); class ACE_IR_Strobe_Effect: All {
exceptions[] = {"ACE_Drag_isNotDragging"}; scope = 1;
showDisabled = 0; displayName = "IR Strobe";
priority = 5; model = "\A3\Weapons_F\empty.p3d";
icon = PATHTOF(UI\detach_ca.paa); simulation = "nvmarker";
hotkey = "T";
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 All; class NATO_Box_Base;
class ACE_IR_Strobe_Effect: All { class EAST_Box_Base;
scope = 1; class IND_Box_Base;
displayName = "IR Strobe"; class FIA_Box_Base_F;
model = "\A3\Weapons_F\empty.p3d";
simulation = "nvmarker";
class NVGMarker { class Box_NATO_Support_F: NATO_Box_Base {
diffuse[] = {0,0,0}; class TransportItems {
ambient[] = {0,0,0}; MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
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 Box_East_Support_F: EAST_Box_Base {
class EAST_Box_Base; class TransportItems {
class IND_Box_Base; MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
class FIA_Box_Base_F; };
class Box_NATO_Support_F: NATO_Box_Base {
class TransportItems {
MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
}; };
};
class Box_East_Support_F: EAST_Box_Base { class Box_IND_Support_F: IND_Box_Base {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_IR_Strobe_Item,12) MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
};
}; };
};
class Box_IND_Support_F: IND_Box_Base { class Box_FIA_Support_F: FIA_Box_Base_F {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_IR_Strobe_Item,12) MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
};
}; };
};
class Box_FIA_Support_F: FIA_Box_Base_F { class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_IR_Strobe_Item,12) MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
};
}; };
};
class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems {
MACRO_ADDITEM(ACE_IR_Strobe_Item,12)
};
};
}; };

View File

@ -1,16 +1,16 @@
class CfgWeapons { class CfgWeapons {
class ACE_ItemCore; class ACE_ItemCore;
class InventoryItem_Base_F; class InventoryItem_Base_F;
class ACE_IR_Strobe_Item: ACE_ItemCore { class ACE_IR_Strobe_Item: ACE_ItemCore {
displayName = "$STR_ACE_IrStrobe_Name"; displayName = "$STR_ACE_IrStrobe_Name";
descriptionShort = "$STR_ACE_IrStrobe_Description"; descriptionShort = "$STR_ACE_IrStrobe_Description";
model = "\A3\weapons_F\ammo\mag_univ.p3d"; model = "\A3\weapons_F\ammo\mag_univ.p3d";
picture = PATHTOF(UI\irstrobe_item.paa); picture = PATHTOF(UI\irstrobe_item.paa);
scope = 2; scope = 2;
ACE_attachable = 1; ACE_attachable = 1;
class ItemInfo: InventoryItem_Base_F { class ItemInfo: InventoryItem_Base_F {
mass = 1; mass = 1;
};
}; };
};
}; };

View File

@ -1,7 +1,8 @@
ace_attach ace_attach
========== ==========
Introducing the ability to attach various throwables to yourself to mark your position and assist in IFF. Introducing the ability to attach various throwables to yourself or vehicles, to mark your position and assist in IFF.
Adds item `ACE_IR_Strobe_Item`.
## Maintainers ## Maintainers
@ -11,3 +12,4 @@ The people responsible for merging changes to this component or answering potent
- [esteldunedain](https://github.com/esteldunedain) - [esteldunedain](https://github.com/esteldunedain)
- [bux578](https://github.com/bux578) - [bux578](https://github.com/bux578)
- [KoffeinFlummi](https://github.com/KoffeinFlummi) - [KoffeinFlummi](https://github.com/KoffeinFlummi)
- [PabstMirror](https://github.com/PabstMirror)

View File

@ -1,15 +1,15 @@
#include "script_component.hpp" #include "script_component.hpp"
class CfgPatches { class CfgPatches {
class ADDON { class ADDON {
units[] = {}; units[] = {};
weapons[] = {"ACE_IR_Strobe_Item"}; weapons[] = {"ACE_IR_Strobe_Item"};
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_interaction"}; requiredAddons[] = {"ace_common", "ace_interaction"};
author[] = {"KoffeinFlummi", "eRazeri", "CAA-Picard"}; author[] = {"KoffeinFlummi", "eRazeri", "CAA-Picard"};
authorUrl = "https://github.com/KoffeinFlummi/"; authorUrl = "https://github.com/KoffeinFlummi/";
VERSION_CONFIG; VERSION_CONFIG;
}; };
}; };
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"

View File

@ -1,18 +1,21 @@
#include "script_component.hpp"
/* /*
Author: eRazeri and CAA-Picard * Author: eRazeri and CAA-Picard
* Attach an item to the unit
Attach an item to the unit *
* Arguments:
Arguments: * 0: unit doing the attach (player) <OBJECT>
0: OBJECT - unit doing the attaching (player) * 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
1: OBJECT - vehicle that it will be attached to (player or vehicle) * 2: Name of the attachable item <STRING>
2: STRING - classname of attached item (from CfgMagazines or CfgWeapons) *
* Return Value:
Return Value: * Nothing
none *
*/ * Example:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_3(_unit,_attachToVehicle,_itemName); PARAMS_3(_unit,_attachToVehicle,_itemName);
@ -25,61 +28,61 @@ _onAtachText = "";
switch true do { switch true do {
case (_itemName == "ACE_IR_Strobe_Item"): { case (_itemName == "ACE_IR_Strobe_Item"): {
_itemVehClass = "ACE_IR_Strobe_Effect"; _itemVehClass = "ACE_IR_Strobe_Effect";
_onAtachText = localize "STR_ACE_Attach_IrStrobe_Attached"; _onAtachText = localize "STR_ACE_Attach_IrStrobe_Attached";
_selfAttachPosition = [_unit,[0,-0.11,0.16],"pilot"]; //makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri _selfAttachPosition = [_unit,[0,-0.11,0.16],"pilot"]; //makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri
}; };
case (_itemName == "B_IR_Grenade"): { case (_itemName == "B_IR_Grenade"): {
_itemVehClass = "B_IRStrobe"; _itemVehClass = "B_IRStrobe";
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
}; };
case (_itemName == "O_IR_Grenade"): { case (_itemName == "O_IR_Grenade"): {
_itemVehClass = "O_IRStrobe"; _itemVehClass = "O_IRStrobe";
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
}; };
case (_itemName == "I_IR_Grenade"): { case (_itemName == "I_IR_Grenade"): {
_itemVehClass = "I_IRStrobe"; _itemVehClass = "I_IRStrobe";
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
}; };
case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}): { case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}): {
_itemVehClass = _itemName; _itemVehClass = _itemName;
_onAtachText = localize "STR_ACE_Attach_Chemlight_Attached"; _onAtachText = localize "STR_ACE_Attach_Chemlight_Attached";
}; };
}; };
if (_itemVehClass == "") exitWith {ERROR("no _itemVehClass for Item");}; if (_itemVehClass == "") exitWith {ERROR("no _itemVehClass for Item");};
if (_unit == _attachToVehicle) then { //Self Attachment if (_unit == _attachToVehicle) then { //Self Attachment
_unit removeItem _itemName; // Remove item _unit removeItem _itemName; // Remove item
_attachedItem = _itemVehClass createVehicle [0,0,0]; _attachedItem = _itemVehClass createVehicle [0,0,0];
_attachedItem attachTo _selfAttachPosition; _attachedItem attachTo _selfAttachPosition;
[_onAtachText] call EFUNC(common,displayTextStructured); [_onAtachText] call EFUNC(common,displayTextStructured);
_attachToVehicle setVariable ["ACE_AttachedObjects", [_attachedItem], true]; _attachToVehicle setVariable ["ACE_AttachedObjects", [_attachedItem], true];
_attachToVehicle setVariable ["ACE_AttachedItemNames", [_itemName], true]; _attachToVehicle setVariable ["ACE_AttachedItemNames", [_itemName], true];
} else { } else {
GVAR(setupObject) = _itemVehClass createVehicleLocal [0,0,-10000]; GVAR(setupObject) = _itemVehClass createVehicleLocal [0,0,-10000];
GVAR(setupObject) enableSimulationGlobal false; GVAR(setupObject) enableSimulationGlobal false;
GVAR(SetupPlacmentText) = _onAtachText; GVAR(SetupPlacmentText) = _onAtachText;
GVAR(SetupPlacmentItem) = _itemName; GVAR(SetupPlacmentItem) = _itemName;
GVAR(SetupAttachVehicle) = _attachToVehicle; GVAR(SetupAttachVehicle) = _attachToVehicle;
GVAR(placer) = _unit; GVAR(placer) = _unit;
[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); [_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus);
[QGVAR(PlacementEachFrame),"OnEachFrame", { [QGVAR(PlacementEachFrame),"OnEachFrame", {
private "_player"; private "_player";
_player = ACE_player; _player = ACE_player;
//Stop if player switch or player gets to far from vehicle //Stop if player switch or player gets to far from vehicle
if ((GVAR(placer) != _player) || {(_player distance GVAR(SetupAttachVehicle)) > 7}) exitWith { if ((GVAR(placer) != _player) || {(_player distance GVAR(SetupAttachVehicle)) > 7}) exitWith {
call FUNC(placeCancel); call FUNC(placeCancel);
}; };
GVAR(pfeh_running) = true; GVAR(pfeh_running) = true;
_pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]); _pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
GVAR(setupObject) setPosATL _pos; GVAR(setupObject) setPosATL _pos;
}] call BIS_fnc_addStackedEventHandler; }] call BIS_fnc_addStackedEventHandler;
//had to delay the mouseHint, not sure why //had to delay the mouseHint, not sure why
[{[localize "STR_ACE_Attach_PlaceAction", localize "STR_ACE_Attach_CancelAction"] call EFUNC(interaction,showMouseHint)}, [], 0, 0] call EFUNC(common,waitAndExecute); [{[localize "STR_ACE_Attach_PlaceAction", localize "STR_ACE_Attach_CancelAction"] call EFUNC(interaction,showMouseHint)}, [], 0, 0] call EFUNC(common,waitAndExecute);
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {GVAR(pfeh_running) AND !isNull (GVAR(setupObject))}, {call FUNC(placeApprove);}] call EFUNC(common,AddActionEventHandler)]; _unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {GVAR(pfeh_running) AND !isNull (GVAR(setupObject))}, {call FUNC(placeApprove);}] call EFUNC(common,AddActionEventHandler)];
_unit setVariable [QGVAR(cancelActionEH), [_unit, "MenuBack", {GVAR(pfeh_running) AND !isNull (GVAR(setupObject))}, {call FUNC(placeCancel);}] call EFUNC(common,AddActionEventHandler)]; _unit setVariable [QGVAR(cancelActionEH), [_unit, "MenuBack", {GVAR(pfeh_running) AND !isNull (GVAR(setupObject))}, {call FUNC(placeCancel);}] call EFUNC(common,AddActionEventHandler)];
}; };

View File

@ -1,17 +1,21 @@
#include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2
*
* Check if a unit can attach a specific item. * Check if a unit can attach a specific item.
* *
* Argument: * Arguments:
* 0: Unit that wants to attach the object (Object) * 0: unit doing the attach (player) <OBJECT>
* 1: Name of the attachable item (String) * 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
* * 2: Name of the attachable item <STRING>
* Return value: *
* Boolean (Bool) * Return Value:
* Boolean <BOOL>
*
* Example:
* Nothing
*
* Public: No
*/ */
#include "script_component.hpp"
PARAMS_3(_unit,_attachToVehicle,_item); PARAMS_3(_unit,_attachToVehicle,_item);

View File

@ -1,16 +1,20 @@
#include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2
* * Check if a unit has an item attached and if it can remove that item.
* Check if a unit has an item attached and if it can remove that item. *
* * Arguments:
* Argument: * 0: unit doing the detaching (player) <STRING>
* 0: Unit that wants to detach something (Object) * 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
* *
* Return value: * Return Value:
* Boolean (Bool) * Boolean <BOOL>
*/ *
* Example:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
private ["_attachedObjects", "_inRange", "_unitPos", "_objectPos"]; private ["_attachedObjects", "_inRange", "_unitPos", "_objectPos"];
@ -20,16 +24,16 @@ _attachedObjects = _attachToVehicle getVariable ["ACE_AttachedObjects", []];
_inRange = false; _inRange = false;
if (_unit == _attachToVehicle) then { if (_unit == _attachToVehicle) then {
_inRange = (count _attachedObjects) > 0; _inRange = (count _attachedObjects) > 0;
} else { } else {
//Scan if unit is within range (using 2d distance) //Scan if unit is within range (using 2d distance)
_unitPos = getPos _unit; _unitPos = getPos _unit;
_unitPos set [2,0]; _unitPos set [2,0];
{ {
_objectPos = getPos _x; _objectPos = getPos _x;
_objectPos set [2, 0]; _objectPos set [2, 0];
if ((_objectPos distance _unitPos) < 4) exitWith {_inRange = true}; if ((_objectPos distance _unitPos) < 4) exitWith {_inRange = true};
} forEach _attachedObjects; } forEach _attachedObjects;
}; };
(canStand _unit) && _inRange && {alive _attachToVehicle} (canStand _unit) && _inRange && {alive _attachToVehicle}

View File

@ -1,17 +1,20 @@
#include "script_component.hpp"
/* /*
Author: eRazeri and CAA-Picard * Author: eRazeri and CAA-Picard
* Detach an item from a unit
Detach an item from a unit *
* Arguments:
Arguments: * 0: unit doing the attaching (player) <STRING>
0: OBJECT - unit doing the attaching (player) * 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
1: OBJECT - vehicle that it will be detached from (player or vehicle) *
* Return Value:
Return Value: * Nothing
none *
*/ * Example:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
private ["_itemName", "_count", "_attachedItem", "_fnc_detachDelay"]; private ["_itemName", "_count", "_attachedItem", "_fnc_detachDelay"];
@ -29,14 +32,14 @@ _minDistance = 1000;
_unitPos = getPos _unit; _unitPos = getPos _unit;
_unitPos set [2,0]; _unitPos set [2,0];
{ {
_objectPos = getPos _x; _objectPos = getPos _x;
_objectPos set [2, 0]; _objectPos set [2, 0];
if ((_objectPos distance _unitPos) < _minDistance) then { if ((_objectPos distance _unitPos) < _minDistance) then {
_minDistance = (_objectPos distance _unitPos); _minDistance = (_objectPos distance _unitPos);
_attachedObject = _x; _attachedObject = _x;
_itemName = _attachedItemsArray select _forEachIndex; _itemName = _attachedItemsArray select _forEachIndex;
_attachedIndex = _forEachIndex; _attachedIndex = _forEachIndex;
}; };
} forEach _attachedObjectsArray; } forEach _attachedObjectsArray;
// Check if unit has an attached item // Check if unit has an attached item
@ -46,21 +49,21 @@ if ((isNull _attachedObject) || {_itemName == ""}) exitWith {ERROR("Could not fi
_count = (count items _unit) + (count magazines _unit); _count = (count items _unit) + (count magazines _unit);
_unit addItem _itemName; _unit addItem _itemName;
if ((count items _unit) + (count magazines _unit) <= _count) exitWith { if ((count items _unit) + (count magazines _unit) <= _count) exitWith {
[localize "STR_ACE_Attach_Inventory_Full"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Attach_Inventory_Full"] call EFUNC(common,displayTextStructured);
}; };
if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { 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 // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle
detach _attachedObject; detach _attachedObject;
_attachedObject setPos [getPos _unit select 0, getPos _unit select 1, ((getPos _unit select 2) - 1000)]; _attachedObject setPos [getPos _unit select 0, getPos _unit select 1, ((getPos _unit select 2) - 1000)];
// Delete attached item after 0.5 seconds // Delete attached item after 0.5 seconds
_fnc_detachDelay = { _fnc_detachDelay = {
deleteVehicle (_this select 0); deleteVehicle (_this select 0);
}; };
[_fnc_detachDelay, [_attachedObject], 0.5, 0] call EFUNC(common,waitAndExecute); [_fnc_detachDelay, [_attachedObject], 0.5, 0] call EFUNC(common,waitAndExecute);
} else { } else {
// Delete attached item // Delete attached item
deleteVehicle _attachedObject; deleteVehicle _attachedObject;
}; };
// Reset unit variables // Reset unit variables
@ -71,13 +74,13 @@ _attachToVehicle setVariable ["ACE_AttachedItemNames", _attachedItemsArray, true
// Display message // Display message
switch true do { switch true do {
case (_itemName == "ACE_IR_Strobe_Item") : { case (_itemName == "ACE_IR_Strobe_Item") : {
[localize "STR_ACE_Attach_IrStrobe_Detached"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Attach_IrStrobe_Detached"] call EFUNC(common,displayTextStructured);
}; };
case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : { case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : {
[localize "STR_ACE_Attach_IrGrenade_Detached"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Attach_IrGrenade_Detached"] call EFUNC(common,displayTextStructured);
}; };
case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : {
[localize "STR_ACE_Attach_Chemlight_Detached"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Attach_Chemlight_Detached"] call EFUNC(common,displayTextStructured);
}; };
}; };

View File

@ -1,21 +1,21 @@
/*
* Author: Garth de Wet (LH)
* Opens the UI for attaching objects.
*
* Arguments:
* 0: unit <STRING>
* 1: target <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* Nothing
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
/*
Author: Garth de Wet (LH)
Description:
Opens the UI for attaching objects.
Parameters:
0: OBJECT - unit
1: OBJECT - target
Returns:
Nothing
Example:
[player] call ACE_Attach_fnc_openAttachUI;
*/
private ["_actions", "_attachables", "_item"]; private ["_actions", "_attachables", "_item"];
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
@ -25,43 +25,43 @@ _listed = [];
_attachables = magazines _unit; _attachables = magazines _unit;
_actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu); _actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu);
{ {
if !(_x in _listed) then { if !(_x in _listed) then {
_item = ConfigFile >> "CfgMagazines" >> _x; _item = ConfigFile >> "CfgMagazines" >> _x;
if (getNumber (_item >> "ACE_Attachable") == 1) then { if (getNumber (_item >> "ACE_Attachable") == 1) then {
_actions = [ _actions = [
_actions, _actions,
getText(_item >> "displayName"), getText(_item >> "displayName"),
getText(_item >> "picture"), getText(_item >> "picture"),
_x _x
] call EFUNC(interaction,addSelectableItem); ] call EFUNC(interaction,addSelectableItem);
};
_listed pushBack _x;
}; };
_listed pushBack _x;
};
} forEach _attachables; } forEach _attachables;
_attachables = items _unit; _attachables = items _unit;
{ {
if !(_x in _listed) then { if !(_x in _listed) then {
_item = ConfigFile >> "CfgWeapons" >> _x; _item = ConfigFile >> "CfgWeapons" >> _x;
if (getNumber (_item >> "ACE_Attachable") == 1) then { if (getNumber (_item >> "ACE_Attachable") == 1) then {
_actions = [ _actions = [
_actions, _actions,
getText(_item >> "displayName"), getText(_item >> "displayName"),
getText(_item >> "picture"), getText(_item >> "picture"),
_x _x
] call EFUNC(interaction,addSelectableItem); ] call EFUNC(interaction,addSelectableItem);
};
_listed pushBack _x;
}; };
_listed pushBack _x;
};
} forEach _attachables; } forEach _attachables;
[ [
_actions, _actions,
{ {
[ACE_player, GVAR(attachTarget), _this] call FUNC(attach); [ACE_player, GVAR(attachTarget), _this] call FUNC(attach);
call EFUNC(interaction,hideMenu); call EFUNC(interaction,hideMenu);
}, },
{ {
call EFUNC(interaction,hideMenu); call EFUNC(interaction,hideMenu);
if !(profileNamespace getVariable [QEGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; if !(profileNamespace getVariable [QEGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)};
} }
] call EFUNC(interaction,openSelectMenu); ] call EFUNC(interaction,openSelectMenu);

View File

@ -1,24 +1,26 @@
/* /*
Name: FUNC(placeApprove) * Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH))
Author(s): * Approves placement of the lightObject, scans for an appropriate location and attaches
Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) *
Description: * Arguments:
Approves placement of the lightObject, releases the placement object for it to settle in a location * Nothing
Parameters: *
Nothing * Return Value:
Returns: * Nothing
Nothing *
Example: * Example:
call FUNC(placeApprove); * Nothing
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_setupObject", "_setupClassname", "_itemClassname", "_placementText", "_attachToVehicle", "_placer", "_startingPosition", "_startingOffset", "_distanceFromCenter", "_closeInUnitVector", "_keepGoingCloser", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"]; private ["_setupObject", "_setupClassname", "_itemClassname", "_placementText", "_attachToVehicle", "_placer", "_startingPosition", "_startingOffset", "_distanceFromCenter", "_closeInUnitVector", "_keepGoingCloser", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"];
if (GVAR(pfeh_running)) then { if (GVAR(pfeh_running)) then {
[QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler; [QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler;
GVAR(pfeh_running) = false; GVAR(pfeh_running) = false;
}; };
_setupObject = GVAR(setupObject); _setupObject = GVAR(setupObject);
@ -54,26 +56,26 @@ _keepGoingCloser = true;
_closeInDistance = 0; _closeInDistance = 0;
while {_keepGoingCloser} do { while {_keepGoingCloser} do {
if (_closeInDistance >= _distanceFromCenter) exitWith {}; if (_closeInDistance >= _distanceFromCenter) exitWith {};
_closeInDistance = _closeInDistance + 0.01; //10mm each step _closeInDistance = _closeInDistance + 0.01; //10mm each step
_endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); _endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance);
_endPosTestOffset set [2, (_startingOffset select 2)]; _endPosTestOffset set [2, (_startingOffset select 2)];
_endPosTest = _attachToVehicle modelToWorld _endPosTestOffset; _endPosTest = _attachToVehicle modelToWorld _endPosTestOffset;
{
_startingPosShifted = _startingPosition vectorAdd _x;
_startASL = if (surfaceIsWater _startingPosShifted) then {_startingPosShifted} else {ATLtoASL _startingPosShifted};
{ {
_endPosShifted = _endPosTest vectorAdd _x; _startingPosShifted = _startingPosition vectorAdd _x;
_endASL = if (surfaceIsWater _startingPosShifted) then {_endPosShifted} else {ATLtoASL _endPosShifted}; _startASL = if (surfaceIsWater _startingPosShifted) then {_startingPosShifted} else {ATLtoASL _startingPosShifted};
{
//Uncomment to see the lazor show, and see how the scanning works: _endPosShifted = _endPosTest vectorAdd _x;
drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]]; _endASL = if (surfaceIsWater _startingPosShifted) then {_endPosShifted} else {ATLtoASL _endPosShifted};
if (_attachToVehicle in lineIntersectsWith [_startASL, _endASL, _placer, _setupObject]) exitWith {_keepGoingCloser = false}; //Uncomment to see the lazor show, and see how the scanning works:
} forEach [[0,0,0.045], [0,0,-0.045], [0,0.045,0], [0,-0.045,0], [0.045,0,0], [-0.045,0,0]]; drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]];
} forEach [[0,0,0], [0,0,0.05], [0,0,-0.05]];
if (_attachToVehicle in lineIntersectsWith [_startASL, _endASL, _placer, _setupObject]) exitWith {_keepGoingCloser = false};
} forEach [[0,0,0.045], [0,0,-0.045], [0,0.045,0], [0,-0.045,0], [0.045,0,0], [-0.045,0,0]];
} forEach [[0,0,0], [0,0,0.05], [0,0,-0.05]];
}; };
//Delete Local Placement Object //Delete Local Placement Object
@ -81,8 +83,8 @@ deleteVehicle _setupObject;
//Checks //Checks
if ((_closeInDistance >= _distanceFromCenter) || (!([_placer,_attachToVehicle,_itemClassname] call FUNC(canAttach)))) exitWith { if ((_closeInDistance >= _distanceFromCenter) || (!([_placer,_attachToVehicle,_itemClassname] call FUNC(canAttach)))) exitWith {
TRACE_2("no valid spot found",_closeInDistance,_distanceFromCenter); TRACE_2("no valid spot found",_closeInDistance,_distanceFromCenter);
[localize "STR_ACE_Attach_Failed"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Attach_Failed"] call EFUNC(common,displayTextStructured);
}; };
//Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull) //Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull)

View File

@ -1,35 +1,27 @@
/* /*
Name: FUNC(placeCancel) * Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH))
* Cancels placement of the lightObject
Author(s): *
Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) * Arguments:
* Nothing
Description: *
Cancels placement of the lightObject * Return Value:
* Nothing
Parameters: *
Nothing * Example:
* Nothing
Returns: *
Nothing * Public: No
*/
Example:
call FUNC(placeCancel);
*/
#include "script_component.hpp" #include "script_component.hpp"
if (GVAR(pfeh_running)) then { if (GVAR(pfeh_running)) then {
[QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler; [QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler;
GVAR(pfeh_running) = false; GVAR(pfeh_running) = false;
}; };
if (!isNull (GVAR(setupObject))) then { if (!isNull (GVAR(setupObject))) then {
deleteVehicle GVAR(setupObject); deleteVehicle GVAR(setupObject);
}; };
GVAR(SetupPlacmentItem) = "";
GVAR(SetupPlacmentText) = "";
GVAR(setupObject) = objNull;
GVAR(SetupAttachVehicle) = objNull;
[GVAR(placer), QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); [GVAR(placer), QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
@ -37,3 +29,7 @@ call EFUNC(interaction,hideMouseHint);
[GVAR(placer), "MenuBack", GVAR(placer) getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler); [GVAR(placer), "MenuBack", GVAR(placer) getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler);
GVAR(placer) = objNull; GVAR(placer) = objNull;
GVAR(SetupPlacmentItem) = "";
GVAR(SetupPlacmentText) = "";
GVAR(setupObject) = objNull;
GVAR(SetupAttachVehicle) = objNull;