Spatial Fear Dev Kit » Guides

Communications Engine


Introduction

toolbar Communications in Spatial Fear are run through the SFCommunication and SFNPCCommunication actors. Both can be added to a level using the corresponding toolbar buttons (they bothlook like Chess Pawns). The communication is a versatile platform for allowing developers to convey ideas in a simple and easy to use manner.

Communications can be used i na number of ways including, but not limited to, NPC conversations, computer messages, paper memos, and non-personal communication (In Spatial Fear's case, the Captain)

Now that you know what a communication is exactly, and what they can be used for, let's continue on to how a communication works.


How a communication works

A communication is simply an actor. You place it like any trigger or decoration. After placing an actor, you should take the time to customize it's paramaters to your liking. After you have the communication params set up, you will need to trigger the communication. A comm is triggered by any event-firing actor, such as a trigger. You can also start communications after killing an enemy, picking up a certain item, or as a part of a more complex scripted sequence.

If you know the basics of how HTML works, then you will have no trouble learning how to control a communication. Our communications system is tag-based , meaning all communication commands are in the form of "tags." A tag is simply a command which the communications engine understands and reacts to. Take, for example, the communication below.

Hello <wait:2>World.

In this example, the "<wait:2>" highlighted in green is a tag that tells the engine to pause for two seconds. This communication would display "Hello ", then wait for 2 seconds, and display " World." Communications tend to become much more complex than that, so let's continue on to learn what they can do.

How to add a communication: Start to finish

Here, you will learn step-by-step how to create a full communication. Although it isn't a very complex one, it will teach you the basics of creating one.

1. Add a communication actor to the level (the pawn-shaped button in the bottom-left) or (Actor Browser » SFObject » SFCommunication)

2. Open it's properties window (F4)

3. For now, all we will add is the following text under "SpatialFear » CommunicationProtocol » [0]"

This is a simple communication example. <wait:2> Let's go ahead and clear the window. <cls> Here I go skipping lines. \n\n\n That's all for now...<wait:2><cls>

4. You may want to modify the communication by changing the type of communication it it. Under "SpatialFear » Type", you can change it to "CT_DataNode"

5 . Now add a trigger to the level. Insert a descriptive name into the trigger's event, and the same word into the Communication's Tag. "Events » Event/Tag"

6 . Now, test your level ad run into the trigger. A communication should start
SFCommunication Actor Class

Now that you know how to add a communication and work with one, we'll move on to a more complex definition of the actor's properties and parameters.

Properties and parameters

The following table lists all of the new properties seen in a communication actor under "SpatialFear » ... "


Animations (sub: [0]-[14]) A list of available animations to the face in the comm window. Values depend on the [Type] of communication you are using. Not relevent for a [CT_DataNode].
bAddToConversationsHistory Defines whether or not a communication will be added to the game's running communication log/history.
bHidePlayerHUD Toggle the player's HUD on/off while in the conversation.
bPlayOnlyOnce Toggles whether or not a communication can be played more than once.
CommunicationProtocol (sub: [0]-[24]) The body of the communication. The text and commands to be processed are entered here.
DetailText (sub: [0]-[24]) Detail text, to be displayed in browser. In case you do not want this to be generated by the system. If you think the text generated from the system does not match, add your own one here.
Events (sub: [0]-[24]) A manifesto of events that can be used in the CommunicationProtocol, with reference from the <event:number> tag, where number is the corresponding number in this list.
FontSize The size of the font to be displayed. Choices are FS_Small, FS_Medium, and FS_Big.
TipNames (sub: [0]-[14]) Tags of actors which have an actorTip which you can reference in the CommunicationProtocol using the <showActorTip:number:TippString> tags where number is the corresponding number in this list.
Title The title of the communication to be displayed in the communication history.
Type The type of communication to be used. Choices are CT_Captain, CT_Trainer, CT_DataNode, and CT_NPC. Only use CT_NPC when dealing with a SFNPCCommunication, however.


Commands

The following is a list of commands that are understood by the communications engine.

\n Creates a new line
<wait:#> pauses the communication for # of seconds
<cls> clears the dialog window
<showActorTip:number:TippString> Shows an actor tip on the HUD using number to index into the TippNames array to find the name of the actor to show the tip for. TippString is the string to display above the actor.
<hideActorTip> hides the currently visible actor tip
<branch:number> branches into a new communication, inside the communication string array (CommunicationProtocol[number])
<event:number> fires an event, using the name configured in Events[number]
<sound:resourcename> plays the sound with the name: resourcename
<tickrate:floatVal> Sets the tickrate of the running text value to floatVal, using -1 resets the tickrate to the saved tickrate before the last change.
<playanim:number> Plays the animation with name Animations[number] on the captains head.
<playtweenanim:number:floatVal> Plays the animation with name Animations[number] on the captains head using the passed tweenfactor to tween from the current animation to the new one.
<loopanim:number> Loops the animation with name Animations[number] on the captains head.
<looptweenanim:number:floatVal> Loops the animation with name Animations[number] on the captains head. The specified tween factor is used to tween from the current animation to the new one.
<askYesNo:number1:number2> Displays a selection box asking for YES or NO. A yes selection branches to branch: number1 and a no selection to branch number2. Unsing -1 as a branch number will continue in the current branch.
<showWeaponDesc:number> Opens the weapon description dialog on the HUD, using the data from the current weapon. If number = 1 the dialog is show, if number = 0 the dialog is hidden again. Used to introduce the weapon dialog. You should not forget to hide the window again. This will corrupt the rest of the HUD code. This function also enables the weapon descripton for the visor.
<waitForEvent:name> Pauses the communication until this actor receives the event with the name: Events[number]. Make sure the event is fired sometime. There is no timeout.
<instantShow:floatVal:Number> 'Hack'!! This messages shows all the text of the current branch IMMEDIATELY in the window! No running/ticking sound. So make sure you have no other markers like <sound> , ... in it, because the text is not interpreted and no markers are removed. Also make sure that the branch fits on one screen, CLS makes no sense for an instantShow message. With [floatVal] you specify how long the message will be shown before processing goes on. With [number] you specify the branch that is executed next (since a<branch> tag will not be evaluated in an instant show message.
<animRate:float> Changes the animation rate for all subsequent playanim and loopanim calls. The default setting for playback/looping is 1.0 and should be modified with this macro.
<giveToPlayer:classname> Add an inventory item to the players inventory. classname must be the fully qualified name of an item. E.g. SFItem.SFKeyCardB.


Those are the basic commands to use for a SFCommunication. More are available for the SFNPCCommunication, and can be found in the corresponding guide.

SFCommunication Writer

The SFCommunication Writer is an application bundled with this dev kit. It allows you to easily create a communication by using a simple form, eliminating the need to set complicated tags. The downside to using it is that it isn't capable of using certain tags such as <askYesNo>, but is ideal for beginners and makes writing communications a cinch. It can be found in the "/applications/SFComm Writer" directory.