Multiplayer Interactive-Fiction Game-Design Blog


Knowledge and rumors – cKnowledge



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

13 Knowledge and rumors – cKnowledge


Factoids make it easy to create a knowledge base for NPCs.


Knowledge and rumors - cKnowledge

As players wander around the world, their characters will learn various

bits of information, such as rumors ("The mayor is a member of an evil

witchcraft organization.") or facts that allow them access to

new maps ("Farmer John's farm is over yon hill.")

These facts are represented by cKnowledge-based objects,

much like factoids (based on cFactoid). In fact, you

can combine a cFactoid and cKnowlege object, so that

when a NPC speaks the factoid, the PC automatically remembers it

as a piece of knowledge. Or, you can combine a cConvStory and

cKnowledge object, causing the knowledge to be automatically

learned when the player hears a story.

If you do this, make sure cKnowledge is lower on the class list than cConvStory

or cFactoid.


During gameplay, the player can see what knowledge their character

knows by typing, "What do I know". They can also tell the knowledge to NPCs,

as well as telling NPCs the source of the knowledge... A witch hunter

might be interested in knowing that the mayor is a witch, but the mayor

would be more interested in knowing who told the player that he was

a witch.


Creating a knowledge object

To create a knowlege object:





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

    of cKnowledge.


  2. If you want the knowledge to automatically

    be imparted to the PC when a NPC speaks a factoid, then also

    base the object off of cFactoid or cConvStory,

    and follow the factoid or story

    creation process, as well as this one. Make sure the cKnowledge class

    is lower priority than the cFactoid or cConvStory class.


  3. The object should not be contained in anything.





  4. Fill in pKnowledgeDescription with a description of the

    knowledge as it will appear in the player's list. For example: "The

    mayor is a member if a witchcraft cult."





  5. Fill in pKnowledgeCategory with a string for the

    category that the knowledge will appear under, such as "Mayor Daily".





  6. pConvElementConversationState should be filled in with

    a list of topics (lower-case string) describing the knowledge. This

    is very important for when a player and NPC go back and forth

    swapping stories and rumors.





You might also wish to fill in the following:







  • pIsInvisible will prevent the knowledge from being

    displayed on the player's list, as well as prevent the player from speaking

    the knowledge to NPCs. This is a useful way to ensure that the player hears

    something only once, but which isn't important enough to see on the

    player's knowledge list.





  • pKnowledgeCanRetell defaults to TRUE indicating that the player

    can retell the knowledge to NPCs. If the knowledge isn't story-worthy,

    then set this to FALSE.





  • pKnowledgeEmotions specifies how the NPC's emotions (happy/sad,

    angry/afraid) will be affected when they hear the knowledge.







  • pKnowledgeLike specifies how the NPC's like/trust towards

    the player will change when they hear the knowledge.







  • pKnowledgeSpeak can contain the string that

    the player will speak when they reveal the knowledge to a NPC.

    If you don't provide this the a sentence will automatically be

    genereated from pKnowledgeDescription.

    Example: "Did you know that Mayor Daily is a witch?"





  • pKnowledgeSpeakFromWhom is used if the

    player mentions their source.

    If you don't provide this the a sentence will automatically be

    genereated from pKnowledgeDescription.

    Example: "%1 (told/told/told) me that Mayor Daily

    is a witch."





  • The KnowledgeSpeak() method generates the sentence

    that the player speaks. Although unlikely, you might wish to

    write your own method.







  • pKnowledgeResponseDontCare is filled with

    a NPC's response if they don't care about the rumor. If not

    filled in, a default response will be used.

    Example: "Don't spread such rumors! You'll get in trouble."







  • pKnowledgeConversationStateExtreme affects how

    much this knowledge affects "sensative" NPCs who list a corresponding

    conversation-state topic in pAIKnowledgeConversationStateExtreme.

    For example: If this is a sad story about a child's death, then NPCs

    hearing it will be saddened. However, if the NPC happens to be the child's

    parent, then there will be an extra effect.







  • pKnowledgeDeduce causes a new piece of knowledge to be

    automatically deduced if the player learns two or more other

    pieces of knowledge. This is useful for a detective title.





  • pKnowledgeAboutRelationships affects what relationship

    connections are learned when the player character hears the knowledge.







  • pKnowledgeMystery causes the player's list of mysteries

    to be added to when this knowledge object is added.







Learning knowledge

If you wish a player character to know about a knowledge object,

call Actor.KnowledgeAdd(). Alternatively, if

you combine a cKnowledge and cFactoid or cConvStory object, then the

knowledge will automatically be learned when a NPC speaks the factoid/story.

You can remove a knowledge object by

calling KnowledgeRemove(). KnowledgeQuery() tests

to see if a character knows about the object.




Knowledge affecting access

If you look under the cMap tutorial, you'll see that a

knowledge object can be used to determine if a player can travel to a given

map. Thus, if the player knows where "John's farm" is, with a cKnowledgeJohnsFarm

object, then they can get to it.


Telling NPCs knowledge in the form of stories and rumors

Players can tell NPCs knowledge they know. Most NPCs won't care about

the knowledge, but some NPCs will react positively, as in the case of

a witch hunter and the mayor. Or, a piece of knowledge could even be

a good joke that the player heard.

NPCs all have general (and automatic) responses to being told

knowledge. This reaction is affected by:



  • If the NPC already knows the knowledge, or if the player has already

    told them it, they may get peeved with the player.

    The method, AIKnowledgeKnow() is used to determine if

    the NPC already knows the object.



  • The more the NPC's pAIConvStoryPreferred correlates with

    the knowledge's pConvElementConversationState, the

    more effect that speaking the knowledge will have. If there's a negative

    correlation due to oppostes (ConversationStateOpposites()) then

    the effects might be reversed.





  • If a NPC has pAIKnowledgeConversationStateExtreme, and

    one or more of the conversation-state topics is in common with the

    knowlege object's pConvElementConversationState, then the NPC

    may have a much stronger reaction.



  • The NPC's speech response will be controlled by a call

    to cKnowledge.KnowledgeGenericResponse(). This method

    returns a response based on how positive or negative the NPC's

    reaction is, and what elements of the knowledge produced the

    positive or negative response.




  • Having the NPC specfically state why they liked/disliked the knowledge

    is important feedback to the player, so they can decide what type

    of stories/rumors to tell in the future. You may need to augment

    KnowledgeGenericResponse(), as per the method's documentation, if you

    add new conversation-state topics to the knowledge object's

    pConvElementConversationState. For example: If you create a "airplane"

    topic, which means that the NPC likes hearing and talking about

    airplanes, then you'll need some positive responses if the player's

    stories includes airplanes, such as "I love to fly."

    Not all NPC's provide regular

    feedback. pAIKnowledgeSayFeedback controls how likely it

    is for a NPC to provide feedback about what they liked or disliked.


To have a NPC react to a specific piece of knowledge that's

spoken by a player, you have three options:



  1. Modify the NPC's pAIKnowledgeInterest to list the

    various knowledge objects that interest the NPC, as well as the NPC's

    responses.




  2. You can also set a flag in pAIKnowledgeInterest to indicate that

    if the player knows the knowledge, and the NPC hasn't already heard

    it from the player, then a context menu item will appear in the

    NPC's menu; this context menu makes it more obvious to players that

    they should tell the NPC about the knowledge/rumor.

  3. Write your own PerceiveKnowledgeSay() method for the NPC.





  4. If PerceiveKnowledgeSay() doesn't provide enough flexibility,

    you can write a cFactoid that is triggered by the player

    speaking "`knowledgesay KNOWLEDGEOBJECT [SOURCEOBJECT]". You probably

    won't have to do this. If you do, make sure you call AIMemoryGet() and

    modify the appropriate flag so the AI know's it has already heard

    the knowledge.






Miscellaneous knowledge

Some information isn't important enough to be spread as rumors, but

you still want players to "write it in their journal" for later.

To add a "journal" entry, call:







  • KnowledgeMiscAdd() will add knowledge as a string.





  • KnowledgeMiscEnum() finds the list of string knowledge known

    about a NPC.








Download 8.87 Mb.

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




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

    Main page