mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added adaptive view distance depending on vehicle
This commit is contained in:
parent
737b1cc216
commit
69648f0e1b
@ -1,11 +1,27 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(viewDistance) {
|
||||
class GVAR(viewDistanceOnFoot) {
|
||||
typeName = "SCALAR";
|
||||
isClientSettable = 1;
|
||||
value = 11; // index, NOT value // not sure what to set this to.
|
||||
value = 11; // index, NOT value // Can set it to client's actual viewdistance in the init function once ACE_Settings supports numbers (if ever).
|
||||
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf
|
||||
displayName = "Change View Distance";
|
||||
description = "Changes in game view distance";
|
||||
displayName = "Client View Distance (On Foot)";
|
||||
description = "Changes in game view distance when the player is on foot.";
|
||||
};
|
||||
class GVAR(viewDistanceLandVehicle) {
|
||||
typeName = "SCALAR";
|
||||
isClientSettable = 1;
|
||||
value = 11; // index, NOT value
|
||||
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf
|
||||
displayName = "Client View Distance (Land Vehicle)";
|
||||
description = "Changes in game view distance when the player is in a land vehicle.";
|
||||
};
|
||||
class GVAR(viewDistanceAirVehicle) {
|
||||
typeName = "SCALAR";
|
||||
isClientSettable = 1;
|
||||
value = 11; // index, NOT value
|
||||
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf
|
||||
displayName = "Client View Distance (Air Vehicle)";
|
||||
description = "Changes in game view distance when the player is in an air vehicle.";
|
||||
};
|
||||
class GVAR(limitViewDistance) {
|
||||
typeName = "SCALAR";
|
||||
@ -13,6 +29,18 @@ class ACE_Settings {
|
||||
displayName = "View Distance Limit";
|
||||
description = "Limit for client's view distance set here and can overridden by module";
|
||||
};
|
||||
class GVAR(terrainGrid) {
|
||||
typeName = "SCALAR";
|
||||
value = 10; // MP default as found in: https://community.bistudio.com/wiki/setTerrainGrid
|
||||
displayName = "Client Terrain Grid";
|
||||
description = "Changes in game terrain grid";
|
||||
};
|
||||
class GVAR(shadows) {
|
||||
typeName = "SCALAR";
|
||||
value = 200; // MP default as found in: https://community.bistudio.com/wiki/setObjectViewDistance
|
||||
displayName = "Client Shadows distance";
|
||||
description = "Changes in game shadows";
|
||||
};
|
||||
};
|
||||
|
||||
// To do: include string table style displayName & description.
|
@ -11,10 +11,16 @@ class CfgVehicles {
|
||||
class Arguments {
|
||||
class moduleViewDistanceLimit {
|
||||
displayName = "View Distance Limit";
|
||||
description = "Sets the limit for how high clients can raise their view distance (< 10000)";
|
||||
description = "Sets the limit for how high clients can raise their view distance (<= 10000)";
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 10000;
|
||||
};
|
||||
class moduleTerrainGridLimit {
|
||||
displayName = "Terrain Grid Limit";
|
||||
description = "Sets the limit for how high clients can raise their terrain grid (<= 50)";
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 50; // range is 3.125 - 50 Reference: https://community.bistudio.com/wiki/setTerrainGrid
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -6,5 +6,6 @@ PREP(initModule);
|
||||
PREP(init);
|
||||
PREP(returnValue);
|
||||
PREP(changeViewDistance);
|
||||
PREP(adaptViewDistance);
|
||||
|
||||
ADDON = true;
|
35
addons/viewdistance/functions/fnc_adaptViewDistance.sqf
Normal file
35
addons/viewdistance/functions/fnc_adaptViewDistance.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: Winter
|
||||
* Sets the player's current view distance according to whether s/he is on foot, in a land vehicle or in an air vehicle.
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_viewdistance_fnc_adaptViewDistance;
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private["_land_vehicle","_air_vehicle"];
|
||||
|
||||
_land_vehicle = (vehicle player) isKindOf "LandVehicle";
|
||||
_air_vehicle = (vehicle player) isKindOf "Air";
|
||||
|
||||
if (!_land_vehicle && !_air_vehicle) exitWith {
|
||||
[GVAR(viewDistanceOnFoot),true] call FUNC(changeViewDistance);
|
||||
};
|
||||
|
||||
if (_land_vehicle) exitWith {
|
||||
[GVAR(viewDistanceLandVehicle),true] call FUNC(changeViewDistance);
|
||||
};
|
||||
|
||||
if (_air_vehicle) exitWith {
|
||||
[GVAR(viewDistanceAirVehicle),true] call FUNC(changeViewDistance);
|
||||
};
|
@ -4,7 +4,8 @@
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
* 0: View Distance setting INDEX <SCALAR>
|
||||
* 1: Show Prompt <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -18,18 +19,24 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_text","_new_view_distance","_view_distance_limit"];
|
||||
PARAMS_2(_index_requested,_prompt);
|
||||
|
||||
// Change the received index number into an actual view distance:
|
||||
_new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue);
|
||||
_new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value
|
||||
_view_distance_limit = GVAR(limitViewDistance); // Grab the limit
|
||||
|
||||
if (_new_view_distance <= _view_distance_limit) then {
|
||||
_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
|
||||
if (_prompt) then {
|
||||
_text = composeText ["View distance: ",str(_new_view_distance)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
setViewDistance _new_view_distance;
|
||||
setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant?
|
||||
}
|
||||
else {
|
||||
_text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)];
|
||||
if (_prompt) then {
|
||||
_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
setViewDistance _view_distance_limit;
|
||||
setObjectViewDistance (0.8 * _view_distance_limit); // maybe make this 0.8 a constant?
|
||||
};
|
||||
};
|
@ -19,9 +19,19 @@
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
// Set the EH which waits for the View Distance setting to be changed
|
||||
if (viewDistance > GVAR(limitViewDistance)) then {
|
||||
setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit.
|
||||
setObjectViewDistance (0.8 * GVAR(limitViewDistance));
|
||||
} else {
|
||||
[] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle.
|
||||
};
|
||||
|
||||
// Set the EH which waits for any of the view distance settings to be changed (avoids the player having to enter or leave their vehicle for the changes to have effect.)
|
||||
["SettingChanged",{
|
||||
if (_this select 0 == QGVAR(viewDistance)) then {
|
||||
[] call FUNC(changeViewDistance);
|
||||
if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then {
|
||||
[] call FUNC(adaptViewDistance);
|
||||
};
|
||||
},true] call ace_common_fnc_addEventHandler;
|
||||
|
||||
// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle
|
||||
["playerVehicleChanged",{[] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler;
|
Loading…
Reference in New Issue
Block a user