Merge pull request #2501 from acemod/commoncleanup4

common code cleanup part 4
This commit is contained in:
commy2
2015-09-18 19:54:04 +02:00
24 changed files with 251 additions and 342 deletions

View File

@ -19,7 +19,6 @@ PREP(binarizeNumber);
PREP(blurScreen); PREP(blurScreen);
PREP(cachedCall); PREP(cachedCall);
PREP(canGetInPosition); PREP(canGetInPosition);
PREP(canInteract);
PREP(canInteractWith); PREP(canInteractWith);
PREP(canUseWeapon); PREP(canUseWeapon);
PREP(changeProjectileDirection); PREP(changeProjectileDirection);
@ -114,7 +113,6 @@ PREP(interpolateFromArray);
PREP(inTransitionAnim); PREP(inTransitionAnim);
PREP(inWater); PREP(inWater);
PREP(isAlive); PREP(isAlive);
PREP(isArrested);
PREP(isAutoWind); PREP(isAutoWind);
PREP(isAwake); PREP(isAwake);
PREP(isEngineer); PREP(isEngineer);
@ -160,8 +158,6 @@ PREP(runAfterSettingsInit);
PREP(sanitizeString); PREP(sanitizeString);
PREP(sendRequest); PREP(sendRequest);
PREP(serverLog); PREP(serverLog);
PREP(setArrestState);
PREP(setCanInteract);
PREP(setCaptivityStatus); PREP(setCaptivityStatus);
PREP(setDefinedVariable); PREP(setDefinedVariable);
PREP(setDisableUserInputStatus); PREP(setDisableUserInputStatus);
@ -235,10 +231,6 @@ PREP(getTurretsOther);
PREP(exportConfig); PREP(exportConfig);
PREP(getChildren); PREP(getChildren);
PREP(getDisplayConfigName); PREP(getDisplayConfigName);
PREP(log);
PREP(logControls);
PREP(logDisplays);
PREP(logModEntries);
PREP(monitor); PREP(monitor);
PREP(showUser); PREP(showUser);

View File

@ -1,19 +0,0 @@
/*
* Author: Glowbal
* Check if unit can interact with enviroment. Unit has to be awake and not be in arrested state.
*
* Arguments:
* 0: Unit that try to Interact <OBJECT>
*
* Return Value:
* Can interact with enviroment <BOOL>
*
* Public: No
*
* Deprecated
*/
#include "script_component.hpp"
params ["_unit"];
(_unit getvariable [QGVAR(canInteract),0]) < 1 && [_unit] call FUNC(isAwake) && !([_unit] call FUNC(isArrested))

View File

@ -2,7 +2,7 @@
* Author: commy2 * Author: commy2
* Removes the brackets around a code and returns the code as a string. It does nothing if the code is already a string. * Removes the brackets around a code and returns the code as a string. It does nothing if the code is already a string.
* *
* Argument: * Arguments:
* 0: Code <CODE, STRING> * 0: Code <CODE, STRING>
* *
* Return value: * Return value:

View File

@ -2,8 +2,8 @@
* Author: esteldunedain * Author: esteldunedain
* Returns a orthonormal system of reference aligned with the supplied vector * Returns a orthonormal system of reference aligned with the supplied vector
* *
* Argument: * Arguments:
* Vector to align the coordinate system with (Array) * Vector to align the coordinate system with <ARRAY>
* *
* Return Value: * Return Value:
* 0: Vector Normalized <ARRAY> * 0: Vector Normalized <ARRAY>

View File

@ -1,25 +1,25 @@
/* /*
* Author: KoffeinFlummi * Author: KoffeinFlummi
*
* Returns the Hadamard Product of two vectors. * Returns the Hadamard Product of two vectors.
* (x hadamard y) = [x1*y1, x2*y2, x3*y3] * (x hadamard y) = [x1*y1, x2*y2, x3*y3]
* *
* Arguments: * Arguments:
* 0: Vector 1 * 0: Vector 1 <ARRAY>
* 1: Vector 2 * 1: Vector 2 <ARRAY>
* *
* Return Value: * Return Value:
* Hadamard Product * Hadamard Product <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_vector1,_vector2); params ["_vector1", "_vector2"];
private ["_newVector", "_i"];
private "_newVector";
_newVector = []; _newVector = [];
for "_i" from 0 to (((count _vector1) min (count _vector2)) - 1) do { for "_i" from 0 to ((count _vector1 min count _vector2) - 1) do {
_newVector pushBack ((_vector1 select _i) * (_vector2 select _i)); _newVector pushBack ((_vector1 select _i) * (_vector2 select _i));
}; };

View File

@ -1,42 +1,49 @@
/** /*
* fnc_headbugfix.sqf * Author: rocko
* @Descr: Fixes animation issues that may get you stuck * Fixes animation issues that may get you stuck
* @Author: rocko
* *
* @Arguments: * Arguments:
* @Return: nil * None
* @PublicAPI: true *
* Return Value:
* None
*
* Public: Yes
*
* Note: Has to be spawned not called
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_pos","_dir","_anim"];
_anim = animationState ACE_player; private ["_unit", "_anim", "_pos", "_dir", "_dummy"];
_unit = ACE_player;
_anim = animationState _unit;
["HeadbugFixUsed", [profileName, _anim]] call FUNC(serverEvent); ["HeadbugFixUsed", [profileName, _anim]] call FUNC(serverEvent);
["HeadbugFixUsed", [profileName, _anim]] call FUNC(localEvent); ["HeadbugFixUsed", [profileName, _anim]] call FUNC(localEvent);
if (ACE_player != vehicle ACE_player || { !([ACE_player, objNull, ["isNotSitting"]] call FUNC(canInteractWith)) } ) exitWith {false}; if (_unit != vehicle _unit || {!([_unit, objNull, ["isNotSitting"]] call FUNC(canInteractWith))}) exitWith {false};
_pos = getposATL ACE_player; _pos = getPosATL _unit;
_dir = getDir ACE_player; _dir = getDir _unit;
titleCut ["", "BLACK"]; titleCut ["", "BLACK"];
[ACE_Player, "headBugFix"] call FUNC(hideUnit); [_unit, "headBugFix"] call FUNC(hideUnit);
// create invisible headbug fix vehicle // create invisible headbug fix vehicle
_ACE_HeadbugFix = "ACE_Headbug_Fix" createVehicleLocal _pos; _dummy = createVehicle ["ACE_Headbug_Fix", _pos, [], 0, "NONE"];
_ACE_HeadbugFix setDir _dir; _dummy setDir _dir;
ACE_player moveInAny _ACE_HeadbugFix; _unit moveInAny _dummy;
sleep 0.1; sleep 0.1;
unassignVehicle ACE_player; unassignVehicle _unit;
ACE_player action ["Eject", vehicle ACE_player]; _unit action ["Eject", vehicle _unit];
ACE_player setDir _dir; _unit setDir _dir;
ACE_player setposATL _pos; _unit setPosATL _pos;
sleep 1.0; sleep 1.0;
deleteVehicle _ACE_HeadbugFix; deleteVehicle _dummy;
[ACE_Player, "headBugFix"] call FUNC(unhideUnit); [_unit, "headBugFix"] call FUNC(unhideUnit);
titleCut ["", "PLAIN"]; titleCut ["", "PLAIN"];
true true

View File

@ -14,10 +14,9 @@
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_reason); params ["_unit", "_reason"];
if (isNull _unit) exitWith {}; if (isNull _unit) exitWith {};
@ -29,6 +28,6 @@ if !(_reason in _setHiddenReasons) then {
_unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true]; _unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true];
}; };
//if !(isObjectHidden _unit) then { (Uncomment when isObjectHidden hits stable branch) if !(isObjectHidden _unit) then {
["hideObjectGlobal",[_unit,true]] call FUNC(serverEvent); ["hideObjectGlobal", [_unit, true]] call FUNC(serverEvent);
//}; };

View File

@ -1,4 +1,15 @@
// by commy2 /*
* Author: commy2
* Check if given unit is in a transitional animation
*
* Arguments:
* 0: A soldier <Object>
*
* Return Value:
* <Bool>
*
* Public: Yes
*/
#include "script_component.hpp" #include "script_component.hpp"
getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "looped") == 0 getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "looped") == 0

View File

@ -1,25 +1,29 @@
/** /*
* fn_inWater_f.sqf * Author: Glowbal
* @Descr: Check if unit is underwater * Check if unit is underwater
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT] * Arguments:
* @Return: BOOL True if unit is in the water * 0: Unit <OBJECT>
* @PublicAPI: true *
* Return Value:
* if unit is in the water (BOOLEAN)
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_return","_aslPos"]; params ["_unit"];
PARAMS_1(_unit); private "_return";
_return = false; _return = false;
if ((surfaceIsWater getPos _unit)) then { if (surfaceIsWater getPosASL _unit) then {
_aslPos = _unit modelToWorldVisual (_unit selectionPosition "head"); private "_pos";
if ((_aslPos select 2) <= 0) then { _pos = _unit modelToWorldVisual (_unit selectionPosition "head");
if (_pos select 2 < 0) then {
_return = true; _return = true;
}; };
}; };
_return; _return

View File

@ -1,6 +1,5 @@
/* /*
* Author: commy2 * Author: commy2
*
* Check if the object still exists and is alive. This function exists because 'alive objNull' actually returns true. * Check if the object still exists and is alive. This function exists because 'alive objNull' actually returns true.
* *
* Argument: * Argument:
@ -8,6 +7,10 @@
* *
* Return value: * Return value:
* The object exists and is alive (Bool). * The object exists and is alive (Bool).
*
* Public: Yes
*
* Deprecated
*/ */
#include "script_component.hpp" #include "script_component.hpp"

View File

@ -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])

View File

@ -1,45 +1,55 @@
/** /*
* fn_loadPerson_f.sqf * Author: Glowbal
* @Descr: Loads a specified unit into any nearby vehicle * Loads a specified unit into any nearby vehicle
* @Author: Glowbal
* *
* @Arguments: [caller OBJECT, unitToBeLoaded OBJECT] * Arguments:
* @Return: OBJECT Returns the vehicle that the unitToBeloaded has been loaded in. Returns ObjNull if function failed * 0: Unit that will load <OBJECT>
* @PublicAPI: true * 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" #include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
private ["_caller", "_unit","_vehicle", "_loadcar", "_loadhelicopter", "_loadtank","_loadboat"]; params ["_caller", "_unit"];
_caller = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
_unit = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param; private ["_vehicle", "_loadcar", "_loadair", "_loadtank", "_loadboat"];
_vehicle = ObjNull;
_vehicle = objNull;
if (!([_caller] call FUNC(canInteract)) || {_caller == _unit}) exitwith {_vehicle}; if (!([_caller] call FUNC(canInteract)) || {_caller == _unit}) exitwith {_vehicle};
_loadcar = nearestObject [_unit, "car"]; _loadcar = nearestObject [_unit, "Car"];
if (_unit distance _loadcar <= 10) then { if (_unit distance _loadcar <= 10) then {
_vehicle = _loadcar; _vehicle = _loadcar;
} else { } else {
_loadhelicopter = nearestObject [_unit, "air"]; _loadair = nearestObject [_unit, "Air"];
if (_unit distance _loadhelicopter <= 10) then {
_vehicle = _loadhelicopter; if (_unit distance _loadair <= 10) then {
_vehicle = _loadair;
} else { } else {
_loadtank = nearestObject [_unit, "tank"]; _loadtank = nearestObject [_unit, "Tank"];
if (_unit distance _loadtank <= 10) then { if (_unit distance _loadtank <= 10) then {
_vehicle = _loadtank; _vehicle = _loadtank;
} else { } else {
_loadboat = nearestObject [_unit, "ship"]; _loadboat = nearestObject [_unit, "Ship_F"];
if (_unit distance _loadboat <= 10) then { if (_unit distance _loadboat <= 10) then {
_vehicle = _loadboat; _vehicle = _loadboat;
}; };
}; };
}; };
}; };
if (!isNull _vehicle) then { if (!isNull _vehicle) then {
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide); [_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 _vehicle

View File

@ -1,25 +1,28 @@
/** /*
* fn_loadPersonLocal_f.sqf * Author: Glowbal
* @Descr: Load a person, local * Load a person, local
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT, vehicle OBJECT, caller OBJECT] * Arguments:
* @Return: void * 0: unit to be loaded <OBJECT>
* @PublicAPI: false * 1: vehicle that will beloaded <OBJECT>
* 2: caller that will load <OBJECT>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit","_vehicle","_caller","_handle","_loaded","_slotsOpen"]; params ["_unit", "_vehicle", "_caller"];
_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;
if (!alive _unit) then { 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 { if (_vehicle emptyPositions "cargo" > 0) then {
_unit moveInCargo _vehicle; _unit moveInCargo _vehicle;
@ -32,26 +35,30 @@ if (_vehicle emptyPositions "cargo" > 0) then {
}; };
if (_slotsOpen) then { if (_slotsOpen) then {
_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]]; private "_loaded";
_loaded pushback _unit; _loaded = _vehicle getVariable [QGVAR(loaded_persons),[]];
_vehicle setvariable [QGVAR(loaded_persons),_loaded,true]; _loaded pushBack _unit;
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;
//Save the "awake" animation before applying the death animation _vehicle setVariable [QGVAR(loaded_persons), _loaded, true];
if (vehicle _unit == _vehicle) then {
_unit setVariable [QEGVAR(medical,vehicleAwakeAnim), [_vehicle, (animationState _unit)]]; // @todo never used. Remove?
/*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,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
};
} else {
if ([_unit] call FUNC(isArrested)) then {
}; _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;
};*/
}; };

View File

@ -13,28 +13,26 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_name", "_isClientSetable", "_isForced", "_profileValue"];
// Iterate through settings // Iterate through settings
{ {
_name = _x select 0; _x params ["_name", "", "_isClientSetable", "", "", "", "_isForced"];
_isClientSetable = _x select 2;
_isForced = _x select 6;
// If setting is user setable // If setting is user setable
if (_isClientSetable) then { if (_isClientSetable) then {
// If setting is not forced // If setting is not forced
if !(_isForced) then { if !(_isForced) then {
_profileValue = profileNamespace getvariable _name; private "_profileValue";
_profileValue = profileNamespace getVariable _name;
// If the setting is stored on the profile // If the setting is stored on the profile
if !(isNil "_profileValue") then { if !(isNil "_profileValue") then {
// If the profile variable has the correct type // 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 // Load the setting from the profile
missionNamespace setvariable [_name, _profileValue]; missionNamespace setVariable [_name, _profileValue];
}; };
}; };
}; };
}; };
false
} forEach GVAR(settings); } count GVAR(settings);

View File

@ -13,24 +13,26 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_parseConfigForSettings"];
GVAR(settings) = []; GVAR(settings) = [];
_parseConfigForSettings = { private "_fnc_parseConfigForSettings";
private ["_config", "_countOptions", "_optionEntry", "_index"]; _fnc_parseConfigForSettings = {
private ["_config", "_countOptions", "_optionEntry"];
_config = _this select 0; _config = _this select 0;
_countOptions = count _config; _countOptions = count _config;
for "_index" from 0 to (_countOptions - 1) do { for "_index" from 0 to (_countOptions - 1) do {
_optionEntry = _config select _index; _optionEntry = _config select _index;
[_optionEntry] call FUNC(setSettingFromConfig); [_optionEntry] call FUNC(setSettingFromConfig);
}; };
// Check if all settings should be forced // Check if all settings should be forced
if (GVAR(forceAllSettings)) then { if (GVAR(forceAllSettings)) then {
{ {
_x set [6, true]; _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 // 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 // Regular config
[configFile >> "ACE_Settings"] call _parseConfigForSettings; [configFile >> "ACE_Settings"] call _fnc_parseConfigForSettings;
// Server config // Server config
[configFile >> "ACE_ServerSettings"] call _parseConfigForSettings; [configFile >> "ACE_ServerSettings"] call _fnc_parseConfigForSettings;
// mission side settings // mission side settings
[missionConfigFile >> "ACE_Settings"] call _parseConfigForSettings; [missionConfigFile >> "ACE_Settings"] call _fnc_parseConfigForSettings;
// Publish all settings data // Publish all settings data
publicVariable QGVAR(settings); publicVariable QGVAR(settings);
// Publish all setting values // Publish all setting values
{ {
publicVariable (_x select 0); publicVariable (_x select 0);
} forEach GVAR(settings); false
} count GVAR(settings);

View File

@ -3,31 +3,37 @@
* *
* Execute a local event on this client only. * Execute a local event on this client only.
* *
* Argument: * Arguments:
* 0: Event name (string) * 0: Event name (string)
* 1: Event args (any) * 1: Event args (any)
* *
* Return value: * Return Value:
* Nothing * None
*
* Public: No
*/ */
#include "script_component.hpp" #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; _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 #ifdef DEBUG_EVENTS
ACE_LOGINFO_1("* Local Event: %1",_eventName); ACE_LOGINFO_1("* Local Event: %1",_eventName);
ACE_LOGINFO_1(" args=%1",_eventArgs); ACE_LOGINFO_1(" args=%1",_eventArgs);
#endif #endif
{ {
if(!isNil "_x") then { if (!isNil "_x") then {
_eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex)); _eventArgs call CALLSTACK_NAMED(_x,FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex));
#ifdef DEBUG_EVENTS_CALLSTACK #ifdef DEBUG_EVENTS_CALLSTACK
ACE_LOGINFO_1(" ID: %1",_forEachIndex); ACE_LOGINFO_1(" ID: %1",_forEachIndex);
#endif #endif

View File

@ -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];
};

View File

@ -1,4 +0,0 @@
// by commy2
#include "script_component.hpp"
[allControls findDisplay _this, {ctrlIDC _this}] call FUNC(map)

View File

@ -1,4 +0,0 @@
// by commy2
#include "script_component.hpp"
[allDisplays, {ctrlIDD _this}] call FUNC(map)

View File

@ -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;

View File

@ -1,44 +0,0 @@
/**
* fn_setArrestState.sqf
* @Descr: Set a unit in arrest state
* @Author: Glowbal
*
* @Arguments: [unitToBeArrested OBJECT, setArrested BOOL]
* @Return: void
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_unit","_setArrest"];
_unit = [_this, 0, objNull, [objNull]] call BIS_fnc_Param;
_setArrest = [_this, 1, false, [false]] call BIS_fnc_Param;
if (_setArrest) then {
[_unit, QGVAR(StateArrested), true] call FUNC(setDefinedVariable);
if ([_unit] call FUNC(isAwake)) then {
if (vehicle _unit == _unit) then {
[_unit,"UnaErcPoslechVelitele2",1] call FUNC(doAnimation);
};
};
if (IsPlayer _unit) then {
[["arrested", true],QUOTE(FUNC(setDisableUserInputStatus)),_unit,false] call EFUNC(common,execRemoteFnc);
};
_unit disableAI "Move";
_unit disableAI "ANIM";
} else {
[_unit, QGVAR(StateArrested), false] call FUNC(setDefinedVariable);
if ([_unit] call FUNC(isAwake)) then {
if (vehicle _unit == _unit) then {
[_unit,"",1] call FUNC(doAnimation);
};
_unit enableAI "Move";
_unit enableAI "ANIM";
};
if (IsPlayer _unit) then {
[["arrested", false],QUOTE(FUNC(setDisableUserInputStatus)),_unit,false] call EFUNC(common,execRemoteFnc);
};
};

View File

@ -1,30 +0,0 @@
/**
* fn_setCanInteract.sqf
* @Descr: N/A
* @Author: Glowbal
*
* @Arguments: []
* @Return:
* @PublicAPI: false
*/
#include "script_component.hpp"
private ["_unit","_to","_return"];
_unit = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
_to = _this select 1;
_return = false;
if (((typeName _to) == "SCALAR")) then {
if (_to <-1) then {
_to = -1;
} else {
if (_to > 1) then {
_to = 1;
};
};
_unit setvariable [QGVAR(canInteract), ([_unit] call FUNC(getCanInteract)) + _to,false];
_return = true;
};
_return

View File

@ -10,23 +10,26 @@
* *
* Public: No * Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
private ["_vehicle","_emptyPos"]; params ["_unit"];
PARAMS_1(_unit);
private "_vehicle";
_vehicle = vehicle _unit; _vehicle = vehicle _unit;
if (_vehicle == _unit) exitwith {false;}; if (_vehicle == _unit) exitWith {false};
if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;};
_emptyPos = ((getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]); if (speed _vehicle > 1 || getPos _vehicle select 2 > 2) exitWith {false};
if (count _emptyPos == 0) exitwith {false};
private "_emptyPos";
_emptyPos = (getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]; // @todo to small?
if (count _emptyPos == 0) exitWith {false};
if (!isNull _vehicle) then { if (!isNull _vehicle) then {
[[_unit], QUOTE(FUNC(unloadPersonLocal)), _unit, false] call EFUNC(common,execRemoteFnc); [[_unit], QUOTE(FUNC(unloadPersonLocal)), _unit, false] call FUNC(execRemoteFnc);
}; };
true; true

View File

@ -10,34 +10,48 @@
* *
* Public: No * Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
private ["_loaded", "_emptyPos","_validVehiclestate"]; params ["_unit", "_vehicle"];
PARAMS_2(_unit,_vehicle);
private ["_validVehiclestate", "_emptyPos", "_loaded"];
_validVehiclestate = true; _validVehiclestate = true;
if (_vehicle isKindOf "Ship" ) then { if (_vehicle isKindOf "Ship") then {
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; if (speed _vehicle > 1 || {getPos _vehicle select 2 > 2}) then {
TRACE_1("SHIP Ground Check", getPosATL _vehicle ); _validVehiclestate = false;
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]); // TODO: if spot is underwater pick another spot. };
TRACE_1("SHIP Ground Check",getPos _vehicle);
_emptyPos = (ASLToAGL getPosASL _vehicle) findEmptyPosition [0, 13, typeof _unit]; // TODO: if spot is underwater pick another spot.
} else { } else {
if (_vehicle isKindOf "Air" ) then { if (_vehicle isKindOf "Air") then {
if !(speed _vehicle <1 && {isTouchingGround _vehicle}) then {_validVehiclestate = false}; if (speed _vehicle > 1 || {isTouchingGround _vehicle}) then {
TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle); _validVehiclestate = false;
_emptyPos = (getPosASL _vehicle) call EFUNC(common,ASLtoPosition); };
_emptyPos = [(_emptyPos select 0) + random(5), (_emptyPos select 1) + random(5), _emptyPos select 2 ];
TRACE_1("Vehicle Ground Check",isTouchingGround _vehicle);
_emptyPos = ASLToAGL getPosASL _vehicle;
_emptyPos = _emptyPos vectorAdd [random 10 - 5, random 10 - 5, 0];
} else { } else {
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; if (speed _vehicle > 1 || {getPos _vehicle select 2 > 2}) then {
_validVehiclestate = false;
};
TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle); TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle);
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]);
_emptyPos = (ASLToAGL getPosASL _vehicle) findEmptyPosition [0, 13, typeof _unit];
}; };
}; };
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
if (!_validVehiclestate) exitwith {
if !(_validVehiclestate) exitwith {
ACE_LOGWARNING_4("Unable to unload patient because invalid (%1) vehicle state. Either moving or Not close enough on the ground. position: %2 isTouchingGround: %3 Speed: %4",_vehicle,getPos _vehicle,isTouchingGround _vehicle,speed _vehicle); ACE_LOGWARNING_4("Unable to unload patient because invalid (%1) vehicle state. Either moving or Not close enough on the ground. position: %2 isTouchingGround: %3 Speed: %4",_vehicle,getPos _vehicle,isTouchingGround _vehicle,speed _vehicle);
false false
}; };
@ -47,36 +61,45 @@ if (count _emptyPos == 0) exitwith {
false false
}; //consider displaying text saying there are no safe places to exit the vehicle }; //consider displaying text saying there are no safe places to exit the vehicle
unassignVehicle _unit; unassignVehicle _unit;
[_unit] orderGetIn false; [_unit] orderGetIn false;
TRACE_1("Ejecting", alive _unit); TRACE_1("Ejecting", alive _unit);
_unit action ["Eject", vehicle _unit]; _unit action ["Eject", vehicle _unit];
[ {
private "_anim"; [{
PARAMS_2(_unit,_emptyPos); params ["_unit", "_emptyPos"];
_unit setPosASL (_emptyPos call EFUNC(common,PositiontoASL));
if (!([_unit] call FUNC(isAwake))) then { _unit setPosASL AGLToASL _emptyPos;
// @todo never used. Remove?
/*if !([_unit] call FUNC(isAwake)) then {
TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake));
if (driver _unit == _unit) then { if (driver _unit == _unit) then {
_anim = [_unit] call EFUNC(common,getDeathAnim); private "_anim";
[_unit, _anim, 1, true] call EFUNC(common,doAnimation); _anim = [_unit] call FUNC(getDeathAnim);
[_unit, _anim, 1, true] call FUNC(doAnimation);
[{ [{
_unit = _this select 0; _unit = _this select 0;
_anim = _this select 1; _anim = _this select 1;
if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then { if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then {
[_unit, _anim, 2, true] call EFUNC(common,doAnimation); [_unit, _anim, 2, true] call FUNC(doAnimation);
}; };
}, [_unit, _anim], 0.5, 0] call EFUNC(common,waitAndExecute); }, [_unit, _anim], 0.5, 0] call FUNC(waitAndExecute);
}; };
}; };*/
},[_unit,_emptyPos], 0.5, 0] call EFUNC(common,waitAndExecute); }, [_unit, _emptyPos], 0.5, 0] call FUNC(waitAndExecute);
[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide); [_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide);
_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]]; _loaded = _vehicle getvariable [QGVAR(loaded_persons),[]];
_loaded = _loaded - [_unit]; _loaded deleteAt (_loaded find _unit);
_vehicle setvariable [QGVAR(loaded_persons),_loaded,true];
_vehicle setvariable [QGVAR(loaded_persons), _loaded, true];
true true