diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index 7c554530f..024333660 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -5,7 +5,8 @@ class cScripts { class init_aceTagging {}; class init_aceItemReplace {}; - class init_skillAdjustment {}; + class init_ai {}; + class init_vehicle {}; class init_staging {}; diff --git a/cScripts/cScripts_preInit.sqf b/cScripts/cScripts_preInit.sqf index 2e1ed269e..6f7c41297 100644 --- a/cScripts/cScripts_preInit.sqf +++ b/cScripts/cScripts_preInit.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp"; /* - * Author: CPL.Brostrom.A + * Author: SGT.Brostrom.A * This is the rules set for the mission using the cba XEH. Each setting here is alterd via cbaSettings */ @@ -37,19 +37,29 @@ private _cScriptSettings = "cScripts Mission Settings"; {}, true ] call CBA_fnc_addSetting; -[ // Ai setting +[ // AI setting QEGVAR(Settings,setAiSystemDifficulty), "LIST", - ["AI Setting", "This adjustes the ai and make them less godlike and more arcade to play against."], + ["AI Setting", "This adjusts the ai and make them less godlike and more arcade to play against."], [_cScriptSettings, "1; Mission"], [[0,1,2], ["Arma Default", "Adjusted", "Faction Based"], 2], true, {}, true ] call CBA_fnc_addSetting; +[ // AI dismount + QEGVAR(Settings,setAiBanDismountOfCrew), + "LIST", + ["(Experimental) Allow AI dismount", "This allow or disallow ai crew to dismount vehicles."], + [_cScriptSettings, "1; Mission"], + false, + true, + {}, + true +] call CBA_fnc_addSetting; -//2; Radios +// 2; Radios [ // Enable QEGVAR(Settings,enableRadios), "CHECKBOX", @@ -370,9 +380,7 @@ call EFUNC(init,chatCommands); call EFUNC(init,zenModuels); -if (EGVAR(Settings,setAiSystemDifficulty) >= 1 ) then { - call EFUNC(init,skillAdjustment); -}; +call EFUNC(init,ai); call EFUNC(init,eventHandlers); diff --git a/cScripts/functions/init/fn_init_ai.sqf b/cScripts/functions/init/fn_init_ai.sqf new file mode 100644 index 000000000..7faeed84a --- /dev/null +++ b/cScripts/functions/init/fn_init_ai.sqf @@ -0,0 +1,114 @@ +#include "..\script_component.hpp"; +/* + * Author: SGT.Brostrom.A + * This function changes AI behaviours + * + * Example: + * call cScripts_fnc_init_ai + * + * Public: No + */ + +if (!isServer) exitWith {}; +INFO("AI", "Applying AI Custom AI..."); + +// AI Behavior +if (EGVAR(Settings,setAiBanDismountOfCrew)) then { + SHOW_WARNING("AI Experimental", "Vehicle AI dismount ban system applied to all vehicles."); + ["AllVehicles", "init", { + params ["_vehicle"]; + _vehicle setUnloadInCombat [true, false]; + _vehicle allowCrewInImmobile [false, true]; + }, true, ["man"], true] call CBA_fnc_addClassEventHandler; +}; + +// AI Skills +if (EGVAR(Settings,setAiSystemDifficulty) >= 1 ) then { + ["CAManBase", "init", { + params ["_unit"]; + + if !(isPlayer _unit) then { + if (EGVAR(Settings,setAiSystemDifficulty) == 1) then { + _unit setSkill ["aimingspeed", 0.420]; + _unit setSkill ["aimingaccuracy", 1.000]; + _unit setSkill ["aimingshake", 0.360]; + _unit setSkill ["spottime", 1.000]; + _unit setSkill ["spotdistance", 1.000]; + _unit setSkill ["commanding", 1.0]; + _unit setSkill ["general", 1.0]; + }; + if (EGVAR(Settings,setAiSystemDifficulty) == 2) then { + if (getLighting select 1 <= 5) then { + if (hmd _unit != "") then { + _unit setSkill ["spottime", 0.015]; + _unit setSkill ["spotdistance", 0.015]; + } else { + _unit setSkill ["spottime", 0.520]; + _unit setSkill ["spotdistance", 0.520]; + }; + } else { + _unit setSkill ["spottime", 1.000]; + _unit setSkill ["spotdistance", 1.000]; + }; + + switch (faction _unit) do { + case "rhs_faction_msv"; + case "rhs_faction_rva"; + case "rhs_faction_tv"; + case "rhs_faction_vdv_45"; + case "rhs_faction_vdv"; + case "rhs_faction_vmf"; + case "rhs_faction_vpvo"; + case "rhs_faction_vv"; + case "rhs_faction_vvs_c"; + case "rhs_faction_vvs": { + _unit setSkill ["general", 1.000]; + _unit setSkill ["commanding", 0.950]; + _unit setSkill ["courage", 1.000]; + _unit setSkill ["aimingspeed", 0.720]; + _unit setSkill ["aimingaccuracy", 0.920]; + _unit setSkill ["aimingshake", 0.260]; + _unit setSkill ["reloadSpeed", 1.000]; + }; + default { + _unit setSkill ["general", 0.900]; // Bad <=> Good + _unit setSkill ["commanding", 0.750]; // Bad <=> Good + _unit setSkill ["courage", 0.750]; // Bad <=> Good + _unit setSkill ["aimingspeed", 0.620]; // Bad <=> Good + _unit setSkill ["aimingaccuracy", 0.830]; // Bad <=> Good + _unit setSkill ["aimingshake", 0.360]; // Good <=> Bad + _unit setSkill ["reloadSpeed", 0.750]; // Bad <=> Good + }; + }; + + // Role adjusted + if (getText (configfile >> "CfgVehicles" >> typeOf _unit >> "textSingular") == "machinegunner") then { + _unit setSkill ["aimingspeed", 0.820]; + _unit setSkill ["aimingaccuracy", 0.820]; + _unit setSkill ["aimingshake", 0.350]; + _unit setSkill ["reloadSpeed", 0.800]; + }; + if (getText (configfile >> "CfgVehicles" >> typeOf _unit >> "textSingular") == "sniper") then { + _unit setSkill ["aimingspeed", 0.600]; + _unit setSkill ["aimingaccuracy", 0.950]; + _unit setSkill ["aimingshake", 0.100]; + _unit setSkill ["reloadSpeed", 0.800]; + }; + + // For logging + private _skillArray = [ + ["general", _unit skill "general", _unit skillFinal "general"], + ["commanding", _unit skill "commanding", _unit skillFinal "commanding"], + ["courage", _unit skill "courage", _unit skillFinal "courage"], + ["aimingspeed", _unit skill "aimingspeed", _unit skillFinal "aimingspeed"], + ["aimingaccuracy", _unit skill "aimingaccuracy", _unit skillFinal "aimingaccuracy"], + ["aimingshake", _unit skill "aimingshake", _unit skillFinal "aimingshake"], + ["reloadSpeed", _unit skill "reloadSpeed", _unit skillFinal "reloadSpeed"], + ["spottime", _unit skill "spottime", _unit skill "spottime"], + ["spotdistance", _unit skill "spotdistance", _unit skillFinal "spotdistance"] + ]; + INFO_3("AI","Unit %1 (%2) have skill levels %3.", _unit, typeOf _unit, _skillArray); + }; + }; + }, true, [], true] call CBA_fnc_addClassEventHandler; +}; diff --git a/cScripts/functions/init/fn_init_skillAdjustment.sqf b/cScripts/functions/init/fn_init_skillAdjustment.sqf deleted file mode 100644 index 5cbe02ecd..000000000 --- a/cScripts/functions/init/fn_init_skillAdjustment.sqf +++ /dev/null @@ -1,102 +0,0 @@ -#include "..\script_component.hpp"; -/* - * Author: CPL.Brostrom.A - * This function changes AI skill values - * - * Example: - * call cScripts_fnc_init_skillAdjustment - * - * Public: No - */ - -INFO("init", "Applying AI Event Handler to units..."); - -if (!isServer) exitWith {}; - -["CAManBase", "init", { - params ["_unit"]; - - if !(isPlayer _unit) then { - if (EGVAR(Settings,setAiSystemDifficulty) == 1) then { - _unit setSkill ["aimingspeed", 0.420]; - _unit setSkill ["aimingaccuracy", 1.000]; - _unit setSkill ["aimingshake", 0.360]; - _unit setSkill ["spottime", 1.000]; - _unit setSkill ["spotdistance", 1.000]; - _unit setSkill ["commanding", 1.0]; - _unit setSkill ["general", 1.0]; - }; - if (EGVAR(Settings,setAiSystemDifficulty) == 2) then { - if (getLighting select 1 <= 5) then { - if (hmd _unit != "") then { - _unit setSkill ["spottime", 0.015]; - _unit setSkill ["spotdistance", 0.015]; - } else { - _unit setSkill ["spottime", 0.520]; - _unit setSkill ["spotdistance", 0.520]; - }; - } else { - _unit setSkill ["spottime", 1.000]; - _unit setSkill ["spotdistance", 1.000]; - }; - - switch (faction _unit) do { - case "rhs_faction_msv"; - case "rhs_faction_rva"; - case "rhs_faction_tv"; - case "rhs_faction_vdv_45"; - case "rhs_faction_vdv"; - case "rhs_faction_vmf"; - case "rhs_faction_vpvo"; - case "rhs_faction_vv"; - case "rhs_faction_vvs_c"; - case "rhs_faction_vvs": { - _unit setSkill ["general", 1.000]; - _unit setSkill ["commanding", 0.950]; - _unit setSkill ["courage", 1.000]; - _unit setSkill ["aimingspeed", 0.720]; - _unit setSkill ["aimingaccuracy", 0.920]; - _unit setSkill ["aimingshake", 0.260]; - _unit setSkill ["reloadSpeed", 1.000]; - }; - default { - _unit setSkill ["general", 0.900]; // Bad <=> Good - _unit setSkill ["commanding", 0.750]; // Bad <=> Good - _unit setSkill ["courage", 0.750]; // Bad <=> Good - _unit setSkill ["aimingspeed", 0.620]; // Bad <=> Good - _unit setSkill ["aimingaccuracy", 0.830]; // Bad <=> Good - _unit setSkill ["aimingshake", 0.360]; // Good <=> Bad - _unit setSkill ["reloadSpeed", 0.750]; // Bad <=> Good - }; - }; - - // Role adjusted - if (getText (configfile >> "CfgVehicles" >> typeOf _unit >> "textSingular") == "machinegunner") then { - _unit setSkill ["aimingspeed", 0.820]; - _unit setSkill ["aimingaccuracy", 0.820]; - _unit setSkill ["aimingshake", 0.350]; - _unit setSkill ["reloadSpeed", 0.800]; - }; - if (getText (configfile >> "CfgVehicles" >> typeOf _unit >> "textSingular") == "sniper") then { - _unit setSkill ["aimingspeed", 0.600]; - _unit setSkill ["aimingaccuracy", 0.950]; - _unit setSkill ["aimingshake", 0.100]; - _unit setSkill ["reloadSpeed", 0.800]; - }; - - // For logging - private _skillArray = [ - ["general", _unit skill "general"], - ["commanding", _unit skill "commanding"], - ["courage", _unit skill "courage"], - ["aimingspeed", _unit skill "aimingspeed"], - ["aimingaccuracy", _unit skill "aimingaccuracy"], - ["aimingshake", _unit skill "aimingshake"], - ["reloadSpeed", _unit skill "reloadSpeed"], - ["spottime", _unit skill "spottime"], - ["spotdistance", _unit skill "spotdistance"] - ]; - INFO_3("init","AI unit %1 (%2) have skill levels %3.", _unit, typeOf _unit, _skillArray); - }; - }; -}, true, [], true] call CBA_fnc_addClassEventHandler;