Customized map lighting for vehicle interiors (#5401)

* Customized map lighting for vehicle interiors

* Tabs for cases

* Add wiki for new configs

* V
This commit is contained in:
PabstMirror 2017-08-22 13:13:03 -05:00 committed by GitHub
parent c3986b0a04
commit e7ebbd5750
5 changed files with 79 additions and 3 deletions

View File

@ -126,3 +126,43 @@ GVAR(hasWatch) = true;
false
} count (assignedItems _unit);
}, true] call CBA_fnc_addPlayerEventHandler;
// Vehicle map lighting:
GVAR(vehicleLightCondition) = {true};
GVAR(vehicleExteriorTurrets) = [];
GVAR(vehicleLightColor) = [1,1,1,0];
["vehicle", {
params ["_unit", "_vehicle"];
if ((isNull _vehicle) || {_unit == _vehicle}) exitWith {};
private _cfg = configfile >> "CfgVehicles" >> (typeOf _vehicle);
GVAR(vehicleExteriorTurrets) = getArray (_cfg >> QGVAR(vehicleExteriorTurrets));
GVAR(vehicleLightColor) = [_cfg >> QGVAR(vehicleLightColor), "array", [1,1,1,0]] call CBA_fnc_getConfigEntry;
// Handle vehicles with toggleable interior lights:
private _vehicleLightCondition = getText (_cfg >> QGVAR(vehicleLightCondition));
if (_vehicleLightCondition == "") then {
private _userAction = toLower getText (_cfg >> "UserActions" >> "ToggleLight" >> "statement");
switch (true) do {
case ((_userAction find "cabinlights_hide") > 0): {_vehicleLightCondition = "(_vehicle animationSourcePhase 'cabinlights_hide') == 1";};
case ((_userAction find "cargolights_hide") > 0): {_vehicleLightCondition = "(_vehicle animationSourcePhase 'cargolights_hide') == 1";};
};
};
GVAR(vehicleLightCondition) = if (_vehicleLightCondition != "") then {
if (_vehicle isKindOf "Helicopter" || {_vehicle isKindOf "Plane"}) then {
compile format ["(driver _vehicle == _unit) || {gunner _vehicle == _unit} || {%1}", _vehicleLightCondition];
} else {
compile _vehicleLightCondition
};
} else {
switch (true) do {
case (_vehicle isKindOf "Tank");
case (_vehicle isKindOf "Wheeled_APC"): { {true} };
case (_vehicle isKindOf "Helicopter");
case (_vehicle isKindOf "Plane"): { {(driver _vehicle == _unit) || {gunner _vehicle == _unit}} };
default { {false} };
};
};
}, true] call CBA_fnc_addPlayerEventHandler;

View File

@ -47,9 +47,9 @@ if (_lightLevel > 0.95) exitWith {
private _vehicle = vehicle _unit;
// Do not obscure the map if the player is on a enclosed vehicle (assume internal illumination)
if ((_vehicle != _unit) && {!isTurnedOut _unit && {_vehicle isKindOf "Tank" || {(_vehicle isKindOf "Helicopter" || _vehicle isKindOf "Plane") && {driver _vehicle == _unit || {gunner _vehicle == _unit}}} || {_vehicle isKindOf "Wheeled_APC"}}}) exitWith {
TRACE_1("Player in a enclosed vehicle","");
[false, [1,1,1,0]]
if ((_vehicle != _unit) && {(!isTurnedOut _unit)} && GVAR(vehicleLightCondition) && {!((_unit call CBA_fnc_turretPath) in GVAR(vehicleExteriorTurrets))}) exitWith {
TRACE_1("Player in a enclosed vehicle",GVAR(vehicleLightColor));
[!(GVAR(vehicleLightColor) isEqualTo [1,1,1,0]), GVAR(vehicleLightColor)]
};
// Player is not in a vehicle

View File

@ -0,0 +1,30 @@
---
layout: wiki
title: Map Framework
description: Explains the Map system for developers
group: framework
order: 5
parent: wiki
mod: ace
version:
major: 3
minor: 11
patch: 0
---
## 1. Config Values
### 1.1 Vehicle Interior Lighting
```cpp
class CfgVehicles {
class MyCar {
// Sets color of light projected onto player's map
ace_map_vehicleLightColor[] = {0,1,0,0.1};
// Lists turret indexes that are outside of the vehicle and would not recieve interior lighting (e.g. riding on top of a tank)
ace_map_vehicleExteriorTurrets[] = {12,13};
// Condition for interior lights to be working (string that when compiled and call should return a bool, will be passed _vehicle)
ace_map_vehicleLightCondition[] = "(_vehicle animationSourcePhase 'cabinlights_hide') == 1";
```

View File

@ -107,6 +107,7 @@ class CfgVehicles {
};
};
class rhs_bmp1tank_base: Tank_F {
EGVAR(map,vehicleLightColor)[] = {0,1,0,0.1};
EGVAR(refuel,fuelCapacity) = 460;
class Turrets: Turrets {
class MainTurret: MainTurret {
@ -147,6 +148,7 @@ class CfgVehicles {
};
};
class rhs_btr_base: Wheeled_APC_F {
EGVAR(map,vehicleLightColor)[] = {0,0,1,0.1};
EGVAR(refuel,fuelCapacity) = 300;
class Turrets: Turrets {
class MainTurret: MainTurret {
@ -271,6 +273,7 @@ class CfgVehicles {
};
class Heli_Light_02_base_F: Helicopter_Base_H {};
class RHS_Mi8_base : Heli_Light_02_base_F {
EGVAR(map,vehicleLightColor)[] = {1,0,0,0.1};
EGVAR(refuel,fuelCapacity) = 3700;
EGVAR(fastroping,enabled) = 0;
class EventHandlers: EventHandlers {
@ -340,6 +343,7 @@ class CfgVehicles {
};
class RHS_Mi24_base : Heli_Attack_02_base_F {
EGVAR(map,vehicleLightColor)[] = {1,0,0,0.1};
EGVAR(refuel,fuelCapacity) = 1851;
EGVAR(fastroping,enabled) = 0;
class Turrets: Turrets {

View File

@ -232,6 +232,7 @@ class CfgVehicles {
};
class rhsusf_CH53E_USMC: Helicopter_Base_H {
EGVAR(map,vehicleLightColor)[] = {1,0,0,0.1};
EGVAR(fastroping,enabled) = 1;
EGVAR(fastroping,ropeOrigins)[] = {{0,-9.5,2.6}};
EGVAR(fastroping,onCut) = QFUNC(onCut);
@ -338,6 +339,7 @@ class CfgVehicles {
class APC_Tracked_02_base_F: Tank_F {};
class rhsusf_m113tank_base: APC_Tracked_02_base_F {
EGVAR(map,vehicleLightColor)[] = {0,1,0,0.1};
EGVAR(refuel,fuelCapacity) = 360;
class Turrets: Turrets {
class MainTurret: MainTurret {