2015-05-08 07:28:48 +00:00
/*
* Author: Winter
* Sets the player's current view distance according to allowed values.
*
*
* Arguments:
2015-05-10 10:00:19 +00:00
* 0: View Distance setting INDEX <SCALAR>
* 1: Show Prompt <BOOL>
2015-05-08 07:28:48 +00:00
*
* Return Value:
* None
*
* Example:
2015-05-08 12:14:15 +00:00
* [] call ace_viewdistance_fnc_changeViewDistance;
2015-05-08 07:28:48 +00:00
*
2015-05-14 16:25:41 +00:00
* Public: No
2015-05-08 07:28:48 +00:00
*/
#include "script_component.hpp"
2015-05-14 15:44:35 +00:00
private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"];
2015-05-14 16:25:41 +00:00
2015-05-14 15:44:35 +00:00
PARAMS_2(_index_requested,_show_prompt);
2015-05-08 12:49:52 +00:00
2015-05-14 16:25:41 +00:00
_new_view_distance = [_index_requested] call FUNC(returnValue); // changes the setting index into an actual view distance value
_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); // changes the setting index into a coefficient.
2015-05-09 16:42:02 +00:00
_view_distance_limit = GVAR(limitViewDistance); // Grab the limit
2015-05-08 12:49:52 +00:00
2015-05-09 09:56:27 +00:00
if (_new_view_distance <= _view_distance_limit) then {
2015-05-14 15:44:35 +00:00
if (_show_prompt) then {
2015-05-14 16:25:41 +00:00
_text = parseText format ["<t align='center'>View Distance: %1<br />Object View Distance Coefficient: %2</t>",str(_new_view_distance),str(_object_view_distance_coeff)];
[_text,2] call EFUNC(common,displayTextStructured);
2015-05-10 10:00:19 +00:00
};
2015-05-09 09:56:27 +00:00
setViewDistance _new_view_distance;
2015-05-14 15:44:35 +00:00
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _new_view_distance);
};
2015-05-08 16:30:28 +00:00
}
else {
2015-05-14 15:44:35 +00:00
if (_show_prompt) then {
2015-05-14 16:25:41 +00:00
_text = parseText format ["<t align='center'>That option is invalid! The limit is: %1<br />Object View Distance Coefficient: %2</t>",str(_view_distance_limit),str(_object_view_distance_coeff)];
[_text,2] call EFUNC(common,displayTextStructured);
};
setViewDistance _view_distance_limit;
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit);
2015-05-10 10:00:19 +00:00
};
2015-05-08 16:30:28 +00:00
};