Skip to content

Commit 82fb824

Browse files
committed
Switched from object module to 3DEN attributes
1 parent f88b609 commit 82fb824

File tree

6 files changed

+75
-154
lines changed

6 files changed

+75
-154
lines changed

addons/conversation/Cfg3DEN.hpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class Cfg3DEN {
2+
class Object {
3+
class AttributeCategories {
4+
class MyCategory {
5+
displayName = "Dynamic Conversation";
6+
collapsed = 1;
7+
class Attributes {
8+
class DynOps_ConversationEnabled {
9+
//--- Mandatory properties
10+
displayName = "Enable"; // Name assigned to UI control class Title
11+
tooltip = "Enable ChatGPT-based conversation for this person. Works only in multiplayer";
12+
property = "DynOps_ConversationEnabled"; // Unique config property name saved in SQM
13+
control = "Checkbox"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes
14+
expression = "_this setVariable ['%s', _value];";
15+
defaultValue = "false";
16+
17+
//--- Optional properties
18+
condition = "objectBrain"; // Condition for attribute to appear (see the table below)
19+
typeName = "BOOL"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants. This is a scripted feature and has no engine support. See code in (configFile >> "Cfg3DEN" >> "Attributes" >> "Combo" >> "attributeSave")
20+
};
21+
22+
class DynOps_ConversationOccupation {
23+
//--- Mandatory properties
24+
displayName = "Occupation"; // Name assigned to UI control class Title
25+
tooltip = "Occupation of this person. Affects vocabulary and conversation style";
26+
property = "DynOps_ConversationOccupation"; // Unique config property name saved in SQM
27+
control = "Edit"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes
28+
expression = "_this setVariable ['%s', _value];";
29+
defaultValue = "Farmer";
30+
31+
//--- Optional properties
32+
condition = "objectBrain"; // Condition for attribute to appear
33+
typeName = "STRING"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants. This is a scripted feature and has no engine support. See code in (configFile >> "Cfg3DEN" >> "Attributes" >> "Combo" >> "attributeSave")
34+
};
35+
36+
class DynOps_ConversationFacts {
37+
//--- Mandatory properties
38+
displayName = "Known Facts"; // Name assigned to UI control class Title
39+
tooltip = "Facts which this person knows about the world and can use in conversation";
40+
property = "DynOps_ConversationFacts"; // Unique config property name saved in SQM
41+
control = "EditMulti5"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes
42+
expression = "_this setVariable ['%s', _value];";
43+
defaultValue = "Arma 4 will be released soon";
44+
45+
//--- Optional properties
46+
condition = "objectBrain"; // Condition for attribute to appear
47+
typeName = "STRING"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants. This is a scripted feature and has no engine support. See code in (configFile >> "Cfg3DEN" >> "Attributes" >> "Combo" >> "attributeSave")
48+
};
49+
};
50+
};
51+
};
52+
};
53+
};

addons/conversation/CfgMissions.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ class CfgMissions
22
{
33
class MPMissions
44
{
5-
//--- ZEUS
6-
class MP_DynOps_ChatTest // class name MUST match the name in the 'directory' path
5+
class MP_DynOps_ChatTest
76
{
87
briefingName = "Dynamic Operations Chat Test";
98
directory = "z\dynops\addons\conversation\mpscenarios\MP_DynOps_ChatTest.Enoch"; // <--- match

addons/conversation/CfgModules.hpp

Lines changed: 0 additions & 127 deletions
This file was deleted.

addons/conversation/XEH_preInit.sqf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ if (isMultiplayer && isServer) then {
2121
}
2222
] remoteExec ["CBA_fnc_addEventHandler", 2, true];
2323
};
24+
25+
["Man", "init", { (_this select 0) spawn FUNC(initAgent); }] call CBA_fnc_addClassEventHandler;

addons/conversation/config.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class CfgPatches {
1212
};
1313
};
1414

15+
#include "Cfg3DEN.hpp"
1516
#include "CfgEventHandlers.hpp"
1617
#include "CfgFunctions.hpp"
1718
#include "CfgMissions.hpp"
18-
#include "CfgModules.hpp"
19-
#include "CfgRemoteExec.hpp"
19+
#include "CfgRemoteExec.hpp"

addons/conversation/fnc_initAgent.sqf

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
#include "script_component.hpp"
22

3-
params [
4-
["_logic", objNull, [objNull]], // module logic
5-
["_units", [], [[]]], // list of affected units
6-
["_activated", true, [true]] // was module activated?
7-
];
3+
params ["_agent"];
84

95
if (!isServer) exitWith { };
6+
if (isPlayer _agent) exitWith { };
7+
if (_agent getVariable ["DynOps_ConversationEnabled", false] != true) exitWith { };
8+
9+
private _name = name _agent;
10+
private _occupation = _agent getVariable ["DynOps_ConversationOccupation", "Civilian"];
11+
private _facts = _agent getVariable ["DynOps_ConversationFacts", "Arma 4 will be released soon"];
1012

1113
private _template =
12-
"The fictional state of Livonia is in state of armed conflict between rebel Freedom and Independence Army (FIA)
13-
faction and government Livonia Defence Force (LDF).
14-
I want you to act as %1, %2 year old %3.
14+
"I want you to act as %1, %2.
1515
1616
You know following facts:
17-
%4.
17+
%3.
1818
1919
Do not break character. Use vocabulary and vernacular which would be expected from person of such background.
2020
Give short answers only";
2121

22+
private _current_uid = _agent getVariable QGVAR(agent_uid);
23+
if (!isNil "_current_uid") exitWith { };
2224

23-
{
24-
if (!isNull (_x getVariable QGVAR(agent_uid))) then { continue };
25-
26-
private _name = name _x;
27-
private _age = _logic getVariable "age";
28-
private _occupation = _logic getVariable "occupation";
29-
private _facts = _logic getVariable "facts";
30-
private _uuid = call EFUNC(extension,uuid);
31-
32-
_x setVariable [QGVAR(agent_uid), _uuid];
33-
GVAR(agents) set [_uuid, _x];
25+
private _uuid = call EFUNC(extension,uuid);
26+
_agent setVariable [QGVAR(agent_uid), _uuid];
27+
GVAR(agents) set [_uuid, _agent];
3428

35-
private _input = format [_template, _name, _age, _occupation, _facts];
36-
["chat:init", [_uuid, _input]] call EFUNC(extension,call);
37-
} forEach _units;
29+
private _input = format [_template, _name, _occupation, _facts];
30+
["chat:init", [_uuid, _input]] call EFUNC(extension,call);
31+
INFO_3("Conversation agent initialized name=%1 occupation=%2 uuid=%3", _name, _occupation, _uuid);

0 commit comments

Comments
 (0)