Merge branch 'master' into explosives_cleanup_plus_minetriggers

This commit is contained in:
VKing 2016-01-22 14:15:45 +01:00
commit 68531bd4a9
87 changed files with 1005 additions and 697 deletions

View File

@ -0,0 +1,16 @@
//Create a location type that won't be drawn on the map
//Ref: https://community.bistudio.com/wiki/Location
class CfgLocationTypes {
class ACE_HashLocation {
color[] = {0,0,0,0};
drawStyle = "bananas";
font = "PuristaMedium";
importance = 5;
name = "HashLocation";
shadow = 0;
size = 0;
textSize = 0.0;
texture = "";
};
};

View File

@ -14,6 +14,7 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgLocationTypes.hpp"
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"

View File

@ -10,17 +10,8 @@ class CfgVehicles {
showDisabled = 1;
priority = 4;
icon = PATHTOF(UI\Explosives_Menu_ca.paa);
insertChildren = QUOTE([_player] call FUNC(addTransmitterActions););
//Sub-menu items
class ACE_Detonate {
displayName = CSTRING(Detonate);
condition = QUOTE([_player] call FUNC(canDetonate));
statement = "";
insertChildren = QUOTE([_player] call FUNC(addTransmitterActions););
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
showDisabled = 1;
icon = PATHTOF(UI\Explosives_Menu_ca.paa);
priority = 2;
};
class ACE_Place {
displayName = CSTRING(Place);
condition = QUOTE((vehicle _player == _player) and {[_player] call FUNC(hasExplosives)});

View File

@ -29,6 +29,7 @@ PREP(canDetonate);
PREP(connectExplosive);
PREP(defuseExplosive);
PREP(detonateExplosive);
PREP(detonateExplosiveAll);
PREP(dialPhone);
PREP(dialingPhone);
@ -53,6 +54,7 @@ PREP(openTimerSetUI);
PREP(placeExplosive);
PREP(removeFromSpeedDial);
PREP(scriptedExplosive);
PREP(selectTrigger);
PREP(setupExplosive);
PREP(setPosition);

View File

@ -19,18 +19,21 @@
params ["_unit", "_detonator"];
TRACE_2("params",_unit,_detonator);
private ["_result", "_item", "_children", "_range", "_required"];
private ["_result", "_item", "_children", "_range", "_required","_explosivesList"];
_range = getNumber (ConfigFile >> "CfgWeapons" >> _detonator >> QGVAR(Range));
_result = [_unit] call FUNC(getPlacedExplosives);
_children = [];
_explosivesList = [];
{
if (!isNull(_x select 0)) then {
_required = getArray (ConfigFile >> "ACE_Triggers" >> (_x select 4) >> "requires");
if (_detonator in _required) then {
_item = ConfigFile >> "CfgMagazines" >> (_x select 3);
_explosivesList pushBack _x;
_children pushBack
[
[
@ -40,13 +43,30 @@ _children = [];
{(_this select 2) call FUNC(detonateExplosive);},
{true},
{},
[ACE_player,_range,_x]
[_unit,_range,_x]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
_unit
];
};
};
} forEach _result;
// Add action to detonate all explosives tied to the detonator
if (count _explosivesList > 0) then {
_children pushBack [
[
"Explosive_All",
localize LSTRING(DetonateAll),
getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"),
{(_this select 2) call FUNC(detonateExplosiveAll);},
{true},
{},
[_unit,_range,_explosivesList]
] call EFUNC(interact_menu,createAction),
[],
_unit
];
};
_children

View File

@ -33,10 +33,10 @@ _children = [];
{},
{true},
{(_this select 2) call FUNC(addDetonateActions);},
[ACE_player,_x]
[_unit,_x]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
_unit
];
} forEach _detonators;

View File

@ -0,0 +1,27 @@
/*
* Author: VKing
* Causes the unit to detonate all passed explosives.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Range (-1 to ignore) <NUMBER>
* 2: Explosives to detonate <ARRAY>
* 0: Explosive <OBJECT>
* 1: Fuse time <NUMBER>
*
* Return Value:
* None
*
* Example:
* [player, -1, [[c4,0.5]]] call ACE_Explosives_fnc_detonateExplosiveAll;
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_range", "_explosivesList"];
TRACE_3("Params",_unit,_range,_explosivesList);
{
[_unit,_range,_x] call FUNC(detonateExplosive);
} forEach _explosivesList;

View File

@ -0,0 +1,27 @@
/*
* Author: VKing
* Detonate explosives via script, for use in triggers or mission scripts to
* detonate editor-placed explosives.
*
* Arguments:
* 0: Explosives objects to detonate <ARRAY>
* 1: Fuze delay (for each explosive; use negative number for random time up to value) <NUMBER> <OPTIONAL>
*
* Return Value:
* None
*
* Example:
* [[charge1, charge2, charge3], -1] call ACE_Explosives_fnc_scriptedExplosive;
* [[claymore1, claymore2]] call ACE_Explosives_fnc_scriptedExplosive;
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_explosiveArr",["_fuzeTime",0]];
private _detTime;
{
_detTime = if (_fuzeTime < 0) then {random abs _fuzeTime} else {_fuzeTime};
[objNull, -1, [_x, _detTime]] call FUNC(detonateExplosive);
} forEach _explosiveArr;

View File

@ -14,28 +14,34 @@
<Russian>Взрывчатка</Russian>
</Key>
<Key ID="STR_ACE_Explosives_Place">
<English>Place &gt;&gt;</English>
<German>Platzieren &gt;&gt;</German>
<Spanish>Colocar &gt;&gt;</Spanish>
<Polish>Umieść &gt;&gt;</Polish>
<French>Placer &gt;&gt;</French>
<Czech>Položit &gt;&gt;</Czech>
<Italian>Piazza &gt;&gt;</Italian>
<Hungarian>Elhelyezés &gt;&gt;</Hungarian>
<Portuguese>Colocar &gt;&gt;</Portuguese>
<Russian>Установить &gt;&gt;</Russian>
<English>Place</English>
<German>Platzieren</German>
<Spanish>Colocar</Spanish>
<Polish>Umieść</Polish>
<French>Placer</French>
<Czech>Položit</Czech>
<Italian>Piazza</Italian>
<Hungarian>Elhelyezés</Hungarian>
<Portuguese>Colocar</Portuguese>
<Russian>Установить</Russian>
</Key>
<Key ID="STR_ACE_Explosives_Detonate">
<English>Detonate &gt;&gt;</English>
<German>Zünden &gt;&gt;</German>
<Spanish>Detonar &gt;&gt;</Spanish>
<Polish>Detonuj &gt;&gt;</Polish>
<French>Mise à feu &gt;&gt;</French>
<Czech>Odpálit &gt;&gt;</Czech>
<Italian>Detona &gt;&gt;</Italian>
<Hungarian>Robbantás &gt;&gt;</Hungarian>
<Portuguese>Detonar &gt;&gt;</Portuguese>
<Russian>Подрыв &gt;&gt;</Russian>
<English>Detonate</English>
<German>Zünden</German>
<Spanish>Detonar</Spanish>
<Polish>Detonuj</Polish>
<French>Mise à feu</French>
<Czech>Odpálit</Czech>
<Italian>Detona</Italian>
<Hungarian>Robbantás</Hungarian>
<Portuguese>Detonar</Portuguese>
<Russian>Подрыв</Russian>
</Key>
<Key ID="STR_ACE_Explosives_DetonateAll">
<English>Detonate All</English>
<German>Zünden Alles</German>
<Spanish>Detonar Todo</Spanish>
<Russian>Подрыв всех</Russian>
</Key>
<Key ID="STR_ACE_Explosives_DetonateCode">
<English>Explosive code: %1</English>

View File

@ -16,7 +16,7 @@
params ["_vehicle", "_turret"];
private _distance = call FUNC(getRange);
call (updateRangeHUD);
call FUNC(updateRangeHUD);
if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {};

View File

@ -17,7 +17,7 @@ params ["_vehicle", "_turret", "_distance", ["_showHint", false], ["_playSound",
private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
call (updateRangeHUD);
call FUNC(updateRangeHUD);
if (isNil "_distance") then {
_distance = call FUNC(getRange);

View File

@ -9,4 +9,8 @@ if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call EFUNC(common,addEventHandler);
};
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
//Cache for ammo type configs
GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0];
GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack);

View File

@ -1,8 +1,56 @@
/*
* Author: nou, jaynus, PabstMirror
* Called from FiredBIS event on AllVehicles
* If spall is not enabled (default), then cache and only track those that will actually trigger fragmentation.
*
* Arguments:
* 0: gun - Object the event handler is assigned to <OBJECT>
* 4: type - Ammo used <STRING>
* 6: round - Object of the projectile that was shot <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [clientFiredBIS-XEH] call ace_frag_fnc_fired
*
* Public: No
*/
// #define DEBUG_ENABLED_FRAG
#include "script_component.hpp"
private["_gun", "_type", "_round"];
_gun = _this select 0;
_type = _this select 4;
_round = _this select 6;
params ["_gun", "", "", "", "_type", "", "_round"];
[_gun, _type, _round] call FUNC(addPfhRound);
private _shouldAdd = GVAR(cacheRoundsTypesToTrack) getVariable _type;
if (isNil "_shouldAdd") then {
TRACE_1("no cache for round",_type);
if (!EGVAR(common,settingsInitFinished)) exitWith {
//Just incase fired event happens before settings init, don't want to set cache wrong if spall setting changes
TRACE_1("Settings not init yet - exit without setting cache",_type);
_shouldAdd = false;
};
if (GVAR(SpallEnabled)) exitWith {
//Always want to run whenever spall is enabled?
_shouldAdd = true;
TRACE_2("SettingCache[spallEnabled]",_type,_shouldAdd);
GVAR(cacheRoundsTypesToTrack) setVariable [_type, _shouldAdd];
};
//Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound)
private _skip = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip));
private _explosive = getNumber (configFile >> "CfgAmmo" >> _type >> "explosive");
private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange");
private _force = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force));
private _fragPower = getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))));
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd);
GVAR(cacheRoundsTypesToTrack) setVariable [_type, _shouldAdd];
};
if (_shouldAdd) then {
TRACE_3("Running Frag Tracking",_gun,_type,_round);
[_gun, _type, _round] call FUNC(addPfhRound);
};

View File

@ -12,4 +12,4 @@ GVAR(GForces_CC) ppEffectCommit 0.4;
GVAR(lastUpdateTime) = 0;
GVAR(oldVel) = [0,0,0];
[FUNC(pfhUpdateGForces), 0, []] call CBA_fnc_addPerFrameHandler;
[DFUNC(pfhUpdateGForces), 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -13,34 +13,18 @@
*/
#include "script_component.hpp"
private ["_interval", "_player", "_newVel", "_accel", "_currentGForce", "_average", "_sum", "_classCoef", "_suitCoef", "_gBlackOut", "_gRedOut", "_g", "_gBO", "_coef", "_strength"];
EXPLODE_2_PVT(_this,_params,_pfhId);
_interval = ACE_time - GVAR(lastUpdateTime);
// Update the g-forces at constant game time intervals
if (_interval < INTERVAL) exitWith {};
if (isNull ACE_player) exitWith {};
if !(alive ACE_player) exitWith {};
// Update the g-forces at constant mission time intervals (taking accTime into account)
if ((ACE_time - GVAR(lastUpdateTime)) < INTERVAL) exitWith {};
GVAR(lastUpdateTime) = ACE_time;
/*if !(vehicle ACE_player isKindOf "Air") exitWith {
GVAR(GForces) = [];
GVAR(GForces_Index) = 0;
waitUntil {sleep 5; (vehicle _player isKindOf "Air") or ((getPos _player select 2) > 5)};
};*/
_newVel = velocity (vehicle ACE_player);
_accel = ((_newVel vectorDiff GVAR(oldVel)) vectorMultiply (1 / INTERVAL)) vectorAdd [0, 0, 9.8];
_currentGForce = (_accel vectorDotProduct vectorUp (vehicle ACE_player)) / 9.8;
if (isNull ACE_player || !(alive ACE_player)) exitWith {};
private _newVel = velocity (vehicle ACE_player);
private _accel = ((_newVel vectorDiff GVAR(oldVel)) vectorMultiply (1 / INTERVAL)) vectorAdd [0, 0, 9.8];
// Cap maximum G's to +- 10 to avoid g-effects when the update is low fps.
_currentGForce = (_currentGForce max -10) min 10;
private _currentGForce = (((_accel vectorDotProduct vectorUp (vehicle ACE_player)) / 9.8) max -10) min 10;
GVAR(GForces) set [GVAR(GForces_Index), _currentGForce];
GVAR(GForces_Index) = (GVAR(GForces_Index) + 1) % round (AVERAGEDURATION / INTERVAL);
@ -63,31 +47,27 @@ GVAR(oldVel) = _newVel;
* Effects and camera shake start 30% the limit value, and build gradually
*/
_average = 0;
if (count GVAR(GForces) > 0) then {
_sum = 0;
{
_sum = _sum + _x;
} forEach GVAR(GForces);
_average = _sum / (count GVAR(GForces));
private _average = 0;
private _count = {
_average = _average + _x;
true
} count GVAR(GForces);
if (_count > 0) then {
_average = _average / _count;
};
_classCoef = ACE_player getVariable ["ACE_GForceCoef",
getNumber (configFile >> "CfgVehicles" >> (typeOf ACE_player) >> "ACE_GForceCoef")];
_suitCoef = if ((uniform ACE_player) != "") then {
getNumber (configFile >> "CfgWeapons" >> (uniform ACE_player) >> "ACE_GForceCoef")
private _classCoef = (ACE_player getVariable ["ACE_GForceCoef",
getNumber (configFile >> "CfgVehicles" >> (typeOf ACE_player) >> "ACE_GForceCoef")]) max 0.001;
private _suitCoef = if ((uniform ACE_player) != "") then {
(getNumber (configFile >> "CfgWeapons" >> (uniform ACE_player) >> "ACE_GForceCoef")) max 0.001
} else {
1
};
//Fix "Error Zero divisor"
if (_classCoef == 0) then {_classCoef = 0.001};
if (_suitCoef == 0) then {_suitCoef = 0.001};
private _gBlackOut = MAXVIRTUALG / _classCoef + MAXVIRTUALG / _suitCoef - MAXVIRTUALG;
_gBlackOut = MAXVIRTUALG / _classCoef + MAXVIRTUALG / _suitCoef - MAXVIRTUALG;
_gRedOut = MINVIRTUALG / _classCoef;
// @todo: Sort the interaction with medical
// Unconsciousness
if ((_average > _gBlackOut) and {isClass (configFile >> "CfgPatches" >> "ACE_Medical") and {!(ACE_player getVariable ["ACE_isUnconscious", false])}}) then {
[ACE_player, true, (10 + floor(random 5))] call EFUNC(medical,setUnconscious);
};
@ -96,12 +76,14 @@ GVAR(GForces_CC) ppEffectAdjust [1,1,0,[0,0,0,1],[0,0,0,0],[1,1,1,1],[10,10,0,0,
if !(ACE_player getVariable ["ACE_isUnconscious", false]) then {
if (_average > 0.30 * _gBlackOut) then {
_strength = ((_average - 0.30 * _gBlackOut) / (0.70 * _gBlackOut)) max 0;
private _strength = ((_average - 0.30 * _gBlackOut) / (0.70 * _gBlackOut)) max 0;
GVAR(GForces_CC) ppEffectAdjust [1,1,0,[0,0,0,1],[0,0,0,0],[1,1,1,1],[2*(1-_strength),2*(1-_strength),0,0,0,0.1,0.5]];
addCamShake [_strength, 1, 15];
} else {
private _gRedOut = MINVIRTUALG / _classCoef;
if (_average < -0.30 * _gRedOut) then {
_strength = ((abs _average - 0.30 * _gRedOut) / (0.70 * _gRedOut)) max 0;
private _strength = ((abs _average - 0.30 * _gRedOut) / (0.70 * _gRedOut)) max 0;
GVAR(GForces_CC) ppEffectAdjust [1,1,0,[1,0.2,0.2,1],[0,0,0,0],[1,1,1,1],[2*(1-_strength),2*(1-_strength),0,0,0,0.1,0.5]];
addCamShake [_strength / 1.5, 1, 15];
};

View File

@ -18,36 +18,27 @@ class CfgWeapons {
GVAR(protection) = 1;
GVAR(lowerVolume) = 0.80;
};
class H_HelmetCrew_0: H_HelmetCrew_B {};
class H_HelmetCrew_I: H_HelmetCrew_B {};
class H_CrewHelmetHeli_B: H_HelmetB {
GVAR(protection) = 0.85;
GVAR(lowerVolume) = 0.75;
};
class H_CrewHelmetHeli_O: H_CrewHelmetHeli_B {};
class H_CrewHelmetHeli_I: H_CrewHelmetHeli_B {};
class H_PilotHelmetHeli_B: H_HelmetB {
GVAR(protection) = 0.85;
GVAR(lowerVolume) = 0.75;
};
class H_PilotHelmetHeli_O: H_PilotHelmetHeli_B {};
class H_PilotHelmetHeli_I: H_PilotHelmetHeli_B {};
class H_PilotHelmetFighter_B: H_HelmetB {
GVAR(protection) = 1;
GVAR(lowerVolume) = 0.80;
};
class H_PilotHelmetFighter_O: H_PilotHelmetFighter_B {};
class H_PilotHelmetFighter_I: H_PilotHelmetFighter_B {};
class HelmetBase;
class H_Cap_headphones: HelmetBase {
GVAR(protection) = 0.5;
GVAR(lowerVolume) = 0.60;
};
class H_Cap_marshal: H_Cap_headphones {};
class H_HelmetB_light: H_HelmetB {
GVAR(protection) = 0.8;

View File

@ -20,6 +20,9 @@ TRACE_2("params",_unit,typeOf _unit);
if (!local _unit) exitWith {}; //XEH should only be called on local units
//Do not add or remove earplugs if gear should be preserved
if (missionNamespace getVariable [QEGVAR(respawn,SavePreDeathGear), false]) exitWith {};
private _respawn = [0] call BIS_fnc_missionRespawnType;
//if respawn is not Group or side:

View File

@ -79,8 +79,7 @@ GVAR(ParsedTextCached) = [];
//Debug to help end users identify mods that break CBA's XEH
[{
private ["_badClassnames"];
_badClassnames = [];
private _badClassnames = [];
{
//Only check Land objects (WeaponHolderSimulated show up in `vehicles` for some reason)
if ((_x isKindOf "Land") && {(isNil (format [QGVAR(Act_%1), typeOf _x])) || {isNil (format [QGVAR(SelfAct_%1), typeOf _x])}}) then {

View File

@ -74,11 +74,6 @@ GVAR(collectedActionPoints) = [];
GVAR(foundActions) = [];
GVAR(lastTimeSearchedActions) = -1000;
// Init CAManBase menus
["CAManBase"] call FUNC(compileMenu);
["CAManBase"] call FUNC(compileMenuSelfAction);
// Init zeus menu
[] call FUNC(compileMenuZeus);

View File

@ -30,9 +30,8 @@ if (_typeNum == 0) then {
[_objectType] call FUNC(compileMenuSelfAction);
};
private ["_varName","_actionTrees", "_parentNode"];
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actionTrees = missionNamespace getVariable [_varName, []];
private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
private _actionTrees = missionNamespace getVariable [_varName, []];
if((count _actionTrees) == 0) then {
missionNamespace setVariable [_varName, _actionTrees];
};
@ -41,7 +40,7 @@ if (_parentPath isEqualTo ["ACE_MainActions"]) then {
[_objectType, _typeNum] call FUNC(addMainAction);
};
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
private _parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
if (isNil {_parentNode}) exitWith {
ERROR("Failed to add action");
ACE_LOGERROR_4("action (%1) to parent %2 on object %3 [%4]",(_action select 0),_parentPath,_objectType,_typeNum);

View File

@ -23,10 +23,10 @@ if (!params [["_object", objNull, [objNull]], ["_typeNum", 0, [0]], ["_parentPat
ERROR("Bad Params");
};
private ["_varName","_actionList"];
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
_actionList = _object getVariable [_varName, []];
if((count _actionList) == 0) then {
private _varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
private _actionList = _object getVariable [_varName, []];
if (_actionList isEqualTo []) then {
_object setVariable [_varName, _actionList];
};

View File

@ -18,14 +18,12 @@
params ["_objectType", "_typeNum"];
private["_actionTrees", "_mainAction", "_parentNode", "_varName"];
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actionTrees = missionNamespace getVariable [_varName, []];
_parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode);
private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
private _actionTrees = missionNamespace getVariable [_varName, []];
private _parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode);
if (isNil {_parentNode}) then {
TRACE_2("No Main Action on object", _objectType, _typeNum);
_mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call FUNC(createAction);
private _mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call FUNC(createAction);
[_objectType, _typeNum, [], _mainAction] call EFUNC(interact_menu,addActionToClass);
};

View File

@ -6,6 +6,7 @@
* 0: Object <OBJECT>
* 1: Original action tree <ARRAY>
* 2: Parent path <ARRAY>
* 3: Distance to base point (will be 0 for self/zeus/in-vehicle) <NUMBER>
*
* Return value:
* Active children <ARRAY>
@ -14,13 +15,11 @@
*/
#include "script_component.hpp"
params ["_object", "_origAction", "_parentPath"];
params ["_object", "_origAction", "_parentPath", "_distanceToBasePoint"];
_origAction params ["_origActionData", "_origActionChildren"];
private ["_target","_player","_fullPath","_activeChildren","_dynamicChildren","_action","_actionData","_x"];
_target = _object;
_player = ACE_player;
private _target = _object;
private _player = ACE_player;
// Check if the function should be modified first
if !((_origActionData select 10) isEqualTo {}) then {
@ -29,54 +28,62 @@ if !((_origActionData select 10) isEqualTo {}) then {
[_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10);
};
_origActionData params ["_actionName", "", "", "_statementCode", "_conditionCode", "_insertChildrenCode", "_customParams", "", "_distance"];
// Return nothing if the action itself is not active
if !([_target, ACE_player, _origActionData select 6] call (_origActionData select 4)) exitWith {
if !([_target, ACE_player, _customParams] call _conditionCode) exitWith {
[]
};
_fullPath = +_parentPath;
_fullPath pushBack (_origActionData select 0);
_activeChildren = [];
// Return nothing if the action is to far (including checking sub actions) [DISABLED FOR NOW ref #2196]
// if (_distanceToBasePoint > _distance) exitWith {
// []
// };
private _fullPath = +_parentPath;
_fullPath pushBack _actionName;
private _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);
if !({} isEqualTo _insertChildrenCode) then {
private _dynamicChildren = [_target, ACE_player, _customParams] call _insertChildrenCode;
// Collect dynamic children class actions
{
_action = [_x select 2, _x, _fullPath] call FUNC(collectActiveActionTree);
private _action = [_x select 2, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
} forEach _dynamicChildren;
nil
} count _dynamicChildren;
};
// Collect children class actions
{
_action = [_object, _x, _fullPath] call FUNC(collectActiveActionTree);
private _action = [_object, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
} forEach _origActionChildren;
nil
} count _origActionChildren;
// Collect children object actions
{
EXPLODE_2_PVT(_x,_actionData,_pPath);
_x params ["_actionData", "_pPath"];
// Check if the action is children of the original action
if (count _pPath == count _fullPath &&
{_pPath isEqualTo _fullPath}) then {
_action = [_object, [_actionData,[]], _fullPath] call FUNC(collectActiveActionTree);
if (_pPath isEqualTo _fullPath) then {
private _action = [_object, [_actionData,[]], _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
if ((count _action) > 0) then {
_activeChildren pushBack _action;
};
};
} forEach GVAR(objectActionList);
nil
} count GVAR(objectActionList);
// If the original action has no statement, and no children, don't display it
if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) exitWith {
if ((_activeChildren isEqualTo []) && {_statementCode isEqualTo {}}) exitWith {
// @todo: Account for showDisabled?
[]
};

View File

@ -14,34 +14,31 @@
params ["_target"];
private ["_objectType","_actionsVarName","_isMan"];
_objectType = _target;
_isMan = false;
private _objectType = _target;
if (_target isEqualType objNull) then {
_objectType = typeOf _target;
_isMan = _target isKindOf "CAManBase";
};
_actionsVarName = format [QGVAR(Act_%1), _objectType];
private _actionsVarName = format [QGVAR(Act_%1), _objectType];
// Exit if the action menu is already compiled for this class
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_position", "_condition", "_showDisabled", "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
params ["_actionsCfg"];
_actions = [];
private _recurseFnc = {
params ["_actionsCfg", "_parentDistance"];
private _actions = [];
{
_entryCfg = _x;
private _entryCfg = _x;
if(isClass _entryCfg) then {
_displayName = getText (_entryCfg >> "displayName");
_distance = getNumber (_entryCfg >> "distance");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
private _displayName = getText (_entryCfg >> "displayName");
private _distance = _parentDistance;
if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");};
// if (_distance < _parentDistance) then {ACE_LOGWARNING_3("[%1] distance %2 less than parent %3", configName _entryCfg, _distance, _parentDistance);};
private _icon = getText (_entryCfg >> "icon");
private _statement = compile (getText (_entryCfg >> "statement"));
// If the position entry is present, compile it
_position = getText (_entryCfg >> "position");
private _position = getText (_entryCfg >> "position");
if (_position != "") then {
_position = compile _position;
} else {
@ -55,7 +52,7 @@ _recurseFnc = {
};
};
_condition = getText (_entryCfg >> "condition");
private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition
@ -63,13 +60,13 @@ _recurseFnc = {
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
};
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = false;
private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
private _runOnHover = false;
if (isText (_entryCfg >> "runOnHover")) then {
_runOnHover = compile getText (_entryCfg >> "runOnHover");
} else {
@ -77,9 +74,9 @@ _recurseFnc = {
};
_condition = compile _condition;
_children = [_entryCfg] call _recurseFnc;
private _children = [_entryCfg, _distance] call _recurseFnc;
_entry = [
private _entry = [
[
configName _entryCfg,
_displayName,
@ -97,19 +94,16 @@ _recurseFnc = {
];
_actions pushBack _entry;
};
} forEach (configProperties [_actionsCfg, "isClass _x", true]);
nil
} count (configProperties [_actionsCfg, "isClass _x", true]);
_actions
};
private ["_actionsCfg","_actions"];
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
TRACE_1("Building ACE_Actions",_objectType);
private _actions = [_actionsCfg, 0] call _recurseFnc;
// If the classname inherits from CAManBase, just copy it's menu without recompiling a new one
_actions = if (_isMan) then {
+ (missionNamespace getVariable QGVAR(Act_CAManBase))
} else {
[_actionsCfg] call _recurseFnc
};
missionNamespace setVariable [_actionsVarName, _actions];
/*
@ -125,7 +119,7 @@ missionNamespace setVariable [_actionsVarName, _actions];
[],
{[0,0,0]},
1,
[false,false,false]
[false,false,false,false,false]
],
[children actions]
]

View File

@ -14,46 +14,42 @@
params ["_target"];
private ["_objectType","_actionsVarName","_isMan"];
_objectType = _target;
_isMan = false;
private _objectType = _target;
if (_target isEqualType objNull) then {
_objectType = typeOf _target;
_isMan = _target isKindOf "CAManBase";
};
_actionsVarName = format [QGVAR(SelfAct_%1), _objectType];
private _actionsVarName = format [QGVAR(SelfAct_%1), _objectType];
// Exit if the action menu is already compiled for this class
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled",
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
private _recurseFnc = {
params ["_actionsCfg"];
_actions = [];
private _actions = [];
{
_entryCfg = _x;
private _entryCfg = _x;
if(isClass _entryCfg) then {
_displayName = getText (_entryCfg >> "displayName");
private _displayName = getText (_entryCfg >> "displayName");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
private _icon = getText (_entryCfg >> "icon");
private _statement = compile (getText (_entryCfg >> "statement"));
_condition = getText (_entryCfg >> "condition");
private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = true;
private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
private _runOnHover = true;
if (isText (_entryCfg >> "runOnHover")) then {
_runOnHover = compile getText (_entryCfg >> "runOnHover");
} else {
@ -61,9 +57,9 @@ _recurseFnc = {
};
_condition = compile _condition;
_children = [_entryCfg] call _recurseFnc;
private _children = [_entryCfg] call _recurseFnc;
_entry = [
private _entry = [
[
configName _entryCfg,
_displayName,
@ -81,16 +77,15 @@ _recurseFnc = {
];
_actions pushBack _entry;
};
} forEach (configProperties [_actionsCfg, "isClass _x", true]);
nil
} count (configProperties [_actionsCfg, "isClass _x", true]);
_actions
};
private ["_actionsCfg","_actions"];
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
private ["_baseDisplayName", "_baseIcon"];
_baseDisplayName = "";
_baseIcon = "";
private _baseDisplayName = "";
private _baseIcon = "";
if (_objectType isKindOf "CAManBase") then {
_baseDisplayName = localize LSTRING(SelfActionsRoot);
_baseIcon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
@ -107,12 +102,9 @@ if (_objectType isKindOf "CAManBase") then {
};
};
// If the classname inherits from CAManBase, just copy it's menu without recompiling a new one
_actions = if (_isMan) then {
+ (missionNamespace getVariable QGVAR(SelfAct_CAManBase))
} else {
// Create a master action to base on self action
[
TRACE_1("Building ACE_SelfActions",_objectType);
// Create a master action to base on self action
private _actions = [
[
[
"ACE_SelfActions",
@ -127,11 +119,10 @@ _actions = if (_isMan) then {
{},
"Spine3",
10,
[false,true,false]
[false,true,false,false,false]
],
[_actionsCfg] call _recurseFnc
]
]
};
];
missionNamespace setVariable [_actionsVarName, _actions];

View File

@ -15,41 +15,38 @@
// Exit if the action menu is already compiled for zeus
if !(isNil {missionNamespace getVariable [QGVAR(ZeusActions), nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled",
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
private _recurseFnc = {
params ["_actionsCfg"];
_actions = [];
private _actions = [];
{
_entryCfg = _x;
private _entryCfg = _x;
if(isClass _entryCfg) then {
_displayName = getText (_entryCfg >> "displayName");
private _displayName = getText (_entryCfg >> "displayName");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
private _icon = getText (_entryCfg >> "icon");
private _statement = compile (getText (_entryCfg >> "statement"));
_condition = getText (_entryCfg >> "condition");
private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = true;
private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
private _runOnHover = true;
if (isText (_entryCfg >> "runOnHover")) then {
_runOnHover = compile getText (_entryCfg >> "runOnHover");
} else {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
};
_condition = compile _condition;
_children = [_entryCfg] call _recurseFnc;
private _condition = compile _condition;
private _children = [_entryCfg] call _recurseFnc;
_entry = [
private _entry = [
[
configName _entryCfg,
_displayName,
@ -60,7 +57,7 @@ _recurseFnc = {
{},
[0,0,0],
10, //distace
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
[_showDisabled,_enableInside,_canCollapse,_runOnHover,false],
_modifierFunction
],
_children
@ -71,8 +68,7 @@ _recurseFnc = {
_actions
};
private ["_actionsCfg"];
_actionsCfg = configFile >> "ACE_ZeusActions";
private _actionsCfg = configFile >> "ACE_ZeusActions";
// Create a master action to base zeus actions on
GVAR(ZeusActions) = [
@ -87,7 +83,7 @@ GVAR(ZeusActions) = [
{},
{[0,0,0]},
10,
[false,true,false]
[false,true,false,false,false]
],
[_actionsCfg] call _recurseFnc
]

View File

@ -13,7 +13,7 @@
* 6: Action parameters <ANY> (Optional)
* 7: Position (Position array, Position code or Selection Name) <ARRAY>, <CODE> or <STRING> (Optional)
* 8: Distance <NUMBER> (Optional)
* 9: Other parameters <ARRAY> (Optional)
* 9: Other parameters [showDisabled,enableInside,canCollapse,runOnHover,doNotCheckLOS] <ARRAY> (Optional)
* 10: Modifier function <CODE> (Optional)
*
* Return value:
@ -26,6 +26,8 @@
*/
#include "script_component.hpp"
// IGNORE_PRIVATE_WARNING(_actionName,_displayName,_icon,_statement,_condition,_insertChildren,_customParams,_position,_distance,_params,_modifierFunction);
params [
"_actionName",
"_displayName",
@ -41,16 +43,16 @@ params [
];
_position = if (_position isEqualType "") then {
// If the action is set to a selection, create the suitable code
compile format ["_target selectionPosition '%1'", _position];
// If the action is set to a selection, create the suitable code - IGNORE_PRIVATE_WARNING(_target);
compile format ["_target selectionPosition '%1'", _position];
} else {
if (_position isEqualType []) then {
// If the action is set to a array position, create the suitable code
compile format ["%1", _position];
} else {
if (_position isEqualType []) then {
// If the action is set to a array position, create the suitable code
compile format ["%1", _position];
} else {
_position;
};
_position;
};
};
[
_actionName,
@ -58,7 +60,6 @@ _position = if (_position isEqualType "") then {
_icon,
_statement,
_condition,
_insertChildren,
_customParams,
_position,

View File

@ -1,11 +1,24 @@
// by commy2
/*
* Author: commy2
* Sets the controls structured text if it isn't already set.
*
* Argument:
* 0: Structured Text Ctrl <CONTROL>
* 1: Index <NUMBER>
* 2: Text <STRING>
*
* Return value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_ctrl", "_index", "_text"];
//systemChat str (_text != ARR_SELECT(GVAR(ParsedTextCached),_index,"-1"));
if (_text != ARR_SELECT(GVAR(ParsedTextCached),_index,"-1")) then {
if (_text != (GVAR(ParsedTextCached) param [_index,"-1"])) then {
GVAR(ParsedTextCached) set [_index, _text];
_ctrl ctrlSetStructuredText parseText _text;
};

View File

@ -11,7 +11,7 @@
* Action node <ARRAY> or <NIL> if not found
*
* Example:
* [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
* [actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
*
* Public: No
*/
@ -19,18 +19,16 @@
params ["_actionTreeList", "_parentPath"];
private ["_parentNode", "_foundParentNode", "_fnc_findFolder", "_actionTree"];
// Hack to make this work on the root node too
if (count _parentPath == 0) exitWith {
if (_parentPath isEqualTo []) exitWith {
[[],_actionTreeList]
};
// Search the class action trees and find where to insert the entry
_parentNode = [[],_actionTreeList];
_foundParentNode = false;
private _parentNode = [[],_actionTreeList];
private _foundParentNode = false;
_fnc_findFolder = {
private _fnc_findFolder = {
params ["_parentPath", "_level", "_actionNode"];
{

View File

@ -14,8 +14,7 @@
params ["_newUnit", "_oldUnit"];
// add to new unit
private "_ehid";
_ehid = [_newUnit, "DefaultAction", {GVAR(openedMenuType) >= 0}, {
private _ehid = [_newUnit, "DefaultAction", {GVAR(openedMenuType) >= 0}, {
if (!GVAR(actionOnKeyRelease) && GVAR(actionSelected)) then {
[GVAR(openedMenuType),true] call FUNC(keyUp);
};

View File

@ -9,18 +9,20 @@
* Return value:
* Bool
*
* Example:
* [[["ACE_SelfActions", player],["ace_Gestures", player]], [["ACE_SelfActions", player]]] call ace_interact_menu_fnc_isSubPath
*
* Public: No
*/
#include "script_component.hpp"
params ["_longPath", "_shortPath"];
private ["_isSubPath","_i"];
_isSubPath = true;
private _isSubPath = true;
if (count _shortPath > count _longPath) exitWith {false};
for [{_i = 0},{_i < count _shortPath},{_i = _i + 1}] do {
for [{private _i = 0},{_i < count _shortPath},{_i = _i + 1}] do {
if !((_longPath select _i) isEqualTo (_shortPath select _i)) exitWith {
_isSubPath = false;
};

View File

@ -65,7 +65,7 @@ if (GVAR(useCursorMenu)) then {
// uiNamespace getVariable QGVAR(cursorMenuOpened);
GVAR(cursorPos) = [0.5,0.5,0];
_ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922];
private _ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922];
_ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH];
_ctrl ctrlCommit 0;
@ -75,8 +75,7 @@ if (GVAR(useCursorMenu)) then {
setMousePosition [0.5, 0.5];
};
GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
GVAR(selfMenuOffset) = (AGLtoASL (positionCameraToWorld [0, 0, 2])) vectorDiff (AGLtoASL (positionCameraToWorld [0, 0, 0]));
if (GVAR(menuAnimationSpeed) > 0) then {
//Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice)

View File

@ -24,9 +24,8 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
if(GVAR(actionSelected)) then {
this = GVAR(selectedTarget);
private ["_player","_target","_actionData"];
_player = ACE_Player;
_target = GVAR(selectedTarget);
private _player = ACE_Player;
private _target = GVAR(selectedTarget);
// Clear the conditions caches
["clearConditionCaches", []] call EFUNC(common,localEvent);
@ -35,7 +34,7 @@ if(GVAR(actionSelected)) then {
if (!(GVAR(actionOnKeyRelease)) && !_calledByClicking) exitWith {};
// Check the action conditions
_actionData = GVAR(selectedAction) select 0;
private _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);

View File

@ -8,8 +8,12 @@
* Return value:
* None
*
* Example:
* [] call ace_interact_menu_fnc_render
*
* Public: No
*/
// #define ENABLE_PERFORMANCE_COUNTERS
#include "script_component.hpp"
BEGIN_COUNTER(fnc_render);
@ -42,7 +46,7 @@ if (GVAR(openedMenuType) >= 0) then {
};
} forEach GVAR(currentOptions);
if(_closestSelection == -1) exitWith {};
if (_closestSelection == -1) exitWith {END_COUNTER(fnc_renderMenuOpen);};
private _closest = GVAR(currentOptions) select _closestSelection;
_closest params ["_action", "_sPos", "_hoverPath"];

View File

@ -14,56 +14,57 @@
GVAR(currentOptions) = [];
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos", "_virtualPoint", "_wavesAtOrigin", "_wavesAtVirtualPoint"];
_player = ACE_player;
private _player = ACE_player;
_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL);
_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos;
private _cameraPosASL = AGLtoASL (positionCameraToWorld [0, 0, 0]);
private _cameraDir = (AGLtoASL (positionCameraToWorld [0, 0, 1])) vectorDiff _cameraPosASL;
_fnc_renderNearbyActions = {
private _fnc_renderNearbyActions = {
// Render all nearby interaction menus
#define MAXINTERACTOBJECTS 3
GVAR(foundActions) = [];
GVAR(lastTimeSearchedActions) = ACE_diagTime;
_numInteractObjects = 0;
_nearestObjects = nearestObjects [ACE_player, ["All"], 13];
private _numInteractObjects = 0;
private _nearestObjects = nearestObjects [ACE_player, ["All"], 13];
{
_target = _x;
private _target = _x;
// Quick oclussion test. Skip objects more than 1 m behind the camera plane
_lambda = ((getPosASL _x) vectorDiff _cameraPos) vectorDotProduct _cameraDir;
private _lambda = ((getPosASL _x) vectorDiff _cameraPosASL) vectorDotProduct _cameraDir;
if ((_lambda > -1) && {!isObjectHidden _target}) then {
_numInteractions = 0;
private _numInteractions = 0;
// Prevent interacting with yourself or your own vehicle
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
{
// Only render them directly if they are base level actions
if (count (_x select 1) == 0) then {
if ((_x select 1) isEqualTo []) then {
// Try to render the menu
_action = _x;
private _action = _x;
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
};
};
} forEach GVAR(objectActionList);
nil
} count GVAR(objectActionList);
// Iterate through base level class actions and render them if appropiate
_classActions = missionNamespace getVariable [_actionsVarName, []];
private _actionsVarName = format [QGVAR(Act_%1), typeOf _target];
private _classActions = missionNamespace getVariable [_actionsVarName, []];
{
_action = _x;
private _action = _x;
// Try to render the menu
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
};
} forEach _classActions;
nil
} count _classActions;
// Limit the amount of objects the player can interact with
if (_numInteractions > 0) then {
@ -73,44 +74,33 @@ _fnc_renderNearbyActions = {
};
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};
} forEach _nearestObjects;
nil
} count _nearestObjects;
};
_fnc_renderLastFrameActions = {
private _fnc_renderLastFrameActions = {
{
_x params ["_target", "_action", "_objectActionList"];
GVAR(objectActionList) = _objectActionList;
[_target, _action] call FUNC(renderBaseMenu);
} forEach GVAR(foundActions);
nil
} count GVAR(foundActions);
};
_fnc_renderSelfActions = {
_target = _this;
private _fnc_renderSelfActions = {
private _target = _this;
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
// Set object actions for collectActiveActionTree
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
/*
{
_action = _x;
// Only render them directly if they are base level actions
if (count (_action select 7) == 1) then {
[_target, _action, 0, [180, 360]] call FUNC(renderMenu);
};
} forEach GVAR(objectActionList);
*/
// Iterate through base level class actions and render them if appropiate
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
_classActions = missionNamespace getVariable [_actionsVarName, []];
private _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
private _classActions = missionNamespace getVariable [_actionsVarName, []];
_pos = if !(GVAR(useCursorMenu)) then {
_virtualPoint = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition);
_wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt);
_wavesAtVirtualPoint = [_virtualPoint] call EFUNC(common,waveHeightAt);
_virtualPoint set [2, ((_virtualPoint select 2) - _wavesAtOrigin + _wavesAtVirtualPoint)];
_virtualPoint
private _pos = if !(GVAR(useCursorMenu)) then {
//Convert to ASL, add offset and then convert back to AGL (handles waves when over water)
ASLtoAGL ((AGLtoASL (positionCameraToWorld [0, 0, 0])) vectorAdd GVAR(selfMenuOffset));
} else {
[0.5, 0.5]
};
@ -118,14 +108,16 @@ _fnc_renderSelfActions = {
{
_action = _x;
[_target, _action, _pos] call FUNC(renderBaseMenu);
} forEach _classActions;
nil
} count _classActions;
};
_fnc_renderZeusActions = {
private _fnc_renderZeusActions = {
{
_action = _x;
private _action = _x;
[_this, _action, [0.5, 0.5]] call FUNC(renderBaseMenu);
} forEach GVAR(ZeusActions);
nil
} count GVAR(ZeusActions);
};
@ -160,11 +152,10 @@ if (count GVAR(collectedActionPoints) > 1) then {
// Order action points according to z
GVAR(collectedActionPoints) sort true;
private ["_i","_j","_delta"];
for [{_i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do {
for [{_j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do {
for [{private _i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do {
for [{private _j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do {
// Check if action point _i is ocluded by _j
_delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1));
private _delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1));
// If _i is inside a cone with 20º half angle with origin on _j
if (_delta select 2 > 0.94) exitWith {
@ -178,4 +169,5 @@ if (count GVAR(collectedActionPoints) > 1) then {
{
_x params ["_z", "_sPos", "_activeActionTree"];
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
} forEach GVAR(collectedActionPoints);
nil
} count GVAR(collectedActionPoints);

View File

@ -16,88 +16,83 @@
BEGIN_COUNTER(fnc_renderBaseMenu)
private ["_distance","_pos","_weaponDir","_ref","_sPos","_activeActionTree", "_line"];
params ["_object", "_baseActionNode"];
_baseActionNode params ["_actionData"];
_actionData params ["_actionName", "", "", "", "", "", "", "_positionCode", "_distance", "_params"];
_distance = _actionData select 8;
// Obtain a 3D position for the action
_pos = if((count _this) > 2) then {
private _pos = if((count _this) > 2) then {
_this select 2
} else {
// Setup scope variables for position code
private ["_target"];
_target = _object;
private _target = _object;
// Get action position
_object modelToWorldVisual (call (_actionData select 7))
_object modelToWorldVisual (call _positionCode)
};
// For non-self actions, exit if the action is too far away or ocluded
if (GVAR(openedMenuType) == 0 && (vehicle ACE_player == ACE_player) && (isNull curatorCamera) &&
private _distanceToBasePoint = 0; //This will be 0 for self/zeus/in-vehicle (used later to check sub action distance)
if ((GVAR(openedMenuType) == 0) && {vehicle ACE_player == ACE_player} && {isNull curatorCamera} &&
{
private ["_headPos","_actualDistance"];
_headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
_actualDistance = _headPos distance _pos;
private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
_distanceToBasePoint = _headPos distance _pos;
if (_actualDistance > _distance) exitWith {true};
if (_distanceToBasePoint > _distance) exitWith {true};
if ((_actualDistance > 1.5) && {!((_actionData select 9) select 4)}) exitWith {
// If distance to action is greater than 1.5 m, check LOS
_line = [_headPos call EFUNC(common,positionToASL), _pos call EFUNC(common,positionToASL), _object, ACE_player];
lineIntersects _line
if ((_distanceToBasePoint > 1.5) && {!(_params select 4)}) exitWith {
// If distance to action is greater than 1.5 m and check isn't disabled in params, check LOS
lineIntersects [AGLtoASL _headPos, AGLtoASL _pos, _object, ACE_player]
};
false
}) exitWith {false};
// Exit if the action is behind you
_sPos = if (count _pos != 2) then {
private _sPos = if (count _pos != 2) then {
worldToScreen _pos
} else {
_pos
};
if(count _sPos == 0) exitWith {false};
if (_sPos isEqualTo []) exitWith {false};
// Exit if the action is off screen
if ((_sPos select 0) < safeZoneXAbs || (_sPos select 0) > safeZoneXAbs + safeZoneWAbs) exitWith {false};
if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZoneH) exitWith {false};
if ((_sPos select 0) < safeZoneXAbs || {(_sPos select 0) > safeZoneXAbs + safeZoneWAbs}) exitWith {false};
if ((_sPos select 1) < safeZoneY || {(_sPos select 1) > safeZoneY + safeZoneH}) exitWith {false};
BEGIN_COUNTER(fnc_collectActiveActionTree)
// Collect active tree
private "_uid";
_uid = format [QGVAR(ATCache_%1), _actionData select 0];
_activeActionTree = [
[_object, _baseActionNode, []],
private _uid = format [QGVAR(ATCache_%1), _actionName];
private _activeActionTree = [
[_object, _baseActionNode, [], _distanceToBasePoint],
DFUNC(collectActiveActionTree),
_object, _uid, 1.0, "interactMenuClosed"
] call EFUNC(common,cachedCall);
END_COUNTER(fnc_collectActiveActionTree)
/*
#ifdef DEBUG_MODE_EXTRA
diag_log "Printing: _activeActionTree";
_fnc_print = {
EXPLODE_2_PVT(_this,_level,_node);
EXPLODE_3_PVT(_node,_actionData,_children,_object);
[0, _activeActionTree] call {
params ["_level", "_node"];
_node params ["_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;
*/
#endif
// Check if there's something left for rendering
if (count _activeActionTree == 0) exitWith {false};
if (_activeActionTree isEqualTo []) exitWith {false};
BEGIN_COUNTER(fnc_renderMenus);
// IGNORE_PRIVATE_WARNING(_cameraPos,_cameraDir);
// IGNORE_PRIVATE_WARNING(_cameraPosASL,_cameraDir);
if (count _pos > 2) then {
_sPos pushBack (((_pos call EFUNC(common,positionToASL)) vectorDiff _cameraPos) vectorDotProduct _cameraDir);
_sPos pushBack (((AGLtoASL _pos) vectorDiff _cameraPosASL) vectorDotProduct _cameraDir);
} else {
_sPos pushBack 0;
};

View File

@ -15,21 +15,20 @@
*/
#include "script_component.hpp"
#define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa)
private ["_ctrl", "_pos", "_displayNum"];
params ["_text", "_icon", "_sPos", "_textSettings"];
//systemChat format ["Icon %1 - %2,%3", _text, _sPos select 0, _sPos select 1];
TRACE_2("Icon",_text,_sPos);
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
_displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
private _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
if (GVAR(useCursorMenu)) then {
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
};
};
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
private _ctrl = GVAR(iconCtrls) select GVAR(iconCount);
if(_icon == "") then {
_icon = DEFAULT_ICON;
@ -41,11 +40,10 @@ _text = if (GVAR(UseListMenu)) then {
format ["<img image='%1' align='center'/><br/><t %2 align='center'>%3</t>", _icon, _textSettings, "ace_break_line" callExtension _text];
};
//_ctrl ctrlSetStructuredText parseText _text;
[_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached);
GVAR(iconCount) = GVAR(iconCount) + 1;
_pos = if (GVAR(UseListMenu)) then {
private _pos = if (GVAR(UseListMenu)) then {
[(_sPos select 0)-(0.0095*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.20*SafeZoneW, 0.035*SafeZoneW]
} else {
[(_sPos select 0)-(0.0750*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.15*SafeZoneW, 0.100*SafeZoneW]

View File

@ -15,22 +15,20 @@
*/
#include "script_component.hpp"
private ["_menuInSelectedPath", "_path", "_menuDepth", "_x", "_offset", "_newPos", "_forEachIndex", "_player", "_pos", "_target", "_textSettings"];
params ["_parentPath", "_action", "_sPos", "_angles"];
_action params ["_actionData", "_activeChildren", "_actionObject"];
_angles params ["_centerAngle", "_maxAngleSpan"];
_menuDepth = (count GVAR(menuDepthPath));
private _menuDepth = (count GVAR(menuDepthPath));
//BEGIN_COUNTER(constructing_paths);
// Store path to action
_path = +_parentPath;
private _path = +_parentPath;
_path pushBack [_actionData select 0,_actionObject];
// Check if the menu is on the selected path
_menuInSelectedPath = true;
private _menuInSelectedPath = true;
{
if (_forEachIndex >= (count GVAR(menuDepthPath))) exitWith {
_menuInSelectedPath = false;
@ -44,7 +42,7 @@ _menuInSelectedPath = true;
//BEGIN_COUNTER(constructing_colors);
//Get text color settings string
_textSettings = GVAR(colorSelectedSettings);
private _textSettings = GVAR(colorSelectedSettings);
if(!_menuInSelectedPath) then {
_textSettings = (GVAR(textSettingsMatrix) select (count _path)) select _menuDepth;
};
@ -68,13 +66,12 @@ if !(_menuInSelectedPath) exitWith {true};
//BEGIN_COUNTER(children);
private ["_numChildren","_angleSpan","_angle","_angleInterval","_scaleX", "_scaleY", "_offset", "_textSize"];
_numChildren = count _activeChildren;
_angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1));
private _numChildren = count _activeChildren;
private _angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1));
if (_angleSpan >= 305) then {
_angleSpan = 360;
};
_angleInterval = 55;
private _angleInterval = 55;
if (_angleSpan < 360) then {
if (_numChildren > 1) then {
_angleInterval = _angleSpan / (_numChildren - 1);
@ -87,15 +84,15 @@ if (_numChildren == 1) then {
};
// Scale menu based on the amount of children
_scaleX = 1;
_scaleY = 1;
private _scaleX = 1;
private _scaleY = 1;
if (GVAR(UseListMenu)) then {
_textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize);
private _textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize);
_scaleX = _textSize * 0.17 * 1.1;
_scaleY = 0.17 * 0.30 * 4/3;
} else {
_textSize = if (GVAR(textSize) > 2) then {1.3} else {1};
private _textSize = if (GVAR(textSize) > 2) then {1.3} else {1};
_scaleX = _textSize * 0.17 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5);
_scaleY = _textSize * 0.17 * 4/3 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5);
};
@ -106,15 +103,13 @@ if (_menuInSelectedPath && {_menuDepth == count _path}) then {
_scaleY = _scaleY * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1));
};
_target = _actionObject;
_player = ACE_player;
private _target = _actionObject;
private _player = ACE_player;
//END_COUNTER(children);
_angle = _centerAngle - _angleSpan / 2;
private _angle = _centerAngle - _angleSpan / 2;
{
//BEGIN_COUNTER(children);
private ["_offset","_newPos"];
_newPos = if (GVAR(UseListMenu)) then {
private _newPos = if (GVAR(UseListMenu)) then {
[(_sPos select 0) + _scaleX,
(_sPos select 1) + _scaleY * (_forEachIndex - _numChildren/2 + 0.5)];
} else {
@ -122,8 +117,6 @@ _angle = _centerAngle - _angleSpan / 2;
(_sPos select 1) + _scaleY * (sin _angle)];
};
//drawLine3D [_pos, _newPos, [1,0,0,0.8]];
//END_COUNTER(children);
[_path, _x, _newPos, [_angle, 150]] call FUNC(renderMenu);
_angle = _angle + _angleInterval;

View File

@ -15,10 +15,8 @@
params ["_sPos", "_icon"];
private ["_displayNum", "_ctrl", "_pos"];
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
_displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
private _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
if (GVAR(useCursorMenu)) then {
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
@ -26,9 +24,9 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
};
};
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
private _ctrl = GVAR(iconCtrls) select GVAR(iconCount);
_pos = if (GVAR(UseListMenu)) then {
private _pos = if (GVAR(UseListMenu)) then {
[_ctrl, GVAR(iconCount), format ["<img image='%1' color='#FF0000' size='1.6'/>", _icon]] call FUNC(ctrlSetParsedTextCached);
[(_sPos select 0)-(0.014*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.05*SafeZoneW, 0.035*SafeZoneW]
} else {

View File

@ -12,15 +12,13 @@
*/
#include "script_component.hpp"
private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize", "_colorShadowMax", "_colorShadowMin", "_colorTextMax", "_colorTextMin", "_shadowSetting"];
//Mixes 2 colors (number arrays) and makes a color string "#AARRGGBB" for structured text
_mixColor = {
private _mixColor = {
params ["_color1", "_color2", "_ratio"];
private ["_return", "_mix", "_index"];
_return = "";
private _return = "";
for "_index" from 0 to 3 do {
_mix = linearConversion [0, 1, _ratio, (_color1 select _index), (_color2 select _index)];
private _mix = linearConversion [0, 1, _ratio, (_color1 select _index), (_color2 select _index)];
if (_index != 3) then {
_return = _return + ([255 * _mix] call EFUNC(common,toHex));
} else {
@ -30,15 +28,17 @@ _mixColor = {
_return
};
_colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]];
_colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]];
_colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]];
_colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]];
_shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2];
_textSize = missionNamespace getVariable [QGVAR(textSize), 2];
private _colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]];
private _colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]];
private _colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]];
private _colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]];
private _shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2];
private _textSize = missionNamespace getVariable [QGVAR(textSize), 2];
_textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor;
_shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor;
TRACE_6("Building text matrix",_colorTextMin,_colorTextMax,_colorShadowMin,_colorShadowMax,_shadowSetting,_textSize);
private _textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor;
private _shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor;
_textSize = switch (_textSize) do {
case (0): {0.4};
case (1): {0.6};
@ -51,7 +51,7 @@ GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowCo
GVAR(textSettingsMatrix) = [];
for "_pathCount" from 0 to 15 do {
_row = [];
private _row = [];
for "_menuDepth" from 0 to 15 do {
if (_menuDepth > 0) then {
_textColor = [_colorTextMin, _colorTextMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor;

View File

@ -13,12 +13,11 @@
*/
#include "script_component.hpp"
private ["_parentPath","_actionName", "_i"];
_parentPath = [];
for [{_i = 0},{_i < (count _this) - 1},{_i = _i + 1}] do {
private _parentPath = [];
for [{private _i = 0},{_i < (count _this) - 1},{_i = _i + 1}] do {
_parentPath pushBack (_this select _i);
};
_actionName = if (count _this > 0) then {
private _actionName = if (count _this > 0) then {
_this select ((count _this) - 1);
} else {
""

View File

@ -1,7 +1,7 @@
/*
* Author: PabstMirror
* Scans for nearby "Static" objects (buildings) and adds the UserActions to them.
* Called when interact_menu starts rendering (from "interact_keyDown" event)
* Called when interact_menu starts rendering (from "interactMenuOpened" event)
*
* Arguments:
* 0: Interact Menu Type (0 - world, 1 - self) <NUMBER>
@ -10,9 +10,9 @@
* Nothing
*
* Example:
* [0] call ace_interact_menu_fnc_addHouseActions
* [0] call ace_interact_menu_fnc_userActions_addHouseActions
*
* Public: Yes
* Public: No
*/
#include "script_component.hpp"
@ -26,7 +26,6 @@ if (_interactionType != 0) exitWith {};
if ((vehicle ACE_player) != ACE_player) exitWith {};
[{
private ["_nearBuidlings", "_typeOfHouse", "_houseBeingScaned", "_actionSet", "_memPoints", "_memPointsActions", "_helperPos", "_helperObject"];
params ["_args", "_pfID"];
_args params ["_setPosition", "_addedHelpers", "_housesScaned", "_housesToScanForActions"];
@ -54,33 +53,34 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
//If player moved >2 meters from last pos, then rescan
if (((getPosASL ace_player) distance _setPosition) < 2) exitWith {};
_nearBuidlings = nearestObjects [ace_player, ["Static"], 30];
private _nearBuidlings = nearestObjects [ace_player, ["Static"], 30];
{
_typeOfHouse = typeOf _x;
private _typeOfHouse = typeOf _x;
if (((count (configFile >> "CfgVehicles" >> _typeOfHouse >> "UserActions")) == 0) && {(count (getArray (configFile >> "CfgVehicles" >> _typeOfHouse >> "ladders"))) == 0}) then {
_housesScaned pushBack _x;
} else {
_housesToScanForActions pushBack _x;
};
} forEach (_nearBuidlings - _housesScaned);
nil
} count (_nearBuidlings - _housesScaned);
_args set [0, (getPosASL ace_player)];
} else {
_houseBeingScaned = _housesToScanForActions deleteAt 0;
_typeOfHouse = typeOf _houseBeingScaned;
private _typeOfHouse = typeOf _houseBeingScaned;
//Skip this house for now if we are outside of it's radius
//(we have to scan far out for the big houses, but we don't want to waste time adding actions on every little shack)
if ((_houseBeingScaned != cursorTarget) && {((ACE_player distance _houseBeingScaned) - ((sizeOf _typeOfHouse) / 2)) > 4}) exitWith {};
_housesScaned pushBack _houseBeingScaned;
_actionSet = [_typeOfHouse] call FUNC(userActions_getHouseActions);
private _actionSet = [_typeOfHouse] call FUNC(userActions_getHouseActions);
_actionSet params ["_memPoints", "_memPointsActions"];
// systemChat format ["Add Actions for [%1] (count %2) @ %3", _typeOfHouse, (count _memPoints), diag_tickTime];
{
_helperPos = (_houseBeingScaned modelToWorld (_houseBeingScaned selectionPosition _x)) call EFUNC(common,positionToASL);
_helperObject = "ACE_LogicDummy" createVehicleLocal _helperPos;
private _helperPos = AGLtoASL (_houseBeingScaned modelToWorld (_houseBeingScaned selectionPosition _x));
private _helperObject = "ACE_LogicDummy" createVehicleLocal _helperPos;
_addedHelpers pushBack _helperObject;
_helperObject setVariable [QGVAR(building), _houseBeingScaned];
_helperObject setPosASL _helperPos;
@ -88,7 +88,8 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
{
[_helperObject, 0, [], _x] call EFUNC(interact_menu,addActionToObject);
} forEach (_memPointsActions select _forEachIndex);
nil
} count (_memPointsActions select _forEachIndex);
} forEach _memPoints;
};

View File

@ -8,22 +8,23 @@
* Return Value:
* [[Array of MemPoints], [Array Of Actions]]
*
* Public: Yes
* Example:
* ["Land_i_House_Big_01_V1_F"] call ace_interact_menu_fnc_userActions_getHouseActions
*
* Public: No
*/
#include "script_component.hpp"
params ["_typeOfBuilding"];
private["_action", "_actionDisplayName", "_actionDisplayNameDefault", "_actionMaxDistance", "_actionOffset", "_actionPath", "_actionPosition", "_building", "_configPath", "_endIndex", "_iconImage", "_index", "_ladders", "_memPointIndex", "_memPoints", "_memPointsActions", "_startIndex"];
_searchIndex = GVAR(cachedBuildingTypes) find _typeOfBuilding;
private _searchIndex = GVAR(cachedBuildingTypes) find _typeOfBuilding;
if (_searchIndex != -1) exitWith {GVAR(cachedBuildingActionPairs) select _searchIndex};
_memPoints = [];
_memPointsActions = [];
private _memPoints = [];
private _memPointsActions = [];
//Get the offset for a memory point:
_fnc_getMemPointOffset = {
private _fnc_getMemPointOffset = {
params ["_memoryPoint"];
_memPointIndex = _memPoints find _memoryPoint;
_actionOffset = [0,0,0];
@ -37,13 +38,13 @@ _fnc_getMemPointOffset = {
};
// Add UserActions for the building:
_fnc_userAction_Statement = {
private _fnc_userAction_Statement = {
params ["_target", "_player", "_variable"];
_variable params ["_actionStatement", "_actionCondition"];
this = _target getVariable [QGVAR(building), objNull];
call _actionStatement;
};
_fnc_userAction_Condition = {
private _fnc_userAction_Condition = {
params ["_target", "_player", "_variable"];
_variable params ["_actionStatement", "_actionCondition"];
this = _target getVariable [QGVAR(building), objNull];
@ -51,16 +52,16 @@ _fnc_userAction_Condition = {
call _actionCondition;
};
_configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions";
private _configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions";
for "_index" from 0 to ((count _configPath) - 1) do {
_actionPath = _configPath select _index;
private _actionPath = _configPath select _index;
_actionDisplayName = getText (_actionPath >> "displayName");
_actionDisplayNameDefault = getText (_actionPath >> "displayNameDefault");
_actionPosition = getText (_actionPath >> "position");
_actionCondition = getText (_actionPath >> "condition");
_actionStatement = getText (_actionPath >> "statement");
_actionMaxDistance = getNumber (_actionPath >> "radius");
private _actionDisplayName = getText (_actionPath >> "displayName");
private _actionDisplayNameDefault = getText (_actionPath >> "displayNameDefault");
private _actionPosition = getText (_actionPath >> "position");
private _actionCondition = getText (_actionPath >> "condition");
private _actionStatement = getText (_actionPath >> "statement");
private _actionMaxDistance = getNumber (_actionPath >> "radius");
if (_actionDisplayName == "") then {_actionDisplayName = (configName _x);};
if (_actionPosition == "") then {ERROR("Bad Position");};
@ -70,53 +71,52 @@ for "_index" from 0 to ((count _configPath) - 1) do {
_actionStatement = compile _actionStatement;
_actionCondition = compile _actionCondition;
_actionMaxDistance = _actionMaxDistance + 0.1; //increase range slightly
_iconImage = "";
//extension ~4x as fast:
_iconImage = "ace_parse_imagepath" callExtension _actionDisplayNameDefault;
private _iconImage = "ace_parse_imagepath" callExtension _actionDisplayNameDefault;
_actionOffset = [_actionPosition] call _fnc_getMemPointOffset;
_memPointIndex = _memPoints find _actionPosition;
private _actionOffset = [_actionPosition] call _fnc_getMemPointOffset;
private _memPointIndex = _memPoints find _actionPosition;
_action = [(configName _actionPath), _actionDisplayName, _iconImage, _fnc_userAction_Statement, _fnc_userAction_Condition, {}, [_actionStatement, _actionCondition], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction);
(_memPointsActions select _memPointIndex) pushBack _action;
};
// Add Ladder Actions for the building:
_fnc_ladder_ladderUp = {
private _fnc_ladder_ladderUp = {
params ["_target", "_player", "_variable"];
_variable params ["_ladderIndex"];
_building = _target getVariable [QGVAR(building), objNull];
private _building = _target getVariable [QGVAR(building), objNull];
TRACE_3("Ladder Action - UP",_player,_building,_ladderIndex);
_player action ["LadderUp", _building, _ladderIndex, 0];
};
_fnc_ladder_ladderDown = {
private _fnc_ladder_ladderDown = {
params ["_target", "_player", "_variable"];
_variable params ["_ladderIndex"];
_building = _target getVariable [QGVAR(building), objNull];
private _building = _target getVariable [QGVAR(building), objNull];
TRACE_3("Ladder Action - Down",_player,_building,_ladderIndex);
_player action ["LadderDown", _building, _ladderIndex, 1];
};
_fnc_ladder_conditional = {
private _fnc_ladder_conditional = {
params ["_target", "_player"];
//(Check distance < 2) and (Don't show actions if on a ladder)
((_target distance _player) < 2) && {((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _player) >> "onLadder")) == 0)}
};
_ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders");
private _ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders");
{
_x params ["_ladderBottomMemPoint", "_ladderTopMemPoint"];
_actionMaxDistance = 3; //interact_menu will check head -> target's offset; leave this high and do a precice distance check in condition
private _actionMaxDistance = 3; //interact_menu will check head -> target's offset; leave this high and do a precice distance check in condition
_actionDisplayName = localize "str_action_ladderup";
_iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderup_ca.paa";
private _actionDisplayName = localize "str_action_ladderup";
private _iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderup_ca.paa";
//Ladder Up Action:
_actionOffset = [_ladderBottomMemPoint] call _fnc_getMemPointOffset;
private _actionOffset = [_ladderBottomMemPoint] call _fnc_getMemPointOffset;
_actionOffset = _actionOffset vectorAdd [0,0,1];
_memPointIndex = _memPoints find _ladderBottomMemPoint;
_action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction);
private _memPointIndex = _memPoints find _ladderBottomMemPoint;
private _action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction);
(_memPointsActions select _memPointIndex) pushBack _action;
_actionDisplayName = localize "str_action_ladderdown";

View File

@ -12,5 +12,3 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define ENABLE_PERFORMANCE_COUNTERS

View File

@ -65,6 +65,10 @@ _newTarget = objNull;
// Bail on fast movement
if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && {cameraOn == ACE_player}) exitWith { // keep it steady.
ACE_player switchCamera "INTERNAL";
if (player != ACE_player) then {
TRACE_2("Zeus, manually reseting RC after switchCamera",player,ACE_player);
player remoteControl ACE_player;
};
};
// Refresh the firemode

View File

@ -84,7 +84,7 @@
#ifdef DISABLE_COMPILE_CACHE
#define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf))
#else
#define PREP(fncName) DFUNC(fncName) = QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) call SLX_XEH_COMPILE
#define PREP(fncName) [QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)), QFUNC(fncName)] call SLX_XEH_COMPILE_NEW
#endif
#define PREP_MODULE(folder) [] call compile preprocessFileLineNumbers QUOTE(PATHTOF(folder\__PREP__.sqf))

View File

@ -11,6 +11,13 @@ class ACE_Settings {
typeName = "SCALAR";
values[] = {"Disabled", "Normal", "Advanced"};
};
class GVAR(increaseTrainingInLocations) {
category = CSTRING(Category_Medical);
displayName = CSTRING(MedicalSettings_increaseTrainingInLocations_DisplayName);
description = CSTRING(MedicalSettings_increaseTrainingInLocations_Description);
value = 0;
typeName = "BOOL";
};
class GVAR(enableFor) {
category = CSTRING(Category_Medical);
value = 0;

View File

@ -58,6 +58,12 @@ class CfgVehicles {
};
};
};
class increaseTrainingInLocations {
displayName = CSTRING(MedicalSettings_increaseTrainingInLocations_DisplayName);
description = CSTRING(MedicalSettings_increaseTrainingInLocations_Description);
typeName = "BOOL";
defaultValue = 0;
};
class allowLitterCreation {
displayName = CSTRING(MedicalSettings_allowLitterCreation_DisplayName);
description = CSTRING(MedicalSettings_allowLitterCreation_Description);

View File

@ -246,6 +246,9 @@ GVAR(lastHeartBeatSound) = ACE_time;
};
["SettingsInitialized", {
// Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set)
[QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler);
if (GVAR(level) == 2) exitWith {
[
{(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)},
@ -276,9 +279,6 @@ GVAR(lastHeartBeatSound) = ACE_time;
[ACE_player] call FUNC(itemCheck);
}] call EFUNC(common,addEventHandler);
// Networked litter
[QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler);
if (hasInterface) then {
["PlayerJip", {
ACE_LOGINFO("JIP Medical init for player.");

View File

@ -8,18 +8,23 @@
* ReturnValue:
* Is in medical facility <BOOL>
*
* Example:
* [player] call ace_medical_fnc_isInMedicalFacility
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_eyePos", "_objects", "_isInBuilding", "_medicalFacility"];
params ["_unit"];
_eyePos = eyePos _unit;
_isInBuilding = false;
//Cache the results as this function could be called rapidly
(_unit getVariable [QGVAR(cacheInFacility), [-9, false]]) params ["_expireTime", "_lastResult"];
if (ACE_time < _expireTime) exitWith {_lastResult};
_medicalFacility =
private _eyePos = eyePos _unit;
private _isInBuilding = false;
private _medicalFacility =
[
"TK_GUE_WarfareBFieldhHospital_Base_EP1",
"TK_GUE_WarfareBFieldhHospital_EP1",
@ -37,18 +42,22 @@ _medicalFacility =
"USMC_WarfareBFieldhHospital"
];
_objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos select 2)], _unit modelToWorldVisual [0, 0, (_eyePos select 2) +10], _unit]);
private _objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos select 2)], _unit modelToWorldVisual [0, 0, (_eyePos select 2) +10], _unit]);
{
if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith {
_isInBuilding = true;
};
} forEach _objects;
if (!_isInBuilding) then {
_objects = position _unit nearObjects 7.5;
_objects = _unit nearObjects 7.5;
{
if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith {
_isInBuilding = true;
};
} forEach _objects;
};
//Save the results (with a 1 second expiry)
_unit setVariable [QGVAR(cacheInFacility), [ACE_time + 1, _isInBuilding]];
_isInBuilding;

View File

@ -8,14 +8,15 @@
* Return Value:
* Is unit in medical vehicle? <BOOL>
*
* Example:
* [player] call ace_medical_fnc_isInMedicalVehicle
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_vehicle"];
params ["_unit"];
_vehicle = vehicle _unit;
private _vehicle = vehicle _unit;
if (_unit == _vehicle) exitWith {false};
if (_unit in [driver _vehicle, gunner _vehicle, commander _vehicle]) exitWith {false};

View File

@ -9,15 +9,23 @@
* ReturnValue:
* Is in of medic class <BOOL>
*
* Example:
* [player] call ace_medical_fnc_isMedic
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_unit", "_class", "_medicN"];
params ["_unit", ["_medicN", 1]];
_class = _unit getVariable [QGVAR(medicClass),
getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "attendant")];
private _class = _unit getVariable [QGVAR(medicClass), getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "attendant")];
if (_class >= _medicN min GVAR(medicSetting)) exitWith {true};
if (!GVAR(increaseTrainingInLocations)) exitWith {false};
if (([_unit] call FUNC(isInMedicalVehicle)) || {[_unit] call FUNC(isInMedicalFacility)}) then {
_class = _class + 1; //boost by one: untrained becomes medic, medic becomes doctor
};
_class >= _medicN min GVAR(medicSetting)

View File

@ -21,6 +21,7 @@ if !(_activated) exitWith {};
[_logic, QGVAR(level), "level"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(medicSetting), "medicSetting"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(increaseTrainingInLocations), "increaseTrainingInLocations"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(allowLitterCreation), "allowLitterCreation"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(litterCleanUpDelay), "litterCleanUpDelay"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(enableScreams), "enableScreams"] call EFUNC(common,readSettingFromModule);

View File

@ -2835,6 +2835,12 @@
<French>Quel niveau de détail voullez vous pour les infirmier?</French>
<Hungarian>Mi a javasolt részletesség orvosok számára?</Hungarian>
</Key>
<Key ID="STR_ACE_Medical_MedicalSettings_increaseTrainingInLocations_DisplayName">
<English>Locations boost training</English>
</Key>
<Key ID="STR_ACE_Medical_MedicalSettings_increaseTrainingInLocations_Description">
<English>Boost medic rating in medical vehicles or near medical facilities [untrained becomes medic, medic becomes doctor]</English>
</Key>
<Key ID="STR_ACE_Medical_MedicalSettings_medicSetting_disable">
<English>Disable medics</English>
<Russian>Отключить медиков</Russian>

View File

@ -14,7 +14,7 @@ class Extended_PostInit_EventHandlers {
class Extended_FiredBIS_EventHandlers {
class CAManBase {
class ADDON {
firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHBB);};);
clientFiredBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHBB);};);
};
};

View File

@ -49,6 +49,20 @@ class CfgWeapons {
GVAR(damage) = 0.85;
};
class cannon_125mm: CannonCore {
GVAR(priority) = 1;
GVAR(angle) = 90;
GVAR(range) = 50;
GVAR(damage) = 0.85;
};
class cannon_105mm: CannonCore {
GVAR(priority) = 1;
GVAR(angle) = 90;
GVAR(range) = 50;
GVAR(damage) = 0.85;
};
class mortar_155mm_AMOS: CannonCore {
GVAR(priority) = 1;
GVAR(angle) = 90;

View File

@ -1,7 +1,7 @@
/*
* Author: joko // Jonas
*
* Handle fire of local launchers
* Cache the shot data for a given weapon/mag/ammo combination.
* Will use the config that has the highest priority.
*
* Argument:
* 0: Weapon <STRING>
@ -9,68 +9,49 @@
* 2: Ammo <STRING>
*
* Return value:
* Array:
* Shot Config <ARRAY>:
* 0: Angle <Number>
* 1: Range <Number>
* 2: Damage <Number>
*
* Example:
* ["cannon_125mm","Sh_125mm_APFSDS_T_Green","24Rnd_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_cacheOverPressureValues
*
* Public: No
*/
#include "script_component.hpp"
#include "script_component.hpp"
params ["_weapon", "_ammo", "_magazine"];
TRACE_3("Parameter",_weapon,_magazine,_ammo);
private ["_array", "_type", "_return", "_config" /*, "_priority"*/];
// get Priority Array from Config
_array = [
private _array = [
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)),
getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(priority)),
getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(priority))
];
TRACE_1("Proiroity Array",_array);
(_array call CBA_fnc_findMax) params ["", ["_indexOfMaxPriority", 0, [0]]];
/* for CBA Upadte 2.1
_priority = _array call CBA_fnc_findMax;
_type = if (isNil "_priority") then {
0
} else {
_priority select 1
};
*/
TRACE_2("Priority Array",_array,_indexOfMaxPriority);
// obsolete as CBA Update 2.1 start
_array params ["_max"];
// set Default type
_type = 0;
// get Highest Entry out the the Priority Array
{
if (_max < _x) then {
_max = _x;
_type = _forEachIndex;
};
} forEach _array;
// obsolete end
TRACE_2("Highest Value",_max,_type);
// create the Config entry Point
_config = [
private _config = [
(configFile >> "CfgWeapons" >> _weapon),
(configFile >> "CfgMagazines" >> _magazine),
(configFile >> "CfgAmmo" >> _ammo)
] select _type;
] select _indexOfMaxPriority;
TRACE_1("ConfigPath",_config);
// get the Variables out of the Configes and create a array with then
_return = [
private _return = [
(getNumber (_config >> QGVAR(angle))),
(getNumber (_config >> QGVAR(range))),
(getNumber (_config >> QGVAR(damage)))
];
TRACE_1("Return",_return);
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return];
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
missionNameSpace setVariable [_varName, _return];
TRACE_2("Return",_varName,_return);
_return

View File

@ -1,7 +1,7 @@
/*
* Author: commy2 and esteldunedain
*
* Handle fire of local launchers
* Called from firedEHBB, only for ace_player with shot that will cause damage
*
* Arguments:
* 0: Unit that fired <OBJECT>
@ -14,51 +14,46 @@
*
* Return value:
* None
*
* Example:
* [player, "launch_RPG32_F", "launch_RPG32_F", "Single", "R_PG32V_F", "RPG32_F", projectile] call ace_overpressure_fnc_fireLauncherBackblast;
*
* Public: No
*/
#include "script_component.hpp"
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
params ["_firer", "_weapon", "_muzzle", "", "_ammo", "_magazine", "_projectile"];
TRACE_6("params",_firer,_weapon,_muzzle,_ammo,_magazine,_projectile);
// Prevent AI from causing backblast damage
if !([_firer] call EFUNC(common,isPlayer)) exitWith {};
private _position = getPosASL _projectile;
private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
private ["_position", "_direction"];
_position = getPosASL _projectile;
_direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
private ["_var","_varName","_backblastAngle", "_backblastRange", "_backblastDamage"];
// Bake variable name and check if the variable exists, call the caching function otherwise
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params["_backblastAngle","_backblastRange","_backblastDamage"];
TRACE_3("cache",_backblastAngle,_backblastRange,_backblastDamage);
// Damage to others
private "_affected";
_affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange];
private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange];
// Let each client handle their own affected units
["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent);
// Damage to the firer
private "_distance";
_distance = 2 * ([_position, _direction, _backblastRange, _firer] call FUNC(getDistance));
private _distance = 2 * ([_position, _direction, _backblastRange, _firer] call FUNC(getDistance));
TRACE_1("Distance",_distance);
if (_distance < _backblastRange) then {
private ["_alpha", "_beta", "_damage"];
private _alpha = sqrt (1 - _distance / _backblastRange);
private _beta = sqrt 0.5;
_alpha = sqrt (1 - _distance / _backblastRange);
_beta = sqrt 0.5;
_damage = _alpha * _beta * _backblastDamage;
private _damage = _alpha * _beta * _backblastDamage;
[_damage * 100] call BIS_fnc_bloodEffect;
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {([_firer] call EFUNC(medical,hasMedicalEnabled))}) then {
@ -75,8 +70,7 @@ if (_distance < _backblastRange) then {
[1,1,0,1]
] call EFUNC(common,addLineToDebugDraw);
private "_ref";
_ref = _direction call EFUNC(common,createOrthonormalReference);
private _ref = _direction call EFUNC(common,createOrthonormalReference);
[ _position,
_position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle),
[1,1,0,1]

View File

@ -1,10 +1,10 @@
/*
* Author: commy2 and esteldunedain
*
* Handle fire of local vehicle weapons creating overpressure zones
* Called from firedEHOP, only for local vehicles
*
* Arguments:
* 0: Unit that fired <OBJECT>
* 0: Vehicle that fired <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
@ -14,33 +14,35 @@
*
* Return value:
* None
*
* Example:
* [tank, "cannon_125mm", "cannon_125mm", "player", "Sh_125mm_APFSDS_T_Green", "24Rnd_125mm_APFSDS_T_Green", projectile] call ace_overpressure_fnc_fireOverpressureZone
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
// Prevent AI from causing overpressure damage
if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; //@todo non-maingun turrets?
params ["_firer", "_weapon", "_muzzle", "", "_ammo", "_magazine", "_projectile"];
TRACE_6("params",_firer,_weapon,_muzzle,_ammo,_magazine,_projectile);
private ["_position", "_direction"];
// Prevent AI from causing overpressure damage (NOTE: Vehicle is local, but turret gunner may not be)
if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {};
_position = getPosASL _projectile;
_direction = vectorDir _projectile;
private ["_var", "_varName", "_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
private _position = getPosASL _projectile;
private _direction = vectorDir _projectile;
// Bake variable name and check if the variable exists, call the caching function otherwise
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"];
TRACE_3("cache",_dangerZoneAngle,_dangerZoneRange,_dangerZoneDamage);
// Damage to others
private "_affected";
_affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange];
private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange];
// Let each client handle their own affected units
["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent);
@ -52,8 +54,7 @@ _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange];
[1,0,0,1]
] call EFUNC(common,addLineToDebugDraw);
private "_ref";
_ref = _direction call EFUNC(common,createOrthonormalReference);
private _ref = _direction call EFUNC(common,createOrthonormalReference);
[ _position,
_position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorAdd ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle),
[1,1,0,1]

View File

@ -1,6 +1,5 @@
/*
* Author: joko // Jonas
*
* Handle fire of local launchers
*
* Arguments:
@ -14,14 +13,22 @@
*
* Return value:
* None
*
* Example:
* [player, "launch_RPG32_F", "launch_RPG32_F", "Single", "R_PG32V_F", "RPG32_F", projectile] call ace_overpressure_fnc_firedEHBB;
*
* Public: No
*/
#include "script_component.hpp"
private ["_damage","_varName"];
params ["", "_weapon", "", "", "_ammo", "_magazine", ""];
params ["_firer", "_weapon", "", "", "_ammo", "_magazine", ""];
// Prevent AI from causing backblast damage (fast exit to only run for local players)
if (_firer != ACE_player) exitWith {};
// Bake variable name and check if the variable exists, call the caching function otherwise
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_damage = if (isNil _varName) then {
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _damage = if (isNil _varName) then {
([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2;
} else {
(missionNameSpace getVariable _varName) select 2;

View File

@ -1,10 +1,9 @@
/*
* Author: joko // Jonas
*
* Handle fire of Other Weapons
* Handle fire of Vehicle Weapons
*
* Arguments:
* 0: Unit that fired <OBJECT>
* 0: Vehicle that fired (XEH will filter only local) <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
@ -14,14 +13,19 @@
*
* Return value:
* None
*
* Example:
* [tank, "cannon_125mm", "cannon_125mm", "player", "Sh_125mm_APFSDS_T_Green", "24Rnd_125mm_APFSDS_T_Green", projectile] call ace_overpressure_fnc_firedEHOP
*
* Public: No
*/
#include "script_component.hpp"
private ["_damage","_varName"];
params ["", "_weapon", "", "", "_ammo", "_magazine", ""];
// Bake variable name and check if the variable exists, call the caching function otherwise
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_damage = if (isNil _varName) then {
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _damage = if (isNil _varName) then {
([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2;
} else {
(missionNameSpace getVariable _varName) select 2;

View File

@ -1,6 +1,5 @@
/*
* Author: commy2 and esteldunedain
*
* Calculate the distance to the first intersection of a line
*
* Arguments:
@ -15,11 +14,12 @@
* Example:
* [[1823.41,5729.05,6.66627], [-0.953255,0.109689,-0.281554], 15, ace_player] call ace_overpressure_fnc_getDistance
*
* Public: No
*/
#include "script_component.hpp"
params ["_posASL", "_direction", "_maxDistance", "_shooter"];
TRACE_3("params",_posASL,_direction,_maxDistance);
TRACE_4("params",_posASL,_direction,_maxDistance, _shooter);
private _intersections = lineIntersectsSurfaces [_posASL, _posASL vectorAdd (_direction vectorMultiply _maxDistance), _shooter, objNull, true, 99];
@ -29,9 +29,10 @@ private _distance = 999;
{
_x params ["_intersectPosASL", "_surfaceNormal", "_intersectObject"];
//Hit something solid that can reflect - (Static covers Building)
if ((isNull _intersectObject) || {(_intersectObject isKindOf "Static") || {_intersectObject isKindOf "AllVehicles"}}) exitWith {
TRACE_3("Intersect",_intersectPosASL,_surfaceNormal,_intersectObject);
//Hit something solid that can reflect - (Static covers Building) [Need to manually filter out _shoot for FFV shots]
if ((isNull _intersectObject) || {(_intersectObject != _shooter) && {(_intersectObject isKindOf "Static") || {_intersectObject isKindOf "AllVehicles"}}}) exitWith {
_distance = _posASL vectorDistance _intersectPosASL;
TRACE_3("hit solid object",_distance,_intersectObject,typeOf _intersectObject);

View File

@ -1,56 +1,56 @@
/*
* Author: commy2 and esteldunedain
*
* Calculate and apply backblast damage to potentially affected local units
* Handles the "overpressure" event.
*
* Argument:
* 0: Unit that fired <OBJECT>
* 1: Pos ASL of the projectile <ARRAY>
* 2: Direction of the projectile <ARRAY>
* 2: Direction of the projectile (reversed for launcher backblast) <ARRAY>
* 3: Weapon fired <STRING>
* 4: Magazine <STRING>
* 5: Ammo <STRING>
*
* Return value:
* None
*
* Example:
* [tank, [1727.57,5786.15,7.24899], [-0.982474,-0.185998,-0.0122501], "cannon_125mm", "24Rnd_125mm_APFSDS_T_Green", "Sh_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_overpressureDamage
*
* Public: No
*/
#include "script_component.hpp"
private ["_var","_overpressureAngle", "_overpressureRange", "_overpressureDamage"];
params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"];
// Bake variable name and check if the variable exists, call the caching function otherwise
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params["_overpressureAngle","_overpressureRange","_overpressureDamage"];
TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,_weapon);
TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage);
{
if (local _x && {_x != _firer} && {vehicle _x == _x}) then {
private ["_targetPositionASL", "_relativePosition", "_axisDistance", "_distance", "_angle", "_line", "_line2"];
private _targetPositionASL = eyePos _x;
private _relativePosition = _targetPositionASL vectorDiff _posASL;
private _axisDistance = _relativePosition vectorDotProduct _direction;
private _distance = vectorMagnitude _relativePosition;
private _angle = acos (_axisDistance / _distance);
_targetPositionASL = eyePos _x;
_relativePosition = _targetPositionASL vectorDiff _posASL;
_axisDistance = _relativePosition vectorDotProduct _direction;
_distance = vectorMagnitude _relativePosition;
_angle = acos (_axisDistance / _distance);
_line = [_posASL, _targetPositionASL, _firer, _x];
_line2 = [_posASL, _targetPositionASL];
private _line = [_posASL, _targetPositionASL, _firer, _x];
private _line2 = [_posASL, _targetPositionASL];
TRACE_4("Affected:",_x,_axisDistance,_distance,_angle);
if (_angle < _overpressureAngle && {_distance < _overpressureRange} && {!lineIntersects _line} && {!terrainIntersectASL _line2}) then {
private ["_alpha", "_beta", "_damage"];
_alpha = sqrt (1 - _distance / _overpressureRange);
_beta = sqrt (1 - _angle / _overpressureAngle);
private _alpha = sqrt (1 - _distance / _overpressureRange);
private _beta = sqrt (1 - _angle / _overpressureAngle);
_damage = _alpha * _beta * _overpressureDamage;
private _damage = _alpha * _beta * _overpressureDamage;
// If the target is the ACE_player
if (_x == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect};
@ -60,6 +60,14 @@ TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,
} else {
_x setDamage (damage _x + _damage);
};
#ifdef DEBUG_MODE_FULL
//Shows damage lines in green
[ _posASL,
_targetPositionASL,
[0,1,0,1]
] call EFUNC(common,addLineToDebugDraw);
#endif
};
};
} forEach ((ASLtoAGL _posASL) nearEntities ["CAManBase", _overpressureRange]);

View File

@ -1,6 +1,8 @@
#define COMPONENT overpressure
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
#ifdef DEBUG_ENABLED_OVERPRESSURE
#define DEBUG_MODE_FULL
#endif

View File

@ -32,6 +32,7 @@ if (isNil "_adjustment") then {
};
_adjustmentDifference = (_adjustment select _weaponIndex) vectorDiff [_elevation, _windage, _zero];
if (_adjustmentDifference isEqualTo [0,0,0]) exitWith {false}; // Don't coninue if no adjustment is made
_adjustment set [_weaponIndex, [_elevation, _windage, _zero]];
[_unit, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);

View File

@ -9,5 +9,11 @@
GVAR(availableVisions) = [[-2,-1,0,1], [-2,-1], [-2,0,1], [-2]] select GVAR(restrictVisions);
}] call EFUNC(common,addEventHandler);
// Create a radio channel for any spectators to text chat in
if (isServer) then {
GVAR(channel) = radioChannelCreate [[0.729,0.149,0.098,1],"Spectator","Spectator (%UNIT_NAME)",[]];
publicVariable QGVAR(channel);
};
// Should prevent unending spectator on mission end
addMissionEventHandler ["Ended",{ [false] call FUNC(setSpectator) }];
addMissionEventHandler ["Ended",{ [QGVAR(EndMission)] call FUNC(interrupt) }];

View File

@ -25,6 +25,9 @@ PREP(updateSpectatableSides);
PREP(updateUnits);
PREP(updateVisionModes);
// Reset the stored display
SETUVAR(GVAR(interface),displayNull);
// Permanent variables
GVAR(availableModes) = [0,1,2];
GVAR(availableSides) = [west,east,resistance,civilian];

View File

@ -22,6 +22,7 @@ params ["_mode",["_args",[]]];
switch (toLower _mode) do {
case "onload": {
_args params ["_display"];
SETUVAR(GVAR(interface),_display);
// Always show interface and hide map upon opening
[_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface);
@ -172,9 +173,12 @@ switch (toLower _mode) do {
[QGVAR(zeus)] call FUNC(interrupt);
["zeus"] call FUNC(handleInterface);
};
if ((isServer || {serverCommandAvailable "#kick"}) && {_dik in (actionKeys "Chat" + actionKeys "PrevChannel" + actionKeys "NextChannel")}) exitWith {
if (_dik in (actionKeys "Chat")) exitWith {
false
};
if (_dik in (actionKeys "PrevChannel" + actionKeys "NextChannel")) exitWith {
!(isServer || serverCommandAvailable "#kick")
};
// Handle held keys (prevent repeat calling)
if (GVAR(heldKeys) param [_dik,false]) exitWith {};
@ -451,13 +455,13 @@ switch (toLower _mode) do {
// PFH to re-open display when menu closes
[{
if !(isNull (findDisplay 49)) exitWith {};
if !(isNull (_this select 0)) exitWith {};
// If still a spectator then re-enter the interface
[QGVAR(escape),false] call FUNC(interrupt);
[_this select 1] call CBA_fnc_removePerFrameHandler;
},0] call CBA_fnc_addPerFrameHandler;
},0,_dlg] call CBA_fnc_addPerFrameHandler;
};
case "zeus": {
openCuratorInterface;

View File

@ -29,16 +29,16 @@ if (_interrupt) then {
};
if (GVAR(interrupts) isEqualTo []) then {
if (isNull (findDisplay 12249)) then {
createDialog QGVAR(interface);
if (isNull (GETUVAR(GVAR(interface),displayNull))) then {
(findDisplay 46) createDisplay QGVAR(interface);
[] call FUNC(transitionCamera);
};
} else {
if !(isNull (findDisplay 12249)) then {
if !(isNull (GETUVAR(GVAR(interface),displayNull))) then {
while {dialog} do {
closeDialog 0;
};
(findDisplay 12249) closeDisplay 0;
(GETUVAR(GVAR(interface),displayNull)) closeDisplay 0;
};
};

View File

@ -24,7 +24,7 @@
params [["_set",true,[true]], ["_force",true,[true]]];
// Only clients can be spectators
if (!hasInterface) exitWith {};
if !(hasInterface) exitWith {};
// Exit if no change
if (_set isEqualTo GVAR(isSet)) exitWith {};
@ -63,9 +63,17 @@ if (_set) then {
GVAR(unitCamera) camCommit 0;
[] call FUNC(transitionCamera);
// Close map and clear radio
// Cache current channel to switch back to on exit
GVAR(channelCache) = currentChannel;
// Channel index starts count after the 5 default channels
GVAR(channel) radioChannelAdd [player];
setCurrentChannel (5 + GVAR(channel));
// Close map and clear the chat
openMap [false,false];
clearRadio;
enableRadio false;
// Disable BI damage effects
BIS_fnc_feedback_allowPP = false;
@ -76,12 +84,13 @@ if (_set) then {
};
[{
disableSerialization;
// Create the display
(findDisplay 46) createDisplay QGVAR(interface);
_display = (findDisplay 46) createDisplay QGVAR(interface);
// If not forced, make esc end spectator
if (_this) then {
(findDisplay 12249) displayAddEventHandler ["KeyDown", {
_display displayAddEventHandler ["KeyDown", {
if (_this select 1 == 1) then {
[false] call ace_spectator_fnc_setSpectator;
true
@ -103,7 +112,7 @@ if (_set) then {
};
// Kill the display
(findDisplay 12249) closeDisplay 0;
(GETUVAR(GVAR(interface),displayNull)) closeDisplay 0;
// Terminate camera
GVAR(freeCamera) cameraEffect ["terminate", "back"];
@ -111,7 +120,16 @@ if (_set) then {
camDestroy GVAR(unitCamera);
camDestroy GVAR(targetCamera);
// Remove from spectator chat
GVAR(channel) radioChannelRemove [player];
// Restore cached channel and delete cache
setCurrentChannel GVAR(channelCache);
GVAR(channelCache) = nil;
// Clear any residual spectator chat
clearRadio;
enableRadio true;
// Return to player view
player switchCamera "internal";
@ -130,7 +148,6 @@ if (_set) then {
//Kill these PFEH handlers now because the PFEH can run before the `onunload` event is handled
GVAR(camHandler) = nil;
GVAR(compHandler) = nil;
GVAR(iconHandler) = nil;
GVAR(toolHandler) = nil;
// Cleanup display variables

View File

@ -66,3 +66,13 @@ if !(_set isEqualTo (GETVAR(_unit,GVAR(isStaged),false))) then {
["spectatorStaged",[_set]] call EFUNC(common,localEvent);
};
//BandAid for #2677 - if player in unitList weird before being staged, weird things can happen
if ((player in GVAR(unitList)) || {ACE_player in GVAR(unitList)}) then {
[] call FUNC(updateUnits); //update list now
if (!(isNull (findDisplay 12249))) then {//If display is open now, close it and restart
ACE_LOGWARNING("Player in unitList, call ace_spectator_fnc_stageSpectator before ace_spectator_fnc_setSpectator");
["fixWeirdList", true] call FUNC(interrupt);
[{["fixWeirdList", false] call FUNC(interrupt);}, []] call EFUNC(common,execNextFrame);
};
};

View File

@ -61,7 +61,6 @@ if (_newMode == 0) then { // Free
};
GVAR(camAgent) switchCamera "internal";
clearRadio;
} else {
_camera = GVAR(unitCamera);
@ -87,11 +86,6 @@ if (_newMode == 0) then { // Free
_camera cameraEffect ["internal", "back"];
};
// Clear radio if group changed
if (group _newUnit != group GVAR(camUnit)) then {
clearRadio;
};
GVAR(camUnit) = _newUnit;
};

View File

@ -1,53 +1,53 @@
class CfgVehicles {
class ACE_Module;
class ACE_ModuleSwitchUnits: ACE_Module {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(Module_DisplayName);
function = FUNC(module);
scope = 2;
isGlobal = 1;
icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa));
class Arguments {
class SwitchToWest {
displayName = CSTRING(SwitchToWest_DisplayName);
description = CSTRING(SwitchToWest_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToEast {
displayName = CSTRING(SwitchToEast_DisplayName);
description = CSTRING(SwitchToEast_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToIndependent {
displayName = CSTRING(SwitchToIndependent_DisplayName);
description = CSTRING(SwitchToIndependent_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToCivilian {
displayName = CSTRING(SwitchToCivilian_DisplayName);
description = CSTRING(SwitchToCivilian_Description);
typeName = "BOOL";
defaultValue = 0;
};
class EnableSafeZone {
displayName = CSTRING(EnableSafeZone_DisplayName);
description = CSTRING(EnableSafeZone_Description);
typeName = "BOOL";
defaultValue = 1;
};
class SafeZoneRadius {
displayName = CSTRING(SafeZoneRadius_DisplayName);
description = CSTRING(SafeZoneRadius_Description);
typeName = "NUMBER";
defaultValue = 100;
};
class ACE_Module;
class ACE_ModuleSwitchUnits: ACE_Module {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(Module_DisplayName);
function = FUNC(module);
scope = 2;
isGlobal = 1;
icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa));
class Arguments {
class SwitchToWest {
displayName = CSTRING(SwitchToWest_DisplayName);
description = CSTRING(SwitchToWest_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToEast {
displayName = CSTRING(SwitchToEast_DisplayName);
description = CSTRING(SwitchToEast_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToIndependent {
displayName = CSTRING(SwitchToIndependent_DisplayName);
description = CSTRING(SwitchToIndependent_Description);
typeName = "BOOL";
defaultValue = 0;
};
class SwitchToCivilian {
displayName = CSTRING(SwitchToCivilian_DisplayName);
description = CSTRING(SwitchToCivilian_Description);
typeName = "BOOL";
defaultValue = 0;
};
class EnableSafeZone {
displayName = CSTRING(EnableSafeZone_DisplayName);
description = CSTRING(EnableSafeZone_Description);
typeName = "BOOL";
defaultValue = 1;
};
class SafeZoneRadius {
displayName = CSTRING(SafeZoneRadius_DisplayName);
description = CSTRING(SafeZoneRadius_Description);
typeName = "NUMBER";
defaultValue = 100;
};
};
class ModuleDescription {
description = CSTRING(Module_Description);
};
};
class ModuleDescription {
description = CSTRING(Module_Description);
};
};
};

View File

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

View File

@ -18,12 +18,10 @@
*/
#include "script_component.hpp"
private ["_sideNearest"];
params ["_faction", "_pos"];
_faction params ["", "_sides"];
_sideNearest = [];
private _sideNearest = [];
{
if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then {

View File

@ -21,7 +21,7 @@ params ["_playerUnit", "_sides"];
if (vehicle _playerUnit == _playerUnit) then {
[_sides] call FUNC(markAiOnMap);
_playerUnit setVariable [QGVAR(IsPlayerUnit), true];
_playerUnit setVariable [QGVAR(IsPlayerUnit), true, true];
_playerUnit allowDamage false;
GVAR(OriginalUnit) = _playerUnit;

View File

@ -37,18 +37,17 @@ GVAR(AllMarkerNames) = [];
// create markers
{
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
private ["_markerName", "_marker", "_markerColor"];
private _markerName = str _x;
_markerName = str _x;
_marker = createMarkerLocal [_markerName, position _x];
private _marker = createMarkerLocal [_markerName, position _x];
_markerName setMarkerTypeLocal "mil_triangle";
_markerName setMarkerShapeLocal "ICON";
_markerName setMarkerSizeLocal [0.5, 0.7];
_markerName setMarkerDirLocal getDir _x;
// commy's one liner magic
_markerColor = format ["Color%1", side group _x];
private _markerColor = format ["Color%1", side group _x];
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
_markerName setMarkerColorLocal "ColorOrange";

View File

@ -35,4 +35,4 @@ GVAR(Module) = true;
[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting);
ACE_LOGINFO("Switch Unit Module Initialized.");
ACE_LOGINFO("SwitchUnits Module Initialized.");

View File

@ -16,11 +16,9 @@
*/
#include "script_component.hpp"
private ["_nearestPlayers"];
params ["_position", "_radius"];
_nearestPlayers = [];
private _nearestPlayers = [];
{
if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then {

View File

@ -19,8 +19,7 @@
params ["_player"];
if (GVAR(EnableSwitchUnits)) then {
private "_sides";
_sides = [];
private _sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};

View File

@ -26,11 +26,11 @@ params ["_originalPlayerUnit"];
if (local _originalPlayerUnit) exitWith {
selectPlayer _originalPlayerUnit;
deleteVehicle _currentUnit;
private "_layer";
_layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer;
_layer cuttext ["","plain"];
// deleteVehicle _currentUnit;
// private _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer;
// _layer cuttext ["","plain"];
[_pfhId] call CBA_fnc_removePerFrameHandler;
};

View File

@ -15,19 +15,17 @@
*/
#include "script_component.hpp"
private ["_nearestEnemyPlayers", "_allNearestPlayers", "_oldUnit", "_leave"];
params ["_unit"];
// don't switch to original player units
if (!([_unit] call FUNC(isValidAi))) exitWith {};
// exit var
_leave = false;
private _leave = false;
if (GVAR(EnableSafeZone)) then {
_allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
_nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter);
private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
private _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter);
if (count _nearestEnemyPlayers > 0) exitWith {
_leave = true;
@ -42,20 +40,28 @@ if (_leave) exitWith {
// should switch locality
// This doesn't work anymore, because one's now able to switch to units from a different side
//[_unit] joinSilent group player;
[[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
[
[_unit, player],
QUOTE({
(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)];
(_this select 0) setOwner owner (_this select 1)
}),
1
] call EFUNC(common,execRemoteFnc);
[{
private ["_respawnEhId", "_oldOwner"];
params ["_args", "_pfhId"];
_args params ["_unit", "_oldUnit"];
[localize LSTRING(TryingToSwitch)] call EFUNC(common,displayTextStructured);
if (local _unit) exitWith {
_oldUnit setVariable [QGVAR(IsPlayerControlled), false, true];
_oldUnit setVariable [QGVAR(PlayerControlledName), "", true];
_respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1];
if (_respawnEhId != -1) then {
_oldUnit removeEventHandler ["Respawn", _respawnEhId];
private _killedEhId = _unit getVariable [QGVAR(KilledEhId), -1];
if (_killedEhId != -1) then {
_oldUnit removeEventHandler ["Killed", _killedEhId];
};
selectPlayer _unit;
@ -63,15 +69,22 @@ if (_leave) exitWith {
_unit setVariable [QGVAR(IsPlayerControlled), true, true];
_unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true];
_respawnEhId = _unit addEventHandler ["Respawn", {
_killedEhId = _unit addEventHandler ["Killed", {
[GVAR(OriginalUnit), _this select 0] call FUNC(switchBack);
}];
_unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true];
_unit setVariable [QGVAR(KilledEhId), _killedEhId, true];
// set owner back to original owner
_oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1];
private _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1];
if (_oldOwner > -1) then {
[[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
[
[_oldUnit, _oldOwner],
QUOTE({
(_this select 0) setOwner (_this select 1)
}), 1
] call EFUNC(common,execRemoteFnc);
};
[localize LSTRING(SwitchedUnit)] call EFUNC(common,displayTextStructured);

View File

@ -1 +1 @@
#include "\z\ace\addons\switchunits\script_component.hpp"
#include "\z\ace\addons\switchunits\script_component.hpp"

View File

@ -13,6 +13,10 @@
<Italian>Cambia unità</Italian>
<Portuguese>Trocado de unidade</Portuguese>
</Key>
<Key ID="STR_ACE_SwitchUnits_TryingToSwitch">
<English>Trying to switch</English>
<German>Versuche zu Wechseln</German>
</Key>
<Key ID="STR_ACE_SwitchUnits_TooCloseToEnemy">
<English>This unit is too close to the enemy.</English>
<German>Diese Einheit ist zu nah am Feind.</German>

View File

@ -35,8 +35,13 @@ if (GVAR(LockVehicleInventory) && //if setting not enabled
playSound "ACE_Sound_Click";
//don't open the vehicles inventory
_handeled = true;
//Just opens a dummy groundContainer (so the player can still see their own inventory)
ACE_player action ["Gear", objNull];
// As of 1.54 the action needs to be delayed a frame to work, which used not to be the case
[{
TRACE_1("delaying a frame", ace_player);
//Just opens a dummy groundContainer (so the player can still see their own inventory)
ACE_player action ["Gear", objNull];
}, []] call EFUNC(common,execNextFrame);
};
_handeled

View File

@ -54,6 +54,12 @@ class CfgWeapons {
ACE_ScopeAdjust_VerticalIncrement = 0.0;
ACE_ScopeAdjust_HorizontalIncrement = 0.5;
};
class rhs_acc_pso1m21: rhs_acc_sniper_base {
ACE_ScopeAdjust_Vertical[] = { 0, 0 };
ACE_ScopeAdjust_Horizontal[] = { -10, 10 };
ACE_ScopeAdjust_VerticalIncrement = 0.0;
ACE_ScopeAdjust_HorizontalIncrement = 0.5;
};
class Launcher_Base_F;
class rhs_weap_rpg7: Launcher_Base_F {
@ -79,4 +85,4 @@ class CfgWeapons {
ace_hearing_protection = 0.5;
ace_hearing_lowerVolume = 0.60;
};
};
};

111
tools/config_validator.py Normal file
View File

@ -0,0 +1,111 @@
#!/usr/bin/env python3
#by PabstMirror - python script to verify all addons using MakePbo's lint checking and extFile Checking
#Arguments (eg: `config_validator.py full`):
#full dump full deRaped config of problem
#skipExt skips checking external file references
import os
import sys
import subprocess
import timeit
import time
######## GLOBALS #########
MAINPREFIX = "Z"
PREFIX = "ACE"
##########################
def Fract_Sec(s):
temp = float()
temp = float(s) / (60*60*24)
d = int(temp)
temp = (temp - d) * 24
h = int(temp)
temp = (temp - h) * 60
m = int(temp)
temp = (temp - m) * 60
sec = temp
return d,h,m,sec
def CheckPBO(p,makePboArgs,errors):
try:
subprocess.run([
"makepbo",
makePboArgs,
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
p,
"{}_{}.pbo".format(PREFIX,p)
], stdin=None, input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
except subprocess.CalledProcessError as e:
print("!! Problem With {} ret {} !!".format(p, e.returncode))
print(" stderr: {}".format(e.stderr))
errors.append(p)
else:
print(" Checked ok {}".format(p))
return
def fullDump(p):
try:
subprocess.run([
"makepbo",
"-PQGs", #Q Lint only - Gs Check external references and show deRap - P dont pause
"-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p),
p,
"{}_{}.pbo".format(PREFIX,p)
], stdin=None, input=None, check=True)
except subprocess.CalledProcessError as e:
input("Press Enter to continue...")
return
def main(argv):
print("""
####################
# ACE3 Config Check #
####################
""")
start_time = timeit.default_timer()
addonspath = os.path.join("P:\\",MAINPREFIX,PREFIX,"addons")
print("Switching to dir: {}".format(addonspath))
try:
os.chdir(addonspath)
except:
raise Exception("Failed to switch to addon dir on P:")
#Q Lint only - G Check external references - P dont pause (Gs) does full derap
makePboArgs = "-PQG"
if "skipExt" in argv:
print("Skipping External Files Check");
makePboArgs = "-PQ"
errors = []
for p in os.listdir(addonspath):
path = os.path.join(addonspath, p)
if not os.path.isdir(path):
continue
if p[0] == ".":
continue
CheckPBO(p,makePboArgs,errors)
d,h,m,s = Fract_Sec(timeit.default_timer() - start_time)
print("\n# Done with {0} errrors [took: {1:2}h {2:2}m {3:4.5f}s]".format(len(errors),h,m,s))
if (len(errors) > 0):
if "full" in argv:
input("Dumping Full DeRap: Press Enter to continue...")
for p in errors:
fullDump(p)
else:
print("use 'full' arg to show derap")
ret = len(errors)
print("return {}".format(ret))
return ret
if __name__ == "__main__":
main(sys.argv)