Global Ai Set Skill Example

This commit is contained in:
PabstMirror 2016-02-26 00:57:18 -06:00
parent 7646068a8b
commit 7fc1c87bc4
11 changed files with 352 additions and 1 deletions

View File

@ -26,4 +26,47 @@ 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;
};
};

View File

@ -11,6 +11,12 @@ class Extended_PreInit_EventHandlers {
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_postInit) );
};
};
class Extended_InitPost_EventHandlers {
class AllVehicles {
class ADDON {

View File

@ -186,4 +186,19 @@ class CfgVehicles {
// sync[] = {};
// };
// };
class GVAR(zeus_globalSetSkill): GVAR(moduleBase) {
author = ECSTRING(common,ACETeam);
category = "ACE";
scope = 1;
scopeCurator = 2;
isTriggerActivated = 0;
displayName = "Global Set AI Skill";
// icon = "\a3\Modules_F_Curator\Data\iconEndMission_ca.paa";
// portrait = "\a3\Modules_F_Curator\Data\portraitEndMission_ca.paa";
function = QFUNC(zeus_globalSetSkill);
curatorInfoType = QGVAR(RscDisplayAttributes_globalSetSkill);
curatorCost = 0;
class Arguments {};
class Attributes {};//todo, make it a threden as well
};
};

View File

@ -0,0 +1,110 @@
class RscControlsGroupNoScrollbars;
class RscText;
class RscListbox;
class RscEdit;
class RscXSliderH;
class RscCheckBox;
class RscDisplayAttributes {
class Controls {
class Background;
class Title;
class Content;
class ButtonOK;
class ButtonCancel;
};
};
class GVAR(RscDisplayAttributes_globalSetSkill): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscDisplayAttributes_globalSetSkill)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscDisplayAttributes_globalSetSkill)))] call FUNC(zeusAttributes));
class Controls: Controls {
class Background: Background {};
class Title: Title {};
class Content: Content {
class Controls {
class globalSetSkill: RscControlsGroupNoScrollbars {
onSetFocus = QUOTE(_this call FUNC(zeusAttributes_globalSetSkill));
idc = 26422;
x = "0";
y = "0";
w = "26 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "6.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
class controls {
class Title1: RscText {
idc = -1;
text = "Skill: General";
toolTip = "Global AI Set Skill: general,commanding,courage";
x = "0 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "10 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0,0,0,0.5};
};
class Value1: RscXSliderH {
idc = 16184;
x = "10.1 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "15.9 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Title2: Title1 {
idc = -1;
text = "Skill: aimingAccuracy";
toolTip = "Global AI Set Skill: aimingAccuracy";
y = "1.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Value2: Value1 {
idc = 16185;
y = "1.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Title3: Title1 {
idc = -1;
text = "Skill: weaponHandling";
toolTip = "Global AI Set Skill: aimingShake,aimingSpeed,reloadSpeed";
y = "2.2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Value3: Value1 {
idc = 16186;
y = "2.2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Title4: Title1 {
idc = -1;
text = "Skill: spotting";
toolTip = "Global AI Set Skill: spotDistance,spotTime";
y = "3.3 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Value4: Value1 {
idc = 16187;
y = "3.3 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Title5: Title1 {
idc = -1;
text = "Seek Cover";
toolTip = "Global AI Set Skill: AI Seek Cover";
y = "4.4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Value5: RscCheckBox {
idc = 16188;
x = "10.1 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "4.4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "1 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Title6: Title5 {
idc = -1;
text = "AUTOCOMBAT";
toolTip = "Global AI Set Skill: Ai Switch To Combat Mode";
y = "5.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class Value6: Value5 {
idc = 16189;
y = "5.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
};
};
};
};
class ButtonOK: ButtonOK {};
class ButtonCancel: ButtonCancel {};
};
};

View File

@ -14,3 +14,7 @@ PREP(moduleSetMedicalFacility);
PREP(moduleSurrender);
PREP(moduleUnconscious);
PREP(moduleZeusSettings);
PREP(setSkillsLocal);
PREP(zeus_globalSetSkill);
PREP(zeusAttributes);
PREP(zeusAttributes_globalSetSkill);

View File

@ -0,0 +1,10 @@
#include "script_component.hpp"
["UpdateAISettings", {
TRACE_1("UpdateAISettings EH",_this);
{
if (local _x) then {
[_x] call FUNC(setSkillsLocal);
};
} forEach allUnits;
}] call EFUNC(common,addEventHandler);

View File

@ -2,7 +2,7 @@
class CfgPatches {
class ADDON {
units[] = {};
units[] = {QGVAR(zeus_globalSetSkill)};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
@ -42,3 +42,4 @@ class ACE_Curator {
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
#include "UI_RscAttributes.hpp"

View File

@ -0,0 +1,29 @@
#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);

View File

@ -0,0 +1,5 @@
#include "script_component.hpp"
TRACE_1("params",_this);
#include "\a3\ui_f_curator\UI\Displays\RscDisplayAttributes.sqf"

View File

@ -0,0 +1,85 @@
#include "script_component.hpp"
disableSerialization;
params ["_control"];
TRACE_1("params",_control);
//Generic Init:
private _display = ctrlparent _control;
private _ctrlButtonOK = _display displayctrl 1; //IDC_OK
private _logic = missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target", objnull];
TRACE_1("logicObject",_logic);
_control ctrlRemoveAllEventHandlers "setFocus";
_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)};
};
_slider ctrlSetTooltip format ["%1 (was %2)", sliderPosition _slider, _curVal];
};
//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;
(_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);
private _fnc_onUnload = {
params [["_display", displayNull, [displayNull]]];
TRACE_1("_fnc_onUnload params",_display);
private _logic = missionnamespace getVariable ["BIS_fnc_initCuratorAttributes_target", objnull];
if (isNull _logic) exitWith {};
_logic setVariable ["closed", true];
};
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];};
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];
_logic setVariable ["set", true, true];
};
_display displayaddeventhandler ["unload", _fnc_onUnload];
_ctrlButtonOK ctrladdeventhandler ["buttonclick", _fnc_onConfirm];

View File

@ -0,0 +1,43 @@
#include "script_component.hpp"
params ["_logic"];
TRACE_1("params",_logic);
if (!isServer) exitWith {};
[{
params ["_logic"];
(isNull _logic) || {_logic getVariable ["closed", false]}
}, {
params ["_logic"];
if (isNull _logic) exitWith {TRACE_1("null",_logic);};
if (_logic getVariable ["set", false]) then {
[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));
};
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; };
["UpdateAISettings", []] call ace_common_fnc_globalEvent;
TRACE_6("ai settings updated",GVAR(aiSkill_general),GVAR(aiSkill_aimingAccuracy),GVAR(aiSkill_weaponHandling),GVAR(aiSkill_spotting),GVAR(aiSkill_COVER),GVAR(aiSkill_AUTOCOMBAT));
} else {
TRACE_1("closed but not set",_logic);
};
deleteVehicle _logic;
}, [_logic]] call ace_common_fnc_waitUntilAndExecute;