mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
lightIntensity, handle soldier flashlights
This commit is contained in:
parent
d34cfdb003
commit
722c2af4dc
@ -193,6 +193,7 @@ PREP(getHitPoints);
|
||||
PREP(getHitPointsWithSelections);
|
||||
PREP(getReflectorsWithSelections);
|
||||
PREP(getLightProperties);
|
||||
PREP(getLightPropertiesWeapon);
|
||||
PREP(getVehicleCrew);
|
||||
|
||||
// turrets
|
||||
|
58
addons/common/functions/fnc_getLightPropertiesWeapon.sqf
Normal file
58
addons/common/functions/fnc_getLightPropertiesWeapon.sqf
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Read properties of given flashlight. @todo, Can weapons themselves still have flashlights (no attachment)?
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A flashlight (String)
|
||||
*
|
||||
* Return Value:
|
||||
* Stuff from config (Array)
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_weapon";
|
||||
|
||||
_weapon = _this select 0;
|
||||
|
||||
private "_config";
|
||||
_config = configFile >> "CfgWeapons" >> _weapon >> "ItemInfo" >> "FlashLight";
|
||||
|
||||
private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
|
||||
|
||||
_intensity = getNumber (_config >> "intensity");
|
||||
_position = getText (_config >> "position");
|
||||
_direction = getText (_config >> "direction");
|
||||
_innerAngle = getNumber (_config >> "innerAngle");
|
||||
_outerAngle = getNumber (_config >> "outerAngle");
|
||||
|
||||
[_intensity, _position, _direction, _innerAngle, _outerAngle]
|
||||
|
||||
/*
|
||||
class FlashLight
|
||||
{
|
||||
color[] = {180,156,120};
|
||||
ambient[] = {0.9,0.78,0.6};
|
||||
intensity = 20;
|
||||
size = 1;
|
||||
innerAngle = 20;
|
||||
outerAngle = 80;
|
||||
coneFadeCoef = 5;
|
||||
position = "flash dir";
|
||||
direction = "flash";
|
||||
useFlare = 1;
|
||||
flareSize = 1.4;
|
||||
flareMaxDistance = "100.0f";
|
||||
dayLight = 0;
|
||||
class Attenuation
|
||||
{
|
||||
start = 0.5;
|
||||
constant = 0;
|
||||
linear = 0;
|
||||
quadratic = 1.1;
|
||||
hardLimitStart = 20;
|
||||
hardLimitEnd = 30;
|
||||
};
|
||||
scale[] = {0};
|
||||
};
|
||||
*/
|
@ -20,37 +20,80 @@ _lightSource = _this select 1;
|
||||
private "_unitPos";
|
||||
_unitPos = _unit modelToWorld (_unit selectionPosition "spine3");
|
||||
|
||||
private ["_lights", "_lightLevel"];
|
||||
|
||||
_lights = [_lightSource] call FUNC(getTurnedOnLights);
|
||||
|
||||
private "_lightLevel";
|
||||
_lightLevel = 0;
|
||||
|
||||
{
|
||||
private ["_properties", "_intensity", "_innerAngle", "_outerAngle", "_position", "_direction", "_directionToUnit", "_distance", "_angle"];
|
||||
if (_lightSource isKindOf "CAManBase") then {
|
||||
// handle persons with flashlights
|
||||
|
||||
_properties = [_lightSource, _x] call FUNC(getLightProperties);
|
||||
private "_weapon";
|
||||
_weapon = currentWeapon _lightSource;
|
||||
|
||||
// @todo intensity affects range?
|
||||
//_intensity = _properties select 0;
|
||||
if !(_lightSource isFlashlightOn _weapon) exitWith {};
|
||||
|
||||
private ["_flashlight", "_properties", "_intensity", "_innerAngle", "_outerAngle", "_position", "_direction", "_directionToUnit", "_distance", "_angle"];
|
||||
|
||||
_flashlight = switch (_weapon) do {
|
||||
case (primaryWeapon _lightSource): {
|
||||
primaryWeaponItems _lightSource select 1
|
||||
};
|
||||
case (secondaryWeapon _lightSource): {
|
||||
secondaryWeaponItems _lightSource select 1
|
||||
};
|
||||
case (handgunWeapon _lightSource): {
|
||||
handgunItems _lightSource select 1
|
||||
};
|
||||
default {""};
|
||||
};
|
||||
|
||||
_properties = [_flashlight] call FUNC(getLightPropertiesWeapon);
|
||||
|
||||
_innerAngle = (_properties select 3) / 2;
|
||||
_outerAngle = (_properties select 4) / 2;
|
||||
|
||||
// get world position and direction
|
||||
_position = _lightSource modelToWorld (_lightSource selectionPosition (_properties select 1));
|
||||
_direction = _lightSource modelToWorld (_lightSource selectionPosition (_properties select 2));
|
||||
_position = _lightSource modelToWorld (_lightSource selectionPosition "rightHand");
|
||||
_direction = _lightSource weaponDirection _weapon;
|
||||
|
||||
_direction = _position vectorFromTo _direction;
|
||||
_directionToUnit = _position vectorFromTo _unitPos;
|
||||
|
||||
_distance = _unitPos distance _position;
|
||||
_angle = acos (_direction vectorDotProduct _directionToUnit);
|
||||
|
||||
_lightLevel = _lightLevel max ((linearConversion [0, 30, _distance, 1, 0, true]) * (linearConversion [_innerAngle, _outerAngle, _angle, 1, 0, true]));
|
||||
_lightLevel = (linearConversion [0, 30, _distance, 1, 0, true]) * (linearConversion [_innerAngle, _outerAngle, _angle, 1, 0, true]);
|
||||
|
||||
//systemChat format ["%1 %2", (linearConversion [0, 30, _distance, 1, 0, true]), (linearConversion [_innerAngle, _outerAngle, _angle, 1, 0, true])];
|
||||
} else {
|
||||
// handle any object, strcutures, cars, tanks, etc.
|
||||
|
||||
} forEach _lights;
|
||||
private "_lights";
|
||||
_lights = [_lightSource] call FUNC(getTurnedOnLights);
|
||||
|
||||
{
|
||||
private ["_properties", "_intensity", "_innerAngle", "_outerAngle", "_position", "_direction", "_directionToUnit", "_distance", "_angle"];
|
||||
|
||||
_properties = [_lightSource, _x] call FUNC(getLightProperties);
|
||||
|
||||
// @todo intensity affects range?
|
||||
//_intensity = _properties select 0;
|
||||
|
||||
_innerAngle = (_properties select 3) / 2;
|
||||
_outerAngle = (_properties select 4) / 2;
|
||||
|
||||
// get world position and direction
|
||||
_position = _lightSource modelToWorld (_lightSource selectionPosition (_properties select 1));
|
||||
_direction = _lightSource modelToWorld (_lightSource selectionPosition (_properties select 2));
|
||||
|
||||
_direction = _position vectorFromTo _direction;
|
||||
_directionToUnit = _position vectorFromTo _unitPos;
|
||||
|
||||
_distance = _unitPos distance _position;
|
||||
_angle = acos (_direction vectorDotProduct _directionToUnit);
|
||||
|
||||
_lightLevel = _lightLevel max ((linearConversion [0, 30, _distance, 1, 0, true]) * (linearConversion [_innerAngle, _outerAngle, _angle, 1, 0, true]));
|
||||
|
||||
//systemChat format ["%1 %2", (linearConversion [0, 30, _distance, 1, 0, true]), (linearConversion [_innerAngle, _outerAngle, _angle, 1, 0, true])];
|
||||
|
||||
} forEach _lights;
|
||||
|
||||
};
|
||||
|
||||
_lightLevel
|
||||
|
Loading…
Reference in New Issue
Block a user