-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] AI Profiles #164
base: master
Are you sure you want to change the base?
[WIP] AI Profiles #164
Changes from 2 commits
b0a761d
c75b1e4
6d2d9c1
0c03f41
6525c91
6b7e058
ddc2aa5
00f8842
7db130b
8bedfed
70bb12b
6fc7cbf
cde9f6b
73ea80a
83397d7
421f93c
c9d1c60
5aa413b
b92fac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class LAMBS_CfgAIProfiles { | ||
class Default { | ||
requestArtillery = 1; | ||
|
||
}; | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class LAMBS_CfgAIProfiles { | ||
class Default { | ||
reactToExplosions = 1; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ class CfgPatches { | |
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "CfgAIProfile.hpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class LAMBS_CfgAIProfiles { | ||
class Default { | ||
#ifdef ISDEV | ||
allowDemoNumberAsBool = 1; | ||
allowDemoRandom = 0.5; | ||
allowDemoBool = "true"; | ||
allowDemoBool2 = "False"; | ||
allowDemoCodeBool = "selectRandom [true, true, false, true, false, false]"; | ||
allowDemoCodeNumber = "random 1"; | ||
#endif | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: joko // Jonas | ||
* Group profiles handler -- Checks and runs AI profiles -- group actions with the fnc_profileXxx prefix. | ||
* | ||
* Arguments: | ||
* 0: Group/Unit <OBJECT, GROUP> | ||
* 1: Profile Tactic <STRING> | ||
* | ||
* Return Value: | ||
* Tactic is allowed to Execute | ||
* | ||
* Example: | ||
* [bob] call lambs_danger_fnc_doesProfileAllow; | ||
* | ||
* Public: No | ||
*/ | ||
params [["_target", objNull, [objNull, grpNull]], ["_tactic", "unkown", [""]]]; | ||
|
||
private _profile = _target getVariable [QGVAR(AIProfile), "default"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of a QoL thing. Have a cba setting which profile should be used as default the CBA setting is a list of available profiles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a dropdown would be impossible because they can be saved in the description and created via scripted modules. and parsing that while in the editor is from my knowledge not possible. the only thing for CBA setting we could do is a normal text box. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I see it, is, a drop down is doable, but only account for config and missionconfig profiles. If someone adds them in editor OR via script it is in their authority to set the default correctly. |
||
|
||
private _profileData = GVAR(ProfilesNamespace) getVariable toLower(_profile); | ||
if (isNil "_profileData") then { | ||
_profileData = GVAR(ProfilesNamespace) getVariable "Default"; | ||
}; | ||
_tactic = toLower(_tactic); | ||
private _value = [_profileData, _tactic] call CBA_fnc_hashGet; | ||
if (_value isEqualType {}) then { | ||
diwako marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_value = [_target, _tactic] call _value; | ||
}; | ||
if (_value isEqualType 0) then { | ||
if (_value in [1,0]) then { | ||
_value = _value isEqualTo 1; | ||
} else { | ||
_value = RND(_value); | ||
}; | ||
}; | ||
if !(_value isEqualType true) then { | ||
_value = true; | ||
}; | ||
_value; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: joko // Jonas | ||
* | ||
* | ||
* Arguments: | ||
* | ||
* | ||
* Return Value: | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* Public: No | ||
*/ | ||
|
||
{ | ||
{ | ||
private _profileName = toLower(configName _x); | ||
private _profile = GVAR(ProfilesNamespace) getVariable _profileName; | ||
if (isNil "_profile") then { | ||
_profile = [[], true] call CBA_fnc_hashCreate; | ||
}; | ||
{ | ||
private _value = false; | ||
private _tactic = toLower(configName _x); | ||
if (isText _x) then { | ||
_value = getText _x; | ||
if (toLower(_value) in ["true", "false"]) then { | ||
switch (toLower _value) do { | ||
case ("true"): { | ||
_value = true; | ||
}; | ||
default { | ||
_value = false; | ||
}; | ||
}; | ||
} else { | ||
_value = compile _value; | ||
}; | ||
} else { | ||
if (isNumber _x) then { | ||
_value = getNumber _x; | ||
}; | ||
}; | ||
_profile = [_profile, _tactic, _value] call CBA_fnc_hashSet; | ||
} forEach configProperties [_x, "!isClass _x", true]; | ||
GVAR(ProfilesNamespace) setVariable [_profileName, _profile, true]; | ||
} forEach configProperties [_x >> "LAMBS_CfgAIProfiles", "isClass _x", true]; | ||
} forEach [configFile, missionConfigFile]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: joko // Jonas | ||
* Group profiles handler -- Checks and runs AI profiles -- group actions with the fnc_profileXxx prefix. | ||
* | ||
* Arguments: | ||
* 0: Profile <STRING> | ||
* 1: Profile Tactic <STRING> | ||
* 2: Profile Enabled <BOOL> | ||
* | ||
* Return Value: | ||
* Tactic is allowed to Execute | ||
* | ||
* Example: | ||
* ["default", "tacticHidding", true] call lambs_danger_fnc_setProfileAllow; | ||
* | ||
* Public: No | ||
*/ | ||
params [["_profileName", "", [""]], ["_tacticName", "", [""]], ["_enabled", true, [true, 0, {}]]]; | ||
_profileName = toLower(_profileName); | ||
private _profile = GVAR(ProfilesNamespace) getVariable _profileName; | ||
if (isNil "_profile") then { | ||
_profile = [[], true] call CBA_fnc_hashCreate; | ||
}; | ||
|
||
_profile = [_profile, toLower(_tacticName), _enabled] call CBA_fnc_hashSet; | ||
|
||
GVAR(ProfilesNamespace) setVariable [_profileName, _profile, true]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: joko // Jonas | ||
* Group profiles handler -- Checks and runs AI profiles -- group actions with the fnc_profileXxx prefix. | ||
* | ||
* Arguments: | ||
* 0: Group/Unit <OBJECT, GROUP> | ||
* 1: Profile Tactic <STRING> | ||
* | ||
* Return Value: | ||
* Tactic is allowed to Execute | ||
* | ||
* Example: | ||
* [bob] call lambs_danger_fnc_setupProfile; | ||
* | ||
* Public: No | ||
*/ | ||
params ["_tacticName", "_tactics"]; | ||
|
||
private _profile = +GVAR(ProfilesNamespace) getVariable "default"; // Create a Copy of the default Profile | ||
|
||
{ | ||
_profile = [_profile, toLower(_x select 0), _x select 1] call CBA_fnc_hashSet; | ||
} forEach _tactics; | ||
|
||
GVAR(ProfilesNamespace) setVariable [toLower(_tacticName), _profile, true]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "\z\lambs\addons\danger\script_component.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the profile stuff is in the main component, wouldn't it be better to have the dev values in danger and the actual prod default values in main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split it into the modules where it is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need then at least in the wiki some entry with all config entries. It is confusing to look at the code and only see a fraction of possible entries. (Or we have to tell people to use the config viewer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally I planned to build a tool that shows and allows you to create and modify profiles in the editor in the release after the profiles where introduced. but writing a small export for the wiki is also fairly easy