2017-09-25 05:52:20 +00:00
|
|
|
/*
|
|
|
|
Author: Aaron Clark - EpochMod.com
|
|
|
|
|
|
|
|
Contributors:
|
|
|
|
|
|
|
|
Description:
|
2017-09-26 19:31:39 +00:00
|
|
|
Controls attributes given custom vars system and returns text based on these changes.
|
2017-09-25 05:52:20 +00:00
|
|
|
|
|
|
|
Licence:
|
|
|
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
|
|
|
|
|
|
|
Github:
|
|
|
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/epoch_code/compile/functions/EPOCH_giveAttributes.sqf
|
|
|
|
|
|
|
|
Example:
|
2017-10-23 18:43:22 +00:00
|
|
|
_text = _x call EPOCH_giveAttributes
|
2017-09-25 05:52:20 +00:00
|
|
|
|
|
|
|
Parameter(s):
|
|
|
|
_this select 0: STRING - Player Stat Name
|
|
|
|
_this select 1: NUMBER - Input
|
|
|
|
_this select 2: NUMBER - 1 = randomize input, 0 = normal
|
|
|
|
Returns:
|
|
|
|
STRING
|
|
|
|
*/
|
|
|
|
|
2016-09-01 00:29:08 +00:00
|
|
|
//[[[cog import generate_private_arrays ]]]
|
2017-09-26 19:31:39 +00:00
|
|
|
private ["_addPlus","_celcuis","_celcuisNew","_color","_currentVal","_customVarIndex","_customVarLimits","_customVarNames","_customVarsInit","_data","_defaultVarValues","_limits","_max","_min","_newValue","_return","_varName","_varNameTmp"];
|
2016-09-01 00:29:08 +00:00
|
|
|
//[[[end]]]
|
2016-06-24 01:43:22 +00:00
|
|
|
params ["_selectedVarName",["_data",0],["_randomizeData",0]];
|
|
|
|
_addPlus = if (_data > 0) then {"+"} else {""};
|
|
|
|
_return = "";
|
2017-09-20 14:23:46 +00:00
|
|
|
|
2017-09-26 19:31:39 +00:00
|
|
|
_customVarsInit = getArray(getMissionConfig "CfgEpochClient" >> "customVarsDefaults");
|
2017-09-20 14:23:46 +00:00
|
|
|
_customVarNames = _customVarsInit apply {_x param [0,""]};
|
|
|
|
_defaultVarValues = _customVarsInit apply {_x param [1,0]};
|
|
|
|
_customVarLimits = _customVarsInit apply {_x param [2,[]]};
|
|
|
|
|
|
|
|
_customVarIndex = _customVarNames find _selectedVarName;
|
2016-06-27 16:51:31 +00:00
|
|
|
if (_customVarIndex != -1) then {
|
2017-09-26 19:31:39 +00:00
|
|
|
|
|
|
|
_varName = format["EPOCH_player%1",_selectedVarName];
|
|
|
|
if (_selectedVarName in _customVarNames) then {
|
|
|
|
_varNameTmp = call compile format["_player%1Key",_selectedVarName];
|
|
|
|
if !(isNil "_varNameTmp") then {_varName = _varNameTmp};
|
|
|
|
};
|
|
|
|
|
2017-09-25 05:52:20 +00:00
|
|
|
_limits = _customVarLimits select _customVarIndex;
|
2016-06-27 16:51:31 +00:00
|
|
|
_limits params [["_max",100],["_min",0]];
|
|
|
|
if (_max isEqualType "") then {
|
|
|
|
_max = missionNamespace getVariable [_max, 0];
|
|
|
|
};
|
|
|
|
if (_min isEqualType "") then {
|
|
|
|
_min = missionNamespace getVariable [_min, 0];
|
|
|
|
};
|
2017-09-26 19:31:39 +00:00
|
|
|
_currentVal = missionNamespace getVariable [_varName, _defaultVarValues select _customVarIndex];
|
2016-06-27 16:51:31 +00:00
|
|
|
if (_randomizeData isEqualTo 1) then {
|
2017-10-27 14:16:01 +00:00
|
|
|
_data = parseNumber ((random _data) toFixed 2);
|
2016-06-27 16:51:31 +00:00
|
|
|
};
|
2017-09-25 05:52:20 +00:00
|
|
|
if (_data != 0) then {
|
|
|
|
_newValue = ((_currentVal + _data) min _max) max _min;
|
|
|
|
missionNamespace setVariable [_varName, _newValue];
|
|
|
|
if (_selectedVarName == "Temp") then {
|
|
|
|
_celcuis = _data call EPOCH_convertTemp;
|
2017-09-26 19:31:39 +00:00
|
|
|
_celcuisNew = _newValue call EPOCH_convertTemp;
|
|
|
|
_return = format["%1: %2%3 (%4 °F) %2%5 (%6 °C)",(localize format["str_epoch_pvar_%1",_selectedVarName]),_addPlus,_data,_newValue,_celcuis,_celcuisNew];
|
2017-09-25 05:52:20 +00:00
|
|
|
} else {
|
2017-09-26 19:31:39 +00:00
|
|
|
_return = format["%1: %2%3 (%4/%5)", (localize format["str_epoch_pvar_%1",_selectedVarName]), _addPlus, _data, _newValue, _max];
|
2017-09-25 05:52:20 +00:00
|
|
|
};
|
|
|
|
};
|
2016-06-24 01:43:22 +00:00
|
|
|
};
|
2016-06-27 16:51:31 +00:00
|
|
|
|
2016-06-24 01:43:22 +00:00
|
|
|
_return
|