Conversations

From Off Grid Wiki
Jump to: navigation, search

How to write up a crypto chat conversation

The in game conversations through cryptochat are an important way to deliver narrative context, tutorialisation of tools and mechanics, or telegraphing the goals and objectives you might need to, to a player playing your level.

To start building your own conversations you only need to know the locations of two lua scripts,

our old friend the 'Mission Script' which as a reminder sits in Assets\StreamingAssets\Levels\*YourLevelName*\Scripts

and then a new script, or actually scripts, you see each conversation is its own lua script found in Assets\StreamingAssets\Levels\NewsPaperOffice\Conversations

Create a new file for your new conversation and give it a name, it can be anything, it is only used a reference for starting the conversation, tieing the name to an objective or event can make it easier to keep in your head when and where the conversation will be called while editing them. The example we are using here is **testConversation.lua**

The file path for the conversations lua files

Conversations can be triggered in many different ways but the most basic example is by a trigger volume such as a mission object.

Set up a trigger volume

Create a game object and give it a name, in this example "MissionObject_1_1"

Give it a mission object component, set the drop down to trigger

Make sure the game object has a box collider, and tick the isTrigger box.

In the mission script, create the trigger

1 -- [[ Mission triggers & interactions]] --
2 
3 MissionObjects["MissionObject_1_1"].OnTriggerEnter = function(name)
4 	if name == Player.GetName() then
5 		Mission.StartObjective(mission.objectives.enterbuilding)
6 	end
7 end

This will fire off the objective on player entry.

Create the objective

Here we create the 'enterbuilding' (or objective name of your choosing) objective.

 1 -- Mission objectives:
 2 	objectives = {
 3 	--[[ Find way into the building ]]--
 4 		enterbuilding = {
 5 			name = "theapostle_obj_enterbuilding_name",
 6 			description = "theapostle_obj_enterbuilding_desc",
 7 			hints = {
 8 				"theapostle_obj_enterbuilding_hint_1",
 9 				"theapostle_obj_enterbuilding_hint_2",
10 			},
11 			messages = {
12 				"theapostle_obj_enterbuilding_msg_1",
13 			},
14 			onStart = function()
15 				print("Started objective 'enterbuilding'")
16 				**Conversation.StartScript("testConversation")**
17 			end,
18 			onCompleted = function()
19 				print("Completed objective 'enterbuilding'")
20 			end,
21 		},

The operative part of the objective here is obviously the moment where we call **Conversation.StartScript("testConversation")** and so now we have all the constituent parts.

Creating the actual conversation

You have already created your conversation script (the example being 'testConversation.lua' that you created at the start of this example) open up this file and then we are ready to get down to the creative bit.

Our example conversation looks like this:

 1 anger = 0
 2 sendData = true
 3 encrypted = true
 4 characters = {
 5 	"Joe",
 6 	"Smedley",
 7 	"Terrence",
 8 	-- "HW",
 9 }
10 
11 begin = function()
12 	Send( {"Smedley", "Joe..."} )
13 	Send( {"Smedley", "you there yet?"} )
14 	SendResponse( {"yes"} )
15 	Send( {"Smedley", "Ok this is Terrence, the newspaper editor I told you about"})
16 	Send( {"Terrence", --[["theapostle_obj_enterbuilding_msg_1"]] 
17 	"Thanks for turning up, I know this was a strange request. Firstly you're going to need to find a way into the buildings server room in the basement"})
18 	Send( {"Smedley", 
19 		function() 
20 			return "Yeah, follow my cues and we'll work that out, something like " .. tostring(math.random(1, 40)) .. " young people have been vanished without a trace in the last " .. tostring(math.random(1,4)) .." months."
21 			end } )
22 	-- Send( {"HW", "Oh, it's you."} )
23 	SendResponse( { "Yes but what the hell am I doing here?!", rude }, { "But why a newspaper office?", ignore } )
24 end
25 
26 rude = function ()
27 	anger = anger+1
28 	Send( {"Smedley", "Keep calm, we have alot to get through"} )
29 	continue()
30 end
31 
32 ignore = function ()
33 	anger = anger-1
34 	Send( {"Terrence", "Apologies for being cryptic, I promise all will be revealed"} )
35 	continue()
36 end
37 
38 continue = function()
39 	End()
40 end


There is quite a lot of power behind the conversations system, it's open to being made in the sprawling, branching mess you have always dreamed of creating, or purely an interactive way of tailoring the humour of the player, with a few witty conversational choises and apt trite responses.

Not only this but you can run functions within conversations to either draw from variables or use mathematical operators, to create complex reactions that draw on 'memory' of previous events in the game.

The conversations themselves can run generate or add to variables, giving the ability to track elements of the conversation and use it to influence events later in the game for instance unlocking a mission by selecting a particular conversation path could be done by having certain choices add increment a variable with each correct selection. That variable reaching the correct value would then unlock the level.

More subtly perhaps this functionality could be used to track the players temperament by choices and give varied reactions from different characters dependent on how the player chooses to talk to them.

Call back functions

It's also possible to get interesitng things to happen once a conversation has ended

1     Conversation.StartScript("path/to/conversation", callbackFunc)
2 
3     function callbackFunc() { makeModal() }

an examppke would be:

TO BE COMPLETED...