Moved and expanded in-vehicle interactions to cockpit_interactions

This commit is contained in:
BaerMitUmlaut 2016-04-29 14:26:30 +02:00
parent 437f85a3b3
commit a0770c7707
34 changed files with 552 additions and 0 deletions

View File

@ -0,0 +1 @@
z\ace\addons\cockpit_interaction

View File

@ -0,0 +1,9 @@
class CfgActions {
class None;
class EngineOn: None {
show = 0;
};
class EngineOff: None {
show = 0;
};
};

View File

@ -0,0 +1,41 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_Init_EventHandlers {
class Air {
class ADDON {
init = QUOTE([ARR_2(_this select 0,local (_this select 0))] call FUNC(onLocal));
};
};
};
class Extended_Engine_EventHandlers {
class Air {
class ADDON {
engine = QUOTE(_this call FUNC(onEngine));
};
};
};
class Extended_Local_EventHandlers {
class Air {
class ADDON {
local = QUOTE(_this call FUNC(onLocal));
};
};
};

View File

@ -0,0 +1,117 @@
class CfgVehicles {
class Helicopter_Base_H;
class Heli_Light_01_base_F: Helicopter_Base_H {
GVAR(enabled) = 1;
class ACE_SelfSpatialActions {
class GVAR(StarterOn) {
icon = QUOTE(PATHTOF(UI\StarterOff.paa));
displayName = "";
selection = "";
position = "[0.057,1.725,-0.24]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(starterOn)),false)]));
statement = QUOTE([_target] call FUNC(switchStarter));
};
class GVAR(StarterOff) {
icon = QUOTE(PATHTOF(UI\StarterOn.paa));
displayName = "";
selection = "";
position = "[0.057,1.725,-0.24]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(starterOn)),false)]));
statement = QUOTE([_target] call FUNC(switchStarter));
};
class GVAR(BatteryOn) {
icon = QUOTE(PATHTOF(UI\BatteryOff.paa));
displayName = "";
selection = "";
position = "[-0.08,1.74,-0.01]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(batteryOn)),false)]));
statement = QUOTE([_target] call FUNC(switchBattery));
};
class GVAR(BatteryOff) {
icon = QUOTE(PATHTOF(UI\BatteryOn.paa));
displayName = "";
selection = "";
position = "[-0.08,1.74,-0.01]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(batteryOn)),false)]));
statement = QUOTE([_target] call FUNC(switchBattery));
};
class GVAR(GeneratorOn) {
icon = QUOTE(PATHTOF(UI\GeneratorOff.paa));
displayName = "";
selection = "";
position = "[-0.08,1.735,-0.05]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(generatorOn)),false)]));
statement = QUOTE([_target] call FUNC(switchGenerator));
};
class GVAR(GeneratorOff) {
icon = QUOTE(PATHTOF(UI\GeneratorOn.paa));
displayName = "";
selection = "";
position = "[-0.08,1.735,-0.05]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(generatorOn)),false)]));
statement = QUOTE([_target] call FUNC(switchGenerator));
};
class GVAR(FuelPumpsOn) {
icon = QUOTE(PATHTOF(UI\FuelPumpsOff.paa));
displayName = "";
selection = "";
position = "[-0.055,1.74,-0.015]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(fuelPumpsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchFuelPumps));
};
class GVAR(FuelPumpsOff) {
icon = QUOTE(PATHTOF(UI\FuelPumpsOn.paa));
displayName = "";
selection = "";
position = "[-0.055,1.74,-0.015]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(fuelPumpsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchFuelPumps));
};
class GVAR(CollisionLightsOn) {
icon = QUOTE(PATHTOF(UI\CollisionLightsOff.paa));
displayName = "";
selection = "";
position = "[-0.008,1.74,-0.015]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(collisionLightsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchCollisionLight));
};
class GVAR(CollisionLightsOff) {
icon = QUOTE(PATHTOF(UI\CollisionLightsOn.paa));
displayName = "";
selection = "";
position = "[-0.008,1.74,-0.015]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(collisionLightsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchCollisionLight));
};
class GVAR(MainLightsOn) {
icon = QUOTE(PATHTOF(UI\MainLightsOff.paa));
displayName = "";
selection = "";
position = "[0.054,1.735,-0.05]";
distance = 1.5;
condition = QUOTE(!(_target getVariable [ARR_2(QUOTE(QGVAR(mainLightsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchMainLight));
};
class GVAR(MainLightsOff) {
icon = QUOTE(PATHTOF(UI\MainLightsOn.paa));
displayName = "";
selection = "";
position = "[0.054,1.735,-0.05]";
distance = 1.5;
condition = QUOTE((_target getVariable [ARR_2(QUOTE(QGVAR(mainLightsOn)),false)]));
statement = QUOTE([_target] call FUNC(switchMainLight));
};
};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
PREP(handleActionsPFH);
PREP(onEngine);
PREP(onLocal);
PREP(switchBattery);
PREP(switchCollisionLight);
PREP(switchFuelPumps);
PREP(switchGenerator);
PREP(switchMainLight);
PREP(switchStarter);
PREP(switchStarterInternal);
PREP(updateElectricalPower);

View File

@ -0,0 +1,25 @@
#include "script_component.hpp"
[QGVAR(setEngineOn), {
params ["_vehicle", "_state"];
_vehicle setVariable [QGVAR(engineOn), _state, true];
_vehicle engineOn _state;
}] call EFUNC(common,addEventHandler);
[QGVAR(setPilotLight), {
params ["_vehicle", "_state"];
_vehicle setPilotLight _state;
}] call EFUNC(common,addEventHandler);
[QGVAR(setCollisionLight), {
params ["_vehicle", "_state"];
_vehicle setCollisionLight _state;
}] call EFUNC(common,addEventHandler);
[QGVAR(simulatePowerLoss), {
params ["_vehicle"];
_vehicle setVariable [QGVAR(engineOn), false, true];
_vehicle engineOn false;
_vehicle setPilotLight false;
_vehicle setCollisionLight false;
}] call EFUNC(common,addEventHandler);

View File

@ -0,0 +1,7 @@
#include "script_component.hpp"
ADDON = false;
#include "XEH_PREP.hpp"
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

View File

@ -0,0 +1,17 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author[] = {""};
authorUrl = "";
VERSION_CONFIG;
};
};
#include "CfgActions.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,31 @@
/*
* Author: BaerMitUmlaut
* PFH for handling vehicle actions.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_handleActionsPFH
*
* Public: No
*/
#include "script_component.hpp"
params ["_arguments", "_pfhHandle"];
_arguments params ["_vehicle"];
if (_vehicle getVariable [QGVAR(hasElectricalPower), false]) then {
if !((isCollisionLightOn _vehicle) isEqualTo (_vehicle getVariable [QGVAR(collisionLightsOn), false])) then {
[_vehicle] call FUNC(switchCollisionLight);
};
if !((isLightOn _vehicle) isEqualTo (_vehicle getVariable [QGVAR(mainLightsOn), false])) then {
[_vehicle] call FUNC(switchMainLight);
};
} else {
_vehicle setCollisionLight false;
_vehicle setPilotLight false;
};

View File

@ -0,0 +1,34 @@
/*
* Author: BaerMitUmlaut
* Disables the engine or switches the switches for AI pilots.
*
* Arguments:
* 0: Aircraft <OBJECT>
* 1: Engine state <BOOL>
*
* Return Value:
* None
*
* Example:
* [_helo, true] call ace_cockpit_interaction_fnc_onEngine
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle", "_engineOn"];
if !(local _vehicle) exitWith {};
if (isPlayer driver _vehicle) then {
if !(_vehicle getVariable [QGVAR(engineOn), false]) then {
_vehicle engineOn false;
};
} else {
// Flip the switches for AI pilots
_vehicle setVariable [QGVAR(engineOn), _engineOn, true];
_vehicle setVariable [QGVAR(batteryOn), _engineOn, true];
_vehicle setVariable [QGVAR(fuelPumpsOn), _engineOn, true];
_vehicle setVariable [QGVAR(generatorOn), _engineOn, true];
_vehicle setVariable [QGVAR(hasElectricalPower), _engineOn, true];
};

View File

@ -0,0 +1,29 @@
/*
* Author: BaerMitUmlaut
* Adds/removes the handleActionsPFH where the vehicle is/was local.
*
* Arguments:
* 0: Aircraft <OBJECT>
* 1: Local <BOOL>
*
* Return Value:
* None
*
* Example:
* [_helo, true] call ace_cockpit_interaction_fnc_onLocal
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle", "_local"];
if !(getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(enabled)) == 1) exitWith {};
if (_local) then {
private _pfh = [FUNC(handleActionsPFH), 0, _vehicle] call CBA_fnc_addPerFrameHandler;
_vehicle setVariable [QGVAR(handleActionsPFH), _pfh];
} else {
private _pfh = _vehicle getVariable [QGVAR(handleActionsPFH), -1];
[_pfh] call CBA_fnc_removePerFrameHandler;
};

View File

@ -0,0 +1,21 @@
/*
* Author: BaerMitUmlaut
* Switches the battery of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchBattery
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
_vehicle setVariable [QGVAR(batteryOn), !(_vehicle getVariable [QGVAR(batteryOn), false]), true];
[_vehicle] call FUNC(updateElectricalPower);

View File

@ -0,0 +1,24 @@
/*
* Author: BaerMitUmlaut
* Switches the anti collision lights of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchCollisionLight
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
private _collisionLightsOn = _vehicle getVariable [QGVAR(collisionLightsOn), false];
private _hasElectricalPower = _vehicle getVariable [QGVAR(hasElectricalPower), false];
_vehicle setVariable [QGVAR(collisionLightsOn), !_collisionLightsOn, true];
[QGVAR(setCollisionLight), _vehicle, [_vehicle, _hasElectricalPower && !_collisionLightsOn]] call EFUNC(common,objectEvent);

View File

@ -0,0 +1,29 @@
/*
* Author: BaerMitUmlaut
* Switches the fuel pumps of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchFuelPumps
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
if (_vehicle getVariable [QGVAR(fuelPumpsOn), false]) then {
if (isEngineOn _vehicle) then {
[QGVAR(setEngineOn), _vehicle, [_vehicle, false]] call EFUNC(common,objectEvent);
[_vehicle] call FUNC(updateElectricalPower);
// TODO: add engine damage?
};
_vehicle setVariable [QGVAR(fuelPumpsOn), false, true];
} else {
_vehicle setVariable [QGVAR(fuelPumpsOn), true, true];
};

View File

@ -0,0 +1,21 @@
/*
* Author: BaerMitUmlaut
* Switches the generator of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchGenerator
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
_vehicle setVariable [QGVAR(generatorOn), !(_vehicle getVariable [QGVAR(generatorOn), false]), true];
[_vehicle] call FUNC(updateElectricalPower);

View File

@ -0,0 +1,24 @@
/*
* Author: BaerMitUmlaut
* Switches the main lights of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchMainLights
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
private _mainLightsOn = _vehicle getVariable [QGVAR(mainLightsOn), false];
private _hasElectricalPower = _vehicle getVariable [QGVAR(hasElectricalPower), false];
_vehicle setVariable [QGVAR(mainLightsOn), !_mainLightsOn, true];
[QGVAR(setPilotLight), _vehicle, [_vehicle, _hasElectricalPower && !_mainLightsOn]] call EFUNC(common,objectEvent);

View File

@ -0,0 +1,24 @@
/*
* Author: BaerMitUmlaut
* Switches the turbine starter switch of any aircraft on or off.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchStarter
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
private _starterOn = _vehicle getVariable [QGVAR(starterOn), false];
if (!_starterOn && {_vehicle getVariable [QGVAR(hasElectricalPower), false]}) then {
[_vehicle] call FUNC(switchStarterInternal);
};
_vehicle setVariable [QGVAR(starterOn), !_starterOn, true];

View File

@ -0,0 +1,32 @@
/*
* Author: BaerMitUmlaut
* Switches the turbine starter of any aircraft on or off. Internal function, disconnected from the switch.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_switchStarterInternal
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
[{
params ["_args", "_pfhID"];
_args params ["_vehicle", "_startTime"];
if !(_vehicle getVariable [QGVAR(hasElectricalPower), false] && {_vehicle getVariable [QGVAR(starterOn), false]}) exitWith {
[_pfhID] call CBA_fnc_removePerFrameHandler;
};
if ((ACE_time - _startTime) > (5 + random 3)) exitWith {
[QGVAR(setEngineOn), _vehicle, [_vehicle, true]] call EFUNC(common,objectEvent);
[_pfhID] call CBA_fnc_removePerFrameHandler;
};
}, 0, [_vehicle, ACE_time]] call CBA_fnc_addPerFrameHandler;

View File

@ -0,0 +1,38 @@
/*
* Author: BaerMitUmlaut
* Turns the electrical power of any aircraft on or off, depending on the state of
* the battery, engine and generator.
*
* Arguments:
* 0: Aircraft <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_helo] call ace_cockpit_interaction_fnc_updateElectricalPower
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
if (_vehicle getVariable [QGVAR(batteryOn), false] || {(isEngineOn _vehicle) && {_vehicle getVariable [QGVAR(generatorOn), false]}}) then {
_vehicle setVariable [QGVAR(hasElectricalPower), true, true];
if (_vehicle getVariable [QGVAR(collisionLightsOn), false]) then {
[QGVAR(setCollisionLight), _vehicle, [_vehicle, true]] call EFUNC(common,objectEvent);
};
if (_vehicle getVariable [QGVAR(mainLightsOn), false]) then {
[QGVAR(setPilotLight), _vehicle, [_vehicle, true]] call EFUNC(common,objectEvent);
};
if (_vehicle getVariable [QGVAR(starterOn), false]) then {
[_vehicle] call FUNC(switchStarterInternal);
};
} else {
_vehicle setVariable [QGVAR(hasElectricalPower), false, true];
[QGVAR(simulatePowerLoss), _vehicle, [_vehicle]] call EFUNC(common,objectEvent);
if (_vehicle getVariable [QGVAR(starterOn), false]) then {
[_vehicle] call FUNC(switchStarterInternal);
};
};

View File

@ -0,0 +1 @@
#include "\z\ace\addons\cockpit_interaction\script_component.hpp"

View File

@ -0,0 +1,13 @@
#define COMPONENT cockpit_interaction
#include "\z\ace\addons\main\script_mod.hpp"
#define DISABLE_COMPILE_CACHE
#ifdef DEBUG_ENABLED_COCKPIT_INTERACTION
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_COCKPIT_INTERACTION
#define DEBUG_SETTINGS DEBUG_SETTINGS_COCKPIT_INTERACTION
#endif
#include "\z\ace\addons\main\script_macros.hpp"