-
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
Draft
jokoho48
wants to merge
19
commits into
master
Choose a base branch
from
AIProfiles
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] AI Profiles #164
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b0a761d
Initial work for AIProfiles
jokoho48 c75b1e4
Merge branch 'master' into AIProfiles
jokoho48 6d2d9c1
implement first idea of BrainAdjust Function
jokoho48 0c03f41
add CBA Setting for Default Profile
jokoho48 6525c91
fix linter
jokoho48 6b7e058
Initial Work on Eden Implementation
jokoho48 ddc2aa5
move parsing to preInit
jokoho48 00f8842
Fix a issue in PREP and SUBPREP when DISABLE_COMPILE_CACHE is Defined
jokoho48 7db130b
add Posibility to define unit/group based overwrite for profiles
jokoho48 8bedfed
add config for CfgAIProfilesValueDescriptions
jokoho48 70bb12b
Merge branch 'master' into AIProfiles
jokoho48 6fc7cbf
Merge branch 'master' into AIProfiles
jokoho48 cde9f6b
update files to new standart format
jokoho48 73ea80a
Merge branch 'master' into AIProfiles
jokoho48 83397d7
fix a few issues and convert last uses of CBA Hashes to Native Hashmaps
jokoho48 421f93c
Merge branch 'master' into AIProfiles
jokoho48 c9d1c60
Fix Merge issue
jokoho48 5aa413b
Merge branch 'master' into AIProfiles
jokoho48 b92fac4
Merge branch 'master' into AIProfiles
jokoho48 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class LAMBS_CfgAIProfiles { | ||
class Default { | ||
requestArtillery = 1; | ||
}; | ||
}; | ||
class LAMBS_CfgAIProfilesValueDescriptions { | ||
class requestArtillery { | ||
name = "Request Artillery"; | ||
description = "The AI is allowed to Request Artillery."; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class LAMBS_CfgAIProfiles { | ||
class Default { | ||
reactToExplosions = 1; | ||
}; | ||
}; | ||
|
||
class LAMBS_CfgAIProfilesValueDescriptions { | ||
class reactToExplosions { | ||
name = "React to Explosion"; | ||
description = "The AI Reacts with Animations to Explosion nearby."; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ class CfgPatches { | |
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "CfgAIProfile.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Cfg3DEN { | ||
class Mission { | ||
class Scenario { | ||
class AttributeCategories { | ||
class GVAR(category) { | ||
class GVAR(AIProfiles) { | ||
property = QGVAR(AIProfiles); | ||
value = 0; | ||
control = "CBA_Settings_CategoryHider"; | ||
displayName = ""; | ||
tooltip = ""; | ||
defaultValue = QUOTE(HASH_NULL); | ||
expression = ""; | ||
wikiType = "[[Array]]"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 | ||
}; | ||
}; | ||
|
||
class LAMBS_CfgAIProfilesValueDescriptions { | ||
#ifdef ISDEV | ||
class allowDemoNumberAsBool { | ||
name = "Demo allowDemoNumberAsBool"; | ||
description = "Description of allowDemoNumberAsBool"; | ||
}; | ||
class allowDemoRandom { | ||
name = "Demo Setting allowDemoRandom"; | ||
description = "Description of allowDemoRandom"; | ||
}; | ||
class allowDemoBool { | ||
name = "Demo allowDemoBool"; | ||
description = "Description of allowDemoBool"; | ||
}; | ||
class allowDemoBool2 { | ||
name = "Demo allowDemoBool2"; | ||
description = "Description of allowDemoBool2"; | ||
}; | ||
class allowDemoCodeBool { | ||
name = "Demo allowDemoCodeBool"; | ||
description = "Description of allowDemoCodeBool"; | ||
}; | ||
class allowDemoCodeNumber { | ||
name = "Demo allowDemoCodeNumber"; | ||
description = "Description of allowDemoCodeNumber"; | ||
}; | ||
#endif | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class ctrlMenuStrip; | ||
class Display3DEN { | ||
class Controls { | ||
class MenuStrip: ctrlMenuStrip { | ||
class Items { | ||
class Tools { | ||
items[] += { | ||
QGVAR(AIProfileEditor) | ||
}; | ||
}; | ||
class GVAR(AIProfileEditor) { | ||
text = CSTRING(OpenAIProfileEditor); | ||
picture = "\A3\ui_f\data\igui\cfg\simpleTasks\types\meet_ca.paa"; | ||
action = QUOTE(call FUNC(profileEditor)); | ||
shortcuts[] = {}; | ||
opensNewWindow = 1; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#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> | ||
* 2: Profile Default Value <ANYTHING> | ||
* | ||
* Return Value: | ||
* Value Stored in the Profile Tactic | ||
* | ||
* Example: | ||
* [bob] call lambs_danger_fnc_getProfileValue; | ||
* | ||
* Remarks: | ||
* Based on the 3rd parameter the type of return is getting defined. | ||
* If the value type of the profile tactic is a different to the _default type it the default gets returned. | ||
* | ||
* | ||
* Public: No | ||
*/ | ||
params [["_target", objNull, [objNull, grpNull]], ["_tactic", "unkown", [""]], ["_default", true, [true, 0]]]; | ||
|
||
private _profile = _target getVariable [QGVAR(AIProfile), GVAR(defaultAIProfile)]; | ||
|
||
private _profileData = GVAR(ProfilesNamespace) getVariable _profile; | ||
if (isNil "_profileData") then { | ||
_profileData = GVAR(ProfilesNamespace) getVariable "default"; | ||
}; | ||
|
||
// Simple Unit/Group Based Overwrite | ||
private _overwrite = _target getVariable QGVAR(OverwriteProfile); | ||
if (!isNil "_overwrite" && { _overwrite isEqualType [] } && { _tactic in _overwrite }) then { | ||
_profileData = _overwrite; | ||
}; | ||
|
||
_tactic = toLower _tactic; | ||
private _value = _profileData get _tactic; | ||
|
||
if (_value isEqualType {}) then { | ||
_value = [_target, _tactic] call _value; | ||
}; | ||
if (_value isEqualType 0) then { | ||
if (_default isEqualType true) then { | ||
_value = _value isEqualTo 1; | ||
}; | ||
}; | ||
_value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = createHashMap; | ||
}; | ||
{ | ||
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 set [_tactic, _value]; | ||
} forEach configProperties [_x, "!isClass _x", true]; | ||
GVAR(ProfilesNamespace) setVariable [_profileName, _profile, true]; | ||
} forEach configProperties [_x >> "LAMBS_CfgAIProfiles", "isClass _x", true]; | ||
} forEach [configFile, missionConfigFile]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
// [{ call Lambs_main_fnc_profileEditor; }, 2] call CBA_fnc_waitAndExecute; | ||
#ifdef ISDEV | ||
private _display = ([findDisplay 46, findDisplay 313] select is3DEN) createDisplay QGVAR(display); | ||
#else | ||
private _display = findDisplay 313 createDisplay QGVAR(display); | ||
#endif | ||
|
||
private _defaultProfile = configProperties [configFile >> "LAMBS_CfgAIProfiles" >> "default", "!isClass _x", true]; | ||
private _height = ((count _defaultProfile) + 1) * (PY(CONST_HEIGHT + CONST_SPACE_HEIGHT) * 2); | ||
|
||
private _basePositionX = 0.5 - (PX(CONST_WIDTH) / 2); | ||
private _basePositionY = 0.5 - (_height / 2); | ||
|
||
private _globalGroup = _display ctrlCreate ["RscText", -1]; | ||
_globalGroup ctrlSetBackgroundColor BACKGROUND_RGB(0.8); | ||
_globalGroup ctrlSetPosition [_basePositionX, 0.5 - (_height / 2), PX(CONST_WIDTH), _height]; | ||
_globalGroup ctrlCommit 0; | ||
|
||
private _header = _display ctrlCreate ["RscText", -1, _globalGroup]; | ||
_header ctrlSetText "Profile: Default"; // TODO(joko): Add Profile Selector | ||
_header ctrlSetFontHeight PY(CONST_HEIGHT); | ||
_header ctrlSetPosition [0.5 - (PX(CONST_WIDTH / 2)), _basePositionY, PX(CONST_WIDTH), PY(5)]; | ||
_header ctrlSetBackgroundColor COLOR_RGBA; | ||
_header ctrlCommit 0; | ||
|
||
_display setVariable ["header", _header]; | ||
|
||
// TODO(joko): Code | ||
// TODO(joko): Checkbox | ||
// TODO(joko): Number | ||
// TODO(joko): Clear | ||
// TOOD(joko): New Profile | ||
// TODO(joko): Duplicate Profile | ||
// TODO(joko): Parsing | ||
// TODO(joko): Saving |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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