Multiplayer Interactive-Fiction Game-Design Blog


AI memory of characters – cAIMemory



Download 8.87 Mb.
Page127/151
Date02.02.2017
Size8.87 Mb.
#15199
1   ...   123   124   125   126   127   128   129   130   ...   151

06 AI memory of characters – cAIMemory


Details how an AI remembers information about player characters.


AI memory of characters - cAIMemory

In most MMORPGs/MUDs/IF software, AIs (if they exist) remember

very little about a player character. Circumreality AIs remember

a lot of information about the player characters they meet.


At the heart of an AI's memory is the cAIMemory class,

which is a superlcass of cAI and cFaction.


Basic cAIMemory methods

The cAIMemory class maintains a database of all the player

characters it has met, stored in pAIMemory. For

each character, it stores several hundred pieces of "information",

such as whether or not the AI likes the character, the last

time they met, what the character's favorite color is, etc.


Each piece of information is labled with a lower case

string, such as "favoritecolor", and is stored as a sub-list.

If your code changes elements within the sub-list, the AI

will remember the information.

Every AI (derived from cAI) remembers a list of dangerous enemies,

as well as friends that will help in combat. (This list is different

than the like/dislike list also supplied for AI's.)


To access an AI's memory about a character's favorite color,

call vFavoriteColor = oAI.AIMemoryGet (Actor,

"favoritecolor", FALSE); Actor is the player character's

object. "favoritecolor" is the piece of information to access.

FALSE indicates that if the memory doesn't exist then don't

bother to create it. When the method returns, vFavoriteColor

will be a list, with (hypothetically) the first element of the

list set to the AI's memory of the character's favorite

color. If the AI had never stored such a memory NULL will

be returned from AIMemoryGet().

An AI's memory is based on the following (fundamental) methods:







  • AIMemoryActorExist() - Tests to see if the AI

    remembers anything at all about the actor.







  • AIMemoryActorRemove() - Causes the AI to forget

    everything it knows about the actor.







  • AIMemoryGet() - Gets (or adds) a memory to the

    AI, as discussed above.







  • AIMemoryRemove() - Causes the AI to forget

    a specific piece of information it knows about the actor,

    such as the actor's favorite color.



An AI manages its database, occasionally deleting old data.

You should be aware that:



  • AIs will remember every player character they meet. They won't

    ever forget a player character, unless the player character

    is deleted from the database, gDatabaseActors. This ensures

    that players won't ever feel cheated by NPCs forgetting them.



  • AIs will also remember other NPCs. They may, however, forget

    about the NPCs if they are deleted, even if the NPCs

    are backed up to a database.





  • AIs will only store about 200 pieces of information on a character before

    deleting old ones. The limit is set by gAIMemoryTrim.



  • If a character hasn't been ecountered for more than

    two weeks by the AI, the memory limit is set to gAIMemoryTrim / 2.





  • Important: If you want a character (that uses cAIMemory)

    in a multiplayer world to remember across reboots then you

    need to also base the character off cSaveToDatabase (see the turtorial).







Advanced memory

You might also wish to do the following:





  • Sometimes you will want to have one NPC in two or more different rooms at

    once. This often happens when you create one copy of a village that exists

    before an orc attack, and another version after the orc attack. You may

    want a few NPCs to survive the orc attack. Thus, they need to be in two

    places at once. To allow for this, create two copies of the NPC. However,

    you'll need to have their memories of player characters stay in sync.

    To do this, have one of NPCs alias its memory to the other NPC

    by using pAIMemoryAliasTo.




07 Factions – cFaction


A class that can be used to create factions and guilds for PCs and NPCs.


06. Factions - cFaction

A faction is a group of characters, either NPCs or PCs.

Factions are also known as guilds, but are not limited to

official organizations. Members of a village or town could all

belong to a faction "MemberOfTownXXX". Likewise, members of

a race or culture could all belong to a faction.


Making NPCs a member of one or more factions is useful for

the following reasons:



  • NPCs will be able to derive knowledge that's "known" to the

    faction. For example, the villagers of Hermansville (a faction)

    all know where the temple is in Hermansville, and all know

    about the goblin raiders to the north.



  • When a player character befriends a NPC in a faction, he

    ever-so-slightly increases the reaction of all members of

    the faction. Thus, is a player makes friends with half the NPCs

    in town, the other NPCs will be friendly also. This works

    in reverse.







  • NPCs can have "enemy" factions. If a player character befriends

    an enemy faction (such as "Enemies of Hermansville"),

    he will not get as good of a reaction (from "Villagers of

    Hermansville").






Players may wish to be part of a faction for the following reasons:







  • Standard MUD/MMORPG guid features, such as guild E-mail.



  • If a PC is a member of a faction, and he makes a good impression

    on an NPC, the NPC's reaction will improve slightly for

    all members of the faction. Thus, if you're a member

    of a guild, your actions affect how all the other guild members

    are seen, positively or negatively.







Creating a faction

To create a faction:







  1. Create an object based on cFaction. Since cFaction

    is based on cAIMemory, the faction's information will automatically

    be saved across reboots.



  2. Make sure the object is an object, and not a class.





  3. Fill in the faction's pNLPNounName and pNLPParseName,

    as usual.





  4. pFactionSize should be filled with the guestimated

    number of members of the faction. The faction size controls how

    much a NPC's reaction to the faction is affected by its

    individual members. Thus, if a player is a member of a faction,

    and makes a good impression on a NPC, the NPC's reaction

    to the faction will only increase by 1/pFactionSize.







Advanced factions

You may also wish to fill in the following faction information:







  • pAIConvScripts dictates what conversations scripts are

    common to all members of a faction.







  • pAIConvStories lists all stories known by faction members.





  • pAIFactionAntiFactions provides an easier way for one

    faction to dislike another.







  • pAIFactoids lists factoids known by all faction members.





  • pAIKnowledgeConversationStateExtreme lists conversation

    states that have a large impact on faction members. For example: Talking

    about "fishing" to members of the fisherman's guild.





  • pAIKnowledgeKnow is a list of knowledge that faction

    members will know.







  • pAILikeDefault is used by AILikeFirstImpressions().





  • pAILikeEquip is used by AILikeFirstImpressions().





  • pAILikeForget controls how quickly factions forget about

    player characters.







  • pAILikeGender and pGender are used by AILikeFirstImpressions().





  • pAILikeRace is used by AILikeFirstImpressions().





  • pAILikeReputation controls how much a player's reputation

    affects faction members.







  • pAILikeRoom causes the NPC to like the player more

    if the NPC is in a specific room.







  • pAILikeSkills is used by AILikeFirstImpressions().





  • pAnonymous causes the faction to be known to only

    a few NPCs.





  • If you se pIsInvisible to TRUE then players won't be

    able to see the faction when they type, "What is my reputation?"



  • Set pAIFactionIsHobby to TRUE to use the faction object

    as a NPC hobby, such as fishing, bowling, or Star Trek fan.





  • AILikeEquip() determines what kind of equipment faction

    members like, such as black robes, etc.







  • AILikeFirstImpressions() controls how much faction members

    like other characters.









Download 8.87 Mb.

Share with your friends:
1   ...   123   124   125   126   127   128   129   130   ...   151




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

    Main page