Jump to content
Poupoko

Make AI say random sentences

Recommended Posts

Hello ! 

I'm doing a mission where a BLUFOR talks to you when you get close with a trigger.

It works very well, the problem is that I'd like it to have several sentences available, and that each time you move away from it then move back towards it, it would "randomly" choose between one of these sentences, to add realism and not repeat himself constantly.

Can anyone help me on this ? 

 

Here is how I did the mission :

 

(First code - brief.bkib 

Second - chat1.sqf

Third - description.ext)

class Sentences
{
    class Brief_Bob_Line_1
    {
        text = "What are you looking at ? Go to the fight you coward lazy ass motherfucker !"
        speech[] = { "\chat\lol.ogg" };
        class Arguments {};
        actor = "Bob";
    };
};

class Arguments {};
class Special {};
startWithVocal[] = {hour};
startWithConsonant[] = {europe, university};
["Briefing", "ConversationsAtBase"] call bis_fnc_kbtell;
class CfgSentences
{
    class ConversationsAtBase
    {
        class Briefing
        {
            file = "brief.bikb";
            #include "brief.bikb"
        };
    };
};

And I have a /chat file where I have the "lol.ogg" + "lol.lip" for the lip sync.

In my mind there would be multiple .ogg files in the /chat that the IA could use each time the trigger gets activated.

 

 

 

 

 

Share this post


Link to post
Share on other sites

Just this morrning i've try some line to do this kind of stuff, i hope this will help you

 

Quote

 _rNum = selectRandom [1,2,3];

if ( _rNum == 1 ) then {  your code  };

if ( _rNum == 2 ) then  { your code };

if ( _rNum == 3 ) then  { your code };

 

this select a number bewteen 1,2 or 3 : selectRandom

 

You can add number as you need. I've use this to make random answer with an action in my mission, it's work SP/MP, i use it with Simple conversation script by R3vo

 

My script look like that :

intero.sqf

 

Spoiler

 _rNum = selectRandom [1,2,3];

if ( _rNum == 1 ) then { line1 = ["Grognon-6", "Bonjour, nous sommes là pour vérifier que tout va bien dans votre ville, avez-vous vu ou entendu quelque chose ?"];
line2 = ["Civil", "Bonjour, merci de vous soucier de nous, le climat actuel est tendu mais tout va bien par ici."];
line3 = ["Grognon-6", "Merci à vous, bonne journée!"];
[[line1,line2,line3],"Direct",0.06,false] execVM "fn_simpleConv.sqf";
playSound ["intero1", true];
sleep 7;
playSound ["intero21", true];
sleep 7;
playSound ["intero3", true];
};

if ( _rNum == 2 ) then  { line1 = ["Grognon-6", "Bonjour, nous sommes là pour vérifier que tout va bien dans votre ville, avez-vous vu ou entendu quelque chose ?"];
line2 = ["Civil", "Bonjour, votre présence me rassure mais je n'ai rien d'intéressant à vous signaler."];
line3 = ["Grognon-6", "Merci à vous, bonne journée!"];
[[line1,line2,line3],"Direct",0.06,false] execVM "fn_simpleConv.sqf";
playSound ["intero1", true];
sleep 7;
playSound ["intero22", true];
sleep 7;
playSound ["intero3", true];
};

if ( _rNum == 3 ) then  { line1 = ["Grognon-6", "Bonjour, nous sommes là pour vérifier que tout va bien dans votre ville, avez-vous vu ou entendu quelque chose ?"];
line2 = ["Civil", "Bonjour, je ne sais pas si c'est vrai mais il se dit que le CSAT prépare quelque chose, mais je n'en sais pas plus."];
line3 = ["Grognon-6", "Merci à vous, bonne journée!"];
[[line1,line2,line3],"Direct",0.06,false] execVM "fn_simpleConv.sqf";
playSound ["intero1", true];
sleep 7;
playSound ["intero23", true];
sleep 7;
playSound ["intero3", true];
};

 

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

×