Merge branch 'master' of https://github.com/KoffeinFlummi/ACE3 into reloadLaunchers

This commit is contained in:
commy2 2015-03-22 10:48:54 +01:00
commit ae5fbaef86
183 changed files with 4528 additions and 1950 deletions

View File

@ -1,23 +1,23 @@
<p align="center">
<img src="https://github.com/KoffeinFlummi/ACE3/blob/master/extras/assets/logo/black/ACE3-Logo.jpg" height="80" />
<img src="https://github.com/KoffeinFlummi/ACE3/blob/master/extras/assets/logo/black/ACE3-Logo.jpg" height="80" />
</p>
<p align="center">
<a href="https://github.com/KoffeinFlummi/ACE3/releases">
<img src="http://img.shields.io/badge/release-3.0-green.svg?style=flat" alt="ACE version">
</a>
<a href="#">
<img src="http://img.shields.io/badge/download-22_MB-blue.svg?style=flat" alt="ACE download">
</a>
<a href="https://github.com/KoffeinFlummi/ACE3/issues">
<img src="http://img.shields.io/github/issues/KoffeinFlummi/ACE3.svg?style=flat" alt="ACE issues">
</a>
<a href="https://github.com/KoffeinFlummi/ACE3/blob/master/LICENSE">
<img src="http://img.shields.io/badge/license-GPLv2-red.svg?style=flat" alt="ACE license">
</a>
<a href="https://github.com/KoffeinFlummi/ACE3/releases">
<img src="http://img.shields.io/badge/release-3.0-green.svg?style=flat" alt="ACE version">
</a>
<a href="#">
<img src="http://img.shields.io/badge/download-22_MB-blue.svg?style=flat" alt="ACE download">
</a>
<a href="https://github.com/KoffeinFlummi/ACE3/issues">
<img src="http://img.shields.io/github/issues/KoffeinFlummi/ACE3.svg?style=flat" alt="ACE issues">
</a>
<a href="https://github.com/KoffeinFlummi/ACE3/blob/master/LICENSE">
<img src="http://img.shields.io/badge/license-GPLv2-red.svg?style=flat" alt="ACE license">
</a>
</p>
<p align="center"><sup><strong>Requires the latest version of <a href="http://www.armaholic.com/page.php?id=18767">CBA A3</a> | <a href="#">BIF thread</a></strong></sup></p>
**ACE 3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
**ACE3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
This mod is entirely **open-source**, and everyone is free to propose changes or maintain their own, customized version as long as they make their changes open to the public in accordance with the GNU General Public License (for more information check the license file attached to this project).

Binary file not shown.

View File

@ -0,0 +1,25 @@
// TMR: Optics initialization and functions
// (C) 2013 Ryan Schultz. See LICENSE.
// Request a resource layer from the game engine.
AGM_Optics_scopeRSC = ["AGM_Optics_Scope"] call BIS_fnc_rscLayer;
// Set global variables
AGM_Optics_inScope = false; // Is the scope up?
AGM_Optics_currentOptic = ""; // What optic is attached right now?
0 = 0 spawn {
waituntil {!isNull (findDisplay 46)};
[] call AGM_Optics_fnc_initScope;
// PiP technique by BadBenson
AGM_Optics_Camera = "camera" camCreate (positioncameratoworld [0,0,0]);
AGM_Optics_Camera camSetFov 0.7;
AGM_Optics_Camera camSetTarget player;
AGM_Optics_Camera camCommit 1;
"agm_optics_rendertarget0" setPiPEffect [2, 1.0, 1.0, 1.0, 0.0, [0.0, 1.0, 0.0, 0.25], [1.0, 0.0, 1.0, 1.0], [0.199, 0.587, 0.114, 0.0]];
AGM_Optics_Camera cameraEffect ["INTERNAL", "BACK","agm_optics_rendertarget0"];
waitUntil {[] call AGM_Optics_fnc_mainLoop; False};
};

View File

@ -0,0 +1,454 @@
class CfgPatches {
class AGM_Optics {
units[] = {};
weapons[] = {};
requiredVersion = 0.60;
requiredAddons[] = {AGM_Core};
version = 0.1;
author[] = {"Taosenai"};
authorUrl = "http://www.ryanschultz.org/tmr/";
};
};
class CfgFunctions {
class AGM_Optics {
class AGM_Optics {
file = "AGM_Optics\functions";
class firedEH;
class hideScope;
class initScope;
class mainLoop;
};
};
};
class Extended_PostInit_EventHandlers {
class AGM_Optics {
clientInit = "call compile preProcessFileLineNumbers '\AGM_Optics\clientInit.sqf'";
};
};
class Extended_FiredBIS_EventHandlers {
class CAManBase {
class AGM_Optics {
clientFiredBIS = "_this call AGM_Optics_fnc_firedEH;";
};
};
};
class CfgOpticsEffect {
class AGM_OpticsRadBlur1 {
type = "radialblur";
params[] = {0.015, 0, 0.14, 0.2};
priority = 950;
};
};
class CfgWeapons {
class ItemCore;
class InventoryItem_Base_F;
class InventoryMuzzleItem_Base_F;
class InventoryOpticsItem_Base_F;
class optic_Hamr : ItemCore {
displayName = "HAMR 4x";
descriptionShort = "High Accuracy Multi-Range Optic<br />Magnification: 4x<br />Reticle: CM-RW 6.5mm";
scope = 2;
weaponInfoType = "AGM_RscWeapon";
AGM_Optics_enhanced = 1;
AGM_Optics_reticle = "\AGM_Optics\data\hamr\hamr-reticle65_ca.paa";
AGM_Optics_reticleIllum = "\AGM_Optics\data\hamr\hamr-reticle65Illum_ca.paa";
AGM_Optics_body = "\AGM_Optics\data\hamr\hamr-body_ca.paa";
AGM_Optics_bodyNight = "\AGM_Optics\data\hamr\hamr-bodyNight_ca.paa";
model = "\A3\weapons_f\acc\acco_hamr_F";
class ItemInfo : InventoryOpticsItem_Base_F {
mass = 4;
optics = 1;
optictype = 1;
rmbhint = "HAMR";
modeloptics = "\AGM_Optics\agm_optics_pip.p3d";
class OpticsModes {
class Hamr2Collimator {
AGM_Optics_enhanced = 0;
opticsID = 1;
useModelOptics = 0;
opticsppeffects[] = {};
opticsFlare = 0;
opticsDisablePeripherialVision = 0;
opticsZoomMin = 0.375;
opticsZoomMax = 1;
opticsZoomInit = 0.75;
memoryPointCamera = "eye";
visionMode[] = {};
distanceZoomMin = 300;
distanceZoomMax = 300;
};
class Hamr2Scope {
cameradir = "";
distanceZoomMin = 300;
distanceZoomMax = 300;
memorypointcamera = "opticView";
opticsdisableperipherialvision = 0;
opticsdisplayname = "IHAMR";
opticsflare = 1;
opticsid = 2;
opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur1", "AGM_OpticsRadBlur1"};
opticszoominit = 0.0872664626;
opticszoommax = 0.0872664626;
opticszoommin = 0.0872664626;
discretefov[] = {0.0872664626};
discreteinitindex = 0;
usemodeloptics = 1;
modeloptics = "\AGM_Optics\agm_optics_pip.p3d";
visionmode[] = {"Normal", "NVG"};
};
};
};
};
class optic_Arco : ItemCore {
descriptionshort = "Advanced Rifle Combat Optic<br />Magnification: 4x<br />Reticle: SpecterDR 6.5mm";
displayname = "ARCO 4x";
picture = "\A3\weapons_F\Data\UI\gear_acco_Arco_CA.paa";
scope = 2;
weaponInfoType = "AGM_RscWeapon";
model = "\A3\weapons_f\acc\acco_Arco_F";
AGM_Optics_enhanced = 1;
AGM_Optics_reticle = "\AGM_Optics\data\arco\arco-reticle65_ca.paa";
AGM_Optics_reticleIllum = "\AGM_Optics\data\arco\arco-reticle65Illum_ca.paa";
AGM_Optics_body = "\AGM_Optics\data\arco\arco-body_ca.paa";
AGM_Optics_bodyNight = "\AGM_Optics\data\arco\arco-bodyNight_ca.paa";
class ItemInfo: InventoryOpticsItem_Base_F {
mass = 4;
optics = 1;
optictype = 1;
rmbhint = "ARCO";
class OpticsModes {
class ARCO2collimator {
AGM_Optics_enhanced = 0;
cameradir = "";
distancezoommax = 300;
distancezoommin = 300;
memorypointcamera = "eye";
opticsdisableperipherialvision = 0;
opticsdisplayname = "CQB";
opticsflare = 0;
opticsid = 1;
opticsppeffects[] = {};
opticszoominit = 0.75;
opticszoommax = 1.1;
opticszoommin = 0.375;
usemodeloptics = 0;
visionmode[] = {};
};
class ARCO2scope: ARCO2collimator {
cameradir = "";
distanceZoomMin = 300;
distanceZoomMax = 300;
memorypointcamera = "opticView";
opticsdisableperipherialvision = 0;
opticsdisplayname = "ARCO";
opticsflare = 1;
opticsid = 2;
opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur1", "AGM_OpticsRadBlur1"};
opticszoominit = 0.0872664626; // 0.0872664626 rad = 5 degrees
opticszoommax = 0.0872664626; // SpecterDR 4x is 6 degrees
opticszoommin = 0.0872664626; // Scope graphic in game covers 1 degree
discretefov[] = {0.0872664626};
discreteinitindex = 0;
usemodeloptics = 1;
modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
visionmode[] = {"Normal"};
};
};
};
};
class optic_MRCO : ItemCore {
displayName = "MRCO 1x/4x";
descriptionShort = "Medium Range Combat Optic<br />Magnification: 1x/4x<br />Reticle: Pitbull Gen II 5.56mm";
scope = 2;
weaponInfoType = "AGM_RscWeapon";
AGM_Optics_enhanced = 1;
AGM_Optics_reticle = "\AGM_Optics\data\mrco\mrco-reticle556_ca.paa";
AGM_Optics_reticleIllum = "\AGM_Optics\data\mrco\mrco-reticle556Illum_ca.paa";
AGM_Optics_body = "\AGM_Optics\data\mrco\mrco-body_ca.paa";
AGM_Optics_bodyNight = "\AGM_Optics\data\mrco\mrco-bodyNight_ca.paa";
class ItemInfo : InventoryOpticsItem_Base_F {
opticType = 1;
mass = 4;
optics = 1;
modelOptics = "\A3\Weapons_f_beta\acc\reticle_MRCO_F";
class OpticsModes {
class MRCOcq {
AGM_Optics_enhanced = 0;
opticsID = 1;
useModelOptics = 0;
opticsPPEffects[] = {};
opticsFlare = 0;
opticsDisablePeripherialVision = 0;
opticsZoomMin = 0.375;
opticsZoomMax = 1;
opticsZoomInit = 0.75;
memoryPointCamera = "eye";
visionMode[] = {};
distanceZoomMin = 100;
distanceZoomMax = 100;
};
class MRCOscope {
cameradir = "";
distanceZoomMin = 300;
distanceZoomMax = 300;
memorypointcamera = "eye";
opticsdisableperipherialvision = 0;
opticsdisplayname = "MRCO";
opticsflare = 1;
opticsid = 2;
opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur2", "AGM_OpticsRadBlur1"};
opticszoominit = 0.0872664626;
opticszoommax = 0.0872664626;
opticszoommin = 0.0872664626;
discretefov[] = {0.0872664626};
discreteinitindex = 0;
usemodeloptics = 1;
modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
visionmode[] = {"Normal"};
};
};
};
};
class optic_Nightstalker : ItemCore {
class ItemInfo: InventoryOpticsItem_Base_F {
class OpticsModes {
class NCTALKEP {};
class Iron : NCTALKEP {
opticsppeffects[] = {}; // Fix Arma 3 bug
};
};
};
};
class optic_SOS: ItemCore {
class ItemInfo: InventoryOpticsItem_Base_F {
modelOptics = "\AGM_Optics\agm_optics_pip.p3d";
class OpticsModes {
class Snip {
visionMode[] = {"Normal","TI","NVG"};
thermalMode[] = {5,6};
opticsPPEffects[] = {"OpticsCHAbera1","radblur"};
modelOptics[] = {"\AGM_Optics\agm_optics_pip.p3d","\AGM_Optics\agm_optics_pip.p3d"};
};
};
};
};
class optic_DMS : ItemCore {
class ItemInfo: InventoryOpticsItem_Base_F {
class OpticsModes {
class Snip {};
class Iron : Snip {
opticsppeffects[] = {}; // Fix Arma 3 bug
};
};
};
};
class optic_LRPS : ItemCore {
descriptionshort = "Nightforce NXS Riflescope<br />Magnification: 5.5-22x";
displayname = "NXS 5.5-22x";
weaponinfotype = "AGM_RscWeapon";
AGM_Optics_enhanced = 1;
AGM_Optics_reticle = "\AGM_Optics\data\sos\sos-reticleMLR_ca.paa";
AGM_Optics_reticleIllum = "\AGM_Optics\data\sos\sos-reticleMLRIllum_ca.paa";
AGM_Optics_body = "\AGM_Optics\data\sos\sos-body_ca.paa";
AGM_Optics_bodyNight = "\AGM_Optics\data\sos\sos-bodyNight_ca.paa";
class ItemInfo: InventoryOpticsItem_Base_F {
modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
weaponinfotype = "RscWeaponRangeZeroingFOV";
opticType = 2; // Sniper optics
class OpticsModes {
// Based on Nightforce NXS 5.5-22 scope
class Snip {
cameradir = "";
discretedistance[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300};
discretedistanceinitindex = 0;
discreteinitindex = 0;
distancezoommax = 2300;
distancezoommin = 100;
memorypointcamera = "opticView";
modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
opticsdisableperipherialvision = 1;
opticsdisplayname = "SOS";
opticsflare = 1;
opticsid = 1;
opticsppeffects[] = {"OpticsCHAbera1", "OpticsBlur1", "AGM_OpticsRadBlur1"};
// How to determine opticszoom
// First do the basic math based on the listed FOV of the scope to
// get a baseline FOV
// 0.1 meter at 100 meters = 1 mrad
//
// 5.5x FOV -- 5.3 m at 100 m = 53 mrad
// = 0.053 rad = 3.037 deg FOV
// 22x FOV -- 1.4 m at 100m = 14 mrad
// = 0.014 rad = 0.802 deg
// The FOV you give the engine is based on a rather larger scope outline, so we
// have to do this extra work ourselves.
// At 1680x1050
// The width of a TMR optic viewfield is 864px
// The engine viewport width (which is what the below FOV is based on) is 980
// (864/980) = (FOV to give engine / true FOV of optic)
// 864/980 * 0.053 = 0.04673
// 864/980 * 0.014 = 0.01234
// Measured experimentally, these values seem quite right.
// Certainly they're close enough after you account for pixel density, etc.
opticszoominit = 0.01234;
opticszoommax = 0.04673;
opticszoommin = 0.01234;
discretefov[] = {};
usemodeloptics = 1;
visionmode[] = {"Normal"};
};
};
};
};
class optic_Yorris : ItemCore {
descriptionshort = "Burris FastFire II Red Dot Sight<br />Magnification: 1x";
displayname = "FastFire II";
};
class optic_MRD : ItemCore {
descriptionshort = "Eotech MRDS Red Dot Sight<br />Magnification: 1x";
displayname = "MRDS";
};
class optic_Holosight : ItemCore {
descriptionshort = "Eotech XPS3 Holographic Sight<br />Magnification: 1x";
displayname = "XPS3 Holo";
};
};
class RscOpticsText;
class RscOpticsValue;
class RscInGameUI {
class RscUnitInfo;
class RscWeaponZeroing;
class AGM_RscWeapon : RscWeaponZeroing {
idd = -1;
controls[] = {"CA_Zeroing", "CA_FOVMode"};
onLoad ="with uiNameSpace do { AGM_OpticsIGUI = _this select 0 }";
class CA_FOVMode : RscOpticsValue {
idc = 154;
style = 2;
colorText[] = {0, 0, 0, 0};
x = 0;
y = 0;
w = 0;
h = 0;
};
};
};
class RscTitles {
class AGM_Optics_Scope {
idd = -1;
onLoad = "with uiNameSpace do { AGM_Optics_Scope = _this select 0 };";
onUnload = "";
movingEnable = 1;
duration = 10000;
controls[] = {"Reticle", "ReticleNight", "BodyNight", "Body"};
class Reticle {
colorBackground[] = {0,0,0, 0};
colorText[] = {1,1,1, 1};
fade = 0;
font = "PuristaMedium";
h = SafeZoneH;
idc = 1;
lineSpacing = 1.0;
movingEnable = 1;
size = 0;
sizeEx = 1;
style = 48;
text = "";
type = 0;
w = SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1));
x = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1)))/2);
y = SafeZoneY;
};
class ReticleNight : Reticle {
idc = 2;
text = "";
};
class Body : Reticle {
idc = 6;
text = "";
x = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1))));
y = SafeZoneY - (SafeZoneH/2);
w = SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1)) * 2;
h = SafeZoneH * 2;
};
class BodyNight : Body {
idc = 5;
text = "";
};
};
};
class PreloadTextures {
class CfgWeapons {
class optic_hamr {
AGM_Optics_body= "*";
AGM_Optics_bodyNight = "*";
AGM_Optics_reticle = "*";
AGM_Optics_reticleIllum = "*";
};
class optic_arco {
AGM_Optics_body= "*";
AGM_Optics_bodyNight = "*";
AGM_Optics_reticle = "*";
AGM_Optics_reticleIllum = "*";
};
class optic_mrco {
AGM_Optics_body= "*";
AGM_Optics_bodyNight = "*";
AGM_Optics_reticle = "*";
AGM_Optics_reticleIllum = "*";
};
class optic_LRPS {
AGM_Optics_body= "*";
AGM_Optics_bodyNight = "*";
AGM_Optics_reticle = "*";
AGM_Optics_reticleIllum = "*";
};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
ambient[]={0,0,0,0.89999998};
diffuse[]={0,0,0,0.89999998};
forcedDiffuse[]={0,0,0,1};
emmisive[]={0,0,0,1};
specular[]={0,0,0,0};
specularPower=1;
PixelShaderID="Normal";
VertexShaderID="Basic";

View File

@ -0,0 +1,20 @@
ambient[]={1,1,1,1};
diffuse[]={1,1,1,1};
forcedDiffuse[]={0,0,0,0};
emmisive[]={1,1,1,1};
specular[]={1,0.99956858,1,1};
specularPower=1;
PixelShaderID="Normal";
VertexShaderID="Basic";
class Stage1
{
texture="#(argb,8,8,3)color(0.5,0.5,0.5,0.5,DT)";
uvSource="tex";
class uvTransform
{
aside[]={1,0,0};
up[]={0,1,0};
dir[]={0,0,0};
pos[]={0,0,0};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,149 @@
/*
* Original Author: Taosenai
* Adapted By: KoffeinFlummi
*
* Animates the scope when firing.
*
* Arguments:
* 0: Unit
* 1: Weapon
* 2: Muzzle
* 3: Mode
* 4: Ammo
* 5: Magazine
* 6: Projectile
*
* Return Value:
* None
*/
if (_this select 0 != AGM_player) exitwith {}; // Sanity check
0 = _this spawn {
disableSerialization;
_weaponType = _this select 1;
_config = configFile >> "CfgWeapons" >> _weaponType;
_scope = uiNameSpace getVariable "AGM_Optics_Scope";
// @todo
_recoilMulti = getNumber (_config >> "tmr_smallarms_recoil_shakeMultiplier"); // Will be 0 if undefined
if (_recoilMulti == 0) then {
_recoilMulti = 1;
};
if (_recoilMulti > 2.6) then {
_recoilMulti = 2.6; // Don't get too high
};
// Reduce the reticle movement as the player drops into lower, supported stances.
_detectStance = (player selectionPosition "Neck" select 2);
if (_detectStance < 1.3) then {
_recoilMulti = _recoilMulti - 0.10;
};
if (_detectStance < 0.7) then {
_recoilMulti = _recoilMulti - 0.20;
};
// Reduce reticle movement if the player is rested (tmr_autorest).
if (player getVariable ["tmr_autorest_rested", false]) then {
_recoilMulti = _recoilMulti - 0.20;
};
// Reduce reticle movement if the player is deployed (tmr_autorest).
if (player getVariable ["tmr_autorest_deployed", false]) then {
_recoilMulti = _recoilMulti - 0.30;
};
_recoilMulti = 1;
// @endtodo
// Constants which determine how the scope recoils
_recoilScope = 0.03 * _recoilMulti + random 0.0015;
_recoilRing = 0.03 * _recoilMulti + random 0.0015;
_randomScopeShiftX = 0.005 * _recoilMulti - random 0.011;
_randomReticleShiftX = 0.0036 * _recoilMulti + random 0.0045; // Always tend up and right;
_randomReticleShiftY = -0.0046 * _recoilMulti - random 0.0055;
/////////
// Center everything
// getResolution select 4 should return the aspect ratio, but it's totally wrong
// for triple head displays. We'll compute it manually.
_aspectRatio = (getResolution select 0) / (getResolution select 1);
_reticleX = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / _aspectRatio)/2);
_reticleY = SafeZoneY;
_reticleW = SafeZoneWAbs / _aspectRatio;
_reticleH = SafeZoneH;
// Reticle
(_scope displayCtrl 1) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
// Reticle night (illum)
(_scope displayCtrl 2) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
_bodyX = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / _aspectRatio));
_bodyY = SafeZoneY - (SafeZoneH/2);
_bodyW = SafeZoneWAbs / _aspectRatio * 2;
_bodyH = SafeZoneH * 2;
// Body night
(_scope displayCtrl 5) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
// Body
(_scope displayCtrl 6) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
_centerDelay = 0.01;
(_scope displayCtrl 1) ctrlCommit _centerDelay;
(_scope displayCtrl 2) ctrlCommit _centerDelay;
(_scope displayCtrl 5) ctrlCommit _centerDelay;
(_scope displayCtrl 6) ctrlCommit _centerDelay;
/////////
// Create and commit recoil effect
// Move reticle
(_scope displayCtrl 1) ctrlSetPosition [_reticleX - (_recoilScope/2) + _randomReticleShiftX, _reticleY - (_recoilScope/2) + _randomReticleShiftY, _reticleW + _recoilScope, _reticleH + _recoilScope];
(_scope displayCtrl 2) ctrlSetPosition [_reticleX - (_recoilScope/2) + _randomReticleShiftX, _reticleY - (_recoilScope/2) + _randomReticleShiftY, _reticleW + _recoilScope, _reticleH + _recoilScope];
// Move body
(_scope displayCtrl 5) ctrlSetPosition [_bodyX - (_recoilScope/2) + _randomScopeShiftX, _bodyY - (_recoilScope/2), _bodyW + _recoilScope, _bodyH + _recoilScope];
(_scope displayCtrl 6) ctrlSetPosition [_bodyX - (_recoilScope/2) + _randomScopeShiftX, _bodyY - (_recoilScope/2), _bodyW + _recoilScope, _bodyH + _recoilScope];
_recoilDelay = 0.036;
_fa = false;
_cwm = currentWeaponMode player;
if (_cwm == "FullAuto" || _cwm == "manual" || _cwm == "Burst") then {
_recoilDelay = getNumber (_config >> _cwm >> "reloadTime")/2.2;
_fa = true;
};
(_scope displayCtrl 1) ctrlCommit _recoilDelay;
(_scope displayCtrl 2) ctrlCommit _recoilDelay;
(_scope displayCtrl 5) ctrlCommit _recoilDelay;
(_scope displayCtrl 6) ctrlCommit _recoilDelay;
//////////////
waituntil {sleep 0.01; ctrlCommitted (_scope displayCtrl 6)};
//////////////
//////
// Bring them all back
(_scope displayCtrl 1) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
(_scope displayCtrl 2) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
(_scope displayCtrl 5) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
(_scope displayCtrl 6) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
_recenterDelay = 0.09;
if (_fa) then {
_recenterDelay = getNumber (_config >> _cwm >> "reloadTime")/2.2;
};
(_scope displayCtrl 1) ctrlCommit _recenterDelay;
(_scope displayCtrl 2) ctrlCommit _recenterDelay;
(_scope displayCtrl 5) ctrlCommit _recenterDelay;
(_scope displayCtrl 6) ctrlCommit _recenterDelay;
};

View File

@ -0,0 +1,19 @@
/*
* Original Author: Taosenai
* Adapted By: KoffeinFlummi
*
* Hides the scope.
*
*/
private ["_scope"];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlCommit 0;

View File

@ -0,0 +1,25 @@
/*
* Original Author: Taosenai
* Adapted By: KoffeinFlummi
*
* Initializes the scope resources.
*
*/
private ["_display"];
// Make sure we only cutRsc when the resource isn't already available
if (isNil {uiNameSpace getVariable "AGM_Optics_Scope"} or {isNull (uiNameSpace getVariable "AGM_Optics_Scope")}) exitWith {
AGM_Optics_scopeRSC cutRsc ["AGM_Optics_Scope","PLAIN",0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlSetTextColor [1,1,1,0];
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlCommit 0;
((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlCommit 0;
True
};
False

View File

@ -0,0 +1,94 @@
/*
* Original Author: Taosenai
* Adapted By: KoffeinFlummi
*
* Monitors the RscInGameUI and displays the overlays when needed.
*
* Arguments:
* None
*
* Return Value:
* None
*/
if !(cameraOn == AGM_player && {alive AGM_player} && {!visibleMap} && {ctrlShown ((uinamespace getVariable "AGM_OpticsIGUI") displayCtrl 154)}) exitWith {
// Failed the state check, hide the scope if it's up
if (AGM_Optics_inScope) then {
// Hide the scope
AGM_Optics_inScope = false;
AGM_Optics_inScope_FOV = ([] call cba_fnc_getFOV) select 0;
[] call AGM_Optics_fnc_hideScope;
};
};
AGM_Optics_Camera setposATL (positioncameratoworld [0,0,0.4]);
AGM_Optics_Camera camPrepareTarget (positioncameratoworld [0,0,50]);
AGM_Optics_Camera camCommitPrepared 0;
if (cameraView == "Gunner") then {
AGM_Optics_Camera camsetFOV 0.7;
AGM_Optics_Camera camcommit 0;
} else {
AGM_Optics_Camera camsetFOV 0.01;
AGM_Optics_Camera camcommit 0;
};
private ["_optic", "_scope"];
disableSerialization;
// Get the name of the attached optic
_optic = (primaryWeaponItems AGM_player) select 2;
_scope = uiNameSpace getVariable "AGM_Optics_Scope";
// Init the scope (if needed)
[] call AGM_Optics_fnc_initScope;
// Check if the optic has changed since we last drew it
_doUpdateAllLayers = false;
if (AGM_Optics_currentOptic != _optic) then {
AGM_Optics_currentOptic = _optic;
_doUpdateAllLayers = true;
};
// Check if Splendid Camera, unit switch, etc. has blanked out our displays for no good reason (grrr)
if (ctrlText (_scope displayCtrl 1) == "") then {
_doUpdateAllLayers = true;
};
// Draw the correct layers (don't show them)
if (_doUpdateAllLayers) then {
(_scope displayCtrl 1) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_reticle");
(_scope displayCtrl 2) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_reticleIllum");
(_scope displayCtrl 5) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_bodyNight");
(_scope displayCtrl 6) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_body");
};
// Stop processing if already in the scope view and FOV hasn't changed
if (AGM_Optics_inScope) exitwith {};
// Mark that we're in enhanced scope view
AGM_Optics_inScope = true;
// Calculate lighting
_lighting = sunOrMoon; // 1 is day, 0 is night
_nightOpacity = 1;
_dayOpacity = (0 max moonIntensity * (1 - (0 max overcast)))/5;
if (_lighting == 1) then {
_nightOpacity = 0;
_dayOpacity = 1;
};
// Apply lighting and make layers visible
(_scope displayCtrl 1) ctrlSetTextColor [1,1,1,1];
(_scope displayCtrl 2) ctrlSetTextColor [1,1,1,_nightOpacity];
(_scope displayCtrl 5) ctrlSetTextColor [1,1,1,_nightOpacity];
(_scope displayCtrl 6) ctrlSetTextColor [1,1,1,_dayOpacity];
(_scope displayCtrl 1) ctrlCommit 0;
(_scope displayCtrl 2) ctrlCommit 0;
(_scope displayCtrl 5) ctrlCommit 0;
(_scope displayCtrl 6) ctrlCommit 0;

View File

@ -53,17 +53,6 @@ class RscTitles {
};
};
class ACE_EventHandlerHelper: ACE_Rsc_Display_Base {
idd = -1;
class controls {
class CameraView: RscMapControl {
onDraw = "if (cameraView != uiNamespace getVariable 'ACE_EventHandler_CameraMode') then {uiNamespace setVariable ['ACE_EventHandler_CameraMode', cameraView]; {[uiNamespace getVariable 'ACE_EventHandler_CameraMode'] call _x; nil} count ((missionNamespace getVariable 'ACE_EventHandler_CameraMode') select 2);};";
idc = -1;
w = 0;
h = 0;
};
};
};
class ACE_EventHandlerHelper2: ACE_Rsc_Display_Base {
class controls {
class MapMarkerCreated: RscMapControl {

View File

@ -6,9 +6,7 @@ ADDON = false;
// ACE Common Function
PREP(addActionEventHandler);
PREP(addActionMenuEventHandler);
PREP(addCameraEventHandler);
PREP(addCanInteractWithCondition);
PREP(addCustomEventHandler);
PREP(addLineToDebugDraw);
PREP(addMapMarkerCreatedEventHandler);
PREP(addScrollWheelEventHandler);
@ -21,8 +19,6 @@ PREP(beingCarried);
PREP(binarizeNumber);
PREP(blurScreen);
PREP(cachedCall);
PREP(callCustomEventHandlers);
PREP(callCustomEventHandlersGlobal);
PREP(canGetInPosition);
PREP(canInteract);
PREP(canInteractWith);
@ -150,9 +146,7 @@ PREP(readSettingFromModule);
PREP(receiveRequest);
PREP(removeActionEventHandler);
PREP(removeActionMenuEventHandler);
PREP(removeCameraEventHandler);
PREP(removeCanInteractWithCondition);
PREP(removeCustomEventHandler);
PREP(removeMapMarkerCreatedEventHandler);
PREP(removeScrollWheelEventHandler);
PREP(removeSpecificMagazine);
@ -258,8 +252,6 @@ if (hasInterface) then {
ACE_player = missionNamespace getVariable ["BIS_fnc_moduleRemoteControl_unit", player];
uiNamespace setVariable ["ACE_player", ACE_player];
// Raise custom event. @todo, remove
[missionNamespace, "playerChanged", [ACE_player, _oldPlayer]] call FUNC(callCustomEventHandlers);
// Raise ACE event
["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent);
};

View File

@ -1,39 +0,0 @@
/*
* Author: commy2
*
* Add a camera view event handler. The event script is called when the camera view changes.
* The argument of the called function is stored in the _this variable and has as first element the new camera mode. Possible arguments are ["INTERNAL"], ["EXTERNAL"], ["GUNNER"] and ["GROUP"].
*
* Argument:
* 0: Code to execute (Code or String)
*
* Return value:
* ID of the event script (used to remove it later).
*/
#include "script_component.hpp"
private ["_statement", "_actionsVar", "_id", "_actionIDs", "_actions"];
_statement = _this select 0;
if (typeName _statement == "STRING") then {
_statement = compile _statement;
};
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_CameraMode", [-1, [], []]];
_id = (_actionsVar select 0) + 1;
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
if (_id == 0) then {
uiNamespace setVariable ["ACE_EventHandler_CameraMode", cameraView];
(QGVAR(EventHandlerHelper) call BIS_fnc_rscLayer) cutRsc [QGVAR(EventHandlerHelper), "PLAIN"];
};
_actionIDs pushBack _id;
_actions pushBack _statement;
missionNamespace setVariable ["ACE_EventHandler_CameraMode", [_id, _actionIDs, _actions]];
_id

View File

@ -1,39 +0,0 @@
/*
* Author: commy2
*
* Add a custom event to a unit. The event scripts are called by FUNC(callCustomEventHandlers).
*
* Argument:
* 0: Object the event should be assigned to or namespace (Object OR Namespace)
* 1: Name of the event (String)
* 2: Code to execute (Code or String)
*
* Return value:
* ID of the event script (used to remove it later).
*/
#include "script_component.hpp"
private ["_object", "_type", "_statement", "_name", "_actionsVar", "_id", "_actionIDs", "_actions"];
_object = _this select 0;
_type = _this select 1;
_statement = _this select 2;
if (typeName _statement == "STRING") then {
_statement = compile _statement;
};
_name = format ["ACE_CustomEventHandlers_%1", _type];
_actionsVar = _object getVariable [_name, [-1, [], []]];
_id = (_actionsVar select 0) + 1;
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_actionIDs pushBack _id;
_actions pushBack _statement;
_object setVariable [_name, [_id, _actionIDs, _actions]];
_id

View File

@ -1,6 +1,6 @@
/*
* Author: CAA-Picard and Jaynus
* Returns the result of the function and caches it up to a given time
* Returns the result of the function and caches it up to a given time or event
*
* Arguments:
* 0: Parameters <ARRAY>
@ -8,6 +8,7 @@
* 2: Namespace to store the cache on <NAMESPACE>
* 3: Cache uid <STRING>
* 4: Max duration of the cache <NUMBER>
* 5: Event that clears the cache <STRING> (Optional)
*
* Return Value:
* Result of the function <ANY>
@ -20,6 +21,40 @@ EXPLODE_5_PVT(_this,_params,_function,_namespace,_uid,_duration);
if (((_namespace getVariable [_uid, [-99999]]) select 0) < diag_tickTime) then {
_namespace setVariable [_uid, [diag_tickTime + _duration, _params call _function]];
// Does the cache needs to be cleared on an event?
if (count _this > 5) then {
private ["_event","_varName","_cacheList"];
_event = _this select 5;
_varName = format [QGVAR(clearCache_%1),_event];
_cacheList = missionNamespace getVariable _varName;
// If there was no EH to clear these caches, add one
if (isNil {_cacheList}) then {
_cacheList = [];
missionNamespace setVariable [_varName, _cacheList];
[_event, {
private ["_varName","_cacheList"];
// _eventName is defined on the function that calls the event
#ifdef DEBUG_MODE_FULL
diag_log text format ["ACE: Clear cached variables on event: %1", _eventName];
#endif
// Get the list of caches to clear
_varName = format [QGVAR(clearCache_%1),_eventName];
_cacheList = missionNamespace getVariable [_varName, []];
// Erase all the cached results
{
_x call FUNC(eraseCache);
} forEach _cacheList;
// Empty the list
missionNamespace setVariable [_varName, []];
}] call FUNC(addEventhandler);
};
// Add this cache to the list of the event
_cacheList pushBack [_namespace, _uid];
};
#ifdef DEBUG_MODE_FULL
diag_log format ["Calculated result: %1 %2", _namespace, _uid];
} else {

View File

@ -1,31 +0,0 @@
/*
* Author: commy2
*
* Execute all custom event script assigned to this object.
*
* Argument:
* 0: Object the eventhandlers are assigned to or namespace (Object or Namespace)
* 1: Name of the event (String)
* 2: Arguments passed to the eventhandler script (Array, optional default: [Object the event handlers are assigned to])
*
* Return value:
* None.
*/
#include "script_component.hpp"
private ["_object", "_type", "_argument", "_name", "_actions"];
_object = _this select 0;
_type = _this select 1;
_argument = _this select 2;
if (isNil "_argument") then {_argument = [_object]};
_name = format ["ACE_CustomEventHandlers_%1", _type];
_actions = (_object getVariable [_name, [-1, [], []]]) select 2;
{
_argument call _x; nil;
} count _actions;
nil

View File

@ -1,16 +0,0 @@
/*
* Author: commy2
*
* Execute all custom event script assigned to this object on every machine.
*
* Argument:
* 0: Object the eventhandlers are assigned to or namespace (Object or Namespace)
* 1: Name of the event (String)
* 2: Arguments passed to the eventhandler script (Array, optional default: [Object the event handlers are assigned to])
*
* Return value:
* None.
*/
#include "script_component.hpp"
[_this, QUOTE(FUNC(callCustomEventHandlers)), 2] call FUNC(execRemoteFnc);

View File

@ -1,16 +1,16 @@
/*
* Author: commy2
*
* Check if the unit can interact.
*
* Arguments:
* 0: The player. (Object)
* 1: The interaction target. objNull to ignore. (Object)
* 2: Exceptions. What general conditions are to skip? (Array)
* 0: The player. <OBJECT>
* 1: The interaction target. objNull to ignore. <OBJECT>
* 2: Exceptions. What general conditions are to skip? <ARRAY> (Optional)
*
* Return Value:
* Unit can interact?
*
* Public: No
*/
#include "script_component.hpp"
@ -18,7 +18,11 @@ private ["_unit", "_target", "_exceptions"];
_unit = _this select 0;
_target = _this select 1;
_exceptions = _this select 2;
_exceptions = if (count _this > 2) then {
_this select 2;
} else {
[];
};
_exceptions = [_exceptions, {toLower _this}] call FUNC(map);

View File

@ -1,24 +1,24 @@
/*
* Author: commy2, Glowbal, PabstMirror
*
* Draw progress bar and execute given function if succesful.
* Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode]
*
* Argument:
* 0: NUMBER - Total Time (in game "time" seconds)
* 1: ARRAY - Arguments, passed to condition, fail and finish
* 2: CODE or STRING - On Finish: Code called or STRING raised as event.
* 3: CODE or STRING - On Failure: Code called or STRING raised as event.
* 4: STRING - (Optional) Localized Title
* 5: CODE - (Optional) Code to check each frame
* 6: ARRAY - (Optional) Exceptions for checking EGVAR(common,canInteractWith)
*
* Return value:
* Nothing
*
* Example:
* [5, [], {Hint "Finished!"}, {hint "Failure!"}, "My Title"] call ace_common_fnc_progressBar
*/
* Author: commy2, Glowbal, PabstMirror
*
* Draw progress bar and execute given function if succesful.
* Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode]
*
* Argument:
* 0: NUMBER - Total Time (in game "time" seconds)
* 1: ARRAY - Arguments, passed to condition, fail and finish
* 2: CODE or STRING - On Finish: Code called or STRING raised as event.
* 3: CODE or STRING - On Failure: Code called or STRING raised as event.
* 4: STRING - (Optional) Localized Title
* 5: CODE - (Optional) Code to check each frame
* 6: ARRAY - (Optional) Exceptions for checking EFUNC(common,canInteractWith)
*
* Return value:
* Nothing
*
* Example:
* [5, [], {Hint "Finished!"}, {hint "Failure!"}, "My Title"] call ace_common_fnc_progressBar
*/
#include "script_component.hpp"
@ -36,65 +36,69 @@ createDialog QGVAR(ProgressBar_Dialog);
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetText _localizedTitle;
if (GVAR(SettingProgressBarLocation) == 1) then {
private "_ctrlPos";
_ctrlPos = [1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2), 29 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2), 38 * (((safezoneW / safezoneH) min 1.2) / 40), 0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)];
(uiNamespace getVariable QGVAR(ctrlProgressBar)) ctrlSetPosition _ctrlPos;
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetPosition _ctrlPos;
(uiNamespace getVariable QGVAR(ctrlProgressBar)) ctrlCommit 0;
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlCommit 0;
private "_ctrlPos";
_ctrlPos = [1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2), 29 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2), 38 * (((safezoneW / safezoneH) min 1.2) / 40), 0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)];
(uiNamespace getVariable QGVAR(ctrlProgressBar)) ctrlSetPosition _ctrlPos;
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetPosition _ctrlPos;
(uiNamespace getVariable QGVAR(ctrlProgressBar)) ctrlCommit 0;
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlCommit 0;
};
_perFrameFunction = {
PARAMS_2(_parameters,_pfhID);
EXPLODE_8_PVT(_parameters,_args,_onFinish,_onFail,_condition,_player,_startTime,_totalTime,_exceptions);
private ["_elapsedTime", "_errorCode"];
PARAMS_2(_parameters,_pfhID);
EXPLODE_8_PVT(_parameters,_args,_onFinish,_onFail,_condition,_player,_startTime,_totalTime,_exceptions);
private ["_elapsedTime", "_errorCode"];
_elapsedTime = time - _startTime;
_errorCode = -1;
_elapsedTime = time - _startTime;
_errorCode = -1;
if (isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
_errorCode = 1;
} else {
if (ACE_player != _player) then {
_errorCode = 2;
if (isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
_errorCode = 1;
} else {
if (!([_args, _elapsedTime, _totalTime, _errorCode] call _condition)) then {
_errorCode = 3;
} else {
if (!([_player, objNull, _exceptions] call EGVAR(common,canInteractWith))) then {
_errorCode = 4;
if (ACE_player != _player) then {
_errorCode = 2;
} else {
if (_elapsedTime >= _totalTime) then {
_errorCode = 0;
};
if (!([_args, _elapsedTime, _totalTime, _errorCode] call _condition)) then {
_errorCode = 3;
} else {
if (!([_player, objNull, _exceptions] call EFUNC(common,canInteractWith))) then {
_errorCode = 4;
} else {
if (_elapsedTime >= _totalTime) then {
_errorCode = 0;
};
};
};
};
};
};
};
if (_errorCode != -1) then {
//Error or Success, close dialog and remove PFEH
closeDialog 0;
[_pfhID] call CBA_fnc_removePerFrameHandler;
if (_errorCode != -1) then {
//Error or Success, close dialog and remove PFEH
if (_errorCode == 0) then {
if ((typeName _onFinish) == (typeName "")) then {
[_onFinish, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
} else {
[_args, _elapsedTime, _totalTime, _errorCode] call _onFinish;
};
//Only close dialog if it's the progressBar:
if (!isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
closeDialog 0;
};
[_pfhID] call CBA_fnc_removePerFrameHandler;
if (_errorCode == 0) then {
if ((typeName _onFinish) == (typeName "")) then {
[_onFinish, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
} else {
[_args, _elapsedTime, _totalTime, _errorCode] call _onFinish;
};
} else {
if ((typeName _onFail) == (typeName "")) then {
[_onFail, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
} else {
[_args, _elapsedTime, _totalTime, _errorCode] call _onFail;
};
};
} else {
if ((typeName _onFail) == (typeName "")) then {
[_onFail, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
} else {
[_args, _elapsedTime, _totalTime, _errorCode] call _onFail;
};
//Update Progress Bar (ratio of elepased:total)
(uiNamespace getVariable QGVAR(ctrlProgressBar)) progressSetPosition (_elapsedTime / _totalTime);
};
} else {
//Update Progress Bar (ratio of elepased:total)
(uiNamespace getVariable QGVAR(ctrlProgressBar)) progressSetPosition (_elapsedTime / _totalTime);
};
};
[_perFrameFunction, 0, [_args, _onFinish, _onFail, _condition, _player, time, _totalTime, _exceptions]] call CBA_fnc_addPerFrameHandler;

View File

@ -1,34 +0,0 @@
/*
* Author: commy2
*
* Remove a camera view event handler.
*
* Argument:
* 0: ID of the event handler (Number)
*
* Return value:
* None.
*/
#include "script_component.hpp"
private ["_id", "_actionsVar", "_currentId", "_actionIDs", "_actions"];
_id = _this select 0;
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_CameraMode", [-1, [], []]];
_currentId = _actionsVar select 0;
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_id = _actionIDs find _id;
if (_id == -1) exitWith {};
_actionIDs set [_id, -1];
_actionIDs = _actionIDs - [-1];
_actions set [_id, []];//{}
_actions = _actions - [[]];//[{}]
missionNamespace setVariable ["ACE_EventHandler_CameraMode", [_currentId, _actionIDs, _actions]];

View File

@ -1,40 +0,0 @@
/*
* Author: commy2
*
* Remove a custom event handler from an object.
*
* Argument:
* 0: Unit the event handler is assigned to or namespace (Object OR Namespace)
* 1: Name of the event (String)
* 2: ID of the event handler (Number)
*
* Return value:
* None.
*/
#include "script_component.hpp"
private ["_object", "_type", "_id", "_name", "_actionsVar", "_currentId", "_actionIDs", "_actions"];
_object = _this select 0;
_type = _this select 1;
_id = _this select 2;
_name = format ["ACE_CustomEventHandlers_%1", _type];
_actionsVar = _object getVariable [_name, [-1, [], []]];
_currentId = _actionsVar select 0;
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_id = _actionIDs find _id;
if (_id == -1) exitWith {};
_actionIDs set [_id, -1];
_actionIDs = _actionIDs - [-1];
_actions set [_id, []];//{}
_actions = _actions - [[]];//[{}]
_object setVariable [_name, [_currentId, _actionIDs, _actions]];

View File

@ -1,44 +1,44 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_preInit) );
};
class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_preInit) );
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) );
};
class ADDON {
clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) );
};
};
class Extended_FiredBIS_EventHandlers {
class CAManBase {
class ADDON {
firedBIS = QUOTE( _this call FUNC(replaceATWeapon) );
class CAManBase {
class ADDON {
firedBIS = QUOTE( _this call FUNC(replaceATWeapon) );
};
};
};
};
// handle preloaded missile
class Extended_Init_EventHandlers {
class CAManBase {
class ADDON {
init = QUOTE( _this call FUNC(takeLoadedATWeapon) );
class CAManBase {
class ADDON {
init = QUOTE( _this call FUNC(takeLoadedATWeapon) );
};
};
};
};
class Extended_Take_EventHandlers {
class CAManBase {
class ADDON {
take = QUOTE( _this call FUNC(takeLoadedATWeapon); [_this select 0] call FUNC(updateInventoryDisplay); );
class CAManBase {
class ADDON {
take = QUOTE( _this call FUNC(takeLoadedATWeapon); [_this select 0] call FUNC(updateInventoryDisplay); );
};
};
};
};
class Extended_Put_EventHandlers {
class CAManBase {
class ADDON {
put = QUOTE( [_this select 0] call FUNC(updateInventoryDisplay); );
class CAManBase {
class ADDON {
put = QUOTE( [_this select 0] call FUNC(updateInventoryDisplay); );
};
};
};
};

View File

@ -1,24 +1,24 @@
class CfgMagazines {
class NLAW_F;
class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine
author = "$STR_ACE_Common_ACETeam";
scope = 1;
displayName = "$STR_ACE_Disposable_PreloadedMissileDummy";
picture = PATHTOEF(common,UI\blank_CO.paa);
weaponPoolAvailable = 0;
mass = 0;
};
class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy {
count = 0;
};
class ACE_UsedTube_F: NLAW_F {
author = "$STR_ACE_Common_ACETeam";
displayName = "$STR_ACE_Disposable_UsedTube";
descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription";
displayNameShort = "-";
count = 0;
weaponPoolAvailable = 0;
modelSpecial = "";
mass = 0;
};
class NLAW_F;
class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine
author = "$STR_ACE_Common_ACETeam";
scope = 1;
displayName = "$STR_ACE_Disposable_PreloadedMissileDummy";
picture = PATHTOEF(common,UI\blank_CO.paa);
weaponPoolAvailable = 0;
mass = 0;
};
class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy {
count = 0;
};
class ACE_UsedTube_F: NLAW_F {
author = "$STR_ACE_Common_ACETeam";
displayName = "$STR_ACE_Disposable_UsedTube";
descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription";
displayNameShort = "-";
count = 0;
weaponPoolAvailable = 0;
modelSpecial = "";
mass = 0;
};
};

View File

@ -1,146 +1,146 @@
class CfgVehicles {
#define MACRO_NONLAW \
class TransportMagazines { \
class _xx_NLAW_F { \
count = 0; \
}; \
#define MACRO_NONLAW \
class TransportMagazines { \
class _xx_NLAW_F { \
count = 0; \
}; \
};
class ReammoBox_F;
class NATO_Box_Base: ReammoBox_F {};
class Box_NATO_Ammo_F: NATO_Box_Base {
MACRO_NONLAW
};
class Box_NATO_WpsLaunch_F: NATO_Box_Base {
MACRO_NONLAW
};
class ReammoBox_F;
class NATO_Box_Base: ReammoBox_F {};
class Box_NATO_Ammo_F: NATO_Box_Base {
MACRO_NONLAW
};
class Box_NATO_WpsLaunch_F: NATO_Box_Base {
MACRO_NONLAW
};
class IND_Box_Base: ReammoBox_F {};
class Box_IND_WpsLaunch_F: IND_Box_Base {
MACRO_NONLAW
};
class Box_IND_Ammo_F: IND_Box_Base {
MACRO_NONLAW
};
class IND_Box_Base: ReammoBox_F {};
class Box_IND_WpsLaunch_F: IND_Box_Base {
MACRO_NONLAW
};
class Box_IND_Ammo_F: IND_Box_Base {
MACRO_NONLAW
};
class B_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class I_supplyCrate_F: B_supplyCrate_F {
MACRO_NONLAW
};
class C_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class B_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class I_supplyCrate_F: B_supplyCrate_F {
MACRO_NONLAW
};
class C_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class B_AssaultPack_rgr;
class B_AssaultPack_rgr_LAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_AssaultPack_rgr_ReconLAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_AssaultPack_rgr;
class B_AssaultPack_rgr_LAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_AssaultPack_rgr_ReconLAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_Carryall_mcamo;
class B_AssaultPack_mcamo_Ammo: B_Carryall_mcamo {
MACRO_NONLAW
};
class B_Carryall_oli;
class I_Fieldpack_oli_Ammo: B_Carryall_oli {
MACRO_NONLAW
};
class B_Carryall_mcamo;
class B_AssaultPack_mcamo_Ammo: B_Carryall_mcamo {
MACRO_NONLAW
};
class B_Carryall_oli;
class I_Fieldpack_oli_Ammo: B_Carryall_oli {
MACRO_NONLAW
};
class B_AssaultPack_dgtl;
class I_Fieldpack_oli_LAT: B_AssaultPack_dgtl {
MACRO_NONLAW
};
class B_AssaultPack_dgtl;
class I_Fieldpack_oli_LAT: B_AssaultPack_dgtl {
MACRO_NONLAW
};
class CargoNet_01_ammo_base_F;
class B_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class I_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class CargoNet_01_ammo_base_F;
class B_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class I_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class Slingload_01_Base_F;
class B_Slingload_01_Cargo_F: Slingload_01_Base_F {
MACRO_NONLAW
};
class Slingload_01_Base_F;
class B_Slingload_01_Cargo_F: Slingload_01_Base_F {
class Tank_F;
class APC_Tracked_01_base_F: Tank_F {
MACRO_NONLAW
};
/*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {
MACRO_NONLAW
};
class Tank_F;
class APC_Tracked_01_base_F: Tank_F {
MACRO_NONLAW
};
/*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};*/
class Car_F;
class MRAP_01_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_01_gmg_base_F: MRAP_01_base_F {
MACRO_NONLAW
};
class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_F: MRAP_01_base_F {
MACRO_NONLAW
};
class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F {
MACRO_NONLAW
};*/
class MRAP_03_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_03_hmg_base_F: MRAP_03_base_F {
MACRO_NONLAW
};
class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_F: MRAP_03_base_F {
MACRO_NONLAW
};
class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};*/
class Wheeled_APC_F: Car_F {};
class APC_Wheeled_03_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
class APC_Wheeled_01_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
/*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F {
MACRO_NONLAW
};*/
};
class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};*/
class Car_F;
class MRAP_01_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_01_gmg_base_F: MRAP_01_base_F {
MACRO_NONLAW
};
class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_F: MRAP_01_base_F {
MACRO_NONLAW
};
class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F {
MACRO_NONLAW
};*/
class MRAP_03_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_03_hmg_base_F: MRAP_03_base_F {
MACRO_NONLAW
};
class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_F: MRAP_03_base_F {
MACRO_NONLAW
};
class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};*/
class Wheeled_APC_F: Car_F {};
class APC_Wheeled_03_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
class APC_Wheeled_01_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
/*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F {
MACRO_NONLAW
};*/
};

View File

@ -1,18 +1,18 @@
class CfgWeapons {
class Launcher_Base_F;
class launch_NLAW_F: Launcher_Base_F {
ACE_UsedTube = "ACE_launch_NLAW_Used_F"; // The class name of the used tube.
magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine
};
class ACE_launch_NLAW_Used_F: launch_NLAW_F { // the used tube should be a sub class of the disposable launcher
scope = 1;
ACE_isUsedLauncher = 1;
author = "$STR_ACE_Common_ACETeam";
displayName = "$STR_ACE_Disposable_UsedTube";
descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription";
magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again.
//picture = ""; @todo
//model = ""; @todo
weaponPoolAvailable = 0;
};
class Launcher_Base_F;
class launch_NLAW_F: Launcher_Base_F {
ACE_UsedTube = "ACE_launch_NLAW_Used_F"; // The class name of the used tube.
magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine
};
class ACE_launch_NLAW_Used_F: launch_NLAW_F { // the used tube should be a sub class of the disposable launcher
scope = 1;
ACE_isUsedLauncher = 1;
author = "$STR_ACE_Common_ACETeam";
displayName = "$STR_ACE_Disposable_UsedTube";
descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription";
magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again.
//picture = ""; @todo
//model = ""; @todo
weaponPoolAvailable = 0;
};
};

View File

@ -1,7 +1,7 @@
ace_disposable
==============
Makes the NLAW a disposable one-way weapon.
Makes the NLAW a disposable one-shot weapon.
## Maintainers

View File

@ -4,10 +4,8 @@
#include "script_component.hpp"
if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then {
GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{
["inventoryDisplayLoaded",{
_player = ACE_player;
[_player, secondaryWeapon _player] call FUNC(takeLoadedATWeapon);
[_player] call FUNC(takeLoadedATWeapon);
[_player, (_this select 0)] call FUNC(updateInventoryDisplay);
}] call EFUNC(common,addEventHandler);
};
}] call EFUNC(common,addEventHandler);

View File

@ -2,7 +2,6 @@
ADDON = false;
PREP(aiDropWeaponCallback);
PREP(replaceATWeapon);
PREP(takeLoadedATWeapon);
PREP(updateInventoryDisplay);

View File

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

View File

@ -1,32 +0,0 @@
/*
* Author: bux, commy2
*
* Remove the ai's missle launcher tube
*
* Return value:
* Nothing
*/
#include "script_component.hpp"
private ["_unit", "_tube", "_projectile", "_logic"];
_unit = (_this select 0) select 0;
_tube = (_this select 0) select 1;
_projectile = (_this select 0) select 2;
if (!isNull _projectile) exitWith {};
//remove frameEH
[(_this select 1)] call cba_fnc_removePerFrameHandler;
if ([_unit] call EFUNC(common,isPlayer)) exitWith {}; //Just in case a player took control
if (!alive _unit) exitWith {}; //No point doing this for dead
//If AI still has tube, throw it on ground
if (secondaryWeapon _unit == _tube) then {
_logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
_logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items
_unit removeWeaponGlobal _tube;
};

View File

@ -1,38 +1,79 @@
/*
* Author: commy2
*
* Author: bux, commy2
* Replace the disposable launcher with the used dummy.
*
* Argument:
* Input from "Fired" eventhandler
*
* Return value:
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
* 1: weapon - Fired weapon <STRING>
* 2: muzzle - Muzzle that was used <STRING>
* 3: mode - Current mode of the fired weapon <STRING>
* 4: ammo - Ammo used <STRING>
* 5: magazine - magazine name which was used <STRING>
* 6: projectile - Object of the projectile that was shot <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [fromBisFiredEH] call ace_disposable_fnc_replaceATWeapon;
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit", "_tube", "_projectile"];
private ["_unit", "_weapon", "_projectile", "_replacementTube", "_items"];
_unit = _this select 0;
_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube");
_weapon = _this select 1;
_projectile = _this select 6;
if (!local _unit) exitWith {};
if (_tube == "") exitWith {};
private "_items";
_replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit
if (_weapon != (secondaryWeapon _unit)) exitWith {}; //just to be sure
//Save array of items attached to launcher
_items = secondaryWeaponItems _unit;
_unit addWeapon _tube;
_unit selectWeapon _tube;
//Replace the orginal weapon with the 'usedTube' weapon
_unit addWeapon _replacementTube;
//Makes sure the used tube is still equiped
_unit selectWeapon _replacementTube;
//Re-add all attachments to the used tube
{
if (_x != "") then {_unit addSecondaryWeaponItem _x};
if (_x != "") then {_unit addSecondaryWeaponItem _x};
} forEach _items;
// AI
// AI - Remove the ai's missle launcher tube after the missle has exploded
if !([_unit] call EFUNC(common,isPlayer)) then {
//waits until _projectile is null, so random 0-2 tickTime seconds after that
[FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler;
[{
EXPLODE_2_PVT(_this,_params,_pfhId);
EXPLODE_3_PVT(_params,_unit,_tube,_projectile);
//don't do anything until projectile is null (exploded/max range)
if (isNull _projectile) then {
//Remove PFEH:
[_pfhId] call cba_fnc_removePerFrameHandler;
//If (tube is dropped) OR (is dead) OR (is player) just exit
if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {};
private ["_items", "_container"];
// _items = secondaryWeaponItems _unit;
_container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
_container setPosAsl (getPosAsl _unit);
_container addWeaponCargoGlobal [_tube, 1];
//This will duplicate attachements, because we will be adding a weapon that may already have attachments on it
//We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container:
// {
// if (_x != "") then {_container addItemCargoGlobal [_x, 1];};
// } forEach _items;
_unit removeWeaponGlobal _tube;
};
}, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;
};

View File

@ -1,48 +1,50 @@
/*
* Author: commy2
*
* Handle the take event. Add a dummy magazine if a disposable rocket launcher is taken.
*
* Argument:
* Input from "Take" eventhandler
*
* Return value:
* Nothing
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
*
* Return Value:
* None
*
* Example:
* [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon;
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit", "_launcher", "_config"];
_unit = _this select 0;
_launcher = secondaryWeapon _unit;
PARAMS_1(_unit);
if (!local _unit) exitWith {};
_launcher = secondaryWeapon _unit;
_config = configFile >> "CfgWeapons" >> _launcher;
if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then {
private ["_magazine", "_isLauncherSelected"];
private ["_magazine", "_isLauncherSelected"];
_magazine = getArray (_config >> "magazines") select 0;
_magazine = getArray (_config >> "magazines") select 0;
_isLauncherSelected = currentWeapon _unit == _launcher;
_isLauncherSelected = currentWeapon _unit == _launcher;
_unit removeMagazines _magazine;
_unit removeMagazines _magazine;
if (backpack _unit == "") then {
_unit addBackpack "Bag_Base";
if (backpack _unit == "") then {
_unit addBackpack "Bag_Base";
_unit addMagazine _magazine;
_unit addWeapon _launcher;
_unit addMagazine _magazine;
_unit addWeapon _launcher;
removeBackpack _unit;
} else {
_unit addMagazine _magazine;
_unit addWeapon _launcher;
};
removeBackpack _unit;
} else {
_unit addMagazine _magazine;
_unit addWeapon _launcher;
};
if (_isLauncherSelected) then {
_unit selectWeapon _launcher;
};
if (_isLauncherSelected) then {
_unit selectWeapon _launcher;
};
};

View File

@ -1,26 +1,28 @@
/*
* Author: bux, commy2
*
* Hide or show the secondary weapon magazine inventory slot to prevent unloading of dummy magazines.
*
* Argument:
* 0: The player. (Object)
*
* Return value:
* Nothing
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_disposable_fnc_updateInventoryDisplay;
*
* Public: No
*/
#include "script_component.hpp"
private ["_player", "_display"];
disableSerialization;
_player = _this select 0;
PARAMS_1(_player);
DEFAULT_PARAM(1,_display,(findDisplay 602));
_player removeMagazines "ACE_PreloadedMissileDummy";
_player removeMagazines "ACE_FiredMissileDummy";
disableSerialization;
_display = [_this, 1, (findDisplay 602)] call BIS_fnc_param;
if (isNull _display) exitWith {};
private ["_launcher", "_control", "_config"];
@ -28,21 +30,21 @@ private ["_launcher", "_control", "_config"];
_launcher = secondaryWeapon _player;
if (_launcher == "" || {getText (configFile >> "CfgWeapons" >> _launcher >> "ACE_UsedTube") == ""}) then {
_control = _display displayCtrl 627;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
_control = _display displayCtrl 627;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "BackgroundSlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "BackgroundSlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
} else {
_control = _display displayCtrl 627;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
_control = _display displayCtrl 627;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
};

View File

@ -48,5 +48,8 @@ if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses_carry) = _initializedClasses;
[_type, 0, ["ACE_MainActions", QGVAR(carry)], localize "STR_ACE_Dragging_Carry", "", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}, 2] call EFUNC(interact_menu,addClassAction);
[_type, 0, ["ACE_MainActions", QGVAR(drop_carry)], localize "STR_ACE_Dragging_Drop", "", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}, 2] call EFUNC(interact_menu,addClassAction);
_carryAction = [QGVAR(drag), localize "STR_ACE_Dragging_Carry", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
_dropAction = [QGVAR(drop), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, ["ACE_MainActions"], _dropAction] call EFUNC(interact_menu,addActionToClass);

View File

@ -48,5 +48,8 @@ if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses) = _initializedClasses;
[_type, 0, ["ACE_MainActions", QGVAR(drag)], localize "STR_ACE_Dragging_Drag", "", "", {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}, 2] call EFUNC(interact_menu,addClassAction);
[_type, 0, ["ACE_MainActions", QGVAR(drop)], localize "STR_ACE_Dragging_Drop", "", "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}, 2] call EFUNC(interact_menu,addClassAction);
_dragAction = [QGVAR(drag), localize "STR_ACE_Dragging_Drag", "", {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}] call EFUNC(interact_menu,createAction);
_dropAction = [QGVAR(drop), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions"], _dragAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, ["ACE_MainActions"], _dropAction] call EFUNC(interact_menu,addActionToClass);

View File

@ -3,7 +3,7 @@
["ACE3", QGVAR(lazeTarget), localize "STR_ACE_FCS_LaseTarget",
{
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false};
@ -20,7 +20,7 @@
GVAR(isDownStateKey1) = false;
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !(GVAR(enabled) && FUNC(canUseFCS)) exitWith {false};
@ -33,7 +33,7 @@
["ACE3", QGVAR(adjustRangeUp), localize "STR_ACE_FCS_AdjustRangeUp",
{
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};
@ -47,7 +47,7 @@
["ACE3", QGVAR(adjustRangDown), localize "STR_ACE_FCS_AdjustRangeDown",
{
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};

View File

@ -26,7 +26,7 @@ class CfgAmmo {
ACE_FRAG_SKIP = 0;
ACE_FRAG_FORCE = 1;
// This is a good high-drag frag type for grenades.
ACE_FRAG_CLASSES[] = {"ACE_frag_medium_HD"};
ACE_FRAG_CLASSES[] = {"ACE_frag_tiny_HD"};
/*
These values are based on the M67 Grenade, should be tweaked for
individual grenades.

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
[QUOTE(ffsBIS), "oneachframe", QUOTE(FUNC(onFrame))] call BIS_fnc_addStackedEventHandler;
if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call CBA_fnc_addClientToServerEventhandler;
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
};
/*
GVAR(replacedBisArtyWrapper) = false;
[] spawn {
waitUntil {
@ -15,3 +15,4 @@ GVAR(replacedBisArtyWrapper) = false;
GVAR(replacedBisArtyWrapper)
};
};
*/

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
#define ACE_TRACE_DRAW_INC 1
ADDON = false;
PREP(fired);
@ -14,7 +14,7 @@ GVAR(trackedObjects) = [];
GVAR(blackList) = [];
GVAR(traceFrags) = false;
GVAR(replacedBisArtyWrapper) = false;
GVAR(replacedBisArtyWrapper) = true;
GVAR(TOTALFRAGS) = 0;

View File

@ -3,5 +3,5 @@ private ["_round"];
_round = _this select 0;
if(alive _round) then {
GVAR(trackedObjects) set[(count GVAR(trackedObjects)), _round];
[FUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), (typeOf _round), time, objNull, false, 0, 0]] call cba_fnc_addPerFrameHandler;
[DFUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), (typeOf _round), time, objNull, false, 0, 0]] call cba_fnc_addPerFrameHandler;
};

View File

@ -17,4 +17,4 @@ _objTVel = sqrt((_objVel select 0)^2 + (_objVel select 1)^2 + (_objVel select 2)
_positions set[(count _positions), [(getPos _obj), _objTVel]];
_data = [_origin, typeOf _origin, typeOf _obj, _objTVel, _positions, _color];
GVAR(traces) set[_index, _data];
[FUNC(trackTrace), 0, [_obj, _index, time]] call cba_fnc_addPerFrameHandler;
[DFUNC(trackTrace), 0, [_obj, _index, time]] call cba_fnc_addPerFrameHandler;

View File

@ -44,13 +44,12 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_exit = false;
_vm = 1;
_velocity = _initialData select 5;
_unitDir = _velocity call BIS_fnc_unitVector;
_oldVelocity = _velocity call BIS_fnc_magnitude;
_curVelocity = (velocity _round) call BIS_fnc_magnitude;
if(alive _round) then {
_diff = [_velocity, (velocity _round)] call FUNC(vectorDiffFast);
_diff = _velocity vectorDiff (velocity _round);
_polar = _diff call CBA_fnc_vect2polar;
// player sideChat format["polar: %1", _polar];
if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then {
@ -63,7 +62,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
};
};
if(!_exit) then {
_unitDir = _velocity call BIS_fnc_unitVector;
_unitDir = vectorNormalized _velocity;
_pos = _hpData select 3;
_spallPos = nil;
for "_i" from 0 to 100 do {
@ -137,7 +136,6 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
// [fnc_spallTrackPFH, 0, [_fragment, diag_tickTime]] call cba_fnc_addPerFrameHandler;
if(GVAR(traceFrags)) then {
[player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
};
@ -159,7 +157,6 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
// [fnc_spallTrackPFH, 0, [_fragment, diag_tickTime]] call cba_fnc_addPerFrameHandler;
if(GVAR(traceFrags)) then {
[player, _fragment, [1,0,0,1]] call FUNC(addTrack);
};

View File

@ -1,5 +1,4 @@
#include "script_component.hpp"
/*
private ["_gun", "_type", "_round", "_doFragTrack", "_doSpall"];
if !(isNil QGVAR(enabled) && {GVAR(enabled)}) exitWith {};
@ -23,7 +22,7 @@ if(_gun == player) then {
};
};
};
_doSpall = true;
_doSpall = false;
if(_doSpall) then {
if(GVAR(spallIsTrackingCount) <= 0) then {
GVAR(spallHPData) = [];
@ -36,15 +35,14 @@ if(_doSpall) then {
};
};
// player sideChat format["c: %1", GVAR(spallIsTrackingCount)];
[player, _round, [1,0,0,1]] call FUNC(addTrack);
[player, _round, [1,0,0,1]] call nou_fnc_addTrack;
if(_doFragTrack && alive _round) then {
GVAR(trackedObjects) set[(count GVAR(trackedObjects)), _round];
GVAR(trackedObjects) pushBack _round;
_spallTrack = [];
_spallTrackID = [];
[FUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), _type, time, _gun, _doSpall, _spallTrack, _spallTrackID]] call cba_fnc_addPerFrameHandler;
[DFUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), _type, time, _gun, _doSpall, _spallTrack, _spallTrackID]] call cba_fnc_addPerFrameHandler;
if(_doSpall) then {
[_round, 2, _spallTrack, _spallTrackID] call FUNC(spallTrack);
};
// player sideChat "WTF2";
};
*/

View File

@ -6,5 +6,5 @@ _shell = _params select 0;
if(alive _shell) then {
drop ["\Ca\Data\Cl_basic","","Billboard",1,30,(getPos _shell),[0,0,0],1,1.275,1.0,0.0,[0.5],[[0,1,0,1]],[0],0.0,2.0,"","",""];
} else {
[_this select 1] call FUNC(removeBISPFH);
[_this select 1] call cba_fnc_removePerFrameHandler;
};

View File

@ -130,11 +130,12 @@ if(_isArmed && (count _objects) > 0) then {
_targetVel = (velocity _target);
_targetPos set[2, (_targetPos select 2)+_add];
_targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))];
_targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))];
_baseVec = [_lastPos, _targetPos] call BIS_fnc_vectorFromXToY;
_targetPos set[2, (_targetPos select 2)+_add];
_baseVec = _lastPos vectorFromTo _targetPos;
_dir = floor(_baseVec call CBA_fnc_vectDir);
_currentCount = _fragArcs select _dir;
@ -213,7 +214,6 @@ if(_isArmed && (count _objects) > 0) then {
_fragObj setVelocity _vel;
#ifdef DEBUG_MODE_FULL
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1;
// [FUNC(frag_trace), 0, [_fragObj]] call cba_fnc_addPerFrameHandler;
GVAR(traceFrags) = true;
#endif
if(GVAR(traceFrags)) then {

View File

@ -21,7 +21,7 @@ if((_this select 0) <= (count GVAR(spallHPData))) then {
// diag_log text format["%1: %2", _forEachIndex, _x];
// } forEach _hp;
// } forEach (_this select 1);
[FUNC(doSpall), 0, [_this, _forEachIndex]] call cba_fnc_addPerFrameHandler;
[DFUNC(doSpall), 0, [_this, _forEachIndex]] call cba_fnc_addPerFrameHandler;
// player sideChat "WEEE";
} forEach (_this select 1);
};

View File

@ -1,5 +1,5 @@
#include "script_component.hpp"
if(GVAR(tracesStarted)) then {
GVAR(tracesStarted) = false;
[GVAR(traceID)] call FUNC(removeBISPFH);
[GVAR(traceID)] call cba_fnc_removePerFrameHandler;
};

View File

@ -12,7 +12,7 @@ _spallTrack = _params select 7;
_foundObjectHPIds = _params select 8;
if (!alive _round) then {
[_this select 1] call FUNC(removeBISPFH);
[_this select 1] call cba_fnc_removePerFrameHandler;
if(_time != time && {_round in GVAR(trackedObjects)} && {!(_round in GVAR(blackList))}) then {
GVAR(trackedObjects) = GVAR(trackedObjects) - [_round];
_skip = getNumber (configFile >> "CfgAmmo" >> _type >> "ACE_FRAG_SKIP");
@ -22,7 +22,7 @@ if (!alive _round) then {
_force = getNumber (configFile >> "CfgAmmo" >> _type >> "ACE_FRAG_FORCE");
_fragPower = getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt(_indirectRange));
if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then {
[QGVAR(frag_eh), _params] call CBA_fnc_clientToServerEvent;
[QGVAR(frag_eh), _params] call ace_common_fnc_serverEvent;
GVAR(trackedObjects) = GVAR(trackedObjects) - [_round];
};
};
@ -38,7 +38,7 @@ if (!alive _round) then {
};
} else {
if(!(_round in GVAR(trackedObjects)) || {_round in GVAR(blackList)}) then {
[_this select 1] call FUNC(removeBISPFH);
[_this select 1] call cba_fnc_removePerFrameHandler;
if(_round in GVAR(blackList)) then {
GVAR(blackList) = GVAR(blackList) - [_round];
};

View File

@ -10,5 +10,5 @@ if(alive _tracerObj && (count GVAR(traces)) > 0) then {
_objTVel = sqrt((_objVel select 0)^2 + (_objVel select 1)^2 + (_objVel select 2)^2);
_positions set[(count _positions), [(getPos _tracerObj), _objTVel]];
} else {
[(_this select 1)] call FUNC(removeBISPFH);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};

View File

@ -1,7 +1,7 @@
#define COMPONENT frag
#include "\z\ace\Addons\main\script_mod.hpp"
#define DEBUG_ENABLED_FRAG
//#define DEBUG_ENABLED_FRAG
#ifdef DEBUG_ENABLED_FRAG
#define DEBUG_MODE_FULL
@ -11,4 +11,6 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_FRAG
#endif
#include "\z\ace\Addons\main\script_macros.hpp"
#include "\z\ace\Addons\main\script_macros.hpp"
#define ACE_TRACE_DRAW_INC 1

View File

@ -1 +1 @@
z\ace\addons\hearing
z\ace\addons\gforces

View File

@ -13,7 +13,7 @@ GVAR(flashbangPPEffectCC) ppEffectForceInNVG true;
["ACE3", QGVAR(switchGrenadeMode), localize "STR_ACE_Grenades_SwitchGrenadeMode",
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotEscorting"]] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, ["isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call EFUNC(common,canUseWeapon))) exitWith {false};

View File

@ -2,21 +2,25 @@
ADDON = false;
PREP(addAction);
PREP(addClassAction);
PREP(addActionToClass);
PREP(addActionToObject);
PREP(compileMenu);
PREP(compileMenuSelfAction);
PREP(collectActiveActionTree);
PREP(createAction);
PREP(findActionNode);
PREP(isSubPath);
PREP(keyDown);
PREP(keyDownSelfAction);
PREP(keyUp);
PREP(keyUpSelfAction);
PREP(removeAction);
PREP(removeClassAction);
PREP(removeActionFromClass);
PREP(removeActionFromObject);
PREP(render);
PREP(renderIcon);
PREP(renderBaseMenu);
PREP(renderIcon);
PREP(renderMenu);
PREP(splitPath);
GVAR(keyDown) = false;
GVAR(keyDownSelfAction) = false;
@ -26,7 +30,6 @@ GVAR(lastTime) = diag_tickTime;
GVAR(rotationAngle) = 0;
GVAR(selectedAction) = [[],[]];
GVAR(selectedStatement) = {};
GVAR(actionSelected) = false;
GVAR(selectedTarget) = objNull;
@ -40,6 +43,7 @@ GVAR(lastPath) = [];
GVAR(expanded) = false;
GVAR(startHoverTime) = diag_tickTime;
GVAR(expandedTime) = diag_tickTime;
GVAR(iconCtrls) = [];
GVAR(iconCount) = 0;

View File

@ -1,59 +0,0 @@
/*
* Author: commy2, NouberNou and CAA-Picard
* Add an ACE action to an object, under a certain config path
* Note: This function is NOT global.
*
* Argument:
* 0: Object the action should be assigned to <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the new action <ARRAY>
* 3: Name of the action shown in the menu <STRING>
* 4: Icon <STRING>
* 5: Position (Position or Selection Name) <POSITION> or <STRING>
* 6: Statement <CODE>
* 7: Condition <CODE>
* 8: Distance <NUMBER>
* 9: Other parameters <ARRAY> (Optional)
*
* Return value:
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
*
* Example:
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100] call ace_interact_menu_fnc_addAction;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_9_PVT(_this,_object,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
private ["_varName","_actions","_params","_entry"];
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
_actions = _object getVariable [_varName, []];
if((count _actions) == 0) then {
_object setVariable [_varName, _actions];
};
_params = [false,false,false,false];
if (count _this > 9) then {
_params = _this select 9;
};
_entry = [
[
_displayName,
_icon,
_position,
_statement,
_condition,
_distance,
_params,
+ _fullPath
],
[]
];
_actions pushBack _entry;
_fullPath

View File

@ -0,0 +1,45 @@
/*
* Author: CAA-Picard
* Insert an ACE action to a class, under a certain path
* Note: This function is NOT global.
*
* Argument:
* 0: TypeOf of the class <STRING>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Parent path of the new action <ARRAY>
* 3: Action <ARRAY>
*
* Return value:
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
*
* Example:
* [typeOf cursorTarget, 0, ["ACE_TapShoulderRight"],VulcanPinchAction] call ace_interact_menu_fnc_addActionToClass;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_4_PVT(_this,_objectType,_typeNum,_parentPath,_action);
// Ensure the config menu was compiled first
if (_typeNum == 0) then {
[_objectType] call FUNC(compileMenu);
} else {
[_objectType] call FUNC(compileMenuSelfAction);
};
private ["_varName","_actionTrees", "_parentNode"];
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actionTrees = missionNamespace getVariable [_varName, []];
if((count _actionTrees) == 0) then {
missionNamespace setVariable [_varName, _actionTrees];
};
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
if (isNil {_parentNode}) exitWith {};
// Add action node as children of the correct node of action tree
(_parentNode select 1) pushBack [_action,[]];
// Return the full path
(+ _parentPath) pushBack (_action select 0)

View File

@ -0,0 +1,35 @@
/*
* Author: CAA-Picard
* Insert an ACE action to an object, under a certain config path
* Note: This function is NOT global.
*
* Argument:
* 0: Object the action should be assigned to <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Parent path of the new action <ARRAY>
* 3: Action <ARRAY>
*
* Return value:
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
*
* Example:
* [typeOf cursorTarget, 0, ["ACE_TapShoulderRight"],VulcanPinchAction] call ace_interact_menu_fnc_addActionToClass;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_4_PVT(_this,_object,_typeNum,_parentPath,_action);
private ["_varName","_actionList"];
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
_actionList = _object getVariable [_varName, []];
if((count _actionList) == 0) then {
_object setVariable [_varName, _actionList];
};
// Add action and parent path to the list of object actions
_actionList pushBack [_action, +_parentPath];
// Return the full path
(+ _parentPath) pushBack (_action select 0)

View File

@ -1,94 +0,0 @@
/*
* Author: CAA-Picard
* Add an ACE action to a class, under a certain path
* Note: This function is NOT global.
*
* Argument:
* 0: TypeOf of the class <STRING>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the new action <ARRAY>
* 3: Name of the action shown in the menu <STRING>
* 4: Icon <STRING>
* 5: Position (Position or Selection Name) <POSITION> or <STRING>
* 6: Statement <CODE>
* 7: Condition <CODE>
* 8: Distance <NUMBER>
* 9: Other parameters <ARRAY> (Optional)
*
* Return value:
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
*
* Example:
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100] call ace_interact_menu_fnc_addClassAction;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_9_PVT(_this,_objectType,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
// Ensure the config menu was compiled first
if (_typeNum == 0) then {
[_objectType] call FUNC(compileMenu);
} else {
[_objectType] call FUNC(compileMenuSelfAction);
};
private ["_varName","_actions","_params","_entry", "_parentLevel", "_foundParentLevel", "_fnc_findFolder"];
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actions = missionNamespace getVariable [_varName, []];
if((count _actions) == 0) then {
missionNamespace setVariable [_varName, _actions];
};
_params = [false,false,false,false];
if (count _this > 9) then {
_params = _this select 9;
};
// Search the class action trees and find where to insert the entry
_parentLevel = _actions;
_foundParentLevel = false;
_fnc_findFolder = {
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
if (count _fullPath == _level + 1) then {
_parentLevel = _classActions;
_foundParentLevel = true;
};
if (_foundParentLevel) exitWith {};
{
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
// The action should go somewhere in here
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
};
} forEach _classActions;
};
[_fullPath, 0, _actions] call _fnc_findFolder;
// Exit if there's no entry point to insert this action
if (!_foundParentLevel) exitWith {};
_entry = [
[
_displayName,
_icon,
_position,
_statement,
_condition,
_distance,
_params,
+ _fullPath
],
[]
];
_parentLevel pushBack _entry;
_fullPath

View File

@ -5,6 +5,7 @@
* Argument:
* 0: Object <OBJECT>
* 1: Original action tree <ARRAY>
* 2: Parent path <ARRAY>
*
* Return value:
* Active children <ARRAY>
@ -13,24 +14,39 @@
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_object,_origAction);
EXPLODE_3_PVT(_this,_object,_origAction,_parentPath);
EXPLODE_2_PVT(_origAction,_origActionData,_origActionChildren);
private ["_resultingAction","_target","_player","_activeChildren","_action","_actionData","_x"];
private ["_target","_player","_fullPath","_activeChildren","_dynamicChildren","_action","_actionData","_x"];
_target = _object;
_player = ACE_player;
// Return nothing if the action itself is not active
if !([_target, ACE_player] call (_origActionData select 4)) exitWith {
if !([_target, ACE_player, _origActionData select 6] call (_origActionData select 4)) exitWith {
[]
};
_fullPath = +_parentPath;
_fullPath pushBack (_origActionData select 0);
_activeChildren = [];
// If there's a statement to dynamically insert children then execute it
if !({} isEqualTo (_origActionData select 5)) then {
_dynamicChildren = [_target, ACE_player, _origActionData select 6] call (_origActionData select 5);
// Collect dynamic children class actions
{
_action = [_x select 2, _x, _fullPath] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
} forEach _dynamicChildren;
};
// Collect children class actions
{
_action = [_object, _x] call FUNC(collectActiveActionTree);
_action = [_object, _x, _fullPath] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
@ -38,26 +54,15 @@ _activeChildren = [];
// Collect children object actions
{
_action = _x;
_actionData = _action select 0;
EXPLODE_2_PVT(_x,_actionData,_pPath);
// Check if the action is children of the original action
if ((count (_actionData select 7)) == (count (_origActionData select 7) + 1)) then {
if (count _pPath == count _fullPath &&
{_pPath isEqualTo _fullPath}) then {
// Compare parent path to see if it's a suitable child
private "_isChild";
_isChild = true;
{
if !(_x isEqualTo ((_actionData select 7) select _forEachIndex)) exitWith {
_isChild = false;
};
} forEach (_origActionData select 7);
if (_isChild) then {
_action = [_object, _action] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
_action = [_object, _action, _fullPath] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
};
} forEach GVAR(objectActions);
@ -69,4 +74,5 @@ if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) e
[]
};
[_origActionData, _activeChildren]
[_origActionData, _activeChildren, _object]

View File

@ -27,8 +27,8 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"];
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
EXPLODE_1_PVT(_this,_actionsCfg);
_actions = [];
for "_i" from 0 to (count _actionsCfg) - 1 do {
@ -46,29 +46,30 @@ _recurseFnc = {
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EGVAR(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
_fullPath = (+ _parentPath);
_fullPath pushBack (configName _entryCfg);
_condition = compile _condition;
_children = [_entryCfg, _fullPath] call _recurseFnc;
_children = [_entryCfg] call _recurseFnc;
_entry = [
[
configName _entryCfg,
_displayName,
_icon,
_selection,
_statement,
_condition,
_insertChildren,
[],
_selection,
_distance,
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
_fullPath
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
],
_children
];
@ -81,20 +82,22 @@ _recurseFnc = {
private "_actionsCfg";
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
missionNamespace setVariable [_actionsVarName, [_actionsCfg, []] call _recurseFnc];
missionNamespace setVariable [_actionsVarName, [_actionsCfg] call _recurseFnc];
/*
[
[
[
"MyAction",
"My Action",
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
[0,0,0],
{ (_this select 0) setVelocity [0,0,10]; },
{ true },
{},
[],
[0,0,0],
1,
[false,false,false]
["ACE_MainActions","TeamManagement","MyAction"]
],
[children actions]
]

View File

@ -27,8 +27,8 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"];
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
EXPLODE_1_PVT(_this,_actionsCfg);
_actions = [];
for "_i" from 0 to (count _actionsCfg) - 1 do {
@ -43,29 +43,30 @@ _recurseFnc = {
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, objNull, %1)] call EGVAR(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, objNull, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
_fullPath = (+ _parentPath);
_fullPath pushBack (configName _entryCfg);
_condition = compile _condition;
_children = [_entryCfg, _fullPath] call _recurseFnc;
_children = [_entryCfg] call _recurseFnc;
_entry = [
[
configName _entryCfg,
_displayName,
_icon,
[0,0,0],
_statement,
_condition,
_insertChildren,
[],
[0,0,0],
10, //distace
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
_fullPath
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
],
_children
];
@ -82,16 +83,18 @@ _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
_actions = [
[
[
"ACE_SelfActions",
"Self Actions",
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
{},
{ true },
{},
[],
"Spine3",
{ true },
{ true },
10,
[false,true,false],
["ACE_SelfActions"]
[false,true,false]
],
[_actionsCfg, ["ACE_SelfActions"]] call _recurseFnc
[_actionsCfg] call _recurseFnc
]
];

View File

@ -0,0 +1,74 @@
/*
* Author: CAA-Picard
* Creates an isolated ACE action
* Note: This function is NOT global.
*
* Argument:
* 0: Action name <STRING>
* 1: Name of the action shown in the menu <STRING>
* 2: Icon <STRING>
* 3: Statement <CODE>
* 4: Condition <CODE>
* 5: Insert children code <CODE> (Optional)
* 6: Action parameters <ANY> (Optional)
* 7: Position (Position or Selection Name) <POSITION> or <STRING> (Optional)
* 8: Distance <NUMBER> (Optional)
* 9: Other parameters <ARRAY> (Optional)
*
* Return value:
* Action <ARRAY>
*
* Example:
* [VulcanPinch","Vulcan Pinch",{_target setDamage 1;},{true},{},[parameters], [0,0,0], 100] call ace_interact_menu_fnc_createAction;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_5_PVT(_this,_actionName,_displayName,_icon,_statement,_condition);
private ["_insertChildren","_customParams","_position","_distance","_params"];
_insertChildren = if (count _this > 5) then {
_this select 5
} else {
{}
};
_customParams = if (count _this > 6) then {
_this select 6
} else {
[]
};
_position = if (count _this > 7) then {
_this select 7
} else {
[0,0,0]
};
_distance = if (count _this > 8) then {
_this select 8
} else {
2
};
_params = if (count _this > 9) then {
_this select 9
} else {
[false,false,false,false]
};
[
_actionName,
_displayName,
_icon,
_statement,
_condition,
_insertChildren,
_customParams,
_position,
_distance,
_params
]

View File

@ -0,0 +1,56 @@
/*
* Author: CAA-Picard
* Return action point from path
* Note: This function is NOT global.
*
* Argument:
* 0: List of Action Tree <ARRAY>
* 1: Path <ARRAY>
*
* Return value:
* Action node <ARRAY>.
*
* Example:
* [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_actionTreeList,_parentPath);
private ["_parentNode", "_foundParentNode", "_fnc_findFolder"];
// Hack to make this work on the root node too
if (count _parentPath == 0) exitWith {
[[],_actionTreeList]
};
// Search the class action trees and find where to insert the entry
_parentNode = [[],_actionTreeList];
_foundParentNode = false;
_fnc_findFolder = {
EXPLODE_3_PVT(_this,_parentPath,_level,_actionNode);
{
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
if ((_actionData select 0) isEqualTo (_parentPath select _level)) exitWith {
if (count _parentPath == _level + 1) exitWith {
_parentNode = _x;
_foundParentNode = true;
};
// The action should go somewhere in here
[_parentPath, _level + 1, _x] call _fnc_findFolder;
};
} forEach (_actionNode select 1);
};
[_parentPath, 0, [[],_actionTreeList]] call _fnc_findFolder;
// Exit if there's no entry point to insert this action
if (!_foundParentNode) exitWith {};
_parentNode

View File

@ -0,0 +1,29 @@
/*
* Author: CAA-Picard
* Check if the first path is a subpath of the other
*
* Argument:
* 0: LongPath <ARRAY>
* 1: ShortPath <STRING>
*
* Return value:
* Bool
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_longPath,_shortPath);
private ["_isSubPath","_i"];
_isSubPath = true;
if (count _shortPath > count _longPath) exitWith {false};
for [{_i = 0},{_i < count _shortPath},{_i = _i + 1}] do {
if !((_longPath select _i) isEqualTo (_shortPath select _i)) exitWith {
_isSubPath = false;
};
};
_isSubPath

View File

@ -14,9 +14,23 @@
if(GVAR(actionSelected)) then {
this = GVAR(selectedTarget);
private ["_player","_target","_actionData"];
_player = ACE_Player;
_target = GVAR(selectedTarget);
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
// Clear the conditions caches
["clearConditionCaches", []] call EFUNC(common,localEvent);
// Check the action conditions
_actionData = GVAR(selectedAction) select 0;
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
// Call the statement
[_target, _player, _actionData select 6] call (_actionData select 3);
// Clear the conditions caches again if the action was performed
["clearConditionCaches", []] call EFUNC(common,localEvent);
};
};
if (GVAR(keyDown)) then {

View File

@ -18,9 +18,23 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
if(GVAR(actionSelected)) then {
this = GVAR(selectedTarget);
private ["_player","_target","_actionData"];
_player = ACE_Player;
_target = GVAR(selectedTarget);
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
// Clear the conditions caches
["clearConditionCaches", []] call EFUNC(common,localEvent);
// Check the action conditions
_actionData = GVAR(selectedAction) select 0;
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
// Call the statement
[_target, _player, _actionData select 6] call (_actionData select 3);
// Clear the conditions caches again if the action was performed
["clearConditionCaches", []] call EFUNC(common,localEvent);
};
};
if (GVAR(keyDownSelfAction)) then {

View File

@ -0,0 +1,39 @@
/*
* Author: CAA-Picard
* Removes an action from a class
*
* Argument:
* 0: TypeOf of the class <STRING>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the new action <ARRAY>
*
* Return value:
* None
*
* Example:
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromClass;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_3_PVT(_this,_objectType,_typeNum,_fullPath);
private ["_res","_varName","_actionTrees"];
_res = _fullPath call FUNC(splitPath);
EXPLODE_2_PVT(_res,_parentPath,_actionName);
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actionTrees = missionNamespace getVariable [_varName, []];
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
if (isNil {_parentNode}) exitWith {};
// Iterate through children of the father
{
if (((_x select 0) select 0) == _actionName) exitWith {
(_parentNode select 1) deleteAt _forEachIndex;
};
} forEach (_parentNode select 1);
_parentLevel deleteAt _actionIndex;

View File

@ -1,30 +1,33 @@
/*
* Author: commy2, NouberNou and CAA-Picard
* Remove an action from an object
*
* Argument:
* 0: Object the action is assigned to <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the action to remove <ARRAY>
*
* Return value:
* None
*
* Example:
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeAction;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_3_PVT(_this,_object,_typeNum,_fullPath);
private ["_varName","_actions"];
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
_actions = _object getVariable [_varName, []];
{
if (((_x select 0) select 7) isEqualTo _fullPath) exitWith {
_actions deleteAt _forEachIndex;
};
} forEach _actions;
/*
* Author: commy2, NouberNou and CAA-Picard
* Removes an action from an object
*
* Argument:
* 0: Object the action is assigned to <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the action to remove <ARRAY>
*
* Return value:
* None
*
* Example:
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromObject;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_3_PVT(_this,_object,_typeNum,_fullPath);
private ["_res","_varName","_actionList"];
_res = _fullPath call FUNC(splitPath);
EXPLODE_2_PVT(_res,_parentPath,_actionName);
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
_actionList = _object getVariable [_varName, []];
{
if (((_x select 0) select 0) isEqualTo _actionName &&
{(_x select 1) isEqualTo _parentPath}) exitWith {
_actionList deleteAt _forEachIndex;
};
} forEach _actionList;

View File

@ -1,72 +0,0 @@
/*
* Author: CAA-Picard
* Removes a class action from a class
* Note: This function is NOT global.
*
* Argument:
* 0: TypeOf of the class <STRING>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Full path of the new action <ARRAY>
*
* Return value:
* None
*
* Example:
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeClassAction;
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_3_PVT(_this,_objectType,_typeNum,_fullPath);
private ["_varName","_actions","_parentLevel", "_actionIndex", "_foundAction", "_fnc_findFolder"];
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actions = missionNamespace getVariable [_varName, []];
// Search the class action trees and find where to insert the entry
_parentLevel = _actions;
_actionIndex = -1;
_foundAction = false;
_fnc_findFolder = {
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
if (count _fullPath == _level + 1) then {
_parentLevel = _classActions;
};
{
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
if (_level + 1 == count _fullPath) exitWith {
_actionIndex = _forEachIndex;
_foundAction = true;
};
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
};
if (_foundAction) exitWith {};
} forEach _classActions;
};
[_fullPath, 0, _actions] call _fnc_findFolder;
// Exit if the action was not found
if (!_foundAction) exitWith {};
_entry = [
[
_displayName,
_icon,
_position,
_statement,
_condition,
_distance,
_params,
+ _fullPath
],
[]
];
_parentLevel deleteAt _actionIndex;

View File

@ -41,17 +41,17 @@ if (GVAR(keyDown)) then {
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
GVAR(objectActions) = _target getVariable [QGVAR(actions), []];
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
{
_action = _x;
// Only render them directly if they are base level actions
if (count ((_action select 0) select 7) == 1) then {
if (count (_x select 1) == 0) then {
// Try to render the menu
_action = [_x,[]];
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
};
};
} forEach GVAR(objectActions);
} forEach GVAR(objectActionList);
// Iterate through base level class actions and render them if appropiate
_classActions = missionNamespace getVariable [_actionsVarName, []];
@ -80,7 +80,7 @@ if (GVAR(keyDown)) then {
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
GVAR(objectActions) = _target getVariable [QGVAR(selfActions), []];
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
/*
{
_action = _x;
@ -88,7 +88,7 @@ if (GVAR(keyDown)) then {
if (count (_action select 7) == 1) then {
[_target, _action, 0, [180, 360]] call FUNC(renderMenu);
};
} forEach GVAR(objectActions);
} forEach GVAR(objectActionList);
*/
// Iterate through base level class actions and render them if appropiate
@ -142,9 +142,8 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,.75], _pos, 0.6*SafeZoneW, 0.6*SafeZoneW, GVAR(rotationAngle), "", 0.5, 0.025, "TahomaB"];
_foundTarget = true;
GVAR(actionSelected) = true;
GVAR(selectedTarget) = (_closest select 0) select 0;
GVAR(selectedAction) = (_closest select 0) select 1;
GVAR(selectedStatement) = ((GVAR(selectedAction)) select 0) select 3;
GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
_misMatch = false;
_hoverPath = (_closest select 2);
@ -153,29 +152,46 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
_misMatch = true;
} else {
{
if(_x != (_hoverPath select _forEachIndex)) exitWith {
if !(_x isEqualTo (_hoverPath select _forEachIndex)) exitWith {
_misMatch = true;
};
} forEach GVAR(lastPath);
};
if(_misMatch) then {
GVAR(lastPath) = _hoverPath;
if(_misMatch && {diag_tickTime-GVAR(expandedTime) > 0.25}) then {
GVAR(startHoverTime) = diag_tickTime;
GVAR(lastPath) = _hoverPath;
GVAR(expanded) = false;
} else {
if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.25) then {
GVAR(expanded) = true;
// Start the expanding menu animation only if the user is not going up the menu
if !([GVAR(menuDepthPath),GVAR(lastPath)] call FUNC(isSubPath)) then {
GVAR(expandedTime) = diag_tickTime;
};
GVAR(menuDepthPath) = +GVAR(lastPath);
// Execute the current action if it's run on hover
private "_runOnHover";
_runOnHover = ((GVAR(selectedAction) select 0) select 6) select 3;
_runOnHover = ((GVAR(selectedAction) select 0) select 9) select 3;
if (_runOnHover) then {
this = GVAR(selectedTarget);
_player = ACE_Player;
_target = GVAR(selectedTarget);
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
// Clear the conditions caches
["clearConditionCaches", []] call EFUNC(common,localEvent);
// Check the action conditions
_actionData = GVAR(selectedAction) select 0;
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
// Call the statement
[_target, _player, _actionData select 6] call (_actionData select 3);
// Clear the conditions caches again if the action was performed
["clearConditionCaches", []] call EFUNC(common,localEvent);
};
};
};
};

View File

@ -4,7 +4,7 @@
*
* Argument:
* 0: Object <OBJECT>
* 1: Action data <ARRAY>
* 1: Action node <ARRAY>
* 2: 3D position <ARRAY> (Optional)
*
* Return value:
@ -16,25 +16,25 @@
private ["_distance","_pos","_weaponDir","_ref","_cameraPos","_sPos","_activeActionTree"];
EXPLODE_2_PVT(_this,_object,_baseAction);
EXPLODE_1_PVT(_baseAction,_actionData);
EXPLODE_2_PVT(_this,_object,_baseActionNode);
EXPLODE_1_PVT(_baseActionNode,_actionData);
_distance = _actionData select 5;
_distance = _actionData select 8;
// Obtain a 3D position for the action
if((count _this) > 2) then {
_pos = _this select 2;
} else {
if(typeName (_actionData select 2) == "ARRAY") then {
_pos = _object modelToWorld (_actionData select 2);
if(typeName (_actionData select 7) == "ARRAY") then {
_pos = _object modelToWorld (_actionData select 7);
} else {
if ((_actionData select 2) == "weapon") then {
if ((_actionData select 7) == "weapon") then {
// Craft a suitable position for weapon interaction
_weaponDir = _object weaponDirection currentWeapon _object;
_ref = _weaponDir call EFUNC(common,createOrthonormalReference);
_pos = (_object modelToWorld (_object selectionPosition "righthand")) vectorAdd ((_ref select 2) vectorMultiply 0.1);
} else {
_pos = _object modelToWorld (_object selectionPosition (_actionData select 2));
_pos = _object modelToWorld (_object selectionPosition (_actionData select 7));
};
};
// Compensate for movement during the frame to get rid of jittering
@ -59,19 +59,30 @@ if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZon
// Collect active tree
private "_uid";
_uid = format [QGVAR(ATCache_%1), (_actionData select 7) select 0];
_uid = format [QGVAR(ATCache_%1), _actionData select 0];
_activeActionTree = [
[_object, _baseAction],
[_object, _baseActionNode, []],
DFUNC(collectActiveActionTree),
_object, _uid, 0.2
_object, _uid, 1.0, "interactMenuClosed"
] call EFUNC(common,cachedCall);
/*
diag_log "Printing: _activeActionTree";
_fnc_print = {
EXPLODE_2_PVT(_this,_level,_node);
EXPLODE_3_PVT(_node,_actionData,_children,_object);
diag_log text format ["Level %1 -> %2 on %3", _level, _actionData select 0, _object];
{
[_level + 1, _x] call _fnc_print;
} forEach _children;
};
[0, _activeActionTree] call _fnc_print;
*/
// Check if there's something left for rendering
if (count _activeActionTree == 0) exitWith {false};
//EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren);
[_object, _activeActionTree, _pos, [180,360]] call FUNC(renderMenu);
[[], _activeActionTree, _pos, [180,360]] call FUNC(renderMenu);
true

View File

@ -3,7 +3,7 @@
* Render an interaction menu and it's children recursively
*
* Argument:
* 0: Object <OBJECT>
* 0: Parent path <ARRAY>
* 1: Action data <ARRAY>
* 2: 3D position <ARRAY>
* 3: Angle range available for rendering <ARRAY>
@ -17,14 +17,15 @@
private ["_menuInSelectedPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"];
EXPLODE_4_PVT(_this,_object,_action,_pos,_angles);
EXPLODE_2_PVT(_action,_actionData,_activeChildren);
EXPLODE_4_PVT(_this,_parentPath,_action,_pos,_angles);
EXPLODE_3_PVT(_action,_actionData,_activeChildren,_actionObject);
EXPLODE_2_PVT(_angles,_centerAngle,_maxAngleSpan);
_menuDepth = (count GVAR(menuDepthPath)) - 1;
_menuDepth = (count GVAR(menuDepthPath));
// Store path to action
_path = [_object] + (_actionData select 7);
_path = +_parentPath;
_path pushBack [_actionData select 0,_actionObject];
// Check if the menu is on the selected path
_menuInSelectedPath = true;
@ -32,7 +33,7 @@ _menuInSelectedPath = true;
if (_forEachIndex >= (count GVAR(menuDepthPath))) exitWith {
_menuInSelectedPath = false;
};
if (_x != (GVAR(menuDepthPath) select _forEachIndex)) exitWith {
if !(_x isEqualTo (GVAR(menuDepthPath) select _forEachIndex)) exitWith {
_menuInSelectedPath = false;
};
} forEach _path;
@ -42,12 +43,12 @@ _menuInSelectedPath = true;
_color = "#FFFFFFFF";
if(!_menuInSelectedPath) then { //_menuDepth > 0 &&
if (_menuDepth > 0) then {
_color = format ["#%1FFFFFF", [255 * ((((count _path) - 2)/_menuDepth) max 0.25)] call EFUNC(common,toHex)];
_color = format ["#%1FFFFFF", [255 * ((((count _path) - 1)/_menuDepth) max 0.25)] call EFUNC(common,toHex)];
} else {
_color = format ["#%1FFFFFF", [255 * 0.75] call EFUNC(common,toHex)];
};
};
[_actionData select 0, _color, _pos, 1, 1, 0, _actionData select 1, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
[_actionData select 1, _color, _pos, 1, 1, 0, _actionData select 2, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
// Add the action to current options
GVAR(currentOptions) pushBack [_this, _pos, _path];
@ -55,26 +56,44 @@ GVAR(currentOptions) pushBack [_this, _pos, _path];
// Exit without rendering children if it isn't
if !(_menuInSelectedPath) exitWith {true};
private ["_angleSpan","_angle"];
private ["_angleSpan","_angle","_angleInterval","_scale"];
_angleSpan = _maxAngleSpan min (55 * ((count _activeChildren) - 1));
if (_angleSpan >= 305) then {
_angleSpan = 360;
};
_angleInterval = 55;
if (_angleSpan < 360) then {
if (count _activeChildren > 1) then {
_angleInterval = _angleSpan / (count _activeChildren - 1);
};
} else {
_angleSpan / (count _activeChildren);
};
if (count _activeChildren == 1) then {
_angleInterval = 60;
};
// Scale menu based on distance
_scale = (0.15 max (0.15 * ((positionCameraToWorld [0, 0, 0]) distance _pos))) / GVAR(selfMenuScale);
// Scale menu based on the amount of children
_scale = _scale * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.4) max 0.5);
// Animate menu scale
if (_menuInSelectedPath && (_menuDepth == count _path)) then {
_scale = _scale * (0.3 + 0.7 * (((diag_tickTime - GVAR(expandedTime)) * 8) min 1));
};
_angle = _centerAngle - _angleSpan / 2;
{
_target = _object;
_target = _actionObject;
_player = ACE_player;
_mod = (0.15 max (0.15 * ((positionCameraToWorld [0, 0, 0]) distance _pos))) / GVAR(selfMenuScale);
_offset = ((GVAR(refSystem) select 1) vectorMultiply (-_mod * cos _angle)) vectorAdd
((GVAR(refSystem) select 2) vectorMultiply (-_mod * sin _angle));
_offset = ((GVAR(refSystem) select 1) vectorMultiply (-_scale * cos _angle)) vectorAdd
((GVAR(refSystem) select 2) vectorMultiply (-_scale * sin _angle));
_newPos = ((_pos call EFUNC(common,positionToASL)) vectorAdd _offset) call EFUNC(common,ASLToPosition);
//drawLine3D [_pos, _newPos, [1,0,0,0.5]];
//drawLine3D [_pos, _newPos, [1,0,0,0.8]];
[_object, _x, _newPos, [_angle, 140]] call FUNC(renderMenu);
[_path, _x, _newPos, [_angle, 140]] call FUNC(renderMenu);
if (_angleSpan == 360) then {
_angle = _angle + _angleSpan / (count _activeChildren);

View File

@ -0,0 +1,27 @@
/*
* Author: CAA-Picard
* Take full path and split it between parent path and action name
*
* Argument:
* Full path of the action to remove <ARRAY>
*
* Return value:
* 0: Parent path <ARRAY>
* 1: Action name <STRING>
*
* Public: No
*/
#include "script_component.hpp"
private ["_parentPath","_actionName"];
_parentPath = [];
for [{_i = 0},{_i < (count _this) - 1},{_i = _i + 1}] do {
_parentPath pushBack (_this select _i);
};
_actionName = if (count _this > 0) then {
_this select ((count _this) - 1);
} else {
""
};
[_parentPath, _actionName]

View File

@ -31,7 +31,7 @@ class CfgVehicles {
condition = QUOTE(true);
statement = "";
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
selection = "spine3";
selection = "pelvis";
class ACE_TeamManagement {
displayName = "$STR_ACE_Interaction_TeamManagement";
@ -140,45 +140,52 @@ class CfgVehicles {
enableInside = 1;
};
};
class ACE_Torso {
displayName = "$STR_ACE_Interaction_Torso";
selection = "spine3";
distance = 1.50;
condition = "";
statement = "";
};
class ACE_Head {
displayName = "$STR_ACE_Interaction_Head";
selection = "pilot";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
class ACE_ArmLeft {
displayName = "$STR_ACE_Interaction_ArmLeft";
selection = "LeftForeArm";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
class ACE_ArmRight {
displayName = "$STR_ACE_Interaction_ArmRight";
selection = "RightForeArm";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
class ACE_LegLeft {
displayName = "$STR_ACE_Interaction_LegLeft";
selection = "LKnee";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
class ACE_LegRight {
displayName = "$STR_ACE_Interaction_LegRight";
selection = "RKnee";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
class ACE_Weapon {
displayName = "$STR_ACE_Interaction_Weapon";
selection = "weapon";
distance = 2.0;
distance = 1.50;
condition = "";
statement = "";
};
@ -412,7 +419,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class Tank: LandVehicle {
class ACE_Actions {
@ -423,7 +437,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class Air;
@ -436,7 +457,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class Plane: Air {
class ACE_Actions {
@ -447,7 +475,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class Ship;
@ -469,7 +504,14 @@ class CfgVehicles {
};
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class StaticWeapon: LandVehicle {
@ -481,7 +523,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class StaticMortar;
@ -494,7 +543,14 @@ class CfgVehicles {
condition = "true";
};
};
class ACE_SelfActions {};
class ACE_SelfActions {
class ACE_Passengers {
displayName = "$STR_ACE_Interaction_Passengers";
condition = "true";
statement = "";
insertChildren = QUOTE(_this call FUNC(addPassengersActions));
};
};
};
class thingX;

View File

@ -19,7 +19,7 @@ GVAR(isOpeningDoor) = false;
["ACE3", QGVAR(openDoor), localize "STR_ACE_Interaction_OpenDoor",
{
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (GVAR(isOpeningDoor) || {[2] call FUNC(getDoor) select 1 == ''}) exitWith {false};
@ -39,7 +39,7 @@ GVAR(isOpeningDoor) = false;
["ACE3", QGVAR(tapShoulder), localize "STR_ACE_Interaction_TapShoulder",
{
// Conditions: canInteract
if !([ACE_player, objNull, []] call EGVAR(common,canInteractWith)) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !([ACE_player, cursorTarget] call FUNC(canTapShoulder)) exitWith {false};
@ -53,7 +53,7 @@ GVAR(isOpeningDoor) = false;
["ACE3", QGVAR(modifierKey), localize "STR_ACE_Interaction_ModifierKey",
{
// Conditions: canInteract
//if !([ACE_player, objNull, ["isNotDragging"]] call EGVAR(common,canInteractWith)) exitWith {false}; // not needed
//if !([ACE_player, objNull, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false}; // not needed
// Statement
ACE_Modifier = 1;

View File

@ -2,6 +2,8 @@
ADDON = false;
PREP(addPassengerActions);
PREP(addPassengersActions);
PREP(addSelectableItem);
PREP(applyButtons);
PREP(canInteractWithCivilian);

Some files were not shown because too many files have changed in this diff Show More