Multiplayer Interactive-Fiction Game-Design Blog


Pre-scripted conversations – cConvScript



Download 8.87 Mb.
Page132/151
Date02.02.2017
Size8.87 Mb.
#15199
1   ...   128   129   130   131   132   133   134   135   ...   151

14 Pre-scripted conversations – cConvScript


How to create pre-scripted conversations between two or more NPCs.


Pre-scripted conversations - cConvScript

You may wish your NPCs to occasionally have conversations with one

another. For example: Two friends might bump into one another at the

fish mongers, or a group of burglers might meet clandestinely the

night before a burglery to arrange who does what.

The easiest way to create a pre-scripted conversation is to

create an object based off cConvScript.


Creating a conversation-script object

To create a conversation-script object:





  1. Create a <ConvScript> resource the scripts

    out the conversation. You'll be able write lines for the NPCs,

    as well as narration, emotes, and sounds.





  2. Create an object, as normal, but base it off

    of cConvScript. For this example, call

    it oConvScriptMeetAtFishMongers.





  3. The object should not be contained in anything.





  4. Fill in pConvScriptResource with the name

    of the resource you created, such as rConvScritMeetAtFishMongers.


  5. If you want to generate the conversation on the fly,

    write your own ConvScriptResource() method.


  6. If your conversation takes place between three or more NPCs, or

    only the NPC, then modify pConvScriptNPCs to indicate

    the number of NPCs involved. (The default value is 2.)





  7. When the two NPCs meet at the fish mongers,

    call oConvScriptMeetAtFishMongers.ConvScriptStart(). That's

    it! The two NPCs will meet and talk about the quality

    of the fish, or whatever.

    (Note: I'll got into an easier way of automatically starting

    conversations later.)




You may also wish to set the following properties and methods:







  • pConvScriptAbortIfPCConv, which defaults to TRUE, causes

    all NPC conversations to automatically stop if a player talks to one

    of the NPCs.





  • pConvScriptAbortIfUnconscious, which defaults to TRUE,

    causes the conversation to automatically stop if any of the NPCs

    is unconscious or killed.





  • pConvScriptSecret will cause the NPCs to abruptly stop

    the conversation if someone enters the room. They won't even automatically start

    it unless they're alone.





  • ConvScriptCompleted() is called when the conversation

    is completed. The default behaviour does nothing, but you could modify this

    if you want your NPCs to act on the conversation. For example,

    the NPCs might talk about the best choice of fish, and one of the NPCs

    might be given the AI goal of buying that particular fish.





Automatic conversation scripts

Conversation scripts also provide a mechanism for making them "automatic" so

that you don't have to constantly check for the right conditions

and call ConvScriptStart(). Instead, conversation scripts can be set up

so they are automatically called whenever a NPC enters/leaves a room,

when a PC enters/leaves a room, or when the NPC is bored.

To have a NPC speak an automatic conversation script, you need to:



  1. Add the conversation script object to the

    NPC's pAIConvScripts property.


  2. If you want all NPCs in a specific faction to use the conversation

    script, such as a secret greeting to one another, then

    modify the faction's pAIConvScripts property.

    Alternatively, if you want conversation scripts associated with

    certain classes, such as all cRaceElf characters using a type

    of conversation script, modify the AIConvScripts() method

    for the class.


  3. If the conversation requires more than two NPCs,

    it must have pConvScriptNPCs. It must also have

    a ConvScriptAutoPermutations() written. This method will

    be called with a list of players and NPCs in the room. It must

    return a list of all the "possible" conversations that could result.

    Since there aren't that many possibilities with only two (or one) NPC,

    the method is trivial and automatically handled. However, if you have

    ten NPCs sitting in a room, the number of possible groups of three

    NPCs to sing as a trio is astronomical.





  4. You need to specify some constraints that limit what two NPCs will

    join together. For example: While all NPCs might have your fish-monger

    conversation at the ready, they'll only use it when they're in

    the fish market. The following properties and methods help limit

    the possibilities.






  5. pConvScriptAutoFactions will limit the conversation so that

    the main NPC (NPC #1) will only use the conversation with NPCs from

    the specified faction(s).

    pConvScriptAutoNPCs will limit the conversation so that

    the main NPC (NPC #1) will only use the conversation with NPCs

    listed in pConvScriptAutoNPCs. Example: Applying this to the fish monger

    might mean that Betty would only talk about fish to a handful of

    her friends.

    pConvScriptAutoListenersExclude can be used to NOT play

    the conversation if certain NPCs are in the room. This can be used to

    ensures that rumors about NPC X aren't spoken while NPC X is in the room.

    pConvScriptAutoKnowledge will only have the conversation

    spoken if the player character doesn't know the specified

    knowledge object. You would use this, for example, to have a pair of NPCs

    speak a rumor only once in the precense of a specific

    player. pConvScriptAutoKnowledgeFlip inverts the test,

    causing the NPCs to speak the script only if the player has the given

    knowledge.

    pConvScriptAutoFracture will only allow the conversation

    script to be spoken when the player is in the given fracture.

    This is passed to IsInDifferentFracture() and FracturerQuery().

    pConvScriptAutoPriority controls which automatic

    conversation script has higher priority.



    pConvScriptAutoRelationship lets the conversation script

    only happen if a specific relationship exists.



    pConvScriptAutoRequiresIntelligent ensures that conversations

    only happen between intelligent creatures.

    These properties won't be enough, though. You'll need

    to write your own ConvScriptAutoValid() method for

    many conversation scripts. The method is called whenever a conversation

    script is "proposed" by ConvScripts() to see if it

    would work in the given situation.


  6. You will need to set the liklihood of the conversation happening

    depending upon the circumstances. If you don't set at least one

    of these properties to non-zero then your conversation will never

    be randomly selected.


  7. pConvScriptProbBored - The probability of the conversation

    script being activated when the NPC is sitting around bored (with

    the oAIGoalBoredConvScript activated). Example: Use this if the NPC

    brings up the "Ever wonder what's up there?" when sitting outside

    on a starry night.

    pConvScriptProbNPCEnters - The probability of the conversation

    script being activated when the NPC enters a room. Example: Use this if the NPC

    says, "Hello everyone!" every time it enters the room.

    pConvScriptProbNPC2Enters - The probability of the conversation

    script being activated when a second NPC enters a room. Example: Use this if the

    first NPC says, "Hi %2!" every time a second NPC enters the room.

    pConvScriptProbNPC2Leaves - The probability of the conversation

    script being activated when a second NPC leaves a room. Example: Use this if the

    first NPC says, "That idiot has finally left." every time a second NPC leaves the room.

    pConvScriptProbPCEnters - The probability of the conversation

    script being activated when a PC enters a room. Example: Use this if the NPC

    says, "Hey, it's the town hero!" every time the PC enters the room.

    pConvScriptProbPCLeaves - The probability of the conversation

    script being activated when a PC leaves a room. Example: Use this if the NPC

    says, "Finally got rid of him!" every time the PC leaves the room.

Some more advanced settings that you may wish to modify:





  • If your conversation requires that a PC be around, perhaps because the

    NPCs are deriding the PC right in front of their face, then

    set pConvScriptRequiresPC to TRUE. You don't have

    to set this if

    either pConvScriptAutoKnowledge or pConvScriptAutoFracture are

    set.



  • To randomly start your own conversation,

    call ConvScriptAutoStart() at an appropriate time.





  • gConvScriptRate controls the default conversation rate. It defaults

    to one act every 3 seconds.








Playing conversation scripts through goals

If you want a conversation script to take place as part of an AI's goal,

then use oAIGoalConvScript to start the conversation.



Download 8.87 Mb.

Share with your friends:
1   ...   128   129   130   131   132   133   134   135   ...   151




The database is protected by copyright ©ininet.org 2024
send message

    Main page