Jump to content
Sign in to follow this  

A Simple Interactive NPC Conversation Script [SP]

Recommended Posts


Hello all!

I have been putting this together over the last few days, and have gotten to a point where my desire to add features outweighs my desire to debug/troubleshoot. So, I am releasing what I have as of now in case others may be interested in using it to make missions, or even just to play around with how to make custom dialogs and onscreen resources. I am a complete novice when it comes to those topics, so it is likely some may find serious inadequacies in my code. Nevertheless, it seems to work pretty smoothly now, and I think I've worked out the major performance/initialization hiccups.


**This is a purely text-based interactive conversation system, completely independent of the system built into the game.

**In interactive mode, the player can be presented with up to three responses, each of which can lead to a new conversation state for the unit (or unit class, represented by a Game Logic).

**The responses can also have associated actions, which are just chunks of code that will be compiled and executed at the time of selection (thus, forks in the mission flow can be set up, tasks can be given, etc.).

**The system can also work passively, where NPC's provide non-interactive dialog for a specified number of seconds before the frame disappears. This is mainly for visual consistency, as the game currently allows this type of scripting without any real complications anyway.

I have included a demo mission, which for simplicity's sake doesn't quite illustrate the full potential of the system. However, it is a bare minimum display of all the different functions involved.

Essential things for a mission are:

* A trigger, set to activation by Game Logic, with the condition set to (time > 1), and the On Act: field set to "_nil = execVM "dialogEngineStart.sqf";"

* Each unit that can be talked to must be initialized with "_nil = this execVM "enableDialog.sqf""

* initDialogs.sqf must be filled with the correct information to set up the NPC's:

** unit setVariable ["dialogState","<start state>"];

** unit setVariable ["dialogStart","<start state>"];

** unit setVariable ["dialogName","<display name>"];

** unit setVariable ["dialogText<state>","<dialog to be spoken>"];

This is extremely basic and incomplete... Look in initDialogs.sqf for examples of what other possibilities exist - I have provided macros to set the text, as well as to set responses and associated actions, and the best way to figure it out is just to see it. This part could probably use some work but it is relatively straightforward. Until such time as I can put together some kind of real documentation, the example mission will have to suffice. And I probably won't do that until I have improved some things.

One thing to note is that in the example mission, arrays instead of units are passed into the dialogEnable script. One game logic will be randomly chosen from the array to initialize the unit. The same principle applies to initDialogs.sqf, where the dialogue is passed as an array of strings instead of a single string. This results in a random string being chosen each time for the conversation.

It is really a lot simpler than it sounds in practice, it just takes a little playing around with. It is very, VERY fast to add additional NPC's to or otherwise adjust the system.

Sample screens (<100kB!):




File link:


Feedback/testing is greatly appreciated! Also, if anyone making a valiant effort to check this out finds themselves struggling, I'll be glad to help. As far as I know, the example mission should work out-of-the-box. If you follow the same patterns, you should be able to set up just about anything - the example is as barebones as it gets, so it would probably be fastest just to use it as a template.


Share this post

Link to post
Share on other sites

Thanks for sending us the release :cool:

Release frontpaged on the Armaholic homepage.


We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post

Link to post
Share on other sites

So I'm using your nice conversation system and of course have a question. I would like to give the player messages from a non-object. For instance, the player would be communicating back to "HQ" for sitreps and the like. Is it possible to disable the camera for specific conversations? Can an image / icon be substituted? Even blank would be ok. Thanks for the help!


Share this post

Link to post
Share on other sites


could I ask for a version of the script with comments, which explain, what some of the things do? I'm afraid, that I wasn't able to catch the meaning of some of the stuff

Thanks :)

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
Sign in to follow this