Merge branch 'master' into miscFixNilFunctions

Conflicts:
	addons/common/functions/fnc_doAnimation.sqf
This commit is contained in:
PabstMirror 2015-09-21 15:08:43 -05:00
commit d3c2420381
102 changed files with 1841 additions and 1459 deletions

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);
@ -82,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);
@ -102,6 +91,8 @@ PREP(getWindDirection);
PREP(getZoom);
PREP(goKneeling);
PREP(hadamardProduct);
PREP(handleScrollWheel);
PREP(handleScrollWheelInit);
PREP(hasItem);
PREP(hasMagazine);
PREP(headBugFix);
@ -208,6 +199,7 @@ PREP(getConfigGunner);
PREP(getConfigCommander);
PREP(getHitPoints);
PREP(getHitPointsWithSelections);
PREP(getSelectionsWithoutHitPoints);
PREP(getReflectorsWithSelections);
PREP(getLightProperties);
PREP(getLightPropertiesWeapon);
@ -250,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);
@ -273,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
@ -295,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 = [];
@ -305,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;
@ -323,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;
@ -338,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

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

View File

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

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,19 +31,22 @@ 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;
private ["_dlg", "_ctrl"];
_dlg = finddisplay 49;
_dlg displayAddEventHandler ["KeyDown", {
_key = _this select 1;
params ["", "_key"];
!(_key == 1)
}];
@ -62,19 +62,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;
};

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 {};
};
TRACE_2("Anim",_priority, _animation);

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

@ -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,28 +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)
* 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 {[
"",

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,19 @@
/*
* 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"];
params ["_vehicle"];
PARAMS_1(_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,25 @@
/*
* 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"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private "_hitPointsWithSelections";
_hitPointsWithSelections = getAllHitPointsDamage _vehicle;
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_hitPointsWithSelections resize 2;
_hitpoints = [];
_selections = [];
// 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

View File

@ -1,28 +1,29 @@
/*
* Author: commy2
*
* Get the config path of a vehicles turret.
*
* Argument:
* 0: vehicles config (Config)
* 1: Turret index (Array)
* Arguments:
* 0: Vehicle Config <CONFIG>
* 1: Turret indecies <ARRAY>
*
* Return value:
* Turret config (Config)
* Return Value:
* Turret config <CONFIG>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_index", "_offset", "_config2", "_foundClasses", "_a"];
params ["_config", "_turretIndex"];
PARAMS_2(_config,_turretIndex);
private ["_offset", "_config2", "_foundClasses"];
for "_index" from 0 to (count _turretIndex - 1) do {
_config = _config >> "Turrets";
_offset = 0;
_config2 = _config select 0;
_foundClasses = 0;
for "_a" from 0 to (count _config - 1) do {
if (isClass _config2) then {
_foundClasses = _foundClasses + 1;
@ -33,6 +34,8 @@ for "_index" from 0 to (count _turretIndex - 1) do {
if (_foundClasses == _turretIndex select _index) exitWith {};
};
_config = _config2;
};
_config

View File

@ -1,23 +1,25 @@
/*
* Author: commy2
*
* Get the turret index of a vehicles copilot.
*
* Argument:
* 0: Vehicle (Object)
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return value:
* Turret index of the vehicles gunner. Empty array means no copilot position. (Array)
* Return Value:
* Vehicle Copilot Turret 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;
@ -26,6 +28,7 @@ _turret = [];
if (getNumber (_config >> "isCopilot") == 1 && {getNumber (_config >> "primaryGunner") != 1} && {getNumber (_config >> "primaryObserver") != 1}) exitWith {
_turret = _x;
};
} forEach _turrets;
false
} count _turrets;
_turret

View File

@ -1,37 +1,47 @@
/*
* Author: jaynus
*
* Get the absolute turret direction for FOV/PIP turret.
*
* Argument:
* 0: Vehicle (Object)
* 1: Turret Position
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Turret Position <ARRAY>
*
* Return value:
* [position, direction]
* Return Value:
* 0: Position ASL <ARRAY>
* 1: Direction <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_vehicle,_position);
private ["_turret", "_povPos", "_povDir", "_gunBeginPos", "_gunEndPos", "_pov", "_gunBeg", "_gunEnd", "_pipDir"];
params ["_vehicle", "_position"];
private ["_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir"];
_turret = [_vehicle, _position] call CBA_fnc_getTurret;
_pov = getText (_turret >> "memoryPointGunnerOptics");
_gunBeg = getText (_turret >> "gunBeg");
_gunEnd = getText (_turret >> "gunEnd");
_gunEnd = getText (_turret >> "gunEnd");
TRACE_3("", _pov, _gunBeg, _gunEnd);
// Pull the PIP pov or barrel direction, depending on how the model is set up
_povPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _pov ) );
_povPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _pov)); //@todo AGLToASL ?
_povDir = [0,0,0];
if (_pov == "pip0_pos") then {
_pipDir = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir" ) );
private "_pipDir";
_pipDir = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir"));
_povDir = _pipDir vectorDiff _povPos;
} else {
_gunBeginPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg ) );
_gunEndPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd ) );
private ["_gunBeginPos", "_gunEndPos"];
_gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg));
_gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd));
_povDir = _gunBeginPos vectorDiff _gunEndPos;
};
[_povPos, _povDir]
[_povPos, _povDir]

View File

@ -1,23 +1,25 @@
/*
* Author: commy2
*
* Get the turret index of a vehicles gunner.
*
* Argument:
* 0: Vehicle (Object)
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return value:
* Turret index of the vehicles gunner. Empty array means no gunner position. (Array)
* Return Value:
* Vehicle Gunner Turret 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;
@ -26,6 +28,7 @@ _turret = [];
if (getNumber (_config >> "primaryGunner") == 1) exitWith {
_turret = _x;
};
} forEach _turrets;
false
} count _turrets;
_turret

View File

@ -1,19 +1,21 @@
/*
* Author: commy2
*
* Get the turret index of a units current turret.
*
* Argument:
* 0: Unit, not the vehicle (as in not a car but the player) (Object)
* Arguments:
* 0: Unit <OBJECT>
*
* Return value:
* Turret index array or config path. E.g: [0] for gunner or [0,0] for commander. Returns empty array if unit is not in a turret. (Array)
* Return Value:
* Turret Index <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit"];
private ["_vehicle", "_turrets", "_units", "_index"];
PARAMS_1(_unit);
_vehicle = vehicle _unit;
if (_unit == _vehicle) exitWith {[]};
@ -21,9 +23,11 @@ if (_unit == _vehicle) exitWith {[]};
_turrets = allTurrets [_vehicle, true];
_units = [];
{
_units pushBack (_vehicle turretUnit _x);
} forEach _turrets;
_units pushBack (_vehicle turretUnit _x);
false
} count _turrets;
_index = _units find _unit;

View File

@ -1,37 +1,45 @@
/*
* Author: commy2
* Get all turret indicies of a vehicle type.
*
* Get all turret indicies of a vehicle.
* Arguments:
* 0: Vehicle type <STRING>
*
* Argument:
* 0: Vehicle type (String)
* Return Value:
* Turret Indecies <ARRAY>
*
* Return value:
* All turret index arrays of the vehicle. E.g: [[0], [0,0]] (Array)
* Public: Yes
*
* Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible
*/
#include "script_component.hpp"
private ["_config", "_turrets", "_fnc_addTurret", "_varName"];
params ["_type"];
PARAMS_1(_type);
private ["_varName", "_turrets"];
_varName = format ["ACE_CachedTurrets_%1", _type];
_varName = format [QGVAR(CachedTurrets_%1), _type];
_turrets = + (uiNamespace getVariable _varName);
if (!isNil "_turrets") exitWith {_turrets};
private ["_config", "_fnc_addTurret"];
_config = configFile >> "CfgVehicles" >> _type;
_turrets = [];
_fnc_addTurret = {
private ["_count", "_offset", "_index", "_path2", "_config2"];
PARAMS_2(_config,_path);
_fnc_addTurret = {
params ["_config", "_path"];
_config = _config >> "Turrets";
private ["_count", "_offset", "_path2", "_config2"];
_count = count _config;
_offset = 0;
for "_index" from 0 to (_count - 1) do {
_path2 = _path + [_index - _offset];
_config2 = _config select _index;

View File

@ -1,23 +1,25 @@
/*
* Author: commy2
*
* Get the turret indices of ffv turrets.
*
* Argument:
* 0: Vehicle (Object)
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return value:
* Turret index of the vehicles gunner. Empty array means no ffv turrets. (Array)
* Return Value:
* Vehicle FFV Turret 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;
@ -26,5 +28,7 @@ _turret = [];
if (getNumber (_config >> "isPersonTurret") == 1) then {
_turret pushBack _x;
};
} forEach _turrets;
false
} count _turrets;
_turret

View File

@ -1,23 +1,25 @@
/*
* Author: commy2
*
* Get the turret indices of other turrets (not gunner, commander, copilot or ffv).
*
* Argument:
* 0: Vehicle (Object)
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return value:
* Turret index of the vehicles gunner. Empty array means no other turrets. (Array)
* Return Value:
* Vehicle Other Turret 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;
@ -30,5 +32,7 @@ _turret = [];
) then {
_turret pushBack _x;
};
} forEach _turrets;
false
} count _turrets;
_turret

View File

@ -1,32 +1,34 @@
/*
Name: FUNC(getUavControlPosition)
Author: Pabst Mirror
Description:
Gets the seat position of a UAV that the unit is activly controlling.
"" - not connected to anything or not activly controling
"DRIVER"
"GUNNER"
Parameters:
0: OBJECT - Unit
Returns:
STRING - Position in the UAV that is currently being controled by the unit.
Example:
[ACE_Player] call FUNC(getUavControlPosition)
*/
* Author: PabstMirror
* Returns the seat position of a UAV that the unit is activly controling.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Position <STRING>
* "" = not connected to anything or activly controling
* "DRIVER"
* "GUNNER"
*
* Example:
* [ACE_Player] call ace_common_fnc_getUavControlPosition
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit"];
private ["_uav", "_positionArray", "_playerIndex"];
PARAMS_1(_unit);
_uav = getConnectedUAV _unit;
if (isNull _uav) exitWith {""};
_positionArray = UAVControl _uav;
_playerIndex = _positionArray find _unit;
if (_playerIndex == -1) exitWith {""};
_positionArray select (_playerIndex + 1)

View File

@ -1,19 +1,20 @@
/*
* Author: commy2
*
* Get the vehicle cargo positions. Codrivers and ffv positions are not listed.
*
* Argument:
* 0: Vehicle type (String)
* Arguments:
* 0: Vehicle type <STRING>
*
* Return value:
* Vehicle cargo positions. (Array)
* Return Value:
* Vehicle cargo positions <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_config", "_cargo", "_codrivers", "_index"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_config", "_cargo", "_codrivers"];
_config = configFile >> "CfgVehicles" >> _vehicle;
@ -25,4 +26,5 @@ for "_index" from 0 to (getNumber (_config >> "transportSoldier") - 1) do {
_cargo pushBack _index;
};
};
_cargo

View File

@ -1,19 +1,20 @@
/*
* Author: commy2
*
* Get the vehicle codriver positions.
*
* Argument:
* 0: Vehicle type (String)
* Arguments:
* 0: Vehicle type <STRING>
*
* Return value:
* Vehicle codriver positions. (Array)
* Return Value:
* Vehicle codriver positions <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_config", "_cargo", "_codrivers", "_index"];
params ["_vehicle"];
PARAMS_1(_vehicle);
private ["_config", "_cargo", "_codrivers"];
_config = configFile >> "CfgVehicles" >> _vehicle;
@ -25,4 +26,5 @@ for "_index" from 0 to (getNumber (_config >> "transportSoldier") - 1) do {
_cargo pushBack _index;
};
};
_cargo

View File

@ -1,36 +1,37 @@
/*
* Author: commy2
*
* Returns array of crew member objects.
*
* Argument:
* 0: Vehicle (Object)
* 1: Slot types. Can contain "driver", "commander", "gunner", "turret", "cargo" and "ffv". Case sensitive (Array)
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Slot types filter (default: ["driver", "commander", "gunner", "turret", "cargo", "ffv"]) <ARRAY>
*
* Return value:
* Crew (Array)
* Return Value:
* Crew <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_crew"];
PARAMS_2(_vehicle,_types);
params ["_vehicle", ["_types", ["driver", "commander", "gunner", "turret", "cargo", "ffv"]]];
private "_crew";
_crew = [];
// iterate through all crew members
{
// this unit is in a ffv position. check if we search for ffv.
if (_x select 4) then {
if ("ffv" in _types) then {
_crew pushBack (_x select 0);
// this unit is in a ffv position. check if we search for ffv.
if (_x select 4) then {
if ("ffv" in _types) then {
_crew pushBack (_x select 0);
};
} else {
// otherwise check if we search for that type. toLower, because fullCrew returns "driver" vs. "Turret".
if (toLower (_x select 1) in _types) then {
_crew pushBack (_x select 0);
};
};
} else {
// otherwise check if we search for that type. toLower, because fullCrew returns "driver" vs. "Turret".
if (toLower (_x select 1) in _types) then {
_crew pushBack (_x select 0);
};
};
} forEach fullCrew _vehicle;
false
} count fullCrew _vehicle;
_crew

View File

@ -1,11 +1,15 @@
/**
* fn_getVersion.sqf
* @Descr: Get the version number of the current ACE Build
* @Author: Glowbal
/*
* Author: Glowbal
* Get the version number of the current ACE build.
*
* @Arguments: []
* @Return: STRING String containing the version
* @PublicAPI: true
* Arguments:
* None
*
* Return Value:
* ACE Version <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
getText (configFile >> "cfgPatches" >> "ACE_main" >> "version");
getText (configFile >> "CfgPatches" >> "ACE_main" >> "version") // return

View File

@ -1,20 +1,21 @@
/*
* Author: commy2
* Get local players weapon direction and slope.
*
* Get players weapon direction and slope
* Arguments:
* 0: Weapon name <STRING>
*
* Argument:
* 0: Weapon name (String)
* Return Value:
* 0: Azimuth <NUMBER>
* 1: Inclination <NUMBER>
*
* Return value:
* 0: Azimuth (Number)
* 1: Inclination or 'slope' (Number)
* Public: Yes
*/
#include "script_component.hpp"
private ["_direction", "_azimuth", "_inclination"];
params ["_weapon"];
PARAMS_1(_weapon);
private ["_direction", "_azimuth", "_inclination"];
_direction = ACE_player weaponDirection _weapon;

View File

@ -1,20 +1,23 @@
/*
* Author: commy2
* Get the index of the weapon.
* 0 = primary, 1 = secondary, 2 = handgun, -1 = other
*
* Argument:
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
*
* Return value:
* Return Value:
* Weapon index <NUMBER>
* 0 = primary
* 1 = secondary
* 2 = handgun
* -1 = other
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_unit,_weapon);
params ["_unit", "_weapon"];
if (_weapon == "") exitWith {-1};
@ -22,4 +25,4 @@ if (_weapon == "") exitWith {-1};
primaryWeapon _unit,
secondaryWeapon _unit,
handgunWeapon _unit
] find _weapon
] find _weapon // return

View File

@ -1,30 +1,34 @@
/*
* Author: commy2
* Get the available firing modes of a weapon. Will ignore the AI helper modes.
*
* Get the available firing modes of a weapon. Will ignore the ai helper modes.
* Arguments:
* 0: Weapon <STRING>
*
* Argument:
* 0: A weapon in cfgWeapons (String)
* Return Value:
* Firing Modes <ARRAY>
*
* Return value:
* All firing modes (Array)
* Public: Yes
*/
#include "script_component.hpp"
private ["_modes"];
params ["_weapon"];
PARAMS_1(_weapon);
private ["_config", "_modes"];
_config = configFile >> "CfgWeapons" >> _weapon;
_modes = [];
{
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> _x >> "showToPlayer") == 1) then {
if (getNumber (_config >> _x >> "showToPlayer") == 1) then {
_modes pushBack _x;
};
if (_x == "this") then {
_modes pushBack _weapon;
};
} forEach getArray (configfile >> "CfgWeapons" >> _weapon >> "modes");
false
} count getArray (_config >> "modes");
_modes

View File

@ -1,20 +1,20 @@
/*
* Author: commy2
*
* Get the muzzles of a weapon.
*
* Argument:
* 0: A weapon in cfgWeapons (String)
* Arguments:
* 0: Weapon <STRING>
*
* Return value:
* All weapon muzzles (Array)
* Return Value:
* All weapon muzzles <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_muzzles"];
PARAMS_1(_weapon);
params ["_weapon"];
private "_muzzles";
_muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles");
if ("this" in _muzzles) then {

View File

@ -1,46 +1,28 @@
/*
* Author: commy2
*
* Return current state of the weapon. Attachments and magazines with ammo.
*
* Argument:
* 0: A unit (Object)
* 1: A weapon (String)
* Arguments:
* 0: unit <OBJECT>
* 1: weapon <STRING>
*
* Return value:
* Weapon info, format: [attachments, muzzles, magazines, ammo] (Array)
* Return Value:
* 0: Attachements <ARRAY>
* 1: Muzzles <ARRAY>
* 2: Magazines <ARRAY>
* 3: Ammo <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp"
#include "script_component.hpp"
PARAMS_2(_unit,_weapon);
params ["_unit", "_weapon"];
private ["_muzzles", "_weaponInfo"];
private "_muzzles";
_muzzles = [_weapon] call FUNC(getWeaponMuzzles);
private "_weaponInfo";
_weaponInfo = [];
switch (_weapon) do {
case (primaryWeapon _unit): {
_weaponInfo pushBack primaryWeaponItems _unit;
};
case (secondaryWeapon _unit): {
_weaponInfo pushBack secondaryWeaponItems _unit;
};
case (handgunWeapon _unit): {
_weaponInfo pushBack handgunItems _unit;
};
default {
_weaponInfo pushBack ["","","",""];
};
};
_weaponInfo = [["","","",""], primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] find _weapon) max 0);
// get loaded magazines and ammo
private ["_magazines", "_ammo"];
@ -51,7 +33,8 @@ _ammo = [];
{
_magazines pushBack "";
_ammo pushBack 0;
} forEach _muzzles;
false
} count _muzzles;
{
if (_x select 2) then {
@ -63,7 +46,8 @@ _ammo = [];
_ammo set [_index, _x select 1];
};
};
} forEach magazinesAmmoFull _unit;
false
} count magazinesAmmoFull _unit;
_weaponInfo append [_muzzles, _magazines, _ammo];

View File

@ -1,19 +1,24 @@
/*
* Author: commy2
* Check what kind of weapon the given class name is.
*
* Check what kind of weapon the given class name is. (primary, secondary or handgun)
* Arguments:
* 0: Weapons <STRING>
*
* Argument:
* 0: Class name of the weapon (String)
* Return Value:
* Slot index <NUMBER>
* 1 = primary
* 2 = secondary
* 3 = handgun
* -1 = other
*
* Return value:
* Slot index of the given class name, 1: primary, 2: secondary, 3: handgun, else: -1 (Number)
* Public: Yes
*/
#include "script_component.hpp"
private ["_type", "_index"];
params ["_weapon"];
PARAMS_1(_weapon);
private ["_type", "_index"];
_type = [getNumber (configFile >> "CfgWeapons" >> _weapon >> "type")] call FUNC(binarizeNumber);
@ -23,9 +28,4 @@ while {!(_type select _index) && {_index < 16}} do {
_index = _index + 1;
};
switch (_index) do {
case 0 : {1};
case 1 : {3};
case 2 : {2};
default {-1};
}
[-1, 1, 3, 2] select (([0, 1, 2] find _index) + 1) // return

View File

@ -1,31 +1,33 @@
/*
* Author: commy2
*
* Get the compass direction the wind is blowing from.
*
* Argument:
* None.
* Arguments:
* None
*
* Return value:
* Wind direction. (String)
* Return Value:
* Wind cardinal direction <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
switch (round (windDir / 360 * 16)) do {
case 1 : {localize QUOTE(DOUBLES(STR,GVAR(SSW)))};
case 2 : {localize QUOTE(DOUBLES(STR,GVAR(SW)))};
case 3 : {localize QUOTE(DOUBLES(STR,GVAR(WSW)))};
case 4 : {localize QUOTE(DOUBLES(STR,GVAR(W)))};
case 5 : {localize QUOTE(DOUBLES(STR,GVAR(WNW)))};
case 6 : {localize QUOTE(DOUBLES(STR,GVAR(NW)))};
case 7 : {localize QUOTE(DOUBLES(STR,GVAR(NNW)))};
case 8 : {localize QUOTE(DOUBLES(STR,GVAR(N)))};
case 9 : {localize QUOTE(DOUBLES(STR,GVAR(NNE)))};
case 10 : {localize QUOTE(DOUBLES(STR,GVAR(NE)))};
case 11 : {localize QUOTE(DOUBLES(STR,GVAR(ENE)))};
case 12 : {localize QUOTE(DOUBLES(STR,GVAR(E)))};
case 13 : {localize QUOTE(DOUBLES(STR,GVAR(ESE)))};
case 14 : {localize QUOTE(DOUBLES(STR,GVAR(SE)))};
case 15 : {localize QUOTE(DOUBLES(STR,GVAR(SSE)))};
default {localize QUOTE(DOUBLES(STR,GVAR(S)))};
};
localize ([
LSTRING(S),
LSTRING(SSW),
LSTRING(SW),
LSTRING(WSW),
LSTRING(W),
LSTRING(WNW),
LSTRING(NW),
LSTRING(NNW),
LSTRING(N),
LSTRING(NNE),
LSTRING(NE),
LSTRING(ENE),
LSTRING(E),
LSTRING(ESE),
LSTRING(SE),
LSTRING(SSE),
LSTRING(S)
] select (round (windDir / 360 * 16))) // return

View File

@ -1,14 +1,17 @@
/*
* Author: commy2
*
* Returns a value depending on current zoom level.
*
* Argument:
* None.
* Arguments:
* None
*
* Return value:
* Zoom. (Number)
* Return Value:
* Zoom <NUMBER>
*
* Public: Yes
*/
#include "script_component.hpp"
(0.5 - ((worldToScreen positionCameraToWorld [0,1,1]) select 1)) * (getResolution select 5)
if (!hasInterface) exitWith {0};
(0.5 - ((worldToScreen positionCameraToWorld [0, 1, 1]) select 1)) * (getResolution select 5)

View File

@ -1,6 +1,5 @@
/*
* Author: Nou
*
* Execute a global event on all clients, including self.
*
* Arguments:

View File

@ -0,0 +1,25 @@
/*
* Author: commy2
* Handles MouseZChanged event.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public : No
*/
#include "script_component.hpp"
// prevents a bug that causes the MouseZChanged to trigger N-times, where N is the number of times you consecutively pressed "Restart" instead of "Preview" in the editor
if (GVAR(ScrollWheelFrame) == diag_frameno) exitWith {};
GVAR(ScrollWheelFrame) = diag_frameno;
{
[_this select 1] call _x;
false
} count ((missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]]) select 2);
nil

View File

@ -0,0 +1,15 @@
/*
* Author: commy2
* Initializes the MouseZChanged eventhandler.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public : No
*/
#include "script_component.hpp"
(findDisplay 46) displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))];

View File

@ -1,64 +0,0 @@
// by commy2
#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) = [];
["playerInventoryChanged", {
private ["_unit", "_assignedItems", "_shownItems"];
_unit = _this select 0;
_assignedItems = _this select 1 select 17;
_shownItems = [
ACE_isMapEnabled,
ACE_isCompassEnabled,
ACE_isWatchEnabled,
ACE_isRadioEnabled,
ACE_isGPSEnabled
];
{
if !(_x in GVAR(AssignedItems)) then {
GVAR(AssignedItems) pushBack _x;
GVAR(AssignedItemsInfo) pushBack toLower getText (configFile >> "CfgWeapons" >> _x >> "ACE_hideItemType")
};
private "_hideItemType";
_hideItemType = GVAR(AssignedItemsInfo) select (GVAR(AssignedItems) find _x);
switch (_hideItemType) do {
case ("map"): {
_shownItems set [0, false];
};
case ("compass"): {
_shownItems set [1, false];
};
case ("watch"): {
_shownItems set [2, false];
};
case ("radio"): {
_shownItems set [3, false];
};
case ("gps"): {
_shownItems set [4, false];
};
};
} forEach _assignedItems;
//systemChat str _shownItems;
showMap (_shownItems select 0);
showCompass (_shownItems select 1);
showWatch (_shownItems select 2);
showRadio (_shownItems select 3);
showGPS (_shownItems select 4 || {cameraOn == getConnectedUAV _unit}); //If player is activly controling a UAV, showGPS controls showing the map (m key)
}] call FUNC(addEventHandler);

View File

@ -1,16 +0,0 @@
// by commy2
#include "script_component.hpp"
GVAR(ScrollWheelFrame) = diag_frameno;
GVAR(onScrollWheel) = {
private ["_scroll"];
_scroll = _this select 1;
if (GVAR(ScrollWheelFrame) == diag_frameno) exitWith {};
GVAR(ScrollWheelFrame) = diag_frameno;
{
[_scroll] call _x;
} count ((missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]]) select 2);
};

View File

@ -482,7 +482,8 @@
<Russian>Проверка аддонов</Russian>
</Key>
<Key ID="STR_ACE_Common_CheckPBO_Description">
<Polish>Sprawdzaj spójność addonów z serwerem</Polish>
<English>Check addon integrity with server and do selected action if an addon is missing.</English>
<Polish>Sprawdzaj spójność addonów z serwerem i wykonuj stosowną akcję jeżeli zostanie wykryty brak addonu.</Polish>
<Spanish>Este módulo verifica la integridad de los addons con los que iniciamos el simulador</Spanish>
<German>Dieses Modul überprüft ob jeder Spieler die richtigen PBO-Dateien hat.</German>
<Czech>Zjistit addon který je v souladu se serverem</Czech>

View File

@ -1,5 +1,5 @@
class CfgVehicles {
#define MACRO_NONLAW \
#define MACRO_NONLAW \
class TransportMagazines { \
class _xx_NLAW_F { \
count = 0; \
@ -73,56 +73,56 @@ class CfgVehicles {
MACRO_NONLAW
};
/*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};*/
MACRO_NONLAW
};
class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};*/
class Car_F;
class MRAP_01_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_01_gmg_base_F: MRAP_01_base_F {
MACRO_NONLAW
};
class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_F: MRAP_01_base_F {
MACRO_NONLAW
};
class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F {
MACRO_NONLAW
};*/
MACRO_NONLAW
};
class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_F: MRAP_01_base_F {
MACRO_NONLAW
};
class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F {
MACRO_NONLAW
};*/
class MRAP_03_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_03_hmg_base_F: MRAP_03_base_F {
MACRO_NONLAW
};
class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_F: MRAP_03_base_F {
MACRO_NONLAW
};
class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};*/
MACRO_NONLAW
};
class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_F: MRAP_03_base_F {
MACRO_NONLAW
};
class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};*/
class Wheeled_APC_F: Car_F {};
class APC_Wheeled_03_base_F: Wheeled_APC_F {
@ -132,15 +132,15 @@ class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};
/*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F {
MACRO_NONLAW
};*/
MACRO_NONLAW
};
class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F {
MACRO_NONLAW
};*/
};

View File

@ -36,6 +36,7 @@ if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber
if (backpack _unit == "") then {
_unit addBackpack "Bag_Base";
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
_unit addWeapon _launcher;
@ -45,6 +46,7 @@ if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber
};
removeBackpack _unit;
} else {
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
_unit addWeapon _launcher;

View File

@ -97,6 +97,8 @@
// Time functions for accuracy per frame
#define ACE_tickTime (ACE_time + (diag_tickTime - ACE_diagTime))
#define ACE_isHC (!hasInterface && !isDedicated)
#define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message)
#define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message)

View File

@ -127,6 +127,7 @@
<Russian>Показывает цифровой компас MK6</Russian>
</Key>
<Key ID="STR_ACE_Mk6Mortar_Module_Description">
<English>This module allows you to setup MK6 mortar settings.</English>
<Polish>Moduł ten pozwala dostosować ustawienia moździerza MK6.</Polish>
<German>Dieses Modul erlaubt das Einstellen des MK6-Mörsers.</German>
<Czech>Tento modul umožňuje nastavení minometu MK6.</Czech>

View File

@ -23,25 +23,22 @@
if (!hasInterface) exitWith {};
private ["_vehicle", "_weapon", "_ammo", "_magazine", "_player"];
_vehicle = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_magazine = _this select 5;
params ["_vehicle", "_weapon", "", "", "_ammo", "_magazine"];
private "_player";
_player = ACE_player;
//If our vehicle didn't shoot, or we're not in NVG mode, exit
if ((_vehicle != (vehicle _player)) || {(currentVisionMode _player) != 1}) exitWith {};
//If we are mounted, and it wasn't our weapon system that fired, exit
if (_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([_player] call EFUNC(common,getTurretIndex))))}) exitWith {};
private ["_silencer", "_visibleFireCoef", "_visibleFireTimeCoef", "_visibleFire", "_visibleFireTime", "_nvgBrightnessCoef", "_fnc_isTracer", "_darkness"];
private["_darkness", "_nvgBrightnessCoef", "_silencer", "_visibleFire", "_visibleFireCoef", "_visibleFireTime", "_visibleFireTimeCoef"];
_silencer = switch (_weapon) do {
case (primaryWeapon _player) : {primaryWeaponItems _player select 0};
case (secondaryWeapon _player) : {secondaryWeaponItems _player select 0};
case (handgunWeapon _player) : {handgunItems _player select 0};
case (primaryWeapon _player): {(primaryWeaponItems _player) select 0};
case (secondaryWeapon _player): {(secondaryWeaponItems _player) select 0};
case (handgunWeapon _player): {(handgunItems _player) select 0};
default {""};
};
@ -83,7 +80,7 @@ _darkness = 1 - (call EFUNC(common,ambientBrightness));
_visibleFire = _darkness * _visibleFireCoef * _visibleFire * _nvgBrightnessCoef / 10 min 1;
_visibleFireTime = _darkness * _visibleFireTimeCoef * _visibleFireTime * _nvgBrightnessCoef / 10 min 0.5;
// ["NightVision", [_visibleFire, _visibleFireTime], {format ["visibleFire: %1 - visibleFireTime: %2", _this select 0, _this select 1]}] call AGM_Debug_fnc_log; //todo
TRACE_2("Player Shot, Adjusting NVG Effect", _visibleFire, _visibleFireTime);
GVAR(ppEffectMuzzleFlash) ppEffectAdjust [1, 1, _visibleFire, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;

View File

@ -16,10 +16,12 @@
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};
params ["_player", "_changeInBrightness"];
TRACE_2("params",_player,_changeInBrightness);
private ["_brightness"];
PARAMS_2(_player,_changeInBrightness);
if (!hasInterface) exitWith {};
_brightness = _player getVariable [QGVAR(NVGBrightness), 0];

View File

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

View File

@ -238,6 +238,7 @@
<Russian>Система точек сбора</Russian>
</Key>
<Key ID="STR_ACE_Respawn_Rallypoint_Module_Description">
<English>This module allows you to use rally points in missions, to which you can quickly teleport from base flag. Requires placing special objects on map - base and flag. Both available in category Empty -&gt; ACE Respawn.</English>
<Polish>Moduł ten pozwala zastosować na misji "punkt zbiórki", do którego można szybko przeteleportować się z "bazy". Wymaga postawienia odpowiednich obiektów na mapie - bazy oraz flagi. Obydwa dostępne są w kategorii Puste -&gt; ACE Odrodzenie.</Polish>
<Czech>Tento modul umožňuje určit místo shromaždiště, kam se mohou jednokty rychle teleportovat ze "základny". Toto vyžaduje vhodné objekty v mapě - základna a vlajka. Oba dva můžete najít v kategorii Prázdné -&gt; ACE Oživení.</Czech>
<Portuguese>Este módulo permite que você aplique em uma missão "pontos de encontro", que pode rapidamente se teletransportar para a "base". Ele requer colocar objetos apropriados no mapa - base e bandeiras. Ambos estão disponíveis na categoria em branco -&gt; ACE Revival.</Portuguese>

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