mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
a8ba96a01b
commit
1b96caedc0
@ -114,7 +114,6 @@ PREP(interpolateFromArray);
|
||||
PREP(inTransitionAnim);
|
||||
PREP(inWater);
|
||||
PREP(isAlive);
|
||||
PREP(isArrested);
|
||||
PREP(isAutoWind);
|
||||
PREP(isAwake);
|
||||
PREP(isEngineer);
|
||||
@ -235,10 +234,6 @@ PREP(getTurretsOther);
|
||||
PREP(exportConfig);
|
||||
PREP(getChildren);
|
||||
PREP(getDisplayConfigName);
|
||||
PREP(log);
|
||||
PREP(logControls);
|
||||
PREP(logDisplays);
|
||||
PREP(logModEntries);
|
||||
PREP(monitor);
|
||||
PREP(showUser);
|
||||
|
||||
|
@ -1,25 +1,29 @@
|
||||
/**
|
||||
* fn_inWater_f.sqf
|
||||
* @Descr: Check if unit is underwater
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if unit is underwater
|
||||
*
|
||||
* @Arguments: [unit OBJECT]
|
||||
* @Return: BOOL True if unit is in the water
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* if unit is in the water (BOOLEAN)
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_return","_aslPos"];
|
||||
params ["_unit"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
private "_return";
|
||||
_return = false;
|
||||
|
||||
if ((surfaceIsWater getPos _unit)) then {
|
||||
_aslPos = _unit modelToWorldVisual (_unit selectionPosition "head");
|
||||
if ((_aslPos select 2) <= 0) then {
|
||||
if (surfaceIsWater getPosASL _unit) then {
|
||||
private "_pos";
|
||||
_pos = _unit modelToWorldVisual (_unit selectionPosition "head");
|
||||
|
||||
if (_pos select 2 < 0) then {
|
||||
_return = true;
|
||||
};
|
||||
};
|
||||
|
||||
_return;
|
||||
_return
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Check if the object still exists and is alive. This function exists because 'alive objNull' actually returns true.
|
||||
*
|
||||
* Argument:
|
||||
@ -8,6 +7,10 @@
|
||||
*
|
||||
* Return value:
|
||||
* The object exists and is alive (Bool).
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
/**
|
||||
* fn_isArrested.sqf
|
||||
* @Descr: Check if unit is in arrested state
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [unit OBJECT]
|
||||
* @Return: BOOL Returns true if unit or object is in arrest state
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
((_this select 0) getvariable [QGVAR(StateArrested),false])
|
@ -1,45 +1,55 @@
|
||||
/**
|
||||
* fn_loadPerson_f.sqf
|
||||
* @Descr: Loads a specified unit into any nearby vehicle
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Loads a specified unit into any nearby vehicle
|
||||
*
|
||||
* @Arguments: [caller OBJECT, unitToBeLoaded OBJECT]
|
||||
* @Return: OBJECT Returns the vehicle that the unitToBeloaded has been loaded in. Returns ObjNull if function failed
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit that will load <OBJECT>
|
||||
* 1: Unit to be loaded <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* the vehicle that the unitToBeloaded has been loaded in. Returns ObjNull if function failed <OBJECT>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
|
||||
|
||||
private ["_caller", "_unit","_vehicle", "_loadcar", "_loadhelicopter", "_loadtank","_loadboat"];
|
||||
_caller = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_unit = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_vehicle = ObjNull;
|
||||
params ["_caller", "_unit"];
|
||||
|
||||
private ["_vehicle", "_loadcar", "_loadair", "_loadtank", "_loadboat"];
|
||||
|
||||
_vehicle = objNull;
|
||||
|
||||
if (!([_caller] call FUNC(canInteract)) || {_caller == _unit}) exitwith {_vehicle};
|
||||
|
||||
_loadcar = nearestObject [_unit, "car"];
|
||||
_loadcar = nearestObject [_unit, "Car"];
|
||||
|
||||
if (_unit distance _loadcar <= 10) then {
|
||||
_vehicle = _loadcar;
|
||||
} else {
|
||||
_loadhelicopter = nearestObject [_unit, "air"];
|
||||
if (_unit distance _loadhelicopter <= 10) then {
|
||||
_vehicle = _loadhelicopter;
|
||||
_loadair = nearestObject [_unit, "Air"];
|
||||
|
||||
if (_unit distance _loadair <= 10) then {
|
||||
_vehicle = _loadair;
|
||||
} else {
|
||||
_loadtank = nearestObject [_unit, "tank"];
|
||||
_loadtank = nearestObject [_unit, "Tank"];
|
||||
|
||||
if (_unit distance _loadtank <= 10) then {
|
||||
_vehicle = _loadtank;
|
||||
} else {
|
||||
_loadboat = nearestObject [_unit, "ship"];
|
||||
_loadboat = nearestObject [_unit, "Ship_F"];
|
||||
|
||||
if (_unit distance _loadboat <= 10) then {
|
||||
_vehicle = _loadboat;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (!isNull _vehicle) then {
|
||||
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
|
||||
[[_unit, _vehicle,_caller], QUOTE(FUNC(loadPersonLocal)), _unit, false] call EFUNC(common,execRemoteFnc);
|
||||
[[_unit, _vehicle, _caller], QFUNC(loadPersonLocal), _unit, false] call FUNC(execRemoteFnc);
|
||||
};
|
||||
|
||||
_vehicle
|
@ -1,25 +1,28 @@
|
||||
/**
|
||||
* fn_loadPersonLocal_f.sqf
|
||||
* @Descr: Load a person, local
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Load a person, local
|
||||
*
|
||||
* @Arguments: [unit OBJECT, vehicle OBJECT, caller OBJECT]
|
||||
* @Return: void
|
||||
* @PublicAPI: false
|
||||
* Arguments:
|
||||
* 0: unit to be loaded <OBJECT>
|
||||
* 1: vehicle that will beloaded <OBJECT>
|
||||
* 2: caller that will load <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit","_vehicle","_caller","_handle","_loaded","_slotsOpen"];
|
||||
_unit = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_vehicle = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_caller = [_this, 2, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_slotsOpen = false;
|
||||
params ["_unit", "_vehicle", "_caller"];
|
||||
|
||||
if (!alive _unit) then {
|
||||
_unit = [_unit,_caller] call FUNC(makeCopyOfBody);
|
||||
_unit = [_unit, _caller] call FUNC(makeCopyOfBody);
|
||||
};
|
||||
|
||||
private "_slotsOpen";
|
||||
|
||||
_slotsOpen = false;
|
||||
|
||||
if (_vehicle emptyPositions "cargo" > 0) then {
|
||||
_unit moveInCargo _vehicle;
|
||||
@ -32,26 +35,29 @@ if (_vehicle emptyPositions "cargo" > 0) then {
|
||||
};
|
||||
|
||||
if (_slotsOpen) then {
|
||||
_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]];
|
||||
_loaded pushback _unit;
|
||||
_vehicle setvariable [QGVAR(loaded_persons),_loaded,true];
|
||||
if (!([_unit] call FUNC(isAwake))) then {
|
||||
_handle = [_unit,_vehicle] spawn {
|
||||
private ["_unit","_vehicle"];
|
||||
_unit = _this select 0;
|
||||
_vehicle = _this select 1;
|
||||
waituntil {vehicle _unit == _vehicle};
|
||||
sleep 0.5;
|
||||
private "_loaded";
|
||||
_loaded = _vehicle getVariable [QGVAR(loaded_persons),[]];
|
||||
_loaded pushBack _unit;
|
||||
|
||||
//Save the "awake" animation before applying the death animation
|
||||
if (vehicle _unit == _vehicle) then {
|
||||
_unit setVariable [QEGVAR(medical,vehicleAwakeAnim), [_vehicle, (animationState _unit)]];
|
||||
};
|
||||
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
|
||||
};
|
||||
} else {
|
||||
if ([_unit] call FUNC(isArrested)) then {
|
||||
_vehicle setVariable [QGVAR(loaded_persons), _loaded, true];
|
||||
|
||||
if !([_unit] call FUNC(isAwake)) then {
|
||||
[{
|
||||
(_this select 0) params ["_unit", "_vehicle"];
|
||||
|
||||
// wait until the unit is in the vehicle
|
||||
if (vehicle _unit != _vehicle) exitWith {
|
||||
// kill this pfh if either one is deleted
|
||||
if (isNull _unit || isNull _vehicle) then {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
};
|
||||
|
||||
_unit setVariable [QEGVAR(medical,vehicleAwakeAnim), [_vehicle, animationState _unit]];
|
||||
|
||||
[_unit, [_unit] call FUNC(getDeathAnim), 1, true] call FUNC(doAnimation);
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
}, 0.5, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
};
|
@ -13,28 +13,26 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_name", "_isClientSetable", "_isForced", "_profileValue"];
|
||||
|
||||
// Iterate through settings
|
||||
{
|
||||
_name = _x select 0;
|
||||
_isClientSetable = _x select 2;
|
||||
_isForced = _x select 6;
|
||||
_x params ["_name", "", "_isClientSetable", "", "", "", "_isForced"];
|
||||
|
||||
// If setting is user setable
|
||||
if (_isClientSetable) then {
|
||||
// If setting is not forced
|
||||
if !(_isForced) then {
|
||||
_profileValue = profileNamespace getvariable _name;
|
||||
private "_profileValue";
|
||||
_profileValue = profileNamespace getVariable _name;
|
||||
|
||||
// If the setting is stored on the profile
|
||||
if !(isNil "_profileValue") then {
|
||||
// If the profile variable has the correct type
|
||||
if (typeName _profileValue == typeName (missionNamespace getvariable _name)) then {
|
||||
if (typeName _profileValue == typeName (missionNamespace getVariable _name)) then {
|
||||
// Load the setting from the profile
|
||||
missionNamespace setvariable [_name, _profileValue];
|
||||
missionNamespace setVariable [_name, _profileValue];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
} forEach GVAR(settings);
|
||||
false
|
||||
} count GVAR(settings);
|
||||
|
@ -13,24 +13,26 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_parseConfigForSettings"];
|
||||
|
||||
GVAR(settings) = [];
|
||||
|
||||
_parseConfigForSettings = {
|
||||
private ["_config", "_countOptions", "_optionEntry", "_index"];
|
||||
private "_fnc_parseConfigForSettings";
|
||||
_fnc_parseConfigForSettings = {
|
||||
private ["_config", "_countOptions", "_optionEntry"];
|
||||
|
||||
_config = _this select 0;
|
||||
_countOptions = count _config;
|
||||
|
||||
for "_index" from 0 to (_countOptions - 1) do {
|
||||
_optionEntry = _config select _index;
|
||||
[_optionEntry] call FUNC(setSettingFromConfig);
|
||||
};
|
||||
|
||||
// Check if all settings should be forced
|
||||
if (GVAR(forceAllSettings)) then {
|
||||
{
|
||||
_x set [6, true];
|
||||
} forEach GVAR(settings);
|
||||
false
|
||||
} count GVAR(settings);
|
||||
};
|
||||
};
|
||||
|
||||
@ -41,17 +43,18 @@ _parseConfigForSettings = {
|
||||
// This ensures that all settings are of their correct type, in case an outdated or corrupt server config is used , as well as have their correct localized display name and description
|
||||
|
||||
// Regular config
|
||||
[configFile >> "ACE_Settings"] call _parseConfigForSettings;
|
||||
[configFile >> "ACE_Settings"] call _fnc_parseConfigForSettings;
|
||||
|
||||
// Server config
|
||||
[configFile >> "ACE_ServerSettings"] call _parseConfigForSettings;
|
||||
[configFile >> "ACE_ServerSettings"] call _fnc_parseConfigForSettings;
|
||||
|
||||
// mission side settings
|
||||
[missionConfigFile >> "ACE_Settings"] call _parseConfigForSettings;
|
||||
[missionConfigFile >> "ACE_Settings"] call _fnc_parseConfigForSettings;
|
||||
|
||||
// Publish all settings data
|
||||
publicVariable QGVAR(settings);
|
||||
// Publish all setting values
|
||||
{
|
||||
publicVariable (_x select 0);
|
||||
} forEach GVAR(settings);
|
||||
false
|
||||
} count GVAR(settings);
|
||||
|
@ -3,31 +3,37 @@
|
||||
*
|
||||
* Execute a local event on this client only.
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Event name (string)
|
||||
* 1: Event args (any)
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_eventName,_eventArgs);
|
||||
params ["_eventName", "_eventArgs"];
|
||||
|
||||
private["_eventIndex", "_eventNames", "_events"];
|
||||
GVAR(events) params ["_eventNames", "_eventArray"];
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
private "_eventIndex";
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
if(_eventIndex != -1) then {
|
||||
_events = (GVAR(events) select 1) select _eventIndex;
|
||||
|
||||
if (_eventIndex != -1) then {
|
||||
private "_events";
|
||||
_events = _eventArray select _eventIndex;
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
ACE_LOGINFO_1("* Local Event: %1",_eventName);
|
||||
ACE_LOGINFO_1(" args=%1",_eventArgs);
|
||||
#endif
|
||||
|
||||
{
|
||||
if(!isNil "_x") then {
|
||||
_eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex));
|
||||
if (!isNil "_x") then {
|
||||
_eventArgs call CALLSTACK_NAMED(_x,FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex));
|
||||
|
||||
#ifdef DEBUG_EVENTS_CALLSTACK
|
||||
ACE_LOGINFO_1(" ID: %1",_forEachIndex);
|
||||
#endif
|
||||
|
@ -1,25 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
if ((_this select 0) in (missionNamespace getVariable ["ACE_Debug", []])) then {
|
||||
_this resize 4;
|
||||
|
||||
PARAMS_4(_type,_argument,_function,_showInGame);
|
||||
|
||||
if (isNil "_function") then {
|
||||
_function = {_this};
|
||||
};
|
||||
|
||||
if (isNil "_showInGame") then {
|
||||
_showInGame = true;
|
||||
};
|
||||
|
||||
private "_result";
|
||||
_result = _argument call _function;
|
||||
|
||||
if (_showInGame) then {
|
||||
systemChat format ["%1", _result];
|
||||
};
|
||||
|
||||
diag_log text format ["[ACE] Debug: %1 : %2 - %3 : %4", _type, diag_frameno, _fnc_scriptNameParent, _result];
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
[allControls findDisplay _this, {ctrlIDC _this}] call FUNC(map)
|
@ -1,4 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
[allDisplays, {ctrlIDD _this}] call FUNC(map)
|
@ -1,18 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_configs", "_entries", "_name"];
|
||||
|
||||
_configs = "true" configClasses (configFile >> _this);
|
||||
|
||||
_entries = [];
|
||||
|
||||
{
|
||||
{
|
||||
_name = toLower configName _x;
|
||||
if !(_name in _entries) then {
|
||||
diag_log text _name;
|
||||
_entries pushBack _name;
|
||||
};
|
||||
} forEach configProperties [_x, "toLower configName _x find 'ace' == 0", false];
|
||||
} forEach _configs;
|
Loading…
Reference in New Issue
Block a user