mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Vehicle Lock - Enable for planes (#6646)
* enable vehicle lock module for planes * Add actions to planes * improved lazy eval * remove superfluous parent class check * IS_KIND_OF_ANY macro * Update addons/vehiclelock/functions/fnc_moduleSync.sqf * Improve handleVehicleInitPost XEH
This commit is contained in:
parent
6f6b0d15f8
commit
001942b2ed
@ -16,21 +16,3 @@ class Extended_PostInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_InitPost_EventHandlers {
|
||||
class Car {
|
||||
class ADDON {
|
||||
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
|
||||
};
|
||||
};
|
||||
class Tank {
|
||||
class ADDON {
|
||||
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
|
||||
};
|
||||
};
|
||||
class Helicopter {
|
||||
class ADDON {
|
||||
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -58,6 +58,9 @@ class CfgVehicles {
|
||||
class Helicopter: Air {
|
||||
MACRO_LOCK_ACTIONS
|
||||
};
|
||||
class Plane: Air {
|
||||
MACRO_LOCK_ACTIONS
|
||||
};
|
||||
class Motorcycle: LandVehicle {
|
||||
MACRO_LOCK_ACTIONS
|
||||
};
|
||||
|
@ -4,12 +4,18 @@
|
||||
[QGVAR(setupCustomKey), {_this call FUNC(serverSetupCustomKeyEH)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(setVehicleLock), {_this call FUNC(setVehicleLockEH)}] call CBA_fnc_addEventHandler;
|
||||
|
||||
if (!hasInterface) exitwith {};
|
||||
|
||||
["ace_settingsInitialized", {
|
||||
TRACE_1("SettingsInitialized eh",GVAR(LockVehicleInventory));
|
||||
TRACE_2("SettingsInitialized eh",GVAR(LockVehicleInventory),GVAR(VehicleStartingLockState));
|
||||
|
||||
if (GVAR(LockVehicleInventory)) then {
|
||||
if (hasInterface && {GVAR(LockVehicleInventory)}) then {
|
||||
["CAManBase", "InventoryOpened", {_this call FUNC(onOpenInventory)}] call CBA_fnc_addClassEventHandler;
|
||||
};
|
||||
if (isServer && {GVAR(VehicleStartingLockState) != -1}) then {
|
||||
[{
|
||||
TRACE_1("adding lock handler",GVAR(VehicleStartingLockState));
|
||||
{
|
||||
[_x, "initpost", LINKFUNC(handleVehicleInitPost), true, [], true] call CBA_fnc_addClassEventHandler;
|
||||
} forEach ["Car", "Tank", "Air"];
|
||||
}, [], 0.25] call CBA_fnc_waitAndExecute;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* For every lockable vehicle, sets the starting lock state to a sane value.
|
||||
* Only run if the InitModule is placed.
|
||||
* Only run if the enabled via settings
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
@ -16,28 +16,18 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
params ["_vehicle"];
|
||||
TRACE_1("params",_vehicle);
|
||||
TRACE_1("handleVehicleInitPost",_vehicle);
|
||||
|
||||
[{
|
||||
//If the module wasn't placed, just exit (needs to be in wait because objectInitEH is before moduleInit)
|
||||
if (GVAR(VehicleStartingLockState) == -1) exitWith {};
|
||||
|
||||
params ["_vehicle"];
|
||||
|
||||
if ((_vehicle isKindOf "Car") || {_vehicle isKindOf "Tank"} || {_vehicle isKindOf "Helicopter"}) then {
|
||||
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states)
|
||||
private _lock = switch (GVAR(VehicleStartingLockState)) do {
|
||||
case (0): { (locked _vehicle) in [2, 3] };
|
||||
case (1): { true };
|
||||
case (2): { false };
|
||||
};
|
||||
if ((_lock && {(locked _vehicle) != 2}) || {!_lock && {(locked _vehicle) != 0}}) then {
|
||||
TRACE_3("Setting Lock State",_lock,(typeOf _vehicle),_vehicle);
|
||||
[QGVAR(SetVehicleLock), [_vehicle, _lock], [_vehicle]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
if (alive _vehicle) then {
|
||||
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states)
|
||||
private _lock = switch (GVAR(VehicleStartingLockState)) do {
|
||||
case 0: {locked _vehicle in [2, 3]};
|
||||
case 1: {true};
|
||||
case 2: {false};
|
||||
};
|
||||
//Delay call until mission start (so everyone has the eventHandler's installed)
|
||||
}, [_vehicle], 0.25] call CBA_fnc_waitAndExecute;
|
||||
if ((_lock && {locked _vehicle != 2}) || {!_lock && {locked _vehicle != 0}}) then {
|
||||
TRACE_3("Setting Lock State",_lock,typeOf _vehicle,_vehicle);
|
||||
[QGVAR(SetVehicleLock), [_vehicle, _lock], [_vehicle]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
};
|
||||
|
@ -28,7 +28,9 @@ if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not ac
|
||||
params ["_syncedObjects"];
|
||||
|
||||
private _listOfVehicles = _syncedObjects select {
|
||||
(_x isKindOf "Car") || {(_x isKindOf "Tank") || {_x isKindOf "Helicopter"}}
|
||||
private _object = _x;
|
||||
#define CLASSNAMES ["Car", "Tank", "Air"]
|
||||
IS_KIND_OF_ANY(_object,CLASSNAMES)
|
||||
};
|
||||
|
||||
if (_listOfVehicles isEqualTo []) exitWith { //Verbose error for mission makers (only shows on server)
|
||||
|
@ -15,3 +15,5 @@
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
#define IS_KIND_OF_ANY(object,classnames) ((classnames) findIf {(object) isKindOf _x} > -1)
|
||||
|
Loading…
Reference in New Issue
Block a user