Merge remote-tracking branch 'origin/master' into cargoClassnames

This commit is contained in:
SilentSpike 2015-09-27 17:41:38 +01:00
commit f5e46bf089
321 changed files with 3916 additions and 3333 deletions

View File

@ -3,9 +3,9 @@
</p>
<p align="center">
<a href="https://github.com/acemod/ACE3/releases">
<img src="https://img.shields.io/badge/Version-3.3.1-blue.svg" alt="ACE3 Version">
<img src="https://img.shields.io/badge/Version-3.3.2-blue.svg" alt="ACE3 Version">
</a>
<a href="https://github.com/acemod/ACE3/releases/download/v3.3.1/ace3_3.3.1.zip">
<a href="https://github.com/acemod/ACE3/releases/download/v3.3.2/ace3_3.3.2.zip">
<img src="http://img.shields.io/badge/Download-62.0_MB-green.svg" alt="ACE3 Download">
</a>
<a href="https://github.com/acemod/ACE3/issues">

Binary file not shown.

View File

@ -1,3 +1,3 @@
#include "script_component.hpp"
["backpackOpened", DFUNC(backpackOpened)] call EFUNC(common,addEventHandler);
["backpackOpened", {_this call FUNC(backpackOpened)}] call EFUNC(common,addEventHandler);

View File

@ -1,18 +1,19 @@
/*
* Author: commy2
* Someone opened your backpack. Play sound and camshake. Execute locally.
*
* Someone opened your backpack. Execute locally.
*
* Argument:
* Arguments:
* 0: Who accessed your inventory? (Object)
* 1: Unit that wields the backpack (Object)
* 2: The backpack object (Object)
*
* Return value:
* None.
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_sounds", "_position"];
params ["_target", "_backpack"];
// do cam shake if the target is the player
@ -20,7 +21,8 @@ if ([_target] call EFUNC(common,isPlayer)) then {
addCamShake [4, 0.5, 5];
};
// play a rustling sound
// play a zipper sound effect
private ["_sounds", "_position"];
_sounds = [
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
@ -32,8 +34,7 @@ _sounds = [
QUOTE(PATHTO_R(sounds\zip_out.wav))
];
_position = _target modelToWorldVisual (_target selectionPosition "Spine3");
_position = _position call EFUNC(common,positionToASL);
_position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3"));
playSound3D [
_sounds select floor random count _sounds,

View File

@ -1,23 +1,24 @@
/*
* Author: commy2
* Check if the given backpack is an actual backpack that can store items. Parachute, static weapon packs, etc. will return false.
*
* Check if the given backpack is an actual backpack that can store items. Parachute backpacks will return false for example.
* Arguments:
* 0: Backpack <OBJECT, STRING>
*
* Argument:
* 0: A backpack (Object or String)
* Return Value:
* Boolean <BOOL>
*
* Return value:
* Boolean (Bool)
* Public: Yes
*/
#include "script_component.hpp"
private ["_config"];
params ["_backpack"];
if (typeName _backpack == "OBJECT") then {
_backpack = typeOf _backpack;
};
private "_config";
_config = configFile >> "CfgVehicles" >> _backpack;
getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0}
getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} // return

View File

@ -1,17 +1,19 @@
/*
* Author: commy2
* Handle the open inventory event. Camshake and sound on target client.
*
* Handle the open inventory event. Display message on target client.
* Arguments:
* 0: Unit <OBJECT>
* 1: Backpack <OBJECT>
*
* Argument:
* Input from "InventoryOpened" eventhandler
*
* Return value:
* Return Value:
* false. Always open the inventory dialog. (Bool)
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit","_backpack"];
params ["_unit", "_backpack"];
// exit if the target is not a real backpack, i.e. parachute, static weapon bag etc.
if !([_backpack] call FUNC(isBackpack)) exitWith {false};

View File

@ -18,7 +18,6 @@ if (isServer) then {
}];
};
["playerVehicleChanged", {_this call FUNC(handleVehicleChanged)}] call EFUNC(common,addEventHandler);
["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler);
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);

View File

@ -23,4 +23,9 @@ params ["_unit", "_target"];
("ACE_CableTie" in (items _unit)) &&
{alive _target} &&
{!(_target getVariable [QGVAR(isHandcuffed), false])} &&
(GVAR(requireSurrender) == 0 || ((_target getVariable [QGVAR(isSurrendering), false]) || (currentWeapon _target == "" && GVAR(requireSurrender) == 2)))
{
(_target getVariable ["ACE_isUnconscious", false]) || //isUnconscious
{GVAR(requireSurrender) == 0} || //or don't require surrendering
{_target getVariable [QGVAR(isSurrendering), false]} || //or is surrendering
{(GVAR(requireSurrender) == 2) && {(currentWeapon _target) == ""}} //or "SurrenderOrNoWeapon" and no weapon
}

View File

@ -26,7 +26,7 @@ if (local _unit) then {
};
if (_unit getVariable [QGVAR(isSurrendering), false]) then {
[_unit, false] call FUNC(setSurrender);
[_unit, false] call FUNC(setSurrendered);
};
if (_unit getVariable [QGVAR(isHandcuffed), false]) then {

View File

@ -16,85 +16,73 @@ class Extended_Killed_EventHandlers {
};
};
class Extended_Init_EventHandlers {
//Need initPost or we have problems with setVariable with 'ACE_Cargo'
class Extended_InitPost_EventHandlers {
class StaticWeapon {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class ReammoBox_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class Cargo_base_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle));
};
};
class CargoNet_01_box_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle));
};
};
class Land_CargoBox_V1_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle));
};
};
class Land_PaperBox_closed_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle));
};
};
class Car {
class ADDON {
init = QUOTE(_this call DFUNC(initVehicle));
};
};
class Tank {
class ADDON {
init = QUOTE(_this call DFUNC(initVehicle));
};
};
class Helicopter {
class ADDON {
init = QUOTE(_this call DFUNC(initVehicle));
};
};
class Plane {
class ADDON {
init = QUOTE(_this call DFUNC(initVehicle));
};
};
class Ship_F {
class ADDON {
init = QUOTE(_this call DFUNC(initVehicle));
};
};
class ACE_RepairItem_Base {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class ACE_bodyBagObject {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class ACE_ConcertinaWireCoil {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));

View File

@ -6,6 +6,7 @@
* 0: Item Classname <STRING>
* 1: Vehicle <OBJECT>
* 2: Amount <NUMBER> (default: 1)
* 3: Show Hint <BOOL> (default: false)
*
* Return Value:
* None
@ -18,7 +19,7 @@
#include "script_component.hpp"
private ["_position", "_item", "_i"];
params ["_itemClass", "_vehicle", ["_amount", 1]];
params ["_itemClass", "_vehicle", ["_amount", 1], ["_showHint", false, [false]] ];
TRACE_3("params",_itemClass,_vehicle,_amount);
for "_i" from 1 to _amount do {

View File

@ -25,7 +25,11 @@ _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
if (isServer) then {
{
if (isClass _x) then {
["AddCargoByClass", [getText (_x >> "type"), _vehicle, getNumber (_x >> "amount")]] call EFUNC(common,localEvent);
private ["_cargoClassname", "_cargoCount"];
_cargoClassname = getText (_x >> "type");
_cargoCount = getNumber (_x >> "amount");
TRACE_3("adding ACE_Cargo", (configName _x), _cargoClassname, _cargoCount);
["AddCargoByClass", [_cargoClassname, _vehicle, _cargoCount]] call EFUNC(common,localEvent);
};
} count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
};
@ -41,7 +45,7 @@ if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) ex
private ["_text", "_condition", "_statement", "_icon", "_action"];
_condition = {
params ["_target", "_player"];
GVAR(enable) && {locked _target < 2} && {[_player, _target, []] call EFUNC(common,canInteractWith)}
GVAR(enable) && {locked _target < 2} && {alive _target} && {[_player, _target, []] call EFUNC(common,canInteractWith)}
};
_text = localize LSTRING(openMenu);
_statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);};

View File

@ -6,6 +6,7 @@
* Arguments:
* 0: Item <OBJECT or STRING>
* 1: Vehicle <OBJECT>
* 2: Show Hint <BOOL> (default: true)
*
* Return value:
* Object loaded <BOOL>
@ -26,6 +27,8 @@ _loaded = _vehicle getVariable [QGVAR(loaded), []];
_loaded pushback _item;
_vehicle setVariable [QGVAR(loaded), _loaded, true];
TRACE_1("added to loaded array",_loaded);
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
_itemSize = [_item] call FUNC(getSizeItem);
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];

View File

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

View File

@ -1,16 +1,18 @@
// ACE - Common
// #define ENABLE_PERFORMANCE_COUNTERS
#include "script_component.hpp"
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
// #define ENABLE_PERFORMANCE_COUNTERS
//////////////////////////////////////////////////
// PFHs
//////////////////////////////////////////////////
//Singe PFEH to handle execNextFrame and waitAndExec:
[{
private ["_entry"];
private "_entry";
//Handle the waitAndExec array:
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
while {!(GVAR(waitAndExecArray) isEqualTo []) && {GVAR(waitAndExecArray) select 0 select 0 <= ACE_Time}} do {
_entry = GVAR(waitAndExecArray) deleteAt 0;
(_entry select 2) call (_entry select 1);
};
@ -18,7 +20,9 @@
//Handle the execNextFrame array:
{
(_x select 0) call (_x select 1);
} forEach GVAR(nextFrameBufferA);
false
} count GVAR(nextFrameBufferA);
//Swap double-buffer:
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
GVAR(nextFrameBufferB) = [];
@ -26,39 +30,46 @@
}, 0, []] call CBA_fnc_addPerFrameHandler;
// Listens for global "SettingChanged" events, to update the force status locally
["SettingChanged", {
PARAMS_2(_name,_value);
if !(count _this > 2) exitWith {};
private ["_force", "_settingData"];
_force = _this select 2;
if (_force) then {
_settingData = [_name] call FUNC(getSettingData);
if (count _settingData == 0) exitWith {};
_settingData set [6,_force];
};
}] call FUNC(addEventhandler);
//////////////////////////////////////////////////
// Get Map Data
//////////////////////////////////////////////////
["HeadbugFixUsed", {
PARAMS_2(_profileName,_animation);
ACE_LOGINFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
}] call FUNC(addEventHandler);
//~~~~~Get Map Data~~~~~
//Find MGRS zone and 100km grid for current map
[] call FUNC(getMGRSdata);
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
[] call FUNC(getMapGridData);
//////////////////////////////////////////////////
// Eventhandlers
//////////////////////////////////////////////////
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);
// Listens for global "SettingChanged" events, to update the force status locally
["SettingChanged", {
params ["_name", "_value", "_force"];
["unloadPersonEvent", DFUNC(unloadPersonLocal)] call FUNC(addEventhandler);
if (_force) then {
private "_settingData";
_settingData = [_name] call FUNC(getSettingData);
if (_settingData isEqualTo []) exitWith {};
_settingData set [6, _force];
};
}] call FUNC(addEventhandler);
// Event to log Fix Headbug output
["HeadbugFixUsed", {
params ["_profileName", "_animation"];
ACE_LOGINFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
}] call FUNC(addEventHandler);
["fixCollision", FUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", FUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", FUNC(fixPosition)] call FUNC(addEventhandler);
["unloadPersonEvent", FUNC(unloadPersonLocal)] call FUNC(addEventhandler);
["lockVehicle", {
_this setVariable [QGVAR(lockStatus), locked _this];
@ -77,22 +88,10 @@ if (isServer) then {
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
};
QGVAR(remoteFnc) addPublicVariableEventHandler {
(_this select 1) call FUNC(execRemoteFnc);
};
[missionNamespace] call FUNC(executePersistent);
private ["_currentVersion", "_previousVersion"];
// check previous version number from profile
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
if (_currentVersion != _previousVersion) then {
// do something
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
};
//////////////////////////////////////////////////
// Set up remote execution
//////////////////////////////////////////////////
// ACE events
"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
@ -100,7 +99,7 @@ if (_currentVersion != _previousVersion) then {
// Synced ACE events
// Handle JIP scenario
if(!isServer) then {
if (!isServer) then {
["PlayerJip", {
ACE_LOGINFO("JIP event synchronization initialized");
["SEH_all", [player]] call FUNC(serverEvent);
@ -108,31 +107,72 @@ if(!isServer) then {
} else {
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
};
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
if (isServer) then {
[FUNC(syncedEventPFH), 0.5, []] call CBA_fnc_addPerFrameHandler;
};
// @todo deprecated
QGVAR(remoteFnc) addPublicVariableEventHandler {
(_this select 1) call FUNC(execRemoteFnc);
};
// @todo figure out what this does.
[missionNamespace] call FUNC(executePersistent);
//////////////////////////////////////////////////
// Check files, previous installed version etc.
//////////////////////////////////////////////////
private ["_currentVersion", "_previousVersion"];
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
// check previous version number from profile
if (_currentVersion != _previousVersion) then {
// do something
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
};
call FUNC(checkFiles);
//////////////////////////////////////////////////
// Set up SettingsInitialized eventhandler
//////////////////////////////////////////////////
["SettingsInitialized", {
[
GVAR(checkPBOsAction),
GVAR(checkPBOsCheckAll),
call compile GVAR(checkPBOsWhitelist)
] call FUNC(checkPBOs)
}] call FUNC(addEventHandler);
// Create a pfh to wait until all postinits are ready and settings are initialized
[{
PARAMS_1(_args);
EXPLODE_1_PVT(_args,_waitingMsgSent);
params ["_args"];
_args params ["_waitingMsgSent"];
// If post inits are not ready then wait
if !(SLX_XEH_MACHINE select 8) exitWith {};
// If settings are not initialized then wait
if (isNil QGVAR(settings) || {(!isServer) && (isNil QEGVAR(modules,serverModulesRead))}) exitWith {
if (!_waitingMsgSent) then {
if (isNil QGVAR(settings) || {!isServer && isNil QEGVAR(modules,serverModulesRead)}) exitWith {
if !(_waitingMsgSent) then {
_args set [0, true];
ACE_LOGINFO("Waiting on settings from server...");
};
};
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[_this select 1] call CBA_fnc_removePerFrameHandler;
ACE_LOGINFO("Settings received from server.");
@ -152,230 +192,272 @@ call FUNC(checkFiles);
//Set init finished and run all delayed functions:
GVAR(settingsInitFinished) = true;
diag_log text format ["[ACE] %1 delayed functions running", (count GVAR(runAtSettingsInitialized))];
ACE_LOGINFO_1("%1 delayed functions running.",count GVAR(runAtSettingsInitialized));
{
_x params ["_func", "_params"];
_params call _func;
} forEach GVAR(runAtSettingsInitialized);
(_x select 1) call (_x select 0);
false
} count GVAR(runAtSettingsInitialized);
GVAR(runAtSettingsInitialized) = nil; //cleanup
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
["SettingsInitialized", {
[
GVAR(checkPBOsAction),
GVAR(checkPBOsCheckAll),
call compile GVAR(checkPBOsWhitelist)
] call FUNC(checkPBOs)
}] call FUNC(addEventHandler);
/***************************************************************************/
/***************************************************************************/
/** everything that only player controlled machines need, goes below this **/
/***************************************************************************/
/***************************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
// everything that only player controlled machines need, goes below this
if (!hasInterface) exitWith {};
call COMPILE_FILE(scripts\assignedItemFix);
call COMPILE_FILE(scripts\initScrollWheel);
//////////////////////////////////////////////////
// Set up mouse wheel eventhandler
//////////////////////////////////////////////////
DFUNC(mouseZHandler) = {
waitUntil {!isNull (findDisplay 46)}; sleep 0.1;
findDisplay 46 displayAddEventHandler ["MouseZChanged", QUOTE( _this call GVAR(onScrollWheel) )];
[false] call FUNC(disableUserInput);
};
call FUNC(assignedItemFix);
addMissionEventHandler ["Loaded", {[] spawn FUNC(mouseZHandler)}];
[] spawn FUNC(mouseZHandler);
GVAR(ScrollWheelFrame) = diag_frameno;
addMissionEventHandler ["Loaded", {call FUNC(handleScrollWheelInit)}];
call FUNC(handleScrollWheelInit);
// @todo remove?
enableCamShake true;
//////////////////////////////////////////////////
// Eventhandler to set player names
//////////////////////////////////////////////////
// Set the name for the current player
["playerChanged", {
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
params ["_newPlayer","_oldPlayer"];
if (alive _newPlayer) then {
[_newPlayer] call FUNC(setName)
};
if (alive _oldPlayer) then {
[_oldPlayer] call FUNC(setName)
[_newPlayer] call FUNC(setName);
};
if (alive _oldPlayer) then {
[_oldPlayer] call FUNC(setName);
};
}] call FUNC(addEventhandler);
GVAR(OldPlayerInventory) = [ACE_player] call FUNC(getAllGear);
GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player;
GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
GVAR(OldCameraView) = cameraView;
GVAR(OldPlayerVehicle) = vehicle ACE_player;
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
//////////////////////////////////////////////////
// Set up numerous eventhanders for player controlled units
//////////////////////////////////////////////////
// default variables
GVAR(OldPlayerVehicle) = vehicle objNull;
GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex);
GVAR(OldPlayerWeapon) = currentWeapon objNull;
GVAR(OldPlayerInventory) = [objNull] call FUNC(getAllGear);
GVAR(OldPlayerVisionMode) = currentVisionMode objNull;
GVAR(OldCameraView) = "";
GVAR(OldVisibleMap) = false;
GVAR(OldInventoryDisplayIsOpen) = nil; //@todo check this
GVAR(OldZeusDisplayIsOpen) = false;
GVAR(OldIsCamera) = false;
// clean up playerChanged eventhandler from preinit and put it in the same PFH as the other events to reduce overhead and guarantee advantageous execution order
if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
[GVAR(PreInit_playerChanged_PFHID)] call CBA_fnc_removePerFrameHandler;
GVAR(PreInit_playerChanged_PFHID) = nil;
};
// PFH to raise varios events
[{
BEGIN_COUNTER(stateChecker);
private ["_newCameraView", "_newInventoryDisplayIsOpen", "_newPlayerInventory", "_newPlayerTurret", "_newPlayerVehicle", "_newPlayerVisionMode", "_newPlayerWeapon", "_newZeusDisplayIsOpen", "_newVisibleMap"];
// "playerInventoryChanged" event
_newPlayerInventory = [ACE_player] call FUNC(getAllGear);
if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then {
// Raise ACE event locally
GVAR(OldPlayerInventory) = _newPlayerInventory;
["playerInventoryChanged", [ACE_player, _newPlayerInventory]] call FUNC(localEvent);
};
private "_data"; // reuse one variable to reduce number of variables that have to be set to private each frame
// "playerVisionModeChanged" event
_newPlayerVisionMode = currentVisionMode ACE_player;
if !(_newPlayerVisionMode isEqualTo GVAR(OldPlayerVisionMode)) then {
// Raise ACE event locally
GVAR(OldPlayerVisionMode) = _newPlayerVisionMode;
["playerVisionModeChanged", [ACE_player, _newPlayerVisionMode]] call FUNC(localEvent);
};
// "playerChanged" event
_data = call FUNC(player);
if !(_data isEqualTo GVAR(OldPlayerVehicle)) then {
private "_oldPlayer";
_oldPlayer = ACE_player;
// "inventoryDisplayChanged" event
_newInventoryDisplayIsOpen = !(isNull findDisplay 602);
if !(_newInventoryDisplayIsOpen isEqualTo GVAR(OldInventoryDisplayIsOpen)) then {
// Raise ACE event locally
GVAR(OldInventoryDisplayIsOpen) = _newInventoryDisplayIsOpen;
["inventoryDisplayChanged", [ACE_player, _newInventoryDisplayIsOpen]] call FUNC(localEvent);
};
ACE_player = _data;
uiNamespace setVariable ["ACE_player", _data];
// "zeusDisplayChanged" event
_newZeusDisplayIsOpen = !(isNull findDisplay 312);
if !(_newZeusDisplayIsOpen isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
// Raise ACE event locally
GVAR(OldZeusDisplayIsOpen) = _newZeusDisplayIsOpen;
["zeusDisplayChanged", [ACE_player, _newZeusDisplayIsOpen]] call FUNC(localEvent);
};
// "cameraViewChanged" event
_newCameraView = cameraView;
if !(_newCameraView isEqualTo GVAR(OldCameraView)) then {
// Raise ACE event locally
GVAR(OldCameraView) = _newCameraView;
["cameraViewChanged", [ACE_player, _newCameraView]] call FUNC(localEvent);
["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent);
};
// "playerVehicleChanged" event
_newPlayerVehicle = vehicle ACE_player;
if !(_newPlayerVehicle isEqualTo GVAR(OldPlayerVehicle)) then {
_data = vehicle ACE_player;
if !(_data isEqualTo GVAR(OldPlayerVehicle)) then {
// Raise ACE event locally
GVAR(OldPlayerVehicle) = _newPlayerVehicle;
["playerVehicleChanged", [ACE_player, _newPlayerVehicle]] call FUNC(localEvent);
GVAR(OldPlayerVehicle) = _data;
["playerVehicleChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "playerTurretChanged" event
_newPlayerTurret = [ACE_player] call FUNC(getTurretIndex);
if !(_newPlayerTurret isEqualTo GVAR(OldPlayerTurret)) then {
_data = [ACE_player] call FUNC(getTurretIndex);
if !(_data isEqualTo GVAR(OldPlayerTurret)) then {
// Raise ACE event locally
GVAR(OldPlayerTurret) = _newPlayerTurret;
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
GVAR(OldPlayerTurret) = _data;
["playerTurretChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "playerWeaponChanged" event
_newPlayerWeapon = currentWeapon ACE_player;
if (_newPlayerWeapon != GVAR(OldPlayerWeapon)) then {
_data = currentWeapon ACE_player;
if (_data != GVAR(OldPlayerWeapon)) then {
// Raise ACE event locally
GVAR(OldPlayerWeapon) = _newPlayerWeapon;
["playerWeaponChanged", [ACE_player, _newPlayerWeapon]] call FUNC(localEvent);
GVAR(OldPlayerWeapon) = _data;
["playerWeaponChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "playerInventoryChanged" event
_data = [ACE_player] call FUNC(getAllGear);
if !(_data isEqualTo GVAR(OldPlayerInventory)) then {
// Raise ACE event locally
GVAR(OldPlayerInventory) = _data;
["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "playerVisionModeChanged" event
_data = currentVisionMode ACE_player;
if !(_data isEqualTo GVAR(OldPlayerVisionMode)) then {
// Raise ACE event locally
GVAR(OldPlayerVisionMode) = _data;
["playerVisionModeChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "cameraViewChanged" event
_data = cameraView;
if !(_data isEqualTo GVAR(OldCameraView)) then {
// Raise ACE event locally
GVAR(OldCameraView) = _data;
["cameraViewChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "visibleMapChanged" event
_newVisibleMap = visibleMap;
if (!_newVisibleMap isEqualTo GVAR(OldVisibleMap)) then {
_data = visibleMap;
if (!_data isEqualTo GVAR(OldVisibleMap)) then {
// Raise ACE event locally
GVAR(OldVisibleMap) = _newVisibleMap;
["visibleMapChanged", [ACE_player, _newVisibleMap]] call FUNC(localEvent);
GVAR(OldVisibleMap) = _data;
["visibleMapChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "inventoryDisplayChanged" event
_data = !(isNull findDisplay 602);
if !(_data isEqualTo GVAR(OldInventoryDisplayIsOpen)) then {
// Raise ACE event locally
GVAR(OldInventoryDisplayIsOpen) = _data;
["inventoryDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "zeusDisplayChanged" event
_data = !(isNull findDisplay 312);
if !(_data isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
// Raise ACE event locally
GVAR(OldZeusDisplayIsOpen) = _data;
["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "activeCameraChanged" event
_data = call FUNC(isfeatureCameraActive);
if !(_data isEqualTo GVAR(OldIsCamera)) then {
// Raise ACE event locally
GVAR(OldIsCamera) = _data;
["activeCameraChanged", [ACE_player, _data]] call FUNC(localEvent);
};
END_COUNTER(stateChecker);
}, 0, []] call CBA_fnc_addPerFrameHandler;
GVAR(OldIsCamera) = false;
//////////////////////////////////////////////////
// Eventhandlers for player controlled machines
//////////////////////////////////////////////////
[{
// "activeCameraChanged" event
private ["_isCamera"];
_isCamera = call FUNC(isfeatureCameraActive);
if !(_isCamera isEqualTo GVAR(OldIsCamera)) then {
// Raise ACE event locally
GVAR(OldIsCamera) = _isCamera;
["activeCameraChanged", [ACE_player, _isCamera]] call FUNC(localEvent);
};
}, 1, []] call CBA_fnc_addPerFrameHandler; // feel free to decrease the sleep ACE_time if you need it.
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
// @todo still needed?
[QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable);
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
["medical_onUnconscious", {if (local (_this select 0) && {!(_this select 1)}) then {[ _this select 0, false, QUOTE(FUNC(loadPerson)), west /* dummy side */] call FUNC(switchToGroupSide);};}] call FUNC(addEventhandler);
["medical_onUnconscious", {
params ["_unit", "_isUnconscious"];
if (local _unit && {!_isUnconscious}) then {
[_unit, false, QFUNC(loadPerson), west /* dummy side */] call FUNC(switchToGroupSide);
};
}] call FUNC(addEventhandler);
//////////////////////////////////////////////////
// Add various canInteractWith conditions
//////////////////////////////////////////////////
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
["isNotInside", {
params ["_unit", "_target"];
// Players can always interact with himself if not boarded
vehicle (_this select 0) == (_this select 0) ||
vehicle _unit == _unit ||
// Players can always interact with his vehicle
{vehicle (_this select 0) == (_this select 1)} ||
{vehicle _unit == _target} ||
// Players can always interact with passengers of the same vehicle
{!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}}
{_unit != _target && {vehicle _unit == vehicle _target}}
}] call FUNC(addCanInteractWithCondition);
//////////////////////////////////////////////////
// Set up PlayerJIP eventhandler
//////////////////////////////////////////////////
// Lastly, do JIP events
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
// Note: usage of player is most likely on purpose
if (didJip) then {
// We are jipping! Get ready and wait, and throw the event
[{
if((!(isNull player)) && GVAR(settingsInitFinished)) then {
["PlayerJip", [player] ] call FUNC(localEvent);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
if(!isNull player && GVAR(settingsInitFinished)) then {
["PlayerJip", [player]] call FUNC(localEvent);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
};
//////////////////////////////////////////////////
// CBA key input handling
//////////////////////////////////////////////////
//Device Handler:
GVAR(deviceKeyHandlingArray) = [];
GVAR(deviceKeyCurrentIndex) = -1;
// Register localizations for the Keybinding categories
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call cba_fnc_registerKeybindModPrettyName;
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"),
{
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"), {
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
true
},
{false},
[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key
[0xC7, [false, false, false]], false] call CBA_fnc_addKeybind; //Home Key
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"),
{
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"), {
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
true
},
{false},
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key
[0xC7, [false, true, false]], false] call CBA_fnc_addKeybind; //CTRL + Home Key
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"),
{
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"), {
[1] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
@ -384,6 +466,6 @@ GVAR(deviceKeyCurrentIndex) = -1;
true
},
{false},
[0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key
[0xC7, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + Home Key
GVAR(commonPostInited) = true;

View File

@ -1,16 +1,13 @@
// by commy2
#include "script_component.hpp"
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
ADDON = false;
// ACE Common Function
PREP(addCanInteractWithCondition);
PREP(addLineToDebugDraw);
PREP(addSetting);
PREP(addToInventory);
PREP(assignedItemFix);
PREP(assignObjectsInList);
PREP(ambientBrightness);
PREP(applyForceWalkStatus);
@ -27,7 +24,6 @@ PREP(checkPBOs);
PREP(claim);
PREP(codeToLetter);
PREP(codeToString);
PREP(convertKeyCode);
PREP(createOrthonormalReference);
PREP(currentChannel);
PREP(debug);
@ -83,14 +79,6 @@ PREP(getTargetAzimuthAndInclination);
PREP(getTargetDistance);
PREP(getTargetObject);
PREP(getTurnedOnLights);
PREP(getTurretCommander);
PREP(getTurretConfigPath);
PREP(getTurretCopilot);
PREP(getTurretGunner);
PREP(getTurretIndex);
PREP(getTurrets);
PREP(getTurretsFFV);
PREP(getTurretsOther);
PREP(getTurretDirection);
PREP(getUavControlPosition);
PREP(getVehicleCargo);
@ -103,6 +91,8 @@ PREP(getWindDirection);
PREP(getZoom);
PREP(goKneeling);
PREP(hadamardProduct);
PREP(handleScrollWheel);
PREP(handleScrollWheelInit);
PREP(hasItem);
PREP(hasMagazine);
PREP(headBugFix);
@ -151,7 +141,6 @@ PREP(removeSpecificMagazine);
PREP(requestCallback);
PREP(resetAllDefaults);
PREP(restoreVariablesJIP);
PREP(revertKeyCodeLocalized);
PREP(runAfterSettingsInit);
PREP(sanitizeString);
PREP(sendRequest);
@ -181,6 +170,7 @@ PREP(toBitmask);
PREP(toHex);
PREP(toNumber);
PREP(unhideUnit);
PREP(uniqueElements);
PREP(uniqueElementsOnly);
PREP(unloadPerson);
PREP(unloadPersonLocal);
@ -209,6 +199,7 @@ PREP(getConfigGunner);
PREP(getConfigCommander);
PREP(getHitPoints);
PREP(getHitPointsWithSelections);
PREP(getSelectionsWithoutHitPoints);
PREP(getReflectorsWithSelections);
PREP(getLightProperties);
PREP(getLightPropertiesWeapon);
@ -251,6 +242,17 @@ PREP(localEvent);
PREP(removeEventHandler);
PREP(removeAlLEventHandlers);
// Synchronized Events
PREP(syncedEventPFH);
PREP(addSyncedEventHandler);
PREP(removeSyncedEventHandler);
PREP(requestSyncedEvent);
PREP(syncedEvent);
PREP(_handleSyncedEvent);
PREP(_handleRequestSyncedEvent);
PREP(_handleRequestAllSyncedEvents);
// other eventhandlers
PREP(addActionEventHandler);
PREP(addActionMenuEventHandler);
@ -274,17 +276,6 @@ PREP(hashListSelect);
PREP(hashListSet);
PREP(hashListPush);
// Synchronized Events
PREP(syncedEventPFH);
PREP(addSyncedEventHandler);
PREP(removeSyncedEventHandler);
PREP(requestSyncedEvent);
PREP(syncedEvent);
PREP(_handleSyncedEvent);
PREP(_handleRequestSyncedEvent);
PREP(_handleRequestAllSyncedEvents);
GVAR(syncedEvents) = HASH_CREATE;
//GVARS for execNextFrame and waitAndExec
@ -296,7 +287,7 @@ GVAR(nextFrameBufferB) = [];
GVAR(settingsInitFinished) = false;
GVAR(runAtSettingsInitialized) = [];
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
// @todo: Generic local-managed global-synced objects (createVehicleLocal)
//Debug
ACE_COUNTERS = [];
@ -306,11 +297,18 @@ if (isServer) then {
call FUNC(loadSettingsOnServer);
};
ACE_player = player;
//////////////////////////////////////////////////
// Set up PlayerChanged eventhandler for pre init
//////////////////////////////////////////////////
ACE_player = objNull;
uiNamespace setVariable ["ACE_player", objNull];
// @todo check if this can be removed
if (hasInterface) then {
// PFH to update the ACE_player variable
[{
GVAR(PreInit_playerChanged_PFHID) = [{
if !(ACE_player isEqualTo (call FUNC(player))) then {
private ["_oldPlayer"];
_oldPlayer = ACE_player;
@ -324,7 +322,11 @@ if (hasInterface) then {
}, 0, []] call CBA_fnc_addPerFrameHandler;
};
//////////////////////////////////////////////////
// Time handling
//////////////////////////////////////////////////
ACE_time = diag_tickTime;
ACE_realTime = diag_tickTime;
ACE_virtualTime = diag_tickTime;
@ -339,6 +341,8 @@ PREP(timePFH);
// Init toHex
[0] call FUNC(toHex);
ADDON = true;
isHC = !hasInterface && !isDedicated; // deprecated because no tag
missionNamespace setVariable ["ACE_isHC", ACE_isHC];
uiNamespace setVariable ["ACE_isHC", ACE_isHC];
isHC = !(hasInterface || isDedicated);
ADDON = true;

View File

@ -80,6 +80,7 @@ if (_eventType == "ACEc") then {
["ACEg", ACEg] call FUNC(_handleNetEvent);
};
};
} forEach _eventTargets;
false
} count _eventTargets;
};
};

View File

@ -21,6 +21,7 @@ params ["_client"];
_eventLog = _eventEntry select 1;
["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent);
} forEach (GVAR(syncedEvents) select 0);
false
} count (GVAR(syncedEvents) select 0);
true

View File

@ -41,7 +41,8 @@ if (isServer) then {
{
_x params ["", "_eventArgs","_ttl"];
[_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent);
} forEach _eventLog;
false
} count _eventLog;
ACE_LOGINFO_1("[%1] synchronized",_eventName);
};

View File

@ -17,11 +17,11 @@ params ["_conditionName", "_conditionFunc"];
_conditionName = toLower _conditionName;
private "_conditions";
private ["_conditions", "_index"];
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
_conditions params ["_conditionNames", "_conditionFuncs"];
private "_index";
_index = _conditionNames find _conditionName;
if (_index == -1) then {

View File

@ -1,6 +1,5 @@
/*
* Author: commy2, idea by Falke
*
* Returns a brightness value depending on the sun and moon state. Ranges from 0 to 1 (dark ... bright).
*
* Arguments:

View File

@ -9,10 +9,10 @@
* None
*
* Example:
* [ACE_Player] call FUNC(applyForceWalkStatus)
* [ACE_Player] call ace_common_fnc_applyForceWalkStatus
*
* Public: No
*/
*/
#include "script_component.hpp"
params ["_unit"];

View File

@ -14,37 +14,40 @@
*
* Public: No
*/
#include "script_component.hpp"
private ["_splittedList", "_nilCheckPassedList"];
params ["_list", "_variable", "_setting", "_global"];
if (typeName _list == "STRING") then {
private ["_splittedList", "_nilCheckPassedList"];
_splittedList = [_list, ","] call BIS_fnc_splitString;
_nilCheckPassedList = "";
{
_x = [_x] call FUNC(stringRemoveWhiteSpace);
if !(isnil _x) then {
if !(isNil _x) then {
if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x;
} else {
_nilCheckPassedList = _nilCheckPassedList + ","+ _x;
};
};
}foreach _splittedList;
false
} count _splittedList;
_list = [] call compile format["[%1]",_nilCheckPassedList];
};
{
if (!isnil "_x") then {
if (!isNil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setvariable [_variable, _setting, _global];
};
};
};
}foreach _list;
false
} count _list;
true

View File

@ -0,0 +1,75 @@
/*
* Author: commy2
* Initialized the assigned item fix.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public : No
*/
#include "script_component.hpp"
private "_config";
ACE_isMapEnabled = call {_config = missionConfigFile >> "showMap"; !isNumber _config || {getNumber _config == 1}}; // default value is 1, so do isNumber check first
ACE_isCompassEnabled = call {_config = missionConfigFile >> "showCompass"; !isNumber _config || {getNumber _config == 1}};
ACE_isWatchEnabled = call {_config = missionConfigFile >> "showWatch"; !isNumber _config || {getNumber _config == 1}};
ACE_isRadioEnabled = call {_config = missionConfigFile >> "showRadio"; !isNumber _config || {getNumber _config == 1}};
ACE_isGPSEnabled = call {_config = missionConfigFile >> "showGPS"; !isNumber _config || {getNumber _config == 1}};
GVAR(AssignedItems) = [];
GVAR(AssignedItemsInfo) = [];
GVAR(AssignedItemsShownItems) = [
ACE_isMapEnabled,
ACE_isCompassEnabled,
ACE_isWatchEnabled,
ACE_isRadioEnabled,
ACE_isGPSEnabled
];
["playerInventoryChanged", {
params ["_unit", "_assignedItems"];
_assignedItems = _assignedItems select 17;
GVAR(AssignedItemsShownItems) = [true, true, true, true, true];
{
if !(_x in GVAR(AssignedItems)) then {
GVAR(AssignedItems) pushBack _x;
GVAR(AssignedItemsInfo) pushBack toLower getText (configFile >> "CfgWeapons" >> _x >> "ACE_hideItemType");
};
switch (GVAR(AssignedItemsInfo) select (GVAR(AssignedItems) find _x)) do {
case ("map"): {
GVAR(AssignedItemsShownItems) set [0, false];
};
case ("compass"): {
GVAR(AssignedItemsShownItems) set [1, false];
};
case ("watch"): {
GVAR(AssignedItemsShownItems) set [2, false];
};
case ("radio"): {
GVAR(AssignedItemsShownItems) set [3, false];
};
case ("gps"): {
GVAR(AssignedItemsShownItems) set [4, false];
};
};
false
} count _assignedItems;
//systemChat str GVAR(AssignedItemsShownItems);
GVAR(AssignedItemsShownItems) params ["_showMap", "_showCompass", "_showWatch", "_showRadio", "_showGPS"];
showMap _showMap;
showCompass _showCompass;
showWatch _showWatch;
showRadio _showRadio;
showGPS (_showGPS || {cameraOn == getConnectedUAV _unit}); //If player is activly controling a UAV, showGPS controls showing the map (m key)
}] call FUNC(addEventHandler);

View File

@ -10,7 +10,6 @@
*
* Public: Yes
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Is the unit able to enter the vehicle in the given position?
*
* Arguments:

View File

@ -17,8 +17,6 @@
params ["_projectile", "_adjustDir", "_adjustUp", ["_adjustSpeed",0]];
//["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
private ["_vdir", "_dir", "_up", "_vlat", "_vup", "_vel"];
// get old direction vector

View File

@ -92,5 +92,5 @@ if (!isServer) then {
};
if (_checkAll) then {
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber); // @todo
0 spawn COMPILE_FILE(scripts\checkVersionNumber); // @todo
};

View File

@ -10,6 +10,7 @@
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -14,4 +14,6 @@
*/
#include "script_component.hpp"
ACE_DEPRECATED("ace_common_fnc_codeToLetter","3.5.0","-");
["", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] select ([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 44, 21] find (_this select 0)) + 1

View File

@ -1,30 +0,0 @@
/*
* Author: commy2
* Get a key code used in AGM key input eh.
*
* Arguments:
* 0: Arma DIK code <NUMBER>
* 1: Key state for shift left and shift right key <BOOL>
* 2: Key state for ctrl left and ctrl right key <BOOL>
* 3: Key state for alt and alt gr key <BOOL>
*
* Return Value:
* Key code <NUMBER>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
#define KEY_MODIFIERS [42, 54, 29, 157, 56, 184]
params ["_key", "_stateShift", "_stateCtrl", "_stateAlt"];
if (_key in KEY_MODIFIERS) exitWith {_key};
if (_stateShift) then {_key = _key + 0.1};
if (_stateCtrl) then {_key = _key + 0.2};
if (_stateAlt) then {_key = _key + 0.4};
_key

View File

@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Returns the current radio / chat / marker channel.
*
* Arguments:

View File

@ -38,8 +38,7 @@ if (_level <= _defaultLoglevel) then {
};
diag_log _message;
// pass it onwards to the log function:
// [0, [], compile format["%1",_msg], true] call FUNC(log);
};
true

View File

@ -1,5 +1,6 @@
/*
* Author: Glowbal
* ?
*
* Arguments:
* None
@ -9,7 +10,6 @@
*
* Public: No
*/
#include "script_component.hpp"
params ["_entity"];

View File

@ -5,23 +5,20 @@
* Arguments:
* 0: True to disable key inputs, false to re-enable them <BOOL>
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
* Public: No
*/
#include "script_component.hpp"
private ["_dlg"];
PARAMS_1(_state);
params ["_state"];
if (_state) then {
disableSerialization;
if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {};
if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) exitWith {};
if (!isNil QGVAR(disableInputPFH)) exitWith {};
// end TFAR and ACRE2 radio transmissions
call FUNC(endRadioTransmission);
@ -34,21 +31,20 @@ if (_state) then {
closeDialog 0;
createDialog QGVAR(DisableMouse_Dialog);
private "_dlg";
_dlg = uiNamespace getVariable QGVAR(dlgDisableMouse);
_dlg displayAddEventHandler ["KeyDown", {
private ["_key", "_dlg", "_ctrl", "_config", "_acc", "_index"];
_key = _this select 1;
params ["", "_key"];
if (_key == 1 && {alive player}) then {
createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer);
disableSerialization;
_dlg = finddisplay 49;
_dlg displayAddEventHandler ["KeyDown", {
_key = _this select 1;
!(_key == 1)
}];
private ["_dlg", "_ctrl"];
_dlg = findDisplay 49;
for "_index" from 100 to 2000 do {
(_dlg displayCtrl _index) ctrlEnable false;
@ -62,19 +58,21 @@ if (_state) then {
_ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer);
_ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)];
_ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}});
_ctrl ctrlEnable (call {private "_config"; _config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}});
_ctrl ctrlSetText "RESPAWN";
_ctrl ctrlSetTooltip "Respawn.";
};
if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
private "_acc";
_acc = accTime;
teamSwitch;
setAccTime _acc;
};
if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then {
if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
openCuratorInterface;
};
@ -95,16 +93,17 @@ if (_state) then {
_dlg displayAddEventHandler ["KeyUp", {true}];
["ACE_DisableUserInput", "onEachFrame", {
GVAR(disableInputPFH) = [{
if (isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) && {!visibleMap && isNull findDisplay 49 && isNull findDisplay 312 && isNull findDisplay 632}) then {
["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
[GVAR(disableInputPFH)] call CBA_fnc_removePerFrameHandler;
GVAR(disableInputPFH) = nil;
[true] call FUNC(disableUserInput);
};
}] call BIS_fnc_addStackedEventHandler;
}, 0, []] call CBA_fnc_addPerFrameHandler;
} else {
if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) then {
["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
if (!isNil QGVAR(disableInputPFH)) then {
[GVAR(disableInputPFH)] call CBA_fnc_removePerFrameHandler;
GVAR(disableInputPFH) = nil;
};
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;

View File

@ -1,24 +1,23 @@
/*
* Author: Glowbal
*
* Draw progress bar and execute given function if succesful.
* Finish/Failure/Conditional are all passed [args, elapsedTime, totalTime, errorCode]
*
* Argument:
* 0: icon ID <STRING>
* 1: show <BOOL>
* 2: Icon Path <STRING>
* 3: Icon color <ARRAY>
* 4: timeAlive. -1 = forever <NUMBER> <OPTIONAL>
*
* Return value:
* Nothing
*
* Example:
* ["myID", true, QUOTE(PATHTOF(data\icon_group.paa)), [1,1,1,1], 0] call ace_gui_fnc_displayIcon;
*/
* Author: Glowbal
* Draw progress bar and execute given function if succesful.
* Finish/Failure/Conditional are all passed [args, elapsedTime, totalTime, errorCode]
*
* Arguments:
* 0: icon ID <STRING>
* 1: show <BOOL>
* 2: Icon Path <STRING>
* 3: Icon color <ARRAY>
* 4: timeAlive. -1 = forever (default: 6) <NUMBER>
*
* Return Value:
* None
*
* Example:
* ["myID", true, QUOTE(PATHTOF(data\icon_group.paa)), [1,1,1,1], 0] call ace_gui_fnc_displayIcon;
*
* Public: Yes
*/
#include "script_component.hpp"
// positions for the icon UI
@ -42,31 +41,37 @@
// other constants
#define DEFAULT_TIME 6
private ["_allControls", "_refresh", "_timeAlive", "_list"];
PARAMS_4(_iconId,_show,_icon,_color);
_timeAlive = if (count _this > 4) then {_this select 4} else {DEFAULT_TIME};
disableSerialization;
_list = missionNamespace getvariable [QGVAR(displayIconList),[]];
params ["_iconId", "_show", "_icon", "_color", ["_timeAlive", DEFAULT_TIME]];
private ["_list", "_refresh"];
_list = missionNamespace getVariable [QGVAR(displayIconList), []];
_refresh = {
private ["_allControls"];
// Refreshing of all icons..
_allControls = missionNamespace getvariable [QGVAR(displayIconListControls), []];
private "_allControls";
_allControls = missionNamespace getVariable [QGVAR(displayIconListControls), []];
{
ctrlDelete _x;
}foreach _allControls;
false
} count _allControls;
_allControls = [];
private ["_ctrl", "_setting", "_position"];
_setting = missionNamespace getvariable[QGVAR(settingFeedbackIcons), 0];
private ["_setting", "_ctrl", "_position"];
_setting = missionNamespace getVariable [QGVAR(settingFeedbackIcons), 0];
if (_setting > 0) then {
{
_x params ["", "_xicon", "_xcolor"];
// +19000 because we want to make certain we are using free IDCs..
_ctrl = ((findDisplay 46) ctrlCreate ["RscPicture", _foreachIndex + 19000]);
_ctrl = (findDisplay 46) ctrlCreate ["RscPicture", _forEachIndex + 19000];
_position = switch (_setting) do {
case TOP_RIGHT_DOWN: {[X_POS_ICONS, Y_POS_ICONS + (_foreachIndex * DIFFERENCE_ICONS), ICON_WIDTH, ICON_WIDTH]};
case TOP_RIGHT_LEFT: {[X_POS_ICONS_SECOND - ((_foreachIndex+3) * DIFFERENCE_ICONS), Y_POS_ICONS_SECOND - (ICON_WIDTH / 2), ICON_WIDTH, ICON_WIDTH]};
@ -74,46 +79,53 @@ _refresh = {
case TOP_LEFT_RIGHT: {[LEFT_SIDE + (0.5 * ICON_WIDTH) - ((_foreachIndex+3) * DIFFERENCE_ICONS), Y_POS_ICONS_SECOND, ICON_WIDTH, ICON_WIDTH]};
default {[X_POS_ICONS, Y_POS_ICONS + (_foreachIndex * DIFFERENCE_ICONS), ICON_WIDTH, ICON_WIDTH]};
};
_ctrl ctrlSetPosition _position;
_ctrl ctrlsetText (_x select 1);
_ctrl ctrlSetTextColor (_x select 2);
_ctrl ctrlSetText _xicon;
_ctrl ctrlSetTextColor _xcolor;
_ctrl ctrlCommit 0;
_allControls pushback _ctrl;
}foreach (missionNamespace getvariable [QGVAR(displayIconList),[]]);
_allControls pushBack _ctrl;
false
} forEach (missionNamespace getVariable [QGVAR(displayIconList),[]]);
};
missionNamespace setvariable [QGVAR(displayIconListControls), _allControls];
missionNamespace setVariable [QGVAR(displayIconListControls), _allControls];
};
if (_show) then {
if ({(_x select 0 == _iconId)} count _list == 0) then {
_list pushback [_iconId, _icon, _color, ACE_time];
if ({_x select 0 == _iconId} count _list == 0) then {
_list pushBack [_iconId, _icon, _color, ACE_time];
} else {
{
if (_x select 0 == _iconId) exitwith {
_list set [_foreachIndex, [_iconId, _icon, _color, ACE_time]];
_list set [_forEachIndex, [_iconId, _icon, _color, ACE_time]];
};
} forEach _list;
};
missionNamespace setvariable [QGVAR(displayIconList), _list];
missionNamespace setVariable [QGVAR(displayIconList), _list];
call _refresh;
if (_timeAlive >= 0) then {
[{
[_this select 0, false, "", [0,0,0], 0] call FUNC(displayIcon);
}, [_iconId], _timeAlive, _timeAlive] call EFUNC(common,waitAndExecute);
[_this select 0, false, "", [0,0,0], 0] call FUNC(displayIcon);
}, [_iconId], _timeAlive, _timeAlive] call FUNC(waitAndExecute);
};
} else {
if ({(_x select 0 == _iconId)} count _list == 1) then {
if ({_x select 0 == _iconId} count _list == 1) then {
private "_newList";
_newList = [];
{
if (_x select 0 != _iconId) then {
_newList pushback _x;
_newList pushBack _x;
};
} forEach _list;
false
} count _list;
missionNamespace setvariable [QGVAR(displayIconList), _newList];
missionNamespace setVariable [QGVAR(displayIconList), _newList];
call _refresh;
};
};

View File

@ -1,42 +1,35 @@
/*
* Author: commy2
*
* Display a message.
*
* Argument:
* 0: Message (String)
* 1: Play a clicking sound (Bool, optional default: false)
* 2: How long before hiding the message in seconds (Number, optional default: 2 sec)
* 3: Priority, higher priority messages will override lesser important ones (Number, optional default: 0)
* Arguments:
* 0: Message <STRING>
* 1: Play a clicking sound (default: false) <BOOL>
* 2: How long before hiding the message in seconds (default: 2) <NUMBER>
* 3: Priority, higher priority messages will override lesser important ones (default: 0) <NUMBER>
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
#define DEFAULT_PLAY_SOUND false
#define DEFAULT_DELAY 2
#define DEFAULT_PRIORITY 0
_this resize 4;
private ["_lastHintTime", "_lastHintPriority", "_time"];
PARAMS_4(_text,_sound,_delay,_priority);
params ["_text", ["_sound", false], ["_delay", 2], ["_priority", 0]];
if (isNil QGVAR(lastHint)) then {
GVAR(lastHint) = [0, 0];
};
if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text};
private ["_lastHintTime", "_lastHintPriority", "_time"];
_lastHintTime = GVAR(lastHint) select 0;
_lastHintPriority = GVAR(lastHint) select 1;
if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text};
if (isNil "_sound") then {_sound = DEFAULT_PLAY_SOUND};
if (isNil "_delay") then {_delay = DEFAULT_DELAY};
if (isNil "_priority") then {_priority = DEFAULT_PRIORITY};
_time = ACE_time;
if (_time > _lastHintTime + _delay || {_priority >= _lastHintPriority}) then {
hintSilent _text;
if (_sound) then {playSound "ACE_Sound_Click"};

View File

@ -1,25 +1,21 @@
/*
* Author: commy2, Glowbal
*
* Display a structured text with image.
*
* Argument:
* Arguments:
* 0: Text <ANY>
* 1: Image <STRING>
* 2: Image color <ARRAY> <OPTIONAL>
* 3: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL>
* 2: Image color (default: [0, 0, 0, 0]) <ARRAY>
* 3: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_imageColor", "_target"];
PARAMS_2(_text,_image);
_imageColor = if (count _this > 2) then {_this select 2} else {[1,1,1]};
_imageColor resize 3;
_target = if (count _this > 3) then {_this select 3} else {ACE_player};
params ["_text", "_image", ["_imageColor", [1,1,1]], ["_target", ACE_player]];
if (_target != ACE_player) exitWith {};
@ -28,16 +24,21 @@ if (typeName _text != "TEXT") then {
if (count _text > 0) then {
{
if (typeName _x == "STRING" && {isLocalized _x}) then {
_text set [_foreachIndex, localize _x];
_text set [_forEachIndex, localize _x];
};
}foreach _text;
} forEach _text;
_text = format _text;
};
};
if (typeName _text == "STRING" && {isLocalized _text}) then {
_text = localize _text;
};
_text = parseText format ["<t align='center'>%1</t>", _text];
};
_text = composeText [parseText format ["<img size='2' align='center' color='%2' image='%1'/>", _image, _imageColor call BIS_fnc_colorRGBtoHTML], lineBreak, _text];
[_text, 2] call FUNC(displayTextStructured);

View File

@ -1,23 +1,20 @@
/*
* Author: commy2, Glowbal
*
* Display a structured text.
*
* Argument:
* Arguments:
* 0: Text <ANY>
* 1: Size of the textbox <NUMBER> <OPTIONAL>
* 2: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL>
* 1: Size of the textbox (default: 1.5) <NUMBER>
* 2: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_text", "_size", "_isShown", "_ctrlHint", "_yPos", "_xPos", "_wPos", "_hPos", "_position", "_target"];
_text = _this select 0;
_size = if (count _this > 1) then {_this select 1} else {1.5;};
_target = if (count _this > 2) then {_this select 2} else {ACE_player};
params ["_text", ["_size", 1.5], ["_target", ACE_player]];
if (_target != ACE_player) exitWith {};
@ -38,6 +35,8 @@ if (typeName _text != "TEXT") then {
_text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]];
};
private ["_isShown", "_ctrlHint", "_xPos", "_yPos", "_wPos", "_hPos", "_position"];
_isShown = ctrlShown (uiNamespace getVariable ["ACE_ctrlHint", controlNull]);
("ACE_RscHint" call BIS_fnc_rscLayer) cutRsc ["ACE_RscHint", "PLAIN", 0, true];
@ -60,8 +59,8 @@ _yPos = safeZoneY + 0.175 * safezoneH;
_wPos = (10 *(((safezoneW / safezoneH) min 1.2) / 40));
_hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
//Zeus Interface Open and Display would be under the "CREATE" list
if (!isnull curatorCamera) then {
// Zeus Interface Open and Display would be under the "CREATE" list
if (!isNull curatorCamera) then {
_xPos = _xPos min ((safezoneX + safezoneW - 12.5 * (((safezoneW / safezoneH) min 1.2) / 40)) - _wPos);
};

View File

@ -3,35 +3,22 @@
*
* Execute an animation. This is used to not break things like the unconsciousness animation.
*
* Argument:
* 0: Unit (Object)
* 1: Animation (String)
* 2: Priority of the animation. (Number, optional default: 0)
* 0: PlayMove
* 1: PlayMoveNow
* 2: SwitchMove (no transitional animation, doesn't overwrite priority 1)
* Arguments:
* 0: Unit <OBJECT>
* 1: Animation <STRING>
* 2: Priority of the animation. (default: 0) <NUMBER>
* 0 = PlayMove
* 1 = PlayMoveNow
* 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_force"];
PARAMS_3(_unit,_animation,_priority);
_force = False;
// no animation given
if (isNil "_animation") exitWith {
ACE_LOGERROR_1("No animation specified in %1.",_fnc_scriptNameParent);
};
if (isNil "_priority") then {
_priority = 0;
};
if (count _this > 3) then {
_force = _this select 3;
};
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
// don't overwrite more important animations
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
@ -47,7 +34,7 @@ if (_animation == "") then {
//if (_animation == animationState _unit) exitWith {};
switch (_priority) do {
case 0 : {
case 0: {
if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
} else {
@ -55,7 +42,7 @@ switch (_priority) do {
[_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc);
};
};
case 1 : {
case 1: {
if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
} else {
@ -63,7 +50,7 @@ switch (_priority) do {
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
};
};
case 2 : {
case 2: {
// try playMoveNow first
if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
@ -80,5 +67,3 @@ switch (_priority) do {
};
default {};
};
["Anim", [_priority, _animation]] call FUNC(log);

View File

@ -1,30 +1,24 @@
/*
* Author: commy2
*
* Drops a backback. Also returns the ground wepaon holder object of the dropped backpack.
*
* Argument:
* 0: Unit that has a backpack (Object)
* Arguments:
* 0: Unit that has a backpack <OBJECT>
*
* Return value:
* Ground wepaon holder with backpack (Object)
* Ground wepaon holder with backpack <OBJECT>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
private ["_backpackObject","_holder"];
private ["_backpackObject", "_holder"];
_backpackObject = backpackContainer _unit;
_unit addBackpack "Bag_Base";
removeBackpack _unit;
_holder = objNull;
{
if (_backpackObject in everyBackpack _x) exitWith {
_holder = _x;
};
} forEach (position _unit nearObjects ["WeaponHolder", 5]);
_holder
objectParent _backpackObject // return

View File

@ -1,10 +1,21 @@
//fnc_dumpArray.sqf
/*
* Author: ?
* ?
*
* Arguments:
* 0: Array to be dumped <ARRAY>
* 1: Depth <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_pad", "_i", "_x"];
PARAMS_2(_var,_depth);
params ["_var", "_depth"];
private "_pad";
_pad = "";
for "_i" from 0 to _depth do {
@ -14,15 +25,18 @@ for "_i" from 0 to _depth do {
_depth = _depth + 1;
if (IS_ARRAY(_var)) then {
if ((count _var) > 0) then {
diag_log text format["%1[", _pad];
if (_var isEqualTo []) then {
diag_log text format ["%1[],", _pad];
} else {
diag_log text format ["%1[", _pad];
{
[_x, _depth] call FUNC(dumpArray);
} forEach _var;
diag_log text format["%1],", _pad];
} else {
diag_log text format["%1[],", _pad];
false
} count _var;
diag_log text format ["%1],", _pad];
};
} else {
diag_log text format["%1%2", _pad, [_var] call FUNC(formatVar)];
diag_log text format ["%1%2", _pad, [_var] call FUNC(formatVar)];
};

View File

@ -1,49 +1,68 @@
//fnc_dumpPerformanceCounters.sqf
#define DEBUG_MODE_FULL
/*
* Author: ?
* Dumps performance counter statistics into Logs.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
diag_log text format ["REGISTERED ACE PFH HANDLERS"];
diag_log text format ["-------------------------------------------"];
diag_log text format["REGISTERED ACE PFH HANDLERS"];
diag_log text format["-------------------------------------------"];
if (!isNil "ACE_PFH_COUNTER") then {
{
private ["_isActive"];
_x params ["_pfh", "_parameters"];
_isActive = if (!isNil {cba_common_PFHhandles select (_pfh select 0)}) then {"ACTIVE"} else {"REMOVED"};
diag_log text format["Registered PFH: id=%1 [%2, delay %3], %4:%5", (_pfh select 0), (_isActive), (_parameters select 1), (_pfh select 1), (_pfh select 2) ];
} forEach ACE_PFH_COUNTER;
private "_isActive";
_isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)};
diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2];
false
} count ACE_PFH_COUNTER;
};
diag_log text format["ACE COUNTER RESULTS"];
diag_log text format["-------------------------------------------"];
diag_log text format ["ACE COUNTER RESULTS"];
diag_log text format ["-------------------------------------------"];
{
private ["_counterEntry", "_iter", "_total", "_count", "_delta", "_averageResult"];
private ["_counterEntry", "_iter", "_total", "_count", "_averageResult", "_delta"];
_counterEntry = _x;
_iter = 0;
_total = 0;
_count = 0;
_averageResult = 0;
if( (count _counterEntry) > 3) then {
if (count _counterEntry > 3) then {
// calc
{
if(_iter > 2) then {
if (_iter > 2) then {
_count = _count + 1;
_delta = (_x select 1) - (_x select 0);
_total = _total + _delta;
};
_iter = _iter + 1;
} forEach _counterEntry;
false
} count _counterEntry;
// results
_averageResult = (_total / _count) * 1000;
// dump results
diag_log text format["%1: Average: %2s / %3 = %4ms", (_counterEntry select 0), _total, _count, _averageResult];
diag_log text format ["%1: Average: %2s / %3 = %4ms", _counterEntry select 0, _total, _count, _averageResult];
} else {
diag_log text format["%1: No results", (_counterEntry select 0) ];
diag_log text format ["%1: No results", _counterEntry select 0];
};
} forEach ACE_COUNTERS;
false
} count ACE_COUNTERS;
/*
// Dump PFH Trackers
@ -71,4 +90,4 @@ diag_log text format["-------------------------------------------"];
//
//} forEach ACRE_EXCESSIVE_FRAME_TRACKER;
*/
*/

View File

@ -4,11 +4,12 @@
* End radio transmissions of addons TFAR and ACRE2. TFAR v0.9.7, ACRE Public Beta 2.0.3.571
*
* Arguments:
* None.
* None
*
* Return Value:
* None.
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -13,6 +13,6 @@
*/
#include "script_component.hpp"
PARAMS_2(_namespace,_uid);
params ["_namespace", "_uid"];
_namespace setVariable [_uid, nil];

View File

@ -29,11 +29,7 @@ if (isNull (call BIS_fnc_displayMission)) exitWith {
}, 1, _this] call CBA_fnc_addPerFrameHandler;
};
private ["_onOK", "_onCancel"];
PARAMS_2(_textHeader,_textMessage);
_onOK = ARR_SELECT(_this,2,{});
_onCancel = ARR_SELECT(_this,3,{});
params ["_textHeader", "_textMessage", ["_onOK", {}], ["_onCancel", {}]];
if (typeName _textMessage == "STRING") then {
_textMessage = parseText _textMessage;

View File

@ -1,18 +1,19 @@
/*
* Author: esteldunedain
*
* Executes a code on the next frame
*
* Argument:
* 0: Code to execute (Code)
* 1: Parameters to run the code with (Array)
* Arguments:
* 0: Code to execute <CODE>
* 1: Parameters to run the code with <ARRAY>
*
* Return value:
* PFH handler ID
* Return Value:
* PFH handler ID <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_func,_params);
params ["_func", "_params"];
if (diag_frameno != GVAR(nextFrameNo)) then {
GVAR(nextFrameBufferA) pushBack [_params, _func];

View File

@ -1,29 +1,29 @@
/*
* Author: commy2
*
* Execute a function on every machine. Function will also be called upon JIP (postInit). The arguments are stored in (_this select 0), while the assigned namespace is stored in (_this select 1).
*
* Argument:
* 0: Function arguments (Array)
* 1: Function to execute, has to be defined on the remote machine first (String)
* 2: Namespace to save that variable in (Object or Namespace)
* 3: Name. Will overwrite previously defined functions with that name (String)
* Arguments:
* 0: Function arguments <ARRAY>
* 1: Function to execute, has to be defined on the remote machine first <STRING>
* 2: Namespace to save that variable in <OBJECT, NAMESPACE>
* 3: Name. Will overwrite previously defined functions with that name <STRING>
*
* Return value:
* Nothing.
* Return Value:
* None
*
* Public: No
*
* Deprecated
*/
#include "script_component.hpp"
private ["_arguments", "_function", "_unit", "_name"];
GVAR(remoteFnc) = _this;
_arguments = _this select 0;
_function = call compile (_this select 1);
_unit = _this select 2;
_name = _this select 3;
params ["_arguments", "_function", "_unit", "_name"];
["Remote", [_arguments, _this select 1, _name], {format ["%1 call %2 id: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log);
_function = call compile _function;
//["Remote", [_arguments, _this select 1, _name], {format ["%1 call %2 id: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log);
// execute function on every currently connected machine
[[_arguments, _unit], _this select 1, 2] call FUNC(execRemoteFnc);

View File

@ -1,35 +1,32 @@
/*
* Author: commy2
*
* Execute a function on a remote machine in mp.
*
* Argument:
* 0: Function arguments (Array)
* 1: Function to execute, has to be defined on the remote machine first (String)
* 2: The function will be executed where this unit is local OR the mode were this function should be executed. (Object OR Number, optional default: 2)
* Mode 0: execute on this machine only
* Mode 1: execute on server
* Mode 2: execute on all clients + server
* Mode 3: execute on dedicated only
* Arguments:
* 0: Function arguments <ARRAY>
* 1: Function to execute, has to be defined on the remote machine first <STRING>
* 2: The function will be executed where this unit is local OR the mode were this function should be executed. (default: 2) <OBJECT, NUMBER>
* 0 = execute on this machine only
* 1 = execute on server
* 2 = execute on all clients + server
* 3 = execute on dedicated only
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: No
*
* Deprecated
*/
#include "script_component.hpp"
private ["_arguments", "_function", "_unit", "_id"];
GVAR(remoteFnc) = _this;
_arguments = _this select 0;
_function = call compile (_this select 1);
_unit = _this select 2;
params ["_arguments", "_function", ["_unit", 2]];
if (isNil "_unit") then {
_unit = 2;
};
_function = call compile _function;
["Remote", [_arguments, _this select 1, _unit], {format ["%1 call %2 to: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log);
//["Remote", [_arguments, _this select 1, _unit], {format ["%1 call %2 to: %3", _this select 0, _this select 1, _this select 2]}, false] call FUNC(log);
if (typeName _unit == "SCALAR") exitWith {
switch (_unit) do {
@ -63,8 +60,7 @@ if (local _unit) then {
_arguments call _function;
} else {
if (isServer) then {
_id = owner _unit;
_id publicVariableClient QGVAR(remoteFnc);
(owner _unit) publicVariableClient QGVAR(remoteFnc);
} else {
publicVariableServer QGVAR(remoteFnc);
};

View File

@ -1,11 +1,22 @@
// by commy2
/*
* Author: commy2
* Execute all Persistent Functions
*
* Arguments:
* ?
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_target);
params ["_target"];
{
if (isNil "_x") then {
ACE_LOGERROR_1("No argument and function for remote function. ID: %1",_forEachIndex);
ACE_LOGERROR_1("No arguments and function for remote function. ID: %1",_forEachIndex);
} else {
if (typeName _x == "ARRAY") then {
[_x select 0, _target] call (_x select 1);

View File

@ -1,17 +1,25 @@
// by commy2
/*
usage:
(configFile >> "CfgAmmo") call FUNC(exportConfig);
*/
* Author: commy2
* Export Config Entrys to RPT logs
*
* Arguments:
* Config Path <CONFIG>
*
* Return Value:
* None
*
* Example:
* [configFile >> "CfgAmmo"] call ace_common_fnc_exportConfig;
*
* Public: No
*/
#include "script_component.hpp"
private "_fnc_logEntries";
_fnc_logEntries = {
private ["_p", "_t", "_e", "_a", "_i"];
params ["_c", "_d"];
PARAMS_2(_c,_d);
private ["_p", "_t", "_e", "_a", "_i"];
_p = inheritsFrom _c;

View File

@ -1,6 +1,5 @@
/*
* Author: KoffeinFlummi, commy2
*
* Filters array and removes every element not fitting the condition
*
* Arguments:
@ -12,22 +11,21 @@
*
* Usage:
* [[0,1,2,3,4], {_this > 2}] call FUNC(filter) ==> [3,4]
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_newArray", "_index"];
params ["_array", "_code"];
PARAMS_2(_array,_code);
private "_result";
_result = [];
if (isNil "_array") exitWith {
ACE_LOGERROR_1("No array for function filter in %1.",_fnc_scriptNameParent);
[]
};
_newArray = [];
for "_index" from 0 to (count _array - 1) do {
if ((_array select _index) call _code) then {
_newArray pushBack (_array select _index);
{
if (_x call _code) then {
_result pushBack _x;
};
};
_newArray
false
} count _array;
_result

View File

@ -1,13 +1,14 @@
/*
* Author: commy2
* Attempt to fix physx collisions causing unreasonable impact forces and damage.
* Attempt to fix PhysX collisions causing unreasonable impact forces and damage.
*
* Arguments:
* 0: Object <OBJECT>
* Object <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,9 +1,20 @@
// by commy2
/*
* Author: commy2
* Fixes zeus placed crates containing buged mine detectors and ace items.
*
* Arguments:
* 0: Crate <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_weapons", "_items"];
params ["_crate"];
PARAMS_1(_crate);
private ["_weapons", "_items"];
// get all weapons inside the crate
_weapons = weaponCargo _crate;

View File

@ -3,30 +3,33 @@
* Attempt to fix floating physx with disabled damage after setPosXXX commands.
*
* Arguments:
* Physx object (Object)
* PhysX object <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Public: No
*/
#include "script_component.hpp"
private "_object";
_object = _this;
// setHitPointDamage requires local object
if (!local _object) exitWith {};
// save and restore hitpoints, see below why
private ["_hitPoints", "_hitPointDamages"];
private "_hitPointDamages";
_hitPointDamages = getAllHitPointsDamage _object;
_hitPoints = [_object] call FUNC(getHitpoints);
_hitPointDamages = [_hitPoints, {_object getHitPointDamage _this}] call FUNC(map);
// get correct format for objects without hitpoints
if (_hitPointDamages isEqualTo []) then {
_hitPointDamages = [[],[],[]];
};
// this prevents physx objects from floating when near other physx objects with allowDamage false
_object setDamage damage _object;
{
_object setHitPointDamage [_x, _hitPointDamages select _forEachIndex];
} forEach _hitPoints;
_object setHitIndex [_forEachIndex, _x];
} forEach (_hitPointDamages select 2);

View File

@ -15,8 +15,8 @@
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"} && {(vehicle _unit) == _unit}) then {
if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"} && {vehicle _unit == _unit}) then {
[_unit, "amovpercmstpsraswrfldnon", 0] call FUNC(doAnimation);
};

View File

@ -4,10 +4,12 @@
* Fixes position of an object. E.g. moves object above ground and adjusts to terrain slope. Requires local object.
*
* Argument:
* Object (Object)
* Object <OBJECT>
*
* Return value:
* NONE
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,30 +1,40 @@
/**
* fn_getAllSetVariables.sqf
* @Descr: Returns an 2d array of all variables that have been set on the object
* @Author: Glowbal
/*
* Author: Glowbal
* Returns an 2d array of all variables that have been set on the object
*
* @Arguments: [unit OBJECT, category STRING (Optional. Only get the variables from the specified category. Default is "" == all)]
* @Return: ARRAY REturns an array with the format [ [name STRING, typeName STRING, value ANY, publicFlag BOOL, peristentFlag BOOL] ]
* @PublicAPI: true
* Arguments:
* 0: Unit <OBJECT>
* 1: Limiting Category (default: "") <STRING>
*
* Return Value:
* Variable Data <ARRAY>
* 0: Name <STRING>
* 1: typeName <STRING>
* 2: value <ANY>
* 3: publicFlag <BOOL>
* 4: peristentFlag <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_return", "_val", "_category"];
PARAMS_1(_object);
_category = if (count _this > 1) then { _this select 1 } else { "" };
params ["_object", ["_category", ""]];
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {
[];
};
if (isNil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {[]};
private ["_return", "_val"];
_return = [];
{
_val = _object getvariable (_x select 0);
if (!isnil "_val") then {
if (!isNil "_val") then {
if (_category == "" || _category == _x select 3) then {
_return pushback [_x select 0, typeName _val, _val, _x select 2, _x select 5];
_return pushBack [_x select 0, typeName _val, _val, _x select 2, _x select 5];
};
};
}foreach GVAR(OBJECT_VARIABLES_STORAGE);
_return
false
} count GVAR(OBJECT_VARIABLES_STORAGE);
_return

View File

@ -1,29 +1,38 @@
/*
* Author: bux578, commy2
*
* Returns an array containing all items of a given unit
*
* Argument:
* 0: Unit (Object)
* Arguments:
* 0: Unit <OBJECT>
*
* Return value:
* Array with all the gear, format:
* 0: headgear (String)
* 1: goggles (String)
* 2,3: uniform (String, Array)
* 4,5: vest (String, Array)
* 6,7: backpack (String, Array)
* 8-10: rifle (String, Array, Array)
* 11-13: launcher (String, Array, Array)
* 14-16: pistol (String, Array, Array)
* 17: map, compass, watch, etc. (Array)
* 18: binocluar (String)
* 19: active weapon, active muzzle, active weaponMode (Array)
* Return Value:
* 0: Headgear <STRING>
* 1: Goggles <STRING>
* 2: Uniform <STRING>
* 3: Uniform Items <ARRAY>
* 4: Vest <String>
* 5: Vest Items <ARRAY>
* 6: Backback <STRING>
* 7: Backpack Items <ARRAY>
* 8: Rifle <STRING>
* 9: Rifle Items <ARRAY>
* 10: Rifle Magazines <ARRAY>
* 11: Launcher <STRING>
* 12: Launcher Items <ARRAY>
* 13: Launcher Magazines <ARRAY>
* 14: Handgun <STRING>
* 15: Handgun Items <ARRAY>
* 16: Handgun Magazines <ARRAY>
* 17: Assigned Items (map, compass, watch, etc.) <ARRAY>
* 18: Binoculars <STRING>
*
* Public: Yes
*
* Note: Element 17 includes the Head Mounted Display (HMD)
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
if (isNull _unit) exitWith {[
"",
@ -35,8 +44,7 @@ if (isNull _unit) exitWith {[
"", ["","","",""], [],
"", ["","","",""], [],
[],
"",
["","",""]
""
]};
[
@ -49,6 +57,5 @@ if (isNull _unit) exitWith {[
secondaryWeapon _unit, secondaryWeaponItems _unit, secondaryWeaponMagazine _unit,
handgunWeapon _unit, handgunItems _unit, handgunMagazine _unit,
assignedItems _unit,
binocular _unit,
[currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit]
binocular _unit
]

View File

@ -1,25 +1,27 @@
/*
* Author: commy2
*
* Return the captivity status of an unit.
*
* Argument:
* 0: Unit (Object)
* Arguments:
* 0: Unit <OBJECT>
*
* Return value:
* Reasons, why the unit is a captive. An empty array is returned if the unit is not a captive (Array of Strings)
* Return Value:
* Captivity Reasons, empty if not captive <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"];
params ["_unit"];
PARAMS_1(_unit);
private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"];
_captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []];
_unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber);
_unitCaptivityReasons = [];
{
if (_unitCaptivityStatus select _forEachIndex) then {
_unitCaptivityReasons pushBack _x;

View File

@ -1,10 +1,20 @@
// by commy2
/*
* Author: commy2
* Obtain children of a config entry
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Parent Entry Class Children <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_classes"];
PARAMS_2(_name,_cfgClass);
params ["_name", "_cfgClass"];
private "_classes";
_classes = format ["configName inheritsFrom _x == '%1'", _name] configClasses (configFile >> _cfgClass);
_classes = [_classes, {configName _this}] call FUNC(map);
_classes
[_classes, {configName _this}] call FUNC(map) // return

View File

@ -1,21 +1,22 @@
/*
* Author: commy2
*
* Get the commander config of a vehicles turret.
*
* Argument:
* 0: vehicle (Object)
* Arguments:
* 0: vehicle <OBJECT>
*
* Return value:
* Commander config (Config)
* Return Value:
* Commander config <CONFIG>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_config", "_turret"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_config", "_turret"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_turret = [_vehicle] call FUNC(getTurretCommander);
[_config, _turret] call FUNC(getTurretConfigPath)
[_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -1,21 +1,22 @@
/*
* Author: commy2
*
* Get the gunner config of a vehicles turret.
*
* Argument:
* 0: vehicle (Object)
* Arguments:
* 0: vehicle <OBJECT>
*
* Return value:
* Gunner config (Config)
* Return Value:
* Gunner config <CONFIG>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_config", "_turret"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_config", "_turret"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_turret = [_vehicle] call FUNC(getTurretGunner);
[_config, _turret] call FUNC(getTurretConfigPath)
[_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -1,17 +1,18 @@
/*
* Author: commy2
* Determins type of item. Can be CfgMagaines, CfgWeapons or CfgGlasses.
*
* What kind of Cfg is the item. Works for CfgMagaines, CfgWeapons and CfgGlasses
* Arguments:
* 0: Item Classname <STRING>
*
* Argument:
* 0: A item's classname. (String)
* Return Value:
* Config category ("CfgWeapons", "CfgMagazines", "CfgGlasses", "") <STRING>
*
* Return value:
* CfgWhatever (String)
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_item);
params ["_item"];
if (isClass (configFile >> "CfgWeapons" >> _item)) exitWith {"CfgWeapons"};

View File

@ -1,17 +1,18 @@
/*
* Author: commy2
* Determins type of object. Can be CfgVehicles or CfgAmmo.
*
* What kind of Cfg is the object. Works for CfgVehicles and CfgAmmo
* Arguments:
* 0: Object classname <STRING>
*
* Argument:
* 0: An object's classname. (String)
* Return Value:
* Config category ("CfgWeapons", "Cfgmagazines", "CfgGlasses", "") <STRING>
*
* Return value:
* CfgWhatever (String)
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_object);
params ["_object"];
if (isClass (configFile >> "CfgVehicles" >> _object)) exitWith {"CfgVehicles"};

View File

@ -9,35 +9,38 @@
* animation <STRING>
*
* Example:
* [bob] call ace_common_fnc_getDeathAnim;
* [bob] call ace_common_fnc_getDeathAnim
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"];
private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation"];
_returnAnimation = "";
_animationState = (animationState _unit);
_unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
//If we're already in a terminal animation just return current
if ((getNumber (_unitAnimationCfg >> "terminal")) == 1) exitWith {_animationState};
_animationState = animationState _unit;
_unitAnimationCfg = configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState;
_unitActionsCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimationCfg >> "actions")));
//If we're already in a terminal animation just return current
if (getNumber (_unitAnimationCfg >> "terminal") == 1) exitWith {_animationState};
_unitActionsCfg = configFile >> "CfgMovesBasic" >> "Actions" >> getText (_unitAnimationCfg >> "actions");
TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg);
if ((vehicle _unit) != _unit) then {
if (vehicle _unit != _unit) then {
_interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo");
for "_index" from 0 to (count _interpolateArray - 1) step 2 do {
_indexAnimation = _interpolateArray select _index;
//No guarentee that first animation will be right so scan for the first "terminal" animation
//E.G.: interpolateTo[] = {"passenger_apc_generic04still",1,"KIA_passenger_apc_generic04",1};
if ((getNumber ((configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation) >> "terminal")) == 1) exitWith {
if (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation >> "terminal") == 1) exitWith {
_returnAnimation = _indexAnimation;
};
};

View File

@ -1,29 +1,47 @@
// by commy2
/*
* Author: commy2
* Get the Defualt animation for the unit
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* animation <STRING>
*
* Example:
* [bob] call ace_common_fnc_getDefaultAnim;
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private ["_anim", "_stance"];
PARAMS_1(_unit);
_anim = toLower (animationState _unit);
_anim = toLower animationState _unit;
// stance is broken for some animations.
_stance = stance _unit;
if (_anim find "ppne" == 4) then {
_stance = "PRONE";
_stance = "PRONE";
};
if (_anim find "pknl" == 4) then {
_stance = "CROUCH";
_stance = "CROUCH";
};
if (_anim find "perc" == 4) then {
_stance = "STAND";
_stance = "STAND";
};
_anim = format ["AmovP%1M%2S%3W%4D%5",
["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0,
["stp", "run"] select (vectorMagnitude velocity _unit > 1),
[["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""),
["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0,
["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"])
["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0,
["stp", "run"] select (vectorMagnitude velocity _unit > 1),
[["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""),
["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0,
["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"])
];
["", _anim] select isClass (configFile >> "CfgMovesMaleSdr" >> "States" >> _anim)

View File

@ -1,33 +1,38 @@
/**
* fn_getVariable.sqf
* @Descr: Grabs a variable. If variable has not been set, attempts to use default defined value
* @Author: Glowbal
/*
* Author: Glowbal
* Grabs a variable. If variable has not been set, attempts to use default defined value
*
* @Arguments: [unit OBJECT, variableName STRING]
* @Return: ANY
* @PublicAPI: true
* Arguments:
* 0: unit <OBJECT>
* 1: Variable Name <STRING>
*
* Return Value:
* Value of variable or default value, if the variable is undefined <ANY>
*
* Public: No
*/
#include "script_component.hpp"
#define UNIT (_this select 0)
#define VARIABLE (_this select 1)
params ["_unit", "_variable", "_defaultValue"];
private "_value";
_value = _unit getvariable _variable;
_value = UNIT getvariable VARIABLE;
if (isnil "_value") then {
if (count _this >2) then {
_value = _this select 2;
if (isNil "_value") then {
if (!isNil "_defaultValue") then {
_value = _defaultValue;
} else {
private "_definedVariable";
_definedVariable = ([VARIABLE] call FUNC(getDefinedVariableInfo));
_definedVariable = [_variable] call FUNC(getDefinedVariableInfo);
if (count _definedVariable > 1) then {
_value = _definedVariable select 1;
};
};
if (isnil "_value") then {
if (isNil "_value") then {
_value = 0;
};
};
_value
_value

View File

@ -1,19 +1,24 @@
/**
* fn_getvariableDefault.sqf
* @Descr: Get the variable default value
* @Author: Glowbal
/*
* Author: Glowbal
* Get the variable default value
*
* @Arguments: [variableName STRING]
* @Return: ANY
* @PublicAPI: true
* Arguments:
* 0: Variable Name <STRING>
*
* Return Value:
* Default value of variable <ANY>
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_varName"];
private "_variableDefinition";
_variableDefinition = ([_this select 0] call FUNC(getDefinedVariableInfo));
if (count _variableDefinition > 0) exitwith {
_variableDefinition = [_varName] call FUNC(getDefinedVariableInfo);
if !(_variableDefinition isEqualTo []) exitwith {
_variableDefinition select 1;
};
nil;
nil

View File

@ -1,12 +1,17 @@
/**
* fn_getvariableInfo.sqf
* @Descr: N/A
* @Author: Glowbal
/*
* Author: Glowbal
* Get the variable Informations
*
* @Arguments: []
* @Return:
* @PublicAPI: false
* Arguments:
* 0: Variable Name <STRING>
*
* Return Value:
* Variable Metadata <ARRAY>
*
* Public: No
*/
#include "script_component.hpp"
+(missionNamespace getvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + (_this select 0),[]])
params ["_varName"];
+ (missionNamespace getVariable [format [QGVAR(OBJECT_VARIABLES_STORAGE_%1), _varName], []])

View File

@ -1,15 +1,31 @@
// by commy2
/*
* Author: commy2
* Get display classnames from config with given idd.
*
* Arguments:
* 0: Display ID (idd) <NUMBER>
*
* Return Value:
* Display Classnames <ARRAY>
*
* Public: Yes
*
* Note: Really slow due to iteration through whole config. Meant for debugging.
*/
#include "script_component.hpp"
private ["_configName", "_index", "_config"];
params ["_idd"];
_configName = "";
private ["_configNames", "_config"];
_configNames = [];
for "_index" from 0 to (count configFile - 1) do {
_config = configFile select _index;
if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _this}) exitWith {
_configName = configName _config;
if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _idd}) then {
_configNames pushBack configName _config;
};
};
_configName
_configNames

View File

@ -1,19 +1,20 @@
/*
* Author: bux578
* Returns all turret indecies of door gunners.
*
* Gets the turret index of door gunners
* Arguments:
* 0: Vehicle <OBJECT>
*
* Argument:
* 0: Vehicle (Object)
* Return Value:
* All turret indecies of the Vehicle <ARRAY>
*
* Return value:
* Turret indexes of the door gunner. Empty array means no gunner position. (Array)
* Public: Yes
*/
#include "script_component.hpp"
private ["_turrets", "_doorTurrets", "_config"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_turrets", "_doorTurrets", "_config"];
_turrets = allTurrets [_vehicle, true];
@ -21,11 +22,13 @@ _doorTurrets = [];
{
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_config = [_config, _x] call FUNC(getTurretConfigPath);
if ((getNumber (_config >> "isCopilot") == 0) && count (getArray (_config >> "weapons")) > 0 ) then {
if (getNumber (_config >> "isCopilot" == 0) && {count getArray (_config >> "weapons") > 0}) then {
_doorTurrets pushBack _x;
};
} forEach _turrets;
false
} count _turrets;
_doorTurrets

View File

@ -1,23 +1,31 @@
/**
* fn_getFirstIntersection.sqf
* @Descr: Returns the the first intersection with an object between two positions
* @Author: Ruthberg
/*
* Author: Ruthberg
* Returns the the first intersection with terrain between two positions. @todo rewrite using lineIntersectsSurfaces?
*
* @Arguments: [position PositionASL, position PositionASL, accuracy FLOAT]
* @Return: [intersects BOOL, intersection PositionASL]
* @PublicAPI: true
* Arguments:
* 0: PositionASL <ARRAY>
* 1: PositionATL <ARRAY>
* 2: Accuracy <NUMBER>
*
* Return Value:
* 0: Intersects <BOOL>
* 1: Intersection Position ASL <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
#include "script_component.hpp"
private ["_distance", "_lower", "_upper", "_mid", "_intersections", "_result", "_dir"];
params ["_source", "_destination", "_accuracy"];
PARAMS_3(_source,_destination,_accuracy);
private ["_result", "_distance"];
_result = [false, [0, 0, 0]];
_distance = _source vectorDistance _destination;
if (count (lineIntersectsWith [_source, _destination]) > 0) then {
if !(lineIntersectsWith [_source, _destination] isEqualTo []) then {
private ["_lower", "_upper", "_mid", "_dir"];
_lower = 0;
_upper = 1;
_mid = 0.5;
@ -27,9 +35,7 @@ if (count (lineIntersectsWith [_source, _destination]) > 0) then {
while {(_upper - _lower) * _distance > _accuracy} do {
_mid = _lower + (_upper - _lower) / 2;
_intersections = count (lineIntersectsWith [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))]);
if (_intersections > 0) then {
if !(lineIntersectsWith [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))] isEqualTo []) then {
_upper = _mid;
} else {
_lower = _mid;

View File

@ -1,23 +1,31 @@
/**
* fn_getFirstIntersection.sqf
* @Descr: Returns the the first intersection with an object between two positions
* @Author: Ruthberg
/*
* Author: Ruthberg
* Returns the the first intersection with an object between two positions. @todo rewrite using lineIntersectsSurfaces?
*
* @Arguments: [position PositionASL, position PositionASL, accuracy FLOAT]
* @Return: [intersects BOOL, intersection PositionASL]
* @PublicAPI: true
* Arguments:
* 0: PositionASL <ARRAY>
* 1: PositionATL <ARRAY>
* 2: Accuracy <NUMBER>
*
* Return Value:
* 0: Intersects <BOOL>
* 1: Intersection Position ASL <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_distance", "_lower", "_upper", "_mid", "_intersection", "_result", "_dir"];
params ["_source", "_destination", "_accuracy"];
PARAMS_3(_source,_destination,_accuracy);
private ["_result", "_distance"];
_result = [false, [0, 0, 0]];
_distance = _source vectorDistance _destination;
if (terrainIntersectASL [_source, _destination]) then {
private ["_lower", "_upper", "_mid", "_dir"];
_lower = 0;
_upper = 1;
_mid = 0.5;
@ -27,9 +35,7 @@ if (terrainIntersectASL [_source, _destination]) then {
while {(_upper - _lower) * _distance > _accuracy} do {
_mid = _lower + (_upper - _lower) / 2;
_intersection = terrainIntersectASL [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))];
if (_intersection) then {
if (terrainIntersectASL [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))]) then {
_upper = _mid;
} else {
_lower = _mid;

View File

@ -1,25 +1,23 @@
/*
Name: FUNC(getForceWalkStatus)
Author: Pabst Mirror (from captivity by commy2)
Description:
Returns reasons why the unit is forceWalk-ing, empty if not forced.
Parameters:
0: OBJECT - Unit
Returns:
ARRAY(of strings) - Reason why the unit is force walking
Example:
[ACE_Player] call FUNC(getForceWalkStatus)
*/
* Author: PabstMirror, commy2
* Returns reasons why the unit is forceWalk-ing.
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* Force Walk reasons <ARRAY>
*
* Example:
* [ACE_Player] call ace_common_fnc_getForceWalkStatus
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"];
params ["_unit"];
PARAMS_1(_unit);
private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"];
_forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
@ -28,6 +26,7 @@ _unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0];
_unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber);
_unitForceWalkReasons = [];
{
if (_unitForceWalkStatus select _forEachIndex) then {
_unitForceWalkReasons pushBack _x;

View File

@ -1,20 +1,19 @@
/*
* Author: commy2
* Returns gunner using specified weapon type in vehicle. Only works if all turrets have different weapons.
*
* Get the gunner of a vehicle who uses the given weapon type. Requires every turret to have a different weapon.
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Weapon <STRING>
*
* Argument:
* 0: The vehicle (Object)
* 1: weapon of the vehicle (String)
* Return Value:
* Gunner <OBJECT>
*
* Return value:
* The turret gunner with this weapon (Object)
* Public: Yes
*/
#include "script_component.hpp"
private ["_vehicle", "_weapon"];
_vehicle = _this select 0;
_weapon = _this select 1;
params ["_vehicle", "_weapon"];
// on foot
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLower _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle};
@ -27,11 +26,12 @@ _gunner = objNull;
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
_gunner = _vehicle turretUnit _x;
};
} forEach allTurrets [_vehicle, true];
false
} count allTurrets [_vehicle, true];
// ensure that at least the pilot is returned if there is no gunner
if (isManualFire _vehicle && {isNull _gunner}) then {
_gunner = driver _vehicle;
_gunner = driver _vehicle;
};
_gunner
_gunner

View File

@ -1,56 +1,21 @@
/*
* Author: commy2
*
* Returns all hitpoints of any vehicle. Non unique hitpoints in turrets are ignored.
* Returns all hitpoints and their selections of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
* 0: Vehicle <OBJECT>
*
* Return Value:
* The hitpoints (Array)
* Hitpoints <ARRAY>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
private ["_config", "_hitpoints", "_i"];
ACE_DEPRECATED("ace_common_fnc_getHitPoints","3.5.0","getAllHitPointsDamage");
PARAMS_1(_vehicle);
params ["_vehicle"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_hitpoints = [];
// get all classes that can contain hitpoints
private "_hitpointClasses";
_hitpointClasses = [_config >> "HitPoints"];
{
private "_class";
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
if (isClass _class) then {
_hitpointClasses pushBack _class;
};
} forEach allTurrets _vehicle;
// iterate through all classes with hitpoints and their parents
{
private "_class";
_class = _x;
while {isClass _class} do {
for "_i" from 0 to (count _class - 1) do {
private "_entry";
_entry = configName (_class select _i);
if (!(_entry in _hitpoints) && {!isNil {_vehicle getHitPointDamage _entry}}) then {
_hitpoints pushBack _entry;
};
};
_class = inheritsFrom _class;
};
} forEach _hitpointClasses;
_hitpoints
(getAllHitPointsDamage _vehicle select 0) - [""]

View File

@ -1,61 +1,27 @@
/*
* Author: commy2
*
* Returns all hitpoints and their selections of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
* Returns all hitpoints and their respective selections of any vehicle. Might contain duplicates for non unique hitpoints in turrets.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
* 0: Vehicle <OBJECT>
*
* Return Value:
* The hitpoints with selections. Format: [hitpoints, selections]. They correspond by index. (Array)
* 0: Hitpoints <ARRAY>
* 1: Selections <ARRAY>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
private ["_config", "_hitpoints", "_selections", "_i"];
ACE_DEPRECATED("ace_common_fnc_getHitPointsWithSelections","3.5.0","getAllHitPointsDamage");
PARAMS_1(_vehicle);
params ["_vehicle"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private "_hitPointsWithSelections";
_hitPointsWithSelections = getAllHitPointsDamage _vehicle;
_hitpoints = [];
_selections = [];
_hitPointsWithSelections resize 2;
// get all classes that can contain hitpoints
private "_hitpointClasses";
_hitpointClasses = [_config >> "HitPoints"];
{
private "_class";
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
if (isClass _class) then {
_hitpointClasses pushBack _class;
};
} forEach allTurrets _vehicle;
// iterate through all classes with hitpoints and their parents
{
private "_class";
_class = _x;
while {isClass _class} do {
for "_i" from 0 to (count _class - 1) do {
if (isClass (_class select _i)) then {
private ["_entry", "_selection"];
_entry = configName (_class select _i);
_selection = getText (_class select _i >> "name");
if (!(_selection in _selections) && {!isNil {_vehicle getHit _selection}}) then {
_hitpoints pushBack _entry;
_selections pushBack _selection;
};
};
};
_class = inheritsFrom _class;
};
} forEach _hitpointClasses;
[_hitpoints, _selections]
_hitPointsWithSelections

View File

@ -1,31 +1,26 @@
/*
* Author: commy2
* Move unit into given vehicle position or switch to that position if the unit is already inside the vehicle.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
* 2: Position ("Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver", "Cargo") <STRING>
* 3: Index (only applies to "Turret", "FFV", "Codriver", "Cargo") (default: next free index) <NUMBER>
*
* Return Value:
* None
*
* Move unit into given vehicle position. Or switch to that position if the unit is already inside the vehicle.
*
* Arguments:
* 0: Unit to enter the vehicle (Object)
* 1: The vehicle to be entered (Object)
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" (String)
* 3: Index. "Turret", "FFV", "Codriver" and "Cargo" support this optional parameter. Which position should be taken.
* Note: This index is diffrent from Armas "cargoIndex". (Number, optional default: next free index)
*
* Return Value:
* Nothing
* Public: Yes
*/
#include "script_component.hpp"
#define CANGETINDRIVER (isNull (driver _vehicle) || {!alive driver _vehicle}) && {!lockedDriver _vehicle} && {getNumber (_config >> "isUav") != 1}
#define CANGETINTURRETINDEX (isNull (_vehicle turretUnit _turret) || {!alive (_vehicle turretUnit _turret)}) && {!(_vehicle lockedTurret _turret)} && {getNumber (_config >> "isUav") != 1}
private ["_position", "_index"];
params ["_unit", "_vehicle", "_position", ["_index", -1]];
PARAMS_2(_unit,_vehicle);
_position = toLower (_this select 2);
_index = _this select 3; // optional, please don't use
if (isNil "_index") then {_index = -1};
_position = toLower _position;
// general
if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false};
@ -39,27 +34,29 @@ _isInside = vehicle _unit == _vehicle;
_script = {};
_enemiesInVehicle = false; //Possible Side Restriction
{
if (side _unit getFriend side _x < 0.6) exitWith {_enemiesInVehicle = true};
} forEach crew _vehicle;
false
} count crew _vehicle;
switch (_position) do {
case "driver" : {
if (CANGETINDRIVER) then {
_script = [
{_unit action [["GetInDriver", "MoveToDriver"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
_script = [
{_unit action [["GetInDriver", "MoveToDriver"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
};
};
case "pilot" : {
if (CANGETINDRIVER) then {
_script = [
{_unit action [["GetInPilot", "MoveToPilot"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "driver";
_script = [
{_unit action [["GetInPilot", "MoveToPilot"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "driver";
};
};
@ -67,10 +64,10 @@ switch (_position) do {
_turret = [_vehicle] call FUNC(getTurretGunner);
if (CANGETINTURRETINDEX) then {
_script = [
{_unit action [["GetInGunner", "MoveToGunner"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInGunner _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
_script = [
{_unit action [["GetInGunner", "MoveToGunner"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInGunner _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
};
};
@ -78,10 +75,10 @@ switch (_position) do {
_turret = [_vehicle] call FUNC(getTurretCommander);
if (CANGETINTURRETINDEX) then {
_script = [
{_unit action [["GetInCommander", "MoveToCommander"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInCommander _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
_script = [
{_unit action [["GetInCommander", "MoveToCommander"] select _isInside, _vehicle];},
{if (_isInside) then {moveOut _unit}; _unit moveInCommander _vehicle; call _fnc_getInEH;}
] select _enemiesInVehicle;
};
};
@ -89,12 +86,12 @@ switch (_position) do {
_turret = [_vehicle] call FUNC(getTurretCopilot);
if (CANGETINTURRETINDEX) then {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner"
_position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner"
};
};
@ -104,8 +101,8 @@ switch (_position) do {
if (_index != -1 && {_turret = _turrets select _index; CANGETINTURRETINDEX}) then {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "gunner";
@ -114,13 +111,13 @@ switch (_position) do {
_turret = _turrets select _index;
if (CANGETINTURRETINDEX) exitWith {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "gunner";
};
};
};
};
};
@ -130,22 +127,22 @@ switch (_position) do {
if (_index != -1 && {_turret = _turrets select _index; CANGETINTURRETINDEX}) then {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner"
} else {
for "_index" from 0 to (count _turrets - 1) do {
_turret = _turrets select _index;
if (CANGETINTURRETINDEX) exitWith {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_turret = _turrets select _index;
if (CANGETINTURRETINDEX) exitWith {
_script = [
{_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];},
{if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner"
};
_position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner"
};
};
};
};
@ -160,8 +157,8 @@ switch (_position) do {
if (_index != -1 && {_index in _positions}) then {
_script = [
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "cargo";
@ -169,8 +166,8 @@ switch (_position) do {
_index = _positions select 0;
if (!isNil "_index") then {
_script = [
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "cargo";
@ -188,8 +185,8 @@ switch (_position) do {
if (_index != -1 && {_index in _positions}) then {
_script = [
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "cargo";
@ -197,8 +194,8 @@ switch (_position) do {
_index = _positions select 0;
if (!isNil "_index") then {
_script = [
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
{_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];},
{if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;}
] select _enemiesInVehicle;
_position = "cargo";

View File

@ -1,83 +1,88 @@
/*
* Author: commy2
* Returns item type of given classname.
*
* What kind of item is given classname
* Arguments:
* 0: Item <STRING>
*
* Argument:
* 0: Classname of a item. (String)
*
* Return value:
* Item type. (Array)
* 0: "weapon", "item", "magazine" or "" (String)
* 1: A description of the item (e.g. "primary" for a weapon or "vest" for a vest item)
* Return Value:
* 0: Type ("weapon", "item", "magazine", "") <STRING>
* 1: Item Description <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_item);
params ["_item"];
private ["_cfgType"];
private ["_cfgType", "_config", "_type", "_simulation", "_default"];
_cfgType = [_item] call FUNC(getConfigType);
if (_cfgType == "") exitWith {["",""]};
if (_cfgType == "") exitWith {["", ""]};
if (_cfgType == "CfgGlasses") exitWith {["item","glasses"]};
private ["_config", "_type"];
if (_cfgType == "CfgGlasses") exitWith {["item", "glasses"]};
_config = configFile >> _cfgType >> _item;
_type = getNumber (_config >> "type");
_simulation = getText (_config >> "simulation");
if (isNumber (_config >> "ItemInfo" >> "type")) then {
_type = getNumber (_config >> "ItemInfo" >> "type");
};
private "_default";
_default = ["item", "magazine"] select (_cfgType == "CfgMagazines");
switch (true) do {
case (_type == 0): {[_default,"unknown"]};
case (_type == 2^0): {["weapon","primary"]};
case (_type == 2^1): {["weapon","handgun"]};
case (_type == 2^2): {["weapon","secondary"]};
case (_type < 2^4): {["weapon","unknown"]};
case (_type == 2^4): {["magazine","handgun"]}; // handgun
case (_type == 2^8): {["magazine","primary"]}; // rifle
case (_type == 2^9): {["magazine","secondary"]}; // rpg, mg, mines
//case (_type < 2^11): {["magazine","unknown"]};
case (_type == 0): {[_default, "unknown"]};
case (_type == 2^0): {["weapon", "primary"]};
case (_type == 2^1): {["weapon", "handgun"]};
case (_type == 2^2): {["weapon", "secondary"]};
case (_type < 2^4): {["weapon", "unknown"]};
case (_type == 2^4): {["magazine", "handgun"]}; // handgun
case (_type == 2^8): {["magazine", "primary"]}; // rifle
case (_type == 2^9): {["magazine", "secondary"]}; // rpg, mg, mines
//case (_type < 2^11): {["magazine", "unknown"]};
case (_type == 101): {["item","muzzle"]};
case (_type == 201): {["item","optics"]};
case (_type == 301): {["item","flashlight"]};
case (_type == 302): {["item","under"]}; // czech for bipod item
case (_type == 401): {["item","first_aid_kit"]};
case (_type == 501): {["item","fins"]}; // not implemented
case (_type == 601): {["item","breathing_bomb"]}; // not implemented
case (_type == 603): {["item","goggles"]};
case (_type == 604): {["item","scuba"]}; // not implemented
case (_type == 605): {["item","headgear"]};
case (_type == 611): {["item","radio"]};
case (_type == 616): {["item","hmd"]};
case (_type == 617): {["item","binocular"]};
case (_type == 619): {["item","medikit"]};
case (_type == 620): {["item","toolkit"]};
case (_type == 621): {["item","uav_terminal"]};
case (_type == 701): {["item","vest"]};
case (_type == 801): {["item","uniform"]};
case (_type == 101): {["item", "muzzle"]};
case (_type == 201): {["item", "optics"]};
case (_type == 301): {["item", "flashlight"]};
case (_type == 302): {["item", "under"]}; // czech for bipod item
case (_type == 401): {["item", "first_aid_kit"]};
case (_type == 501): {["item", "fins"]}; // not implemented
case (_type == 601): {["item", "breathing_bomb"]}; // not implemented
case (_type == 603): {["item", "goggles"]};
case (_type == 604): {["item", "scuba"]}; // not implemented
case (_type == 605): {["item", "headgear"]};
case (_type == 611): {["item", "radio"]};
case (_type == 616): {["item", "hmd"]};
case (_type == 617): {["item", "binocular"]};
case (_type == 619): {["item", "medikit"]};
case (_type == 620): {["item", "toolkit"]};
case (_type == 621): {["item", "uav_terminal"]};
case (_type == 701): {["item", "vest"]};
case (_type == 801): {["item", "uniform"]};
case (_type == 2^12): {
switch (toLower getText (_config >> "simulation")) do {
case ("weapon"): {["weapon","binocular"]};
case ("binocular"): {["weapon","binocular"]};
case ("nvgoggles"): {["item","nvgoggles"]};
case ("itemminedetector"): {["item","minedetector"]};
default {[_default,"unknown"]};
switch (toLower _simulation) do {
case ("weapon"): {["weapon", "binocular"]};
case ("binocular"): {["weapon", "binocular"]};
case ("nvgoggles"): {["item", "nvgoggles"]};
case ("itemminedetector"): {["item", "minedetector"]};
default {[_default, "unknown"]};
};
};
case (_type == 2^16): {["weapon","vehicle"]};
case (_type == 2^17): {[_default,"unknown"]}; // ???
default {[_default,"unknown"]};
case (_type == 2^16): {["weapon", "vehicle"]};
case (_type == 2^17): {
switch (toLower _simulation) do {
case ("itemmap"): {["item", "map"]};
case ("itemgps"): {["item", "gps"]};
case ("itemradio"): {["item", "radio"]};
case ("itemcompass"): {["item", "compass"]};
case ("itemwatch"): {["item", "watch"]};
default {[_default, "unknown"]};
};
};
default {[_default, "unknown"]};
};

View File

@ -3,22 +3,26 @@
* Read properties of given vehicles light.
*
* Arguments:
* 0: Object with lights (Object)
* 1: Light classname (String)
* 0: Object with lights <OBJECT>
* 1: Light classname <STRING>
*
* Return Value:
* Stuff from config (Array)
* 0: Light intensity <NUMBER>
* 1: Light position <STRING>
* 2: Light direction <STRING>
* 3: Light inner angle <NUMBER>
* 4: Light outer angle <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_vehicle,_light);
params ["_vehicle", "_light"];
private ["_config", "_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
private "_config";
_config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "Reflectors" >> _light;
private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
_intensity = getNumber (_config >> "intensity");
_position = getText (_config >> "position");
_direction = getText (_config >> "direction");
@ -26,35 +30,3 @@ _innerAngle = getNumber (_config >> "innerAngle");
_outerAngle = getNumber (_config >> "outerAngle");
[_intensity, _position, _direction, _innerAngle, _outerAngle]
/*
class Reflectors
{
class Light_1
{
color[] = {1000,1000,1100};
ambient[] = {10,10,11};
intensity = 5;
size = 1;
innerAngle = 90;
outerAngle = 130;
coneFadeCoef = 2;
position = "Light_1_pos";
direction = "Light_1_dir";
hitpoint = "Light_1_hitpoint";
selection = "Light_1_hide";
useFlare = 1;
flareSize = 0.9;
flareMaxDistance = 85;
class Attenuation
{
start = 0;
constant = 0;
linear = 0;
quadratic = 0.9;
hardLimitStart = 40;
hardLimitEnd = 60;
};
};
};
*/

View File

@ -1,23 +1,29 @@
/*
* Author: commy2
* Read properties of given flashlight. @todo, Can weapons themselves still have flashlights (no attachment)?
* Read properties of given flashlight.
*
* Arguments:
* 0: A flashlight (String)
* 0: Flashlight <STRING>
*
* Return Value:
* Stuff from config (Array)
* 0: Light intensity <NUMBER>
* 1: Light position <STRING>
* 2: Light direction <STRING>
* 3: Light inner angle <NUMBER>
* 4: Light outer angle <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_weapon);
params ["_weapon"];
// @todo: Can weapons themselves still have flashlights (no attachment)?
private ["_config", "_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
private "_config";
_config = configFile >> "CfgWeapons" >> _weapon >> "ItemInfo" >> "FlashLight";
private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
_intensity = getNumber (_config >> "intensity");
_position = getText (_config >> "position");
_direction = getText (_config >> "direction");
@ -25,32 +31,3 @@ _innerAngle = getNumber (_config >> "innerAngle");
_outerAngle = getNumber (_config >> "outerAngle");
[_intensity, _position, _direction, _innerAngle, _outerAngle]
/*
class FlashLight
{
color[] = {180,156,120};
ambient[] = {0.9,0.78,0.6};
intensity = 20;
size = 1;
innerAngle = 20;
outerAngle = 80;
coneFadeCoef = 5;
position = "flash dir";
direction = "flash";
useFlare = 1;
flareSize = 1.4;
flareMaxDistance = "100.0f";
dayLight = 0;
class Attenuation
{
start = 0.5;
constant = 0;
linear = 0;
quadratic = 1.1;
hardLimitStart = 20;
hardLimitEnd = 30;
};
scale[] = {0};
};
*/

View File

@ -1,28 +1,28 @@
/*
* Author: VKing
* Gets the current map's MGRS grid zone designator and 100km square.
* Also gets longitude, latitude and altitude offset for the map
* Also gets longitude, latitude and altitude offset for the map.
* Writes return values to GVAR(MGRS_data) if run on the current map.
*
* Argument:
* 0: Optional: Map name, if undefined the current map is used (String)
* 0: Map name (default: worldName) <STRING>
*
* Return value:
* 0: Grid zone designator (String)
* 1: 100km square (String)
* 2: GZD + 100km sq. as a single string (String)
* Writes return values to GVAR(MGRS_data) if run on the current map
* Return Value:
* 0: Grid zone designator <STRING>
* 1: 100km square <STRING>
* 2: GZD + 100km sq. as a single string <STRING>
*
* Public: No
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"
private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing", "_altitude"];
params [["_map", worldName]];
DEFAULT_PARAM(0,_map,worldName);
private ["_long", "_lat", "_altitude", "_UTM", "_easting", "_northing", "_zone", "_band", "_GZD"];
_long = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "longitude");
_lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude");
_altitude = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "elevationOffset");
_long = getNumber (configFile >> "CfgWorlds" >> _map >> "longitude");
_lat = getNumber (configFile >> "CfgWorlds" >> _map >> "latitude");
_altitude = getNumber (configFile >> "CfgWorlds" >> _map >> "elevationOffset");
if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; _altitude = 0; };
if (_map in ["Altis", "Stratis"]) then { _lat = 40; _altitude = 0; };
@ -46,11 +46,10 @@ if (_map in ["lingor"]) then { _lat = -4; _altitude = 0; };
if (_map in ["Panthera3"]) then { _lat = 46; _altitude = 0; };
if (_map in ["Kunduz"]) then { _lat = 37; _altitude = 400; };
_UTM = [_long,_lat] call BIS_fnc_posDegToUTM;
_easting = _UTM select 0;
_northing = _UTM select 1;
// _zone = _UTM select 2;
//_zone = _UTM select 2;
TRACE_4("",_UTM,_easting,_northing,_zone);
/*
@ -76,9 +75,11 @@ _band = switch (true) do {
case (_lat>8): {"P"};
case (_lat>=0): {"N"};
};
*/
*/
_zone = 1 + (floor ((_long + 180) / 6));
_band = "Z";
if (_lat <= -80) then {
_band = "A";
} else {
@ -86,13 +87,13 @@ if (_lat <= -80) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1];
};
};
if (_map == "VR") then {_zone = 0; _band = "RV";};
_GZD = format ["%1%2",_zone,_band];
TRACE_3("",_zone,_band,_GZD);
private ["_set1","_set2","_set3","_set4","_set5","_set6","_metaE","_metaN","_letterE","_letterN","_grid100km"];
private ["_set1", "_set2", "_set3", "_set4", "_set5", "_set6", "_metaE", "_metaN", "_letterE", "_letterN", "_grid100km"];
_set1 = [1,7,13,19,25,31,37,43,49,55];
_set2 = [2,8,14,20,26,32,38,44,50,56];
@ -102,25 +103,25 @@ _set5 = [5,11,17,23,29,35,41,47,53,59];
_set6 = [6,12,18,24,30,36,42,48,54,60];
switch (true) do {
case (_zone in _set1): {_metaE = 1; _metaN = 1;};
case (_zone in _set2): {_metaE = 2; _metaN = 2;};
case (_zone in _set3): {_metaE = 3; _metaN = 1;};
case (_zone in _set4): {_metaE = 1; _metaN = 2;};
case (_zone in _set5): {_metaE = 2; _metaN = 1;};
case (_zone in _set6): {_metaE = 3; _metaN = 2;};
case (_zone in _set1): {_metaE = 1; _metaN = 1;};
case (_zone in _set2): {_metaE = 2; _metaN = 2;};
case (_zone in _set3): {_metaE = 3; _metaN = 1;};
case (_zone in _set4): {_metaE = 1; _metaN = 2;};
case (_zone in _set5): {_metaE = 2; _metaN = 1;};
case (_zone in _set6): {_metaE = 3; _metaN = 2;};
};
TRACE_2("",_metaE,_metaN);
switch (true) do {
case (_zone == 0): {_letterE = "E"};
case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; };
case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; };
case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; };
case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; };
case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; };
case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; };
case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; };
case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; };
case (_zone == 0): {_letterE = "E"};
case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; };
case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; };
case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; };
case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; };
case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; };
case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; };
case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; };
case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; };
default {_letterE="@"};
};
TRACE_1("",_letterE);
@ -129,37 +130,38 @@ _northing = _northing mod 2000000;
TRACE_1("",_northing);
switch (true) do {
case (_zone == 0): {_letterN = "N"};
case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; };
case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; };
case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; };
case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; };
case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; };
case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; };
case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; };
case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; };
case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; };
case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; };
case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; };
case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; };
case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; };
case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; };
case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; };
case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; };
case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; };
case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; };
case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; };
case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; };
case (_zone == 0): {_letterN = "N"};
case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; };
case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; };
case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; };
case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; };
case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; };
case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; };
case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; };
case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; };
case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; };
case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; };
case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; };
case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; };
case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; };
case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; };
case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; };
case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; };
case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; };
case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; };
case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; };
case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; };
};
TRACE_1("",_letterN);
_grid100km = _letterE+_letterN;
_grid100km = _letterE + _letterN;
TRACE_1("",_grid100km);
if (_map == worldName) then {
GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km];
GVAR(MGRS_data) = [_GZD, _grid100km, _GZD + _grid100km];
GVAR(mapAltitude) = _altitude;
GVAR(mapLatitude) = _lat;
GVAR(mapLongitude) = _long;
};
[_GZD,_grid100km,_GZD+_grid100km]
[_GZD, _grid100km, _GZD + _grid100km]

View File

@ -1,12 +1,13 @@
/*
* Author: PabstMirror (ideas from Nou's mapGridToPos and BIS_fnc_gridToPos)
* Author: PabstMirror
* Finds real x/y offset and map step for a 10 digit grid
* Save time by preparing data one time at startup
* Ideas from Nou's mapGridToPos and BIS_fnc_gridToPos
*
* Argument:
* Arguments:
* None
*
* Return values:
* Return Value:
* None
*
* Example:
@ -16,10 +17,10 @@
*/
#include "script_component.hpp"
private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"];
GVAR(mapGridData) = [];
private ["_cfgGrid", "_offsetX", "_offsetY", "_zoomMax", "_formatX", "_formatY", "_stepX", "_stepY", "_zoom", "_letterGrid", "_heightOffset", "_startGrid", "_originGrid", "_realOffsetY"];
//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos)
_cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid";
_offsetX = getNumber (_cfgGrid >> "offsetX");
@ -29,6 +30,7 @@ _formatX = "";
_formatY = "";
_stepX = 1e10;
_stepY = 1e10;
{
_zoom = getnumber (_x >> "zoomMax");
if (_zoom < _zoomMax) then {
@ -38,11 +40,14 @@ _stepY = 1e10;
_stepX = getNumber (_x >> "stepX");
_stepY = getNumber (_x >> "stepY");
};
} foreach configProperties [_cfgGrid, "isClass _x", false];
false
} count configProperties [_cfgGrid, "isClass _x", false];
_letterGrid = false;
if (((toLower _formatX) find "a") != -1) then {_letterGrid = true};
if (((toLower _formatY) find "a") != -1) then {_letterGrid = true};
if (toLower _formatX find "a" != -1) then {_letterGrid = true};
if (toLower _formatY find "a" != -1) then {_letterGrid = true};
if (_letterGrid) exitWith {
ACE_LOGWARNING_3("Map Grid Warning (%1) - Map uses letter grids [%2, %3]",worldName,_formatX,_formatY);
};
@ -51,13 +56,14 @@ if (_letterGrid) exitWith {
_heightOffset = 500;
_startGrid = mapGridPosition [0, _heightOffset];
_originGrid = _startGrid;
while {_startGrid == _originGrid} do {
_heightOffset = _heightOffset + 1;
_originGrid = mapGridPosition [0, _heightOffset];
};
//Calculate the real y offset
_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1;
_realOffsetY = (parseNumber (_originGrid select [count _formatX, count _formatY])) * _stepY + _heightOffset - 1;
//Calculate MGRS 10digit step - they should both be 1 meter:
_stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
@ -66,10 +72,12 @@ _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
if (_stepYat5 < 0) then {
ACE_LOGWARNING_1("Map Grid Warning (%1) - Northing is reversed.",worldName);
};
if (_stepXat5 != 1) then {
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x.",worldName,_stepXat5);
};
if ((_stepYat5 != 1) && {_stepYat5 != -1}) then {
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y.",worldName,_stepXat5);
};

View File

@ -2,57 +2,58 @@
* Author: VKing, PabstMirror
* Gets a 10-digit map grid for the given world position
*
* Argument:
* Arguments:
* 0: Position (2D Position) <ARRAY>
* 1: Return type; false for array of easting and northing, true for single string <Bool>
* 1: Return type; false for array of easting and northing, true for single string (default: false) <BOOL>
*
* Return values:
* Return Value:
* 0: Easting <String>
* 1: Northing <String>
*
* Example:
* [(getPos player)] call ace_common_fnc_getMapGridFromPos;
* [getPos player] call ace_common_fnc_getMapGridFromPos
*
* Public: Yes
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_pos);
DEFAULT_PARAM(1,_returnSingleString,false);
params ["_pos", ["_returnSingleString", false]];
private["_count", "_easting", "_nativeGrid", "_northing"];
private ["_nativeGrid", "_count", "_easting", "_northing"];
//Fallback, when map data is weird (letters)
if ((count GVAR(mapGridData)) == 0) exitWith {
if (GVAR(mapGridData) isEqualTo []) exitWith {
_nativeGrid = mapGridPosition _pos;
if (_returnSingleString) then {
_nativeGrid
} else {
_count = floor ((count _nativeGrid) / 2);
[(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])]
[_nativeGrid select [0, _count], _nativeGrid select [_count, _count]]
};
};
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
GVAR(mapGridData) params ["_offsetX", "_realOffsetY", "_stepXat5", "_stepYat5"];
_easting = floor (((_pos select 0) - _offsetX) / _stepXat5);
_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5);
//Attempt to handle negative east/north (e.g.: moving west of map bounds)
if (_easting > 0) then {
_easting = str _easting;
while {count _easting < 5} do {_easting = "0" + _easting;};
while {count _easting < 5} do {_easting = "0" + _easting};
} else {
_easting = str abs _easting;
while {count _easting < 4} do {_easting = "0" + _easting;};
while {count _easting < 4} do {_easting = "0" + _easting};
_easting = "-" + _easting;
};
if (_northing > 0) then {
_northing = str _northing;
while {count _northing < 5} do {_northing = "0" + _northing;};
while {count _northing < 5} do {_northing = "0" + _northing};
} else {
_northing = str abs _northing;
while {count _northing < 4} do {_northing = "0" + _northing;};
while {count _northing < 4} do {_northing = "0" + _northing};
_northing = "-" + _northing;
};
@ -60,4 +61,4 @@ if (_returnSingleString) then {
_easting + _northing
} else {
[_easting, _northing]
};
}; // return

View File

@ -2,9 +2,9 @@
* Author: PabstMirror
* Gets position from grid cords
*
* Argument:
* Arguments:
* 0: Grid Cords <STRING>
* 1: Get Center or bottom right <BOOL><OPTIONAL>
* 1: Grid center (true), Grid Bottom Right (false) (default: true) <BOOL>
*
* Return values:
* Position <ARRAY>
@ -16,24 +16,23 @@
*/
#include "script_component.hpp"
PARAMS_1(_inputString);
DEFAULT_PARAM(1,_getCenterOfGrid,true);
params ["_inputString", ["_getCenterOfGrid", true]];
private["_countInput", "_countInputHalf", "_xPart", "_xPos", "_yPart", "_yPos"];
if ((count GVAR(mapGridData)) == 0) exitWith {
if (count GVAR(mapGridData) == 0) exitWith {
ERROR("Map has bad data, falling back to BIS_fnc_gridToPos");
(_this call BIS_fnc_gridToPos) select 0
};
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
GVAR(mapGridData) params ["_offsetX", "_realOffsetY", "_stepXat5", "_stepYat5"];
private ["_countInput", "_countInputHalf", "_xPart", "_yPart", "_xPos", "_yPos"];
_countInput = count _inputString;
_countInputHalf = floor (_countInput / 2);
//Split string, ignoring middle
_xPart = _inputString select [0, _countInputHalf];
_yPart = _inputString select [(ceil (_countInput / 2)), _countInputHalf];
_yPart = _inputString select [ceil (_countInput / 2), _countInputHalf];
_xPos = ((parseNumber _xPart) * _stepXat5 * 10 ^ (5 - _countInputHalf)) + _offsetX;
_yPos = ((parseNumber _yPart) * _stepYat5 * 10 ^ (5 - _countInputHalf)) + _realOffsetY;
@ -43,4 +42,4 @@ if (_getCenterOfGrid) then {
_yPos = _yPos + 0.5 * _stepYat5 * 10 ^ (5 - _countInputHalf);
};
[_xPos, _yPos, 0];
[_xPos, _yPos, 0]

View File

@ -1,19 +1,20 @@
/*
* Author: KoffeinFlummi
*
* Get the apropriate marker for a group.
*
* Arguments:
* 0: Group
*
* Return Value:
* Marker Type (string)
* Marker Type <STRING>
*
* Public: No
*/
#include "script_component.hpp"
private ["_leader","_vehicle","_side"];
params ["_group"];
PARAMS_1(_group);
private ["_leader", "_vehicle", "_side"];
_leader = leader _group;
_vehicle = vehicle _leader;
@ -21,56 +22,61 @@ _side = side _leader;
if (_vehicle == _leader) exitWith {
if (
(getNumber (configFile >> "CfgVehicles" >> (typeOf _leader) >> "detectSkill") > 20) or
(getNumber (configFile >> "CfgVehicles" >> (typeOf _leader) >> "camouflage") < 1) or
(getText (configFile >> "CfgVehicles" >> (typeOf _leader) >> "textsingular") == "diver")
) then {
["n_recon", "b_recon", "o_recon"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
getNumber (configFile >> "CfgVehicles" >> typeOf _leader >> "detectSkill") > 20 ||
getNumber (configFile >> "CfgVehicles" >> typeOf _leader >> "camouflage") < 1 ||
getText (configFile >> "CfgVehicles" >> typeOf _leader >> "textsingular") == "diver"
) then {
["n_recon", "b_recon", "o_recon"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
} else {
["n_inf", "b_inf", "o_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_inf", "b_inf", "o_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
};
if (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "attendant") == 1) exitWith {
["n_med", "b_med", "o_med"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant") == 1) exitWith {
["n_med", "b_med", "o_med"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportRepair") > 0) or
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportFuel") > 0) or
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportAmmo") > 0) or
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "ACE_canRepair") > 0) or
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "ACE_fuelCapacityCargo") > 0)
) exitWith {
["n_maint", "b_maint", "o_maint"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportRepair") > 0 ||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportFuel") > 0 ||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportAmmo") > 0 ||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "ACE_canRepair") > 0 ||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "ACE_fuelCapacityCargo") > 0
) exitWith {
["n_maint", "b_maint", "o_maint"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (_vehicle isKindOf "Plane") exitWith {
["n_plane", "b_plane", "o_plane"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_plane", "b_plane", "o_plane"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (_vehicle isKindOf "Air") exitWith {
["n_air", "b_air", "o_air"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_air", "b_air", "o_air"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (_vehicle isKindOf "StaticMortar") exitWith {
["n_mortar", "b_mortar", "o_mortar"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_mortar", "b_mortar", "o_mortar"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "artilleryScanner") == 1) exitWith {
["n_art", "b_art", "o_art"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "artilleryScanner") == 1) exitWith {
["n_art", "b_art", "o_art"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (_vehicle isKindOf "Car") exitWith {
["n_motor_inf", "b_motor_inf", "o_motor_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
};
if ((_vehicle isKindOf "Tank") and (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportSoldier") > 0)) exitWith {
["n_mech_inf", "b_mech_inf", "o_mech_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_motor_inf", "b_motor_inf", "o_motor_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
if (_vehicle isKindOf "Tank") exitWith {
["n_armor", "b_armor", "o_armor"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportSoldier") > 0) then {
["n_mech_inf", "b_mech_inf", "o_mech_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
} else {
["n_armor", "b_armor", "o_armor"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
};
if (_vehicle isKindOf "Ship") exitWith {
["n_naval", "b_naval", "o_naval"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_naval", "b_naval", "o_naval"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
};
// generic marker
["n_unknown", "b_unknown", "o_unknown"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
["n_unknown", "b_unknown", "o_unknown"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)

View File

@ -1,25 +1,21 @@
/*
* Author: commy2
*
* Returns the name of the object. Used to prevent issues with the name command.
*
* Argument:
* 0: Object (Object)
* 1: Show effective commander name? (Bool, optinal default: false)
* Arguments:
* 0: Object <OBJECT>
* 1: Use effective commander name when used on vehicles (default: false) <BOOL>
*
* Return value:
* The name.
* Return Value:
* Object Name <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_name"];
PARAMS_2(_unit,_showEffective);
if (isNil "_showEffective") then {
_showEffective = false;
};
params ["_unit", ["_showEffective", false]];
private "_name";
_name = "";
if (_unit isKindOf "CAManBase") then {

View File

@ -1,18 +1,16 @@
/*
* Author: commy2
*
* Get a number from the mission.sqm file. Mission has to be saved in the Editor.
* On non-existing entries, it might return 0 or the value of an entry with the same name of another calss.
*
* Argument:
* 0: Path of the entry in the mission.sqm (Array)
* Arguments:
* 0: Path of the entry in the mission.sqm <ARRAY>
*
* Return value:
* Value of the entry. Note: If the entry does not exist, it might return 0 or an entry with the same name of another class! (Number)
* Return Value:
* Entry value <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
private "_number";
_number = _this call FUNC(getStringFromMissionSQM);
parseNumber _number;
parseNumber (_this call FUNC(getStringFromMissionSQM)) // return

View File

@ -1,26 +1,30 @@
/**
* fn_getNumberMagazinesIn.sqf
* @Descr:
* @Author: Glowbal
/*
* Author: Glowbal
* Count magazines of unit.
*
* @Arguments: []
* @Return:
* @PublicAPI: true
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
*
* Return Value:
* Magazine amount <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_magazine);
private ["_return"];
params ["_unit", "_magazine"];
private "_return";
_return = 0;
if (_unit isKindOf "CAManBase") then {
_return = {_x == _magazine} count magazines _unit;
} else {
{
_return = _return + {_x == _magazine} count magazines _x;
} forEach (crew _unit);
false
} count crew _unit;
_return = _return + ({_x == _magazine} count getMagazineCargo _unit);
};

View File

@ -1,14 +1,19 @@
/*
* Author: KoffeinFlummi
*
* Returns [pitch, bank, yaw] for given vehicle in degrees.
* Returns pitch, bank, yaw for given vehicle in degrees.
*
* Arguments:
* 0: Unit/Vehicle
* 0: Unit/Vehicle <OBJECT>
*
* Return Value:
* [pitch, bank, yaw]
* 0: pitch <NUMBER>
* 1: bank <NUMBER>
* 2: yaw <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
((_this select 0) call BIS_fnc_getPitchBank) + [getDir (_this select 0)]
params ["_vehicle"];
(_vehicle call BIS_fnc_getPitchBank) + [getDir _vehicle]

View File

@ -6,16 +6,19 @@
* They behave like having an armor value of 0.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
* 0: Vehicle <OBJECT>
*
* Return Value:
* The light names and selections (Array)
* 0: Light Hitpoints <ARRAY>
* 1: Selections <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_config", "_hitpoints", "_selections", "_i"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_config", "_hitpoints", "_selections"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;

View File

@ -0,0 +1,28 @@
/*
* Author: commy2
*
* Returns all damageable selections without hitpoints of any vehicle.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
*
* Return Value:
* The selections without hitpoints, i.e. reflectors. (Array)
*/
#include "script_component.hpp"
params ["_vehicle"];
private ["_hitPointsFull", "_allSelectionsWithoutHitpoints"];
_hitPointsFull = getAllHitPointsDamage _vehicle;
_allSelectionsWithoutHitpoints = [];
{
if (_x == "") then {
_allSelectionsWithoutHitpoints pushBack (_hitPointsFull select 1 select _forEachIndex);
};
} forEach (_hitPointsFull select 0);
_allSelectionsWithoutHitpoints

View File

@ -3,29 +3,32 @@
* Returns the metadata of a setting if it exists
*
* Arguments:
* 0: Name of the setting (String)
* 0: Setting Name <STRING>
*
* Return Value:
* Setting Data (Array)
* 0: _name
* 1: _typeName
* 2: _isClientSetable
* 3: _localizedName
* 4: _localizedDescription
* 5: _possibleValues
* 6: _isForced
* 7: _defaultValue
* 0: Name <STRING>
* 1: Type Name <STRING>
* 2: Is Client Settable <BOOL>
* 3: Localized Name <STRING>
* 4: Localized Description <STRING>
* 5: Possible Values <ARRAY>
* 6: Is Forced <BOOL>
* 7: Default Value <ANY>
* 8: Localized Category <STRING>
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_name);
params ["_name"];
private ["_value"];
private "_value";
_value = [];
{
if ((_x select 0) == _name) exitWith {_value = _x};
} forEach GVAR(settings);
if (_x select 0 == _name) exitWith {_value = _x};
false
} count GVAR(settings);
_value

View File

@ -1,28 +1,34 @@
/*
* Author: commy2
* Get a string from the mission.sqm file. Mission has to be saved in the Editor.
* The string cannot contain the ; character.
* If the entry does not exist, it might return an empty string or an entry with the same name of another class!
*
* Get a string from the mission.sqm file. Mission has to be saved in the Editor. The string cannot contain the ; character.
* Arguments:
* 0: Path of the entry in the mission.sqm <ARRAY>
*
* Argument:
* 0: Path of the entry in the mission.sqm (Array)
* Return Value:
* Value of the entry. <STRING>
*
* Return value:
* Value of the entry. Note: If the entry does not exist, it might return an empty string or an entry with the same name of another class! (String)
* Public: No
*/
#include "script_component.hpp"
private ["_path", "_mission", "_a", "_class", "_index", "_array", "_b", "_entry"];
private ["_path", "_mission", "_class", "_index", "_array", "_entry"];
_path = _this;
if (missionName == "") exitWith {""};
_mission = toArray toLower loadFile "mission.sqm";
_mission resize 65536;
{
if (_x < 33) then {
_mission set [_forEachIndex, -1];
}
} forEach _mission;
_mission = toString (_mission - [-1]);
{_path set [_forEachIndex, toLower _x]} forEach _path;
@ -33,9 +39,11 @@ for "_a" from 0 to (count _path - 2) do {
_index = _mission find _class;
_array = toArray _mission;
for "_b" from 0 to (_index + count toArray _class - 1) do {
_array set [_b, -1];
};
_array = _array - [-1];
_mission = toString _array;
@ -43,16 +51,20 @@ for "_a" from 0 to (count _path - 2) do {
_entry = format ["%1=", _path select (count _path - 1)];
_index = _mission find _entry;
if (_index == -1) exitWith {""};
_array = toArray _mission;
for "_b" from 0 to (_index + count toArray _entry - 1) do {
_array set [_b, -1];
};
_mission = toString (_array - [-1]);
_index = _mission find ";";
_mission = toArray _mission;
_mission resize _index;
format ["%1", toString _mission];
format ["%1", toString _mission] // return

View File

@ -1,14 +1,15 @@
/*
* Author: commy2
* Get players viewing direction and slope.
*
* Get players viewing direction and slope
* Arguments:
* None
*
* Argument:
* None.
* Return Value:
* 0: Azimuth <NUMBER>
* 1: Inclination <NUMBER>
*
* Return value:
* 0: Azimuth (Number)
* 1: Inclination or 'slope' (Number)
* Public: Yes
*/
#include "script_component.hpp"

View File

@ -1,21 +1,22 @@
/*
* Author: commy2
*
* Get the distance to the next object the player is looking at. Used for laser distance measurements.
*
* Argument:
* 0: How accurate will the measurement be? In meters. (Number)
* 1: Maximal distance to measure. (Number)
* 2: Minimal distance to measure. (optional, Number)
* Arguments:
* 0: Messurement Accuracy <NUMBER>
* 1: Maximal messure distance <NUMBER>
* 2: Minimal messure distance (default: nil) <NUMBER>
*
* Return value:
* Measured distance in meters. Can return maximal or minimal distance (Number)
* Return Value:
* Distance in meters <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_position", "_laser", "_line", "_distance", "_iteration"];
params ["_interval", "_maxDistance", "_minDistance"];
PARAMS_3(_interval,_maxDistance,_minDistance);
private ["_position", "_laser", "_line", "_distance", "_iteration"];
_position = ATLToASL positionCameraToWorld [0, 0, 0];
_position set [2, (_position select 2) - (getTerrainHeightASL _position min 0)];
@ -42,6 +43,6 @@ _distance = _interval * round (_distance / _interval);
_distance = _distance min _maxDistance;
if !(isNil "_minDistance") then {_distance = _distance max _minDistance};
if (!isNil "_minDistance") then {_distance = _distance max _minDistance};
_distance

View File

@ -1,19 +1,20 @@
/*
* Author: commy2
*
* Get the nearest object the player is looking at. Used for laser designator instead of cursorTarget.
*
* Argument:
* 0: Maximal distance to search. (Number)
* Arguments:
* 0: Maximum search distance <NUMBER>
*
* Return value:
* Nearest object directly in line of sight, if none objNull (Object)
* Return Value:
* Nearest object in line of sight, objNull if none are found <OBJECT>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_position", "_laser", "_intersects"];
params ["_maxDistance"];
PARAMS_1(_maxDistance);
private ["_position", "_laser", "_intersects"];
_position = ATLToASL positionCameraToWorld [0, 0, 0];
_position set [2, (_position select 2) - (getTerrainHeightASL _position min 0)];
@ -23,4 +24,6 @@ _laser set [2, (_laser select 2) - (getTerrainHeightASL _laser min 0)];
_intersects = lineIntersectsObjs [_position, _laser, objNull, objNull, true, 2];
if (count _intersects == 0) then {objNull} else {_intersects select 0}
if (_intersects isEqualTo []) exitWith {objNull};
_intersects select 0 // return

View File

@ -1,21 +1,22 @@
/*
* Author: commy2
*
* Returns all turned on lights of any vehicle or streetlamp.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
* 0: Vehicle <OBJECT>
*
* Return Value:
* All burning lights (Array)
* All burning lights <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_vehicle);
params ["_vehicle"];
if (!isLightOn _vehicle) exitWith {[]};
private ["_reflectorsWithSelections", "_lights", "_hitpoints"];
private ["_reflectorsWithSelections", "_lights", "_hitpoints", "_turnedOnLights"];
_reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNamespace, format [QEGVAR(cache,%1_%2), QUOTE(DFUNC(getReflectorsWithSelections)), typeOf _vehicle], 1E11] call FUNC(cachedCall);
//_reflectorsWithSelections = [_vehicle] call FUNC(getReflectorsWithSelections);
@ -23,13 +24,12 @@ _reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNa
_lights = _reflectorsWithSelections select 0;
_hitpoints = _reflectorsWithSelections select 1;
private "_turnedOnLights";
_turnedOnLights = [];
{
if (_vehicle getHit _x <= 0.9) then {
_turnedOnLights pushBack (_lights select _forEachIndex);
};
} forEach _hitpoints;
_turnedOnLights

View File

@ -1,30 +1,34 @@
/*
* Author: commy2
*
* Get the turret index of a vehicles commander.
*
* Argument:
* 0: Vehicle (Object)
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return value:
* Turret index of the vehicles commander. Empty array means no observer position. (Array)
* Return Value:
* Vehicle commander turrent indecies <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_turrets", "_turret", "_config"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true];
_turret = [];
{
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_config = [_config, _x] call FUNC(getTurretConfigPath);
_config = [_config, _x] call FUNC(getTurretConfigPath);
if (getNumber (_config >> "primaryObserver") == 1) exitWith {
_turret = _x;
};
false
} count _turrets;
if (getNumber (_config >> "primaryObserver") == 1) exitWith {
_turret = _x;
};
} forEach _turrets;
_turret

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