Conversations

From Off Grid Wiki
Jump to navigation Jump to 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 it's 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

-- [[ Mission triggers & interactions]] --

MissionObjects["MissionObject_1_1"].OnTriggerEnter = function(name)
	if name == Player.GetName() then
		Mission.StartObjective(mission.objectives.enterbuilding)
	end
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.

-- Mission objectives:
	objectives = {
	--[[ Find way into the building ]]--
		enterbuilding = {
			name = "theapostle_obj_enterbuilding_name",
			description = "theapostle_obj_enterbuilding_desc",
			hints = {
				"theapostle_obj_enterbuilding_hint_1",
				"theapostle_obj_enterbuilding_hint_2",
			},
			messages = {
				"theapostle_obj_enterbuilding_msg_1",
			},
			onStart = function()
				print("Started objective 'enterbuilding'")
				**Conversation.StartScript("testConversation")**
			end,
			onCompleted = function()
				print("Completed objective 'enterbuilding'")
			end,
		},

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:

anger = 0
sendData = true
encrypted = true
characters = {
	"Joe",
	"Smedley",
	"Terrence",
	-- "HW",
}

begin = function()
	Send( {"Smedley", "Joe..."} )
	Send( {"Smedley", "you there yet?"} )
	SendResponse( {"yes"} )
	Send( {"Smedley", "Ok this is Terrence, the newspaper editor I told you about"})
	Send( {"Terrence", --[["theapostle_obj_enterbuilding_msg_1"]] 
	"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"})
	Send( {"Smedley", 
		function() 
			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."
			end } )
	-- Send( {"HW", "Oh, it's you."} )
	SendResponse( { "Yes but what the hell am I doing here?!", rude }, { "But why a newspaper office?", ignore } )
end

rude = function ()
	anger = anger+1
	Send( {"Smedley", "Keep calm, we have alot to get through"} )
	continue()
end

ignore = function ()
	anger = anger-1
	Send( {"Terrence", "Apologies for being cryptic, I promise all will be revealed"} )
	continue()
end

continue = function()
	End()
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.