mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Rewrite global AI skill zeus module
Remove the use of ace settings and makes the module more zeus specific. It might be worth adding a similar module or mission settings to ace_ai for mission editing.
This commit is contained in:
parent
5b460205a9
commit
d90d5a7ac1
@ -26,47 +26,4 @@ class ACE_Settings {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
};
|
||||
|
||||
class GVAR(aiSkill_set) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: Master Enable";
|
||||
typeName = "BOOL";
|
||||
value = 0;
|
||||
};
|
||||
class GVAR(aiSkill_general) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: general,commanding,courage";
|
||||
typeName = "SCALAR";
|
||||
value = 0.5;
|
||||
};
|
||||
class GVAR(aiSkill_aimingAccuracy) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: aimingAccuracy";
|
||||
typeName = "SCALAR";
|
||||
value = 0.5;
|
||||
};
|
||||
class GVAR(aiSkill_weaponHandling) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: aimingShake,aimingSpeed,reloadSpeed";
|
||||
typeName = "SCALAR";
|
||||
value = 0.5;
|
||||
};
|
||||
class GVAR(aiSkill_spotting) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: spotDistance,spotTime";
|
||||
typeName = "SCALAR";
|
||||
value = 0.5;
|
||||
};
|
||||
class GVAR(aiSkill_COVER) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: AI Seek Cover";
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
class GVAR(aiSkill_AUTOCOMBAT) {
|
||||
category = QUOTE(PREFIX);
|
||||
displayName = "Global AI Set Skill: Ai Switch To Combat Mode";
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
};
|
||||
|
@ -117,7 +117,7 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
class GVAR(moduleGlobalSetSkill): GVAR(moduleBase) {
|
||||
displayName = "Global Set AI Skill";
|
||||
displayName = "Global AI Skill";
|
||||
// icon = "\a3\Modules_F_Curator\Data\iconEndMission_ca.paa";
|
||||
// portrait = "\a3\Modules_F_Curator\Data\portraitEndMission_ca.paa";
|
||||
curatorInfoType = QGVAR(RscGlobalSetSkill);
|
||||
|
@ -16,7 +16,6 @@ PREP(moduleSurrender);
|
||||
PREP(moduleTeleportPlayers);
|
||||
PREP(moduleUnconscious);
|
||||
PREP(moduleZeusSettings);
|
||||
PREP(setSkillsLocal);
|
||||
PREP(ui_globalSetSkill);
|
||||
PREP(ui_teleportPlayers);
|
||||
PREP(ui_vehCargo);
|
||||
|
@ -1,14 +1,4 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isServer) then {
|
||||
["ServerUpdateAISettings",FUNC(moduleGlobalSetSkill)] call EFUNC(common,addEventHandler);
|
||||
};
|
||||
|
||||
["UpdateAISettings", {
|
||||
TRACE_1("UpdateAISettings EH",_this);
|
||||
{
|
||||
if (local _x) then {
|
||||
[_x] call FUNC(setSkillsLocal);
|
||||
};
|
||||
} forEach allUnits;
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
// Global skill module PVs values for persistence, just listen for the PV
|
||||
QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill);
|
||||
|
@ -8,4 +8,6 @@ if (isServer) then {
|
||||
["zeusUnitAssigned", FUNC(handleZeusUnitAssigned)] call EFUNC(common,addEventHandler);
|
||||
};
|
||||
|
||||
GVAR(GlobalSkillAI) = [0.5,0.5,0.5,0.5,true,true];
|
||||
|
||||
ADDON = true;
|
||||
|
@ -1,27 +1,32 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_logic"];
|
||||
TRACE_1("params",_logic);
|
||||
_this params ["_varName","_varValue"];
|
||||
_varValue params ["_general","_accuracy","_handling","_spotting","_cover","_combat"];
|
||||
TRACE_1("Params",_this);
|
||||
|
||||
[QGVAR(aiSkill_set), true, false, true] call ace_common_fnc_setSetting;
|
||||
if (!GVAR(aiSkill_set)) exitWith {
|
||||
TRACE_1("Setting must be forced off", GVAR(aiSkill_set));
|
||||
};
|
||||
TRACE_6("AI settings updated",GVAR(GlobalSkillAI));
|
||||
{
|
||||
if (local _x) then {
|
||||
_unit setSkill ["general", _general];
|
||||
_unit setSkill ["commanding", _general];
|
||||
_unit setSkill ["courage", _general];
|
||||
_unit setSkill ["aimingAccuracy", _accuracy];
|
||||
_unit setSkill ["aimingShake", _handling];
|
||||
_unit setSkill ["aimingSpeed", _handling];
|
||||
_unit setSkill ["reloadSpeed", _handling];
|
||||
_unit setSkill ["spotDistance", _spotting];
|
||||
_unit setSkill ["spotTime", _spotting];
|
||||
|
||||
private _val = _logic getVariable ["aiSkill_general", -1];
|
||||
if (_val != -1) then { [QGVAR(aiSkill_general), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
_val = _logic getVariable ["aiSkill_aimingAccuracy", -1];
|
||||
if (_val != -1) then { [QGVAR(aiSkill_aimingAccuracy), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
_val = _logic getVariable ["aiSkill_weaponHandling", -1];
|
||||
if (_val != -1) then { [QGVAR(aiSkill_weaponHandling), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
_val = _logic getVariable ["aiSkill_spotting", -1];
|
||||
if (_val != -1) then { [QGVAR(aiSkill_spotting), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
_val = _logic getVariable ["aiSkill_COVER", -1];
|
||||
if (!(_val isEqualTo -1)) then { [QGVAR(aiSkill_COVER), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
_val = _logic getVariable ["aiSkill_AUTOCOMBAT", -1];
|
||||
if (!(_val isEqualTo -1)) then { [QGVAR(aiSkill_AUTOCOMBAT), _val, false, true] call ace_common_fnc_setSetting; };
|
||||
if (_cover) then {
|
||||
_unit enableAI "COVER";
|
||||
} else {
|
||||
_unit disableAI "COVER";
|
||||
};
|
||||
|
||||
["UpdateAISettings", []] call ace_common_fnc_globalEvent;
|
||||
deleteVehicle _logic;
|
||||
|
||||
TRACE_6("ai settings updated",GVAR(aiSkill_general),GVAR(aiSkill_aimingAccuracy),GVAR(aiSkill_weaponHandling),GVAR(aiSkill_spotting),GVAR(aiSkill_COVER),GVAR(aiSkill_AUTOCOMBAT));
|
||||
if (_combat) then {
|
||||
_unit enableAI "AUTOCOMBAT";
|
||||
} else {
|
||||
_unit disableAI "AUTOCOMBAT";
|
||||
};
|
||||
};
|
||||
} forEach allUnits;
|
||||
|
@ -1,29 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
TRACE_1("params",_unit);
|
||||
|
||||
{
|
||||
_unit setSkill [_x, GVAR(aiSkill_general)];
|
||||
} forEach ["general", "commanding", "courage"];
|
||||
{
|
||||
_unit setSkill [_x, GVAR(aiSkill_aimingAccuracy)];
|
||||
} forEach ["aimingAccuracy"];
|
||||
{
|
||||
_unit setSkill [_x, GVAR(aiSkill_weaponHandling)];
|
||||
} forEach ["aimingShake", "aimingSpeed", "reloadSpeed"];
|
||||
{
|
||||
_unit setSkill [_x, GVAR(aiSkill_spotting)];
|
||||
} forEach ["spotDistance", "spotTime"];
|
||||
if (GVAR(aiSkill_COVER)) then {
|
||||
_unit enableAI "COVER";
|
||||
} else {
|
||||
_unit disableAI "COVER";
|
||||
};
|
||||
if (GVAR(aiSkill_AUTOCOMBAT)) then {
|
||||
_unit enableAI "AUTOCOMBAT";
|
||||
} else {
|
||||
_unit disableAI "AUTOCOMBAT";
|
||||
};
|
||||
|
||||
TRACE_1("ai sills set",_unit);
|
@ -13,61 +13,49 @@ TRACE_1("logicObject",_logic);
|
||||
|
||||
_control ctrlRemoveAllEventHandlers "setFocus";
|
||||
|
||||
_fnc_sliderMove = {
|
||||
//Specific on-load stuff:
|
||||
private _fnc_sliderMove = {
|
||||
params ["_slider"];
|
||||
private _idc = ctrlIDC _slider;
|
||||
private _curVal = switch (_idc) do {
|
||||
case (16184): {GVAR(aiSkill_general)};
|
||||
case (16185): {GVAR(aiSkill_aimingAccuracy)};
|
||||
case (16186): {GVAR(aiSkill_weaponHandling)};
|
||||
case (16187): {GVAR(aiSkill_spotting)};
|
||||
};
|
||||
private _idc = ctrlIDC _slider; // IDCs ∈ [16184,16187]
|
||||
private _curVal = GVAR(GlobalSkillAI) select (_idc - 16184); // [0,3]
|
||||
_slider ctrlSetTooltip format ["%1%3 (was %2%3)", round(sliderPosition _slider * 100), round(_curVal * 100), "%"];
|
||||
};
|
||||
|
||||
//Specific on-load stuff:
|
||||
(_display displayCtrl 16184) sliderSetRange [0, 1];
|
||||
(_display displayCtrl 16184) sliderSetPosition (GVAR(aiSkill_general) max 0);
|
||||
(_display displayCtrl 16184) ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
|
||||
(_display displayCtrl 16184) call _fnc_sliderMove;
|
||||
{
|
||||
private _slider = _display displayCtrl _x;
|
||||
_slider sliderSetRange [0, 1];
|
||||
_slider sliderSetSpeed [0.01,0.1];
|
||||
_slider sliderSetPosition (GVAR(GlobalSkillAI) select _forEachIndex);
|
||||
_slider ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
|
||||
_slider call _fnc_sliderMove;
|
||||
} forEach [16184,16185,16186,16187];
|
||||
|
||||
(_display displayCtrl 16185) sliderSetRange [0, 1];
|
||||
(_display displayCtrl 16185) sliderSetPosition (GVAR(aiSkill_aimingAccuracy) max 0);
|
||||
(_display displayCtrl 16185) ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
|
||||
(_display displayCtrl 16185) call _fnc_sliderMove;
|
||||
|
||||
(_display displayCtrl 16186) sliderSetRange [0, 1];
|
||||
(_display displayCtrl 16186) sliderSetPosition (GVAR(aiSkill_weaponHandling) max 0);
|
||||
(_display displayCtrl 16186) ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
|
||||
(_display displayCtrl 16186) call _fnc_sliderMove;
|
||||
|
||||
(_display displayCtrl 16187) sliderSetRange [0, 1];
|
||||
(_display displayCtrl 16187) sliderSetPosition (GVAR(aiSkill_spotting) max 0);
|
||||
(_display displayCtrl 16187) ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
|
||||
(_display displayCtrl 16187) call _fnc_sliderMove;
|
||||
|
||||
(_display displayCtrl 16188) cbSetChecked GVAR(aiSkill_COVER);
|
||||
|
||||
(_display displayCtrl 16189) cbSetChecked GVAR(aiSkill_AUTOCOMBAT);
|
||||
(_display displayCtrl 16188) cbSetChecked (GVAR(GlobalSkillAI) select 4);
|
||||
(_display displayCtrl 16189) cbSetChecked (GVAR(GlobalSkillAI) select 5);
|
||||
|
||||
private _fnc_onConfirm = {
|
||||
params [["_ctrlButtonOK", controlNull, [controlNull]]];
|
||||
TRACE_1("_fnc_onConfirm params",_this);
|
||||
|
||||
private _display = ctrlparent _ctrlButtonOK;
|
||||
if (isNull _display) exitWith {};
|
||||
|
||||
private _logic = missionnamespace getvariable ["BIS_fnc_initCuratorAttributes_target", objnull];
|
||||
if (isNull _logic) exitWith {diag_log text format ["[POTATO] - ERROR Logic [%1] is null on confirm", _logic];};
|
||||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
|
||||
if (isNull _logic) exitWith {};
|
||||
|
||||
TRACE_2("set",_logic, sliderPosition (_display displayCtrl 16184));
|
||||
_logic setVariable ["aiSkill_general", sliderPosition (_display displayCtrl 16184), true];
|
||||
_logic setVariable ["aiSkill_aimingAccuracy", sliderPosition (_display displayCtrl 16185), true];
|
||||
_logic setVariable ["aiSkill_weaponHandling", sliderPosition (_display displayCtrl 16186), true];
|
||||
_logic setVariable ["aiSkill_spotting", sliderPosition (_display displayCtrl 16187), true];
|
||||
_logic setVariable ["aiSkill_COVER", cbChecked (_display displayCtrl 16188), true];
|
||||
_logic setVariable ["aiSkill_AUTOCOMBAT", cbChecked (_display displayCtrl 16189), true];
|
||||
GVAR(GlobalSkillAI) = [
|
||||
sliderPosition (_display displayCtrl 16184), // General
|
||||
sliderPosition (_display displayCtrl 16185), // Accuracy
|
||||
sliderPosition (_display displayCtrl 16186), // Handling
|
||||
sliderPosition (_display displayCtrl 16187), // Spotting
|
||||
cbChecked (_display displayCtrl 16188), // Seek cover
|
||||
cbChecked (_display displayCtrl 16189) // Autocombat
|
||||
];
|
||||
publicVariable QGVAR(GlobalSkillAI); // Values should persist for future use
|
||||
|
||||
["ServerUpdateAISettings", [_logic]] call EFUNC(common,serverEvent);
|
||||
// PV EH won't run on local machine
|
||||
[QGVAR(GlobalSkillAI),GVAR(GlobalSkillAI)] call FUNC(moduleGlobalSetSkill);
|
||||
deleteVehicle _logic;
|
||||
};
|
||||
|
||||
_ctrlButtonOK ctrladdeventhandler ["buttonclick", _fnc_onConfirm];
|
||||
|
@ -35,11 +35,12 @@ private _fnc_onUnload = {
|
||||
|
||||
private _fnc_onConfirm = {
|
||||
params [["_ctrlButtonOK", controlNull, [controlNull]]];
|
||||
|
||||
private _display = ctrlparent _ctrlButtonOK;
|
||||
if (isNull _display) exitWith {};
|
||||
|
||||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
|
||||
if (isNull _logic) exitWith {diag_log text format ["[POTATO] - ERROR Logic [%1] is null on confirm", _logic];};
|
||||
if (isNull _logic) exitWith {};
|
||||
|
||||
private _lb = _display displayCtrl 16189;
|
||||
|
||||
|
@ -36,8 +36,8 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
class controls {
|
||||
class Title1: RscText {
|
||||
idc = -1;
|
||||
text = "Skill: General";
|
||||
toolTip = "Global AI Set Skill: general,commanding,courage";
|
||||
text = "General Skill";
|
||||
toolTip = "Changes: general, commanding, courage";
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = W_PART(10);
|
||||
@ -53,8 +53,8 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
};
|
||||
class Title2: Title1 {
|
||||
idc = -1;
|
||||
text = "Skill: aimingAccuracy";
|
||||
toolTip = "Global AI Set Skill: aimingAccuracy";
|
||||
text = "Accuracy";
|
||||
toolTip = "Changes: aimingAccuracy";
|
||||
y = H_PART(1.1);
|
||||
};
|
||||
class Value2: Value1 {
|
||||
@ -63,8 +63,8 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
};
|
||||
class Title3: Title1 {
|
||||
idc = -1;
|
||||
text = "Skill: weaponHandling";
|
||||
toolTip = "Global AI Set Skill: aimingShake,aimingSpeed,reloadSpeed";
|
||||
text = "Weapon Handling";
|
||||
toolTip = "Changes: aimingShake, aimingSpeed, reloadSpeed";
|
||||
y = H_PART(2.2);
|
||||
};
|
||||
class Value3: Value1 {
|
||||
@ -73,8 +73,8 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
};
|
||||
class Title4: Title1 {
|
||||
idc = -1;
|
||||
text = "Skill: spotting";
|
||||
toolTip = "Global AI Set Skill: spotDistance,spotTime";
|
||||
text = "Spotting";
|
||||
toolTip = "Changes: spotDistance, spotTime";
|
||||
y = H_PART(3.3);
|
||||
};
|
||||
class Value4: Value1 {
|
||||
@ -84,7 +84,7 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
class Title5: Title1 {
|
||||
idc = -1;
|
||||
text = "Seek Cover";
|
||||
toolTip = "Global AI Set Skill: AI Seek Cover";
|
||||
toolTip = "Will AI seek cover";
|
||||
y = H_PART(4.4);
|
||||
};
|
||||
class Value5: RscCheckBox {
|
||||
@ -97,7 +97,7 @@ class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
|
||||
class Title6: Title5 {
|
||||
idc = -1;
|
||||
text = "AUTOCOMBAT";
|
||||
toolTip = "Global AI Set Skill: Ai Switch To Combat Mode";
|
||||
toolTip = "Will AI automatically switch to combat mode";
|
||||
y = H_PART(5.5);
|
||||
};
|
||||
class Value6: Value5 {
|
||||
|
Loading…
Reference in New Issue
Block a user