-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View Distance Module #1063
Merged
Merged
View Distance Module #1063
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c2bb638
Added required files for new module
simonamdev 2c8dddf
Adding required files
simonamdev 6b604c1
First working version
simonamdev a5d68f1
Added working limiter (config based)
simonamdev bb625aa
Used ACE common function instead of hint
simonamdev 5732015
Added moduleViewDistance file
simonamdev 6cda97e
Adding required files for module integration
simonamdev 45992e5
All working except module returning any.
simonamdev 0b41377
Cleaned up code
simonamdev 96e1e9c
Added name + email to authors.txt
simonamdev ae1628e
Renamed init file for neatness
simonamdev 9e40e16
Adjusted XEH_preinit accordingly
simonamdev 7201a23
Adjusted post init, removed redundant settings
simonamdev bba216e
Rewrote switch statement
simonamdev 2dfaaa0
Reworked limiting system
simonamdev f64f76e
Fixed wrong file name
simonamdev a9d6fbd
Attempting to fix module value not being read
simonamdev f4d7c68
Attempted fix #2
simonamdev cad8628
Fixed module value not overriding.
simonamdev 737b1cc
Renamed variable limit to limitViewDistance
simonamdev 69648f0
Added adaptive view distance depending on vehicle
simonamdev c05a91f
Suppress prompts when changing vehicle.
simonamdev 2ce1336
Removed terrain grid related configs
simonamdev 6a66818
Replaced player with ACE_player
simonamdev 283768f
Fixed code style in switch statement
simonamdev 495e94f
Merged fnc_init.sqf into XEH_postInit.sqf
simonamdev cb64f7d
Adjusted PBOPREFIX
simonamdev d8cce9e
Removed redundant settings
simonamdev 7fe73c2
Added Object View Distance Coefficient setting
simonamdev 853333a
Added new function, updated settings
simonamdev 3480168
Integrated new function into module
simonamdev 8c7d752
Made final adjustments
simonamdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\ace\addons\blank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class ACE_Settings { | ||
class GVAR(viewDistanceOnFoot) { | ||
typeName = "SCALAR"; | ||
isClientSettable = 1; | ||
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 = "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"; | ||
value = 10000; // Value, NOT index. 10000 is the maximum in A3 | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
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)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class CfgVehicles { | ||
class ACE_Module; | ||
class GVAR(ModuleSettings) : ACE_Module { | ||
author = "$STR_ACE_Common_ACETeam"; | ||
category = "ACE"; | ||
function = QUOTE(DFUNC(initModule)); | ||
displayName = "View Distance Limiter"; | ||
scope = 2; | ||
isGlobal = 1; | ||
//icon = ""; // needs an icon | ||
class Arguments { | ||
class moduleViewDistanceLimit { | ||
displayName = "View Distance Limit"; | ||
description = "Sets the limit for how high clients can raise their view distance (<= 10000)"; | ||
typeName = "NUMBER"; | ||
defaultValue = 10000; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "script_component.hpp" | ||
|
||
[] call FUNC(init); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
PREP(initModule); | ||
PREP(init); | ||
PREP(returnValue); | ||
PREP(changeViewDistance); | ||
PREP(adaptViewDistance); | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = {"ace_common"}; | ||
author[] = {"Winter"}; | ||
authorUrl = "https://github.com/Winter259"; | ||
VERSION_CONFIG; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "ACE_Settings.hpp" | ||
#include "CfgVehicles.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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: | ||
* 0: Show Prompt <BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [] call ace_viewdistance_fnc_adaptViewDistance; | ||
* | ||
* Public: Yes | ||
*/ | ||
|
||
#include "script_component.hpp" | ||
|
||
PARAMS_1(_show_prompt); | ||
|
||
private["_land_vehicle","_air_vehicle"]; | ||
|
||
_land_vehicle = (vehicle player) isKindOf "LandVehicle"; | ||
_air_vehicle = (vehicle player) isKindOf "Air"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. player should be ACE_player |
||
|
||
if (!_land_vehicle && !_air_vehicle) exitWith { | ||
[GVAR(viewDistanceOnFoot),_show_prompt] call FUNC(changeViewDistance); | ||
}; | ||
|
||
if (_land_vehicle) exitWith { | ||
[GVAR(viewDistanceLandVehicle),_show_prompt] call FUNC(changeViewDistance); | ||
}; | ||
|
||
if (_air_vehicle) exitWith { | ||
[GVAR(viewDistanceAirVehicle),_show_prompt] call FUNC(changeViewDistance); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Author: Winter | ||
* Sets the player's current view distance according to allowed values. | ||
* | ||
* | ||
* Arguments: | ||
* 0: View Distance setting INDEX <SCALAR> | ||
* 1: Show Prompt <BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [] call ace_viewdistance_fnc_changeViewDistance; | ||
* | ||
* Public: Yes | ||
*/ | ||
|
||
#include "script_component.hpp" | ||
|
||
private ["_text","_new_view_distance","_view_distance_limit"]; | ||
PARAMS_2(_index_requested,_prompt); | ||
|
||
_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 { | ||
if (_prompt) then { | ||
_text = composeText ["View distance successfully changed to: ",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 { | ||
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? | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Author: Winter | ||
* Assigns the Event Handler which triggers when a player adjusts their view distance in the menu | ||
* | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [] call ace_viewdistance_fnc_initViewDistance; | ||
* | ||
* Public: Yes | ||
*/ | ||
|
||
#include "script_component.hpp" | ||
|
||
if (!hasInterface) exitWith {}; | ||
|
||
if (viewDistance > GVAR(limitViewDistance)) then { | ||
setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit. | ||
setObjectViewDistance (0.8 * GVAR(limitViewDistance)); | ||
} else { | ||
[true] 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 a vehicle for the changes to have effect. | ||
["SettingChanged",{ | ||
if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then { | ||
[true] 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",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Author: Winter | ||
* Initialises the view distance limiter module | ||
* | ||
* | ||
* Arguments: | ||
* 0: logic <OBJECT> | ||
* 1: Synchronised Units <ARRAY> | ||
* 2: Module Activated <BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
*/ | ||
|
||
#include "script_component.hpp" | ||
|
||
if (!isServer) exitWith {}; | ||
|
||
PARAMS_3(_logic,_units,_activated); | ||
|
||
if (!_activated) exitWith { | ||
diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; | ||
}; | ||
|
||
[_logic, QGVAR(limitViewDistance),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); | ||
|
||
diag_log format ["[ACE]: View Distance Limit Module Initialized. Limit set by module: %1",GVAR(limitViewDistance)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Author: Winter | ||
* Returns the view distance value according to the given index | ||
* | ||
* | ||
* Arguments: | ||
* 0: View Distance Index <SCALAR> | ||
* | ||
* Return Value: | ||
* View Distance <SCALAR> | ||
* | ||
* Example: | ||
* [2] call ace_viewdistance_fnc_returnViewDistanceValue; | ||
* | ||
* Public: Yes | ||
*/ | ||
|
||
#include "script_component.hpp" | ||
|
||
PARAMS_1(_index); | ||
|
||
private ["_return"]; | ||
|
||
_return = switch (_index) do | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please adjust to match our style:
Also use 4 spaces for indentation. |
||
case 0: {1500}; | ||
case 1: {2000}; | ||
case 2: {2500}; | ||
case 3: {3000}; | ||
case 4: {3500}; | ||
case 5: {4000}; | ||
case 6: {5000}; | ||
case 7: {6000}; | ||
case 8: {7000}; | ||
case 9: {8000}; | ||
case 10: {9000}; | ||
case 11: {10000}; | ||
default {1000}; | ||
}; | ||
|
||
_return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "\z\ace\addons\viewdistance\script_component.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#define COMPONENT viewdistance | ||
#include "\z\ace\addons\main\script_mod.hpp" | ||
|
||
#ifdef DEBUG_ENABLED_VIEWDISTANCE | ||
#define DEBUG_MODE_FULL | ||
#endif | ||
|
||
#ifdef DEBUG_SETTINGS_VIEWDISTANCE | ||
#define DEBUG_SETTINGS DEBUG_SETTINGS_VIEWDISTANCE | ||
#endif | ||
|
||
#include "\z\ace\addons\main\script_macros.hpp" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
FUNC(init)
is only ever supposed to be called once and on postInit, the contents of it might as well be in postInit?