Merge pull request #328 from veteran29/feature/0.964-param_load_save
Mission parameters saving/loading
This commit is contained in:
commit
b00945cffc
|
@ -1,92 +1,50 @@
|
|||
if ( isMultiplayer ) then {
|
||||
GRLIB_difficulty_modifier = ["Difficulty",2] call bis_fnc_getParamValue;
|
||||
GRLIB_time_factor = ["DayDuration",12] call bis_fnc_getParamValue;
|
||||
GRLIB_resources_multiplier = ["ResourcesMultiplier",3] call bis_fnc_getParamValue;
|
||||
GRLIB_fatigue = ["Fatigue",1] call bis_fnc_getParamValue;
|
||||
GRLIB_introduction = ["Introduction",1] call bis_fnc_getParamValue;
|
||||
GRLIB_deployment_cinematic = ["DeploymentCinematic",1] call bis_fnc_getParamValue;
|
||||
GRLIB_unitcap = ["Unitcap",2] call bis_fnc_getParamValue;
|
||||
GRLIB_adaptive_opfor = ["AdaptToPlayercount",1] call bis_fnc_getParamValue;
|
||||
GRLIB_civilian_activity = ["civilians",1] call bis_fnc_getParamValue;
|
||||
GRLIB_teamkill_penalty = ["TeamkillPenalty",0] call bis_fnc_getParamValue;
|
||||
GRLIB_build_first_fob = ["FirstFob",0] call bis_fnc_getParamValue;
|
||||
GRLIB_param_wipe_savegame_1 = ["WipeSave1",0] call bis_fnc_getParamValue;
|
||||
GRLIB_param_wipe_savegame_2 = ["WipeSave2",0] call bis_fnc_getParamValue;
|
||||
GRLIB_permissions_param = ["Permissions",1] call bis_fnc_getParamValue;
|
||||
GRLIB_halo_param = ["HaloJump",1] call bis_fnc_getParamValue;
|
||||
GRLIB_use_whitelist = ["Whitelist",0] call bis_fnc_getParamValue;
|
||||
GRLIB_cleanup_vehicles = ["CleanupVehicles",2] call bis_fnc_getParamValue;
|
||||
GRLIB_csat_aggressivity = ["Aggressivity",2] call bis_fnc_getParamValue;
|
||||
GRLIB_weather_param = ["Weather",3] call bis_fnc_getParamValue;
|
||||
GRLIB_shorter_nights = ["ShorterNights",0] call bis_fnc_getParamValue;
|
||||
GRLIB_remote_sensors = 0;
|
||||
GRLIB_blufor_defenders = [ "BluforDefenders",1] call bis_fnc_getParamValue;
|
||||
GRLIB_autodanger = [ "Autodanger",0] call bis_fnc_getParamValue;
|
||||
GRLIB_maximum_fobs = [ "MaximumFobs",26] call bis_fnc_getParamValue;
|
||||
GRLIB_max_squad_size = ["MaxSquadSize",10] call bis_fnc_getParamValue;
|
||||
KP_liberation_arsenalUsePreset = ["ArsenalUsePreset",1] call BIS_fnc_getParamValue;
|
||||
KP_liberation_mapmarkers = ["MapMarkers",1] call bis_fnc_getParamValue;
|
||||
KP_liberation_mobilerespawn = ["MobileRespawn",1] call bis_fnc_getParamValue;
|
||||
KP_liberation_mobilearsenal = ["MobileArsenal",1] call bis_fnc_getParamValue;
|
||||
KP_liberation_ailogistics = ["AiLogistics",1] call bis_fnc_getParamValue;
|
||||
// Arty Supp deactivated for now - KP_liberation_suppMod_enb = ["SuppMod",1] call BIS_fnc_getParamValue;
|
||||
KP_liberation_restart = ["ServerRestart",0] call BIS_fnc_getParamValue;
|
||||
KP_liberation_cr_param_buildings = ["CR_Building",0] call BIS_fnc_getParamValue;
|
||||
KP_liberation_civinfo_debug = ["DebugCivInfo",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_civrep_debug = ["DebugCivRep",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_savegame_debug = ["DebugSave",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_asymmetric_debug = ["DebugAsymmetric",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_logistic_debug = ["DebugLogistic",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_sectorspawn_debug = ["DebugSectorSpawn",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_kill_debug = ["DebugKill",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_production_debug = ["DebugProduction",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_respawn_cooldown = ["RespawnCooldown",900] call bis_fnc_getParamValue;
|
||||
KP_liberation_clear_cargo = ["ClearCargo",1] call bis_fnc_getParamValue;
|
||||
} else {
|
||||
GRLIB_difficulty_modifier = 2;
|
||||
GRLIB_time_factor = 12;
|
||||
GRLIB_resources_multiplier = 3;
|
||||
GRLIB_fatigue = 1;
|
||||
GRLIB_introduction = 1;
|
||||
GRLIB_deployment_cinematic = 1;
|
||||
GRLIB_adaptive_opfor = 1;
|
||||
GRLIB_unitcap = 2;
|
||||
GRLIB_civilian_activity = 1;
|
||||
GRLIB_teamkill_penalty = 0;
|
||||
GRLIB_build_first_fob = 0;
|
||||
GRLIB_param_wipe_savegame_1 = 0;
|
||||
GRLIB_param_wipe_savegame_2 = 0;
|
||||
GRLIB_permissions_param = 0;
|
||||
GRLIB_halo_param = 1;
|
||||
GRLIB_use_whitelist = 0;
|
||||
GRLIB_cleanup_vehicles = 2;
|
||||
GRLIB_csat_aggressivity = 2;
|
||||
GRLIB_weather_param = 3;
|
||||
GRLIB_shorter_nights = 0;
|
||||
GRLIB_remote_sensors = 0;
|
||||
GRLIB_blufor_defenders = 1;
|
||||
GRLIB_autodanger = 0;
|
||||
GRLIB_maximum_fobs = 26;
|
||||
GRLIB_max_squad_size = 10;
|
||||
KP_liberation_arsenalUsePreset = 1;
|
||||
KP_liberation_mapmarkers = 1;
|
||||
KP_liberation_mobilerespawn = 1;
|
||||
KP_liberation_mobilearsenal = 1;
|
||||
KP_liberation_ailogistics = 1;
|
||||
// Arty Supp deactivated for now - KP_liberation_suppMod_enb = 1;
|
||||
KP_liberation_restart = 0;
|
||||
KP_liberation_cr_param_buildings = 0;
|
||||
KP_liberation_civinfo_debug = 0;
|
||||
KP_liberation_civrep_debug = 0;
|
||||
KP_liberation_savegame_debug = 0;
|
||||
KP_liberation_asymmetric_debug = 0;
|
||||
KP_liberation_logistic_debug = 0;
|
||||
KP_liberation_sectorspawn_debug = 0;
|
||||
KP_liberation_kill_debug = 0;
|
||||
KP_liberation_production_debug = 0;
|
||||
KP_liberation_respawn_cooldown = 900;
|
||||
KP_liberation_clear_cargo = 1;
|
||||
};
|
||||
/* Not saveable params */
|
||||
GRLIB_param_wipe_savegame_1 = ["WipeSave1",0] call bis_fnc_getParamValue;
|
||||
GRLIB_param_wipe_savegame_2 = ["WipeSave2",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_civinfo_debug = ["DebugCivInfo",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_civrep_debug = ["DebugCivRep",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_savegame_debug = ["DebugSave",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_asymmetric_debug = ["DebugAsymmetric",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_logistic_debug = ["DebugLogistic",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_sectorspawn_debug = ["DebugSectorSpawn",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_kill_debug = ["DebugKill",0] call bis_fnc_getParamValue;
|
||||
KP_liberation_production_debug = ["DebugProduction",0] call bis_fnc_getParamValue;
|
||||
|
||||
KP_load_params = ["LoadSaveParams", 1] call BIS_fnc_getParamValue;
|
||||
/* Saveable params */
|
||||
GRLIB_difficulty_modifier = ["Difficulty",2] call F_getSaveableParam;
|
||||
GRLIB_time_factor = ["DayDuration",12] call F_getSaveableParam;
|
||||
GRLIB_resources_multiplier = ["ResourcesMultiplier",3] call F_getSaveableParam;
|
||||
GRLIB_fatigue = ["Fatigue",1] call F_getSaveableParam;
|
||||
GRLIB_introduction = ["Introduction",1] call F_getSaveableParam;
|
||||
GRLIB_deployment_cinematic = ["DeploymentCinematic",1] call F_getSaveableParam;
|
||||
GRLIB_unitcap = ["Unitcap",2] call F_getSaveableParam;
|
||||
GRLIB_adaptive_opfor = ["AdaptToPlayercount",1] call F_getSaveableParam;
|
||||
GRLIB_civilian_activity = ["civilians",1] call F_getSaveableParam;
|
||||
GRLIB_teamkill_penalty = ["TeamkillPenalty",0] call F_getSaveableParam;
|
||||
GRLIB_build_first_fob = ["FirstFob",0] call F_getSaveableParam;
|
||||
GRLIB_permissions_param = ["Permissions",1] call F_getSaveableParam;
|
||||
GRLIB_halo_param = ["HaloJump",1] call F_getSaveableParam;
|
||||
GRLIB_use_whitelist = ["Whitelist",0] call F_getSaveableParam;
|
||||
GRLIB_cleanup_vehicles = ["CleanupVehicles",2] call F_getSaveableParam;
|
||||
GRLIB_csat_aggressivity = ["Aggressivity",2] call F_getSaveableParam;
|
||||
GRLIB_weather_param = ["Weather",3] call F_getSaveableParam;
|
||||
GRLIB_shorter_nights = ["ShorterNights",0] call F_getSaveableParam;
|
||||
GRLIB_remote_sensors = 0;
|
||||
GRLIB_blufor_defenders = ["BluforDefenders",1] call F_getSaveableParam;
|
||||
GRLIB_autodanger = ["Autodanger",0] call F_getSaveableParam;
|
||||
GRLIB_maximum_fobs = ["MaximumFobs",26] call F_getSaveableParam;
|
||||
GRLIB_max_squad_size = ["MaxSquadSize",10] call F_getSaveableParam;
|
||||
KP_liberation_arsenalUsePreset = ["ArsenalUsePreset",1] call F_getSaveableParam;
|
||||
KP_liberation_mapmarkers = ["MapMarkers",1] call F_getSaveableParam;
|
||||
KP_liberation_mobilerespawn = ["MobileRespawn",1] call F_getSaveableParam;
|
||||
KP_liberation_mobilearsenal = ["MobileArsenal",1] call F_getSaveableParam;
|
||||
KP_liberation_ailogistics = ["AiLogistics",1] call F_getSaveableParam;
|
||||
// Arty Supp deactivated for now - KP_liberation_suppMod_enb = ["SuppMod",1] call F_getSaveableParam;
|
||||
KP_liberation_restart = ["ServerRestart",0] call F_getSaveableParam;
|
||||
KP_liberation_cr_param_buildings = ["CR_Building",0] call F_getSaveableParam;
|
||||
KP_liberation_respawn_cooldown = ["RespawnCooldown",900] call F_getSaveableParam;
|
||||
KP_liberation_clear_cargo = ["ClearCargo",1] call F_getSaveableParam;
|
||||
|
||||
if (GRLIB_fatigue < 0.1) then {GRLIB_fatigue = false} else {GRLIB_fatigue = true};
|
||||
if (GRLIB_introduction == 1) then {GRLIB_introduction = true} else {GRLIB_introduction = false};
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
f_kp_getSaveableParam.sqf
|
||||
Author: veteran29
|
||||
Date: 2018-01-27
|
||||
|
||||
Description:
|
||||
Saves/loads/fetches mission parameter from profileNamespace depending on "_action" argument.
|
||||
If no action provided value from "KP_load_params" variable is used.
|
||||
On SP enviroment saving/loading is disabled.
|
||||
|
||||
Parameters:
|
||||
_this select 0 - STRING - Name of parameter
|
||||
_this select 1 - NUMBER - Default value if parameter not found or no saved value
|
||||
_this select 2 - NUMBER - Should save(0)/load(1) from profile namespace or get(2) from selected param value
|
||||
*/
|
||||
params ["_paramName", ["_defaultValue", 0], ["_action", nil]];
|
||||
|
||||
private _saveKey = "KP_LIBERATION_" + (toUpper worldName) + "_SAVE_PARAMS";
|
||||
private _value = nil;
|
||||
|
||||
// Use lobby value if no action specified
|
||||
if(isNil "_action") then {_action = KP_load_params;};
|
||||
|
||||
// We propably shoud not load parameters on SP environment
|
||||
if(!isMultiplayer) then {_action = 2};
|
||||
|
||||
switch (_action) do {
|
||||
// Save to profileNamespace
|
||||
case 0: {
|
||||
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
|
||||
private _savedParams = profileNamespace getVariable _saveKey;
|
||||
|
||||
if(isNil "_savedParams") then {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log "[KP LIBERATION] [SAVE PARAM] Param save data is corrupted, creating new.";};
|
||||
// Create new "associative" array
|
||||
_savedParams = [[_paramName, _value]];
|
||||
|
||||
} else {
|
||||
private _singleParam = ([_savedParams, { (_x select 0) == _paramName}] call bis_fnc_conditionalSelect) select 0;
|
||||
if(isNil "_singleParam") then {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log format ["[KP LIBERATION] [SAVE PARAM] Saving value: %1 for param: %2,", _value, _paramName];};
|
||||
_savedParams pushBack [_paramName, _value];
|
||||
|
||||
} else {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log format ["[KP LIBERATION] [SAVE PARAM] Overwriting value: %1 with: %2 for param: %3,", (_singleParam select 1), _value, _paramName];};
|
||||
// _singleparam is an reference to array in _savedParams, we can use "set"
|
||||
_singleParam set [1, _value];
|
||||
};
|
||||
};
|
||||
|
||||
// Save params to profile namespace
|
||||
profileNamespace setVariable [_saveKey, _savedParams];
|
||||
saveProfileNamespace;
|
||||
};
|
||||
// Load from profileNamespace
|
||||
case 1: {
|
||||
private _savedParams = profileNamespace getVariable _saveKey;
|
||||
if(isNil "_savedParams") then {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log "[KP LIBERATION] [SAVE PARAM] Param save data is corrupted, can't load!";};
|
||||
// Fix param save data
|
||||
profileNamespace setVariable [_saveKey, []];
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log format ["[KP LIBERATION] [SAVE PARAM] No saved value for param: %1, fetching value.", _paramName];};
|
||||
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
|
||||
} else {
|
||||
private _singleParam = ([_savedParams, { (_x select 0) == _paramName}] call bis_fnc_conditionalSelect) select 0;
|
||||
if(isNil "_singleParam") then {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log format ["[KP LIBERATION] [SAVE PARAM] No saved value for param: %1, fetching value.", _paramName];};
|
||||
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
|
||||
} else {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log format ["[KP LIBERATION] [SAVE PARAM] Found value: %1 for param: %2,", (_singleParam select 1), _paramName];};
|
||||
_value = _singleParam select 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
// Get param
|
||||
default {
|
||||
if (KP_liberation_savegame_debug > 0) then {diag_log "[KP LIBERATION] [SAVE PARAM] Fetch selected value for param";};
|
||||
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
|
||||
};
|
||||
};
|
||||
|
||||
// Return param value
|
||||
_value;
|
|
@ -59,3 +59,4 @@ F_createCrate = compileFinal preprocessFileLineNumbers "scripts\shared\functions
|
|||
F_isClassUAV = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_isClassUAV.sqf";
|
||||
F_checkGear = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_checkGear.sqf";
|
||||
F_setFobMass = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_setFobMass.sqf";
|
||||
F_getSaveableParam = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_getSaveableParam.sqf";
|
||||
|
|
|
@ -5538,5 +5538,17 @@
|
|||
<Chinesesimp>生产</Chinesesimp>
|
||||
<Portuguese>Produção</Portuguese>
|
||||
</Key>
|
||||
<Key ID="STR_PARAMS_LOADSAVEPARAMS">
|
||||
<Original>Load/Save Parameters</Original>
|
||||
</Key>
|
||||
<Key ID="STR_PARAMS_LOADSAVEPARAMS_SAVE">
|
||||
<Original>SAVE selected parameters</Original>
|
||||
</Key>
|
||||
<Key ID="STR_PARAMS_LOADSAVEPARAMS_LOAD">
|
||||
<Original>LOAD parameters or use selected if no saved value found</Original>
|
||||
</Key>
|
||||
<Key ID="STR_PARAMS_LOADSAVEPARAMS_SELECTED">
|
||||
<Original>Use selected parameters without saving</Original>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
class Params
|
||||
{
|
||||
class LoadSaveParams {
|
||||
title = $STR_PARAMS_LOADSAVEPARAMS;
|
||||
values[] = { 0, 1, 2 };
|
||||
texts[] = { $STR_PARAMS_LOADSAVEPARAMS_SAVE, $STR_PARAMS_LOADSAVEPARAMS_LOAD, $STR_PARAMS_LOADSAVEPARAMS_SELECTED };
|
||||
default = 1;
|
||||
};
|
||||
class MissionOptions {
|
||||
title = $STR_PARAMS_MISSIONOPTIONS;
|
||||
values[] = { "" };
|
||||
|
|
Loading…
Reference in New Issue