Jump to content
Raider_18

Help with BI conversation scripting

Recommended Posts

What's up Arma community! Throwing this out there because I am terrible at this and stuck with getting a conversation scripted. Below all the posted scripts I describe how I am currently experimenting with it

 

What I am trying to do is get an interactive conversation flow between the player and an NPC with the scroll menu and different response options, like in Arma 2. BI has a pretty decent conversations page for this exact subject, with lip synch and all, I have copied it and made only minor tweaks to make it more readable for myself, and for my sound files to play. The example mission is here if someone who knows this stuff wants to take a look or if someone wants a good starting point for conversations in their scenario ----> Google drive example mission

 

What works - I have kbTell working fine, so I know the code and folder set ups are ok, and my sound files play just fine. 

What is the problem? - when using kbAddTopic nothing! No errors!, no RPT log suspects, no stuttering... but also no functionality 😔. It must be something I am doing wrong but I cannot for the life of me debug it or figure out why. So here we are. It would be super cool to have AI conversations with player choices, especially for the SP crowd

 

My directory -

kb ---------------	folder with bikb and sqf
sounds -----------  folder with a few test samples in .ogg that are confirmed 100% to work in game
description.ext 
mission.sqm

 

Scripts - 

Description.ext

class CfgSentences
{
	class event1
	{
		class talk
		{
			file = "kb\talk.bikb";
			#include "kb\talk.bikb" // avoids a double declaration
		};
	};
};

kb\talk.bikb

class Sentences
{
	class sentence1
	{
		text = "";	
		textPlain = "Shuuuush";
		speech[] = { "\sounds\officer_intro_1.ogg" };	
		class Arguments {};
		actor = "officer"
	};
	class sentence2
	{
		text = "";	
		textPlain = "Go Away";
		speech[] = { "\sounds\officer_intro_2.ogg" };	
		class Arguments {};
		actor = "officer"
	};
	

	// these sentences are EH options for later
	class response{ text = "response"; speech[] = { "\sounds\squelch.ogg" }; class Arguments {}; actor = nomad; };
	class option1 { text = "op1"; speech[] = { "\sounds\squelch.ogg" }; class Arguments {}; actor = nomad; };
	class option2 { text = "op2"; speech[] = { "\sounds\squelch.ogg" }; class Arguments {}; actor = nomad; };
	class option3 { text = "op3"; speech[] = { "\sounds\squelch.ogg" }; class Arguments {}; actor = nomad; };

	// the Interrupted sentence triggered when the conversation menu is closed without answering (e.g using backspace)
	class Interrupted
	{
		text = "SideChat text";
		speech[] = { "\sounds\officer_intro_3" };
		class Arguments {};
		actor = "officer";
	};
};

// Needed parameters.
class Arguments {};
class Special {};
startWithVocal[] = { hour };
startWithConsonant[] = { europe, university };

kb\talk.sqf

I am also not entirely sure how this one works, I am somewhat scripting literate (after so many hours trial and error) but I don't know if I should replace all the private _variables with the planned interlocuters or...??? that cant be right can it?, idk!? 😟

/* 

-------BI notes I kept--------
here we will be storing all the sentences from which the player will choose (left side menu)
if there is only one option in the array, the sentence will replace the "Talk to" action name
we want the player to be able to approach his buddy and talk to him via the action menu.
we need to check:
if the player is pointing at his buddy
if the player is not answering any of his buddy's sentences
if the player has not told him hello already
then we add that array to _convMenu - the parameters are mostly self-explanatory:
------BI Params--------------- (do these have to be replaced?)
_this: Object - the player receiving the sentence. Must have had this particular script assigned via kbAddTopic Player, AI player talking with or both??
_from: Object - the unit that told the sentence
_sentenceId: String - the sentence the player is reacting to. Defined in .bikb in class Sentences
_topic: String - topic name used in kbAddTopic

*/

private _convMenu = [];
if (_from == officer && _sentenceId == "" && !(_this kbWasSaid [_from, _topic, "sentence1", 999999])) then
{
	_convMenu pushBack ["menu text", _topic, "sentence1", []];
};

// here we make the unit say the proper sentence based on the one he just received
// switch-case-do is used here but it is only one solution to manage sentences (if-then etc could do)

switch (_sentenceId) do
{
	case "sentence1":
	{
		_this kbTell [_from, _topic, "a player response?"];
	};
	case "sentence2":
	{
		_this kbTell [_from, _topic, "????"];
	};
	case "responses":
	{
		// the player will have 3 answers to choose from:
		_convMenu pushBack ["op1",		_topic, "option1",		[]];
		_convMenu pushBack ["op2",		_topic, "option2",		[]];
		_convMenu pushBack ["op3",		_topic, "option3",		[]];
	};
};

// return the sentence list pool
_convMenu;

the above is kind of hard for me to make sense of honestly with all the scopes and the switch-case-do wizardry.

 

I have the player named nomad and a BLUFOR AI named officer. I have two triggers one for kbTell and one for BIS_fnc_kbAddTopic

When I trigger kbTell all is good, would be great if you only needed to fire off some sentences and be done. 

["the topic", "Cfg of topic"] spawn BIS_fnc_kbTell - no issues all is good

 

But with kbAddTopic no such luck here using the following on player only, officer only, both, as objects or as strings, and for any of the methods below:

 

X kbAddTopic ["myTest", "kb\talk.bikb", "kb\talk.sqf"];  

X kbAddTopic ["myTest", "kb\talk.bikb"];

X kbAddTopic ["myTest", "kb\talk.bikb", "compile preprocessFileLineNumbers "kb\talk.sqf"];

 

what I mean by X -->  (player, nomad, officer, with and without"") from trigger, from unit init, from a script. Nothing

Again no errors or anything to start chipping away at like usual. 

 

Here are the resources I have already tried and poured many hours over:

Conversations official Biki, 99% of what I have is from the source already, read many times over

kbAddTopic

Jezuro's old posting

HateDead's old posting

IndeedPete's pretty cool conversation system that I may just have to adopt if I cant figure this out. Also where I got the sample sound files. 

Youtube, but kind of like the BI fourm threads a lot of the stuff is outdated 

Google of course

Prayer and hope

 

 

Anything you guys have would be MUCH appreciated. Thank you so much! 

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, Raider_18 said:

X kbAddTopic ["myTest", "kb\talk.bikb", "compile preprocessFileLineNumbers "kb\talk.sqf"];

person kbAddTopic [topicName, conversationFile, fsmFile, eventHandler]

  • topicName - Anything STRING, a name to reference the topic by. "myTest" is fine
  • conversationFile - bikb file that holds class Sentences. "kb/talk.bikb is correct.
  • fsmFile - FSM for AI auto response to received sentences. Missing. FSM editor is available in Arma Tools download. See ALSO links under Conversation FSM on conversation page for more info
  • eventHandler - code for PLAYER auto response/conv menu additions. Should be { compile preprocessFileLineNumbers "kb\talk.sqf" }

Quotes from Conversation page...

fsmFile

Quote

the Conversation FSM fires on sentences received by an AI and defines an AI unit's reaction.

eventHandler

Quote

The Conversation Event Handler is not an Event Handler as we know them. It is Code that will be executed with each sentence received by a player, and will constantly fire (onEachFrame) when the player is pointing at a "talkable" person at "talkable" range.

 

See my example MISSION here.

From my init.sqf...

//Add sentences and FSM flow to informant AI
informant kbAddTopic ["informer", "informer\informer.bikb", "informer\informer.fsm"];

//Add sentences and SQF flow to player
//no need for FSM, hence the empty quotes
player kbAddTopic ["informer", "informer\informer.bikb", "", { call compile preprocessFileLineNumbers "informer\informer.sqf"}];

Otherwise, every thing looks correct from a cursory glance.

  • Like 3

Share this post


Link to post
Share on other sites

You absolute madman! THANK YOU!!! Your way looks super clean and is exactly what I needed, I am about to deep dive the example and start learning, but it looks way easier than I thought so far. And as always you went above and beyond with an example mission. You da man!

 

**Will update this thread after I get something hashed out from scratch after reverse engineering it**

Share this post


Link to post
Share on other sites

Do you use the Arma tools FSM editor or is there another preference for FSM editing?? 

Share this post


Link to post
Share on other sites

I just use the Arma tools FSM editor

Share this post


Link to post
Share on other sites

Im learning so much about FSMs, so useful!

I got conversations working but how would you make the pushback comments happen one at a time in order? For example:

 

This is how the first menu entry is created:
_nul = BIS_convMenu pushBack ["Say Hello.", _topic, "intro_greeting", []];


And this needs to be a secondary response added later:
_nul = BIS_convMenu pushBack ["Yes, sorry", _topic, "exit_apologize", []];


I have it inside of an IF THEN like the example you provided:
if (_this kbWasSaid [_from, _topic, "first_response", 999999]) then { _nul = BIS_convMenu pushBack ["Yes, sorry", _topic, "exit_apologize", []]; };


However both options are shown in the menu from the start regardless, and the response should come after a sentence from the NPC, like a natural conversation. I have tried the BI Switch-Case-Do format as well but does not seem to work when I arrange it like such:

switch (_sentenceId) do
{
	case "first_response":
	{
		BIS_convMenu pushBack ["Yes, sorry", _topic, "exit_apologize", []];
	};
};

Any reason you see why the option is not waiting for the correct response before showing up in BIS_convMenu??

Thanks alot I have learned a ton so far! 

 

 

 

 

Share this post


Link to post
Share on other sites
On 1/7/2023 at 12:07 AM, Raider_18 said:

and the response should come after a sentence from the NPC

On 1/7/2023 at 12:07 AM, Raider_18 said:

if (_this kbWasSaid [_from, _topic, "first_response", 999999]) then

Although this suggests that the option should be added if the player (_this) said to the NPC (_from) "first_response".

 

On 1/7/2023 at 12:07 AM, Raider_18 said:

Any reason you see why the option is not waiting for the correct response before showing up in BIS_convMenu??

Would really need to see your setup (example mission) to provide better help.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×