Remember a player character's reputation.
As discusses in the factions tutorial, a player character's reputation
precedes him because of the memory stored in the cFaction object.
You might also wish a faction-independent method for storing
a reputation, such as how heroic the character is, or perhaps
his wealth.
The faction-independent reptutation system works as follows:
-
Come up with a lower-case language-independent string
to represent the character's reputation, such as "goodfisherman" to
indicate how high the player's reputation is based on his fishing
skills. (Make sure that you don't have any spaces.)
-
You will need to make a global, gReputationNameGoodFisherman with
a language-dependent name of the reputation, like "Good fisherman".
This global will be accessed by calls
to ReputationToName(), which is used when the
player types, "What is my reputation?"
-
As the player character completes quests (or whatever), you can
increase (or decrease) the reputation by
calling ReputationSet(), passing in "goodfisherman" and
a value from -10 (lower the reputation) to 10 (increase the reputation).
-
To make NPCs that are impressed by a reputation, provide
a pAILikeReputation property for the NPC.
-
Likewise, to make all NPCs in a faction impressed by a reputation,
set the cFaction.pAILikeReputation.
-
You may also wish to write your
own AILikeReputation() method for NPCs or their factions.
That's all! As a player's "goodfisherman" reputation improves, NPCs
will like (or trust) the player character more.
09 AI like and trust of characters – cAI
Talks about APIs use to get and set how much an AI likes/dislikes and trusts/mistrusts a character.
AI like and trust of characters - cAI
As players wander through an interactive fiction title, they
will encounter NPCs. In most text IF and MUDs, NPCs instantly
forget about PCs as soon as the PCs leave the room. Not so
with Circumreality. NPCs remember a variety of information about the PCs
in the cAIMemory class.
Two of the most commonly remembered pieces of information are
whether or not the NPC liked the PC, and whether or not the NPC
trusts the PC. "Like" can be used to determine how much information
the NPC will reveal to the PC. "Trust" indicates what type
of tasks the NPC will give to the PC.
Both the like and trust memories are stored as values, ranging
from -10 to 10. Here is a sample of what the values mean:
|
Like |
Trust |
+10 |
The NPC likes the PC a lot, and will do anything for the PC.
|
The NPC trusts the PC with his/her life.
|
+6 |
The NPC would consider the PC a friend.
|
The NPC trusts the PC with important tasks.
|
+3 |
The NPC thinks of the PC as a friendly acquaintance.
|
The NPC will give the PC minor tasks whose failure
won't signficantly hurt the NPC.
|
0 |
Neutral
|
Neutral
|
-3 |
The NPC dislikes the PC.
|
The NPC might give the PC a task, just to see what happens,
but won't expect it to be completed.
|
-6 |
The NPC considers the PC an enemy.
|
The NPC doesn't trust the PC as far as he can throw him.
|
-10 |
Hatred.
|
The NPC thinks the PC is completely incompetent.
|
To find out how much a NPC likes or trusts a PC (or other NPC),
call oNPC.AILikeGet(). This will return a list
with the first element being the like value, and the second
with the trust value.
You can adjust how much a NPC likes or trusts a PC (or other
NPC) by calling oNPC.AILikeSet() whenever
the PC performs an action that gives a positive or negative
impression of the PC to the NPC. The values passed into AILikeSet()
for like/trust depend upon how significant the player's actions
are:
|
AILikeSet() Like |
AILikeSet() Trust |
+10 |
PC does something for the NPC that the NPC has always desired,
but not even the NPC's best friends have done it.
For example: Giving the NPC $1,000,000.
|
The PC saves the NPC's life, or completes a very important
task.
|
+6 |
The PC does something very nice for the NPC.
|
The PC completes a major task for the NPC.
|
+3 |
The PC does something nice for the NPC.
|
The PC completes a minor task.
|
+1 |
The PC smiles at the PC, or some other polite formality.
|
The PC pays a bill, or some other small task.
|
-1 |
The PC doesn't smile at the PC, or some other small social mistake.
|
The PC is late for an appointment.
|
-3 |
The PC comes off as being unintentionally rude.
|
The PC misses an appointment.
|
-6 |
The PC is intentionally rude or mean.
|
The PC fails to complete an important task.
|
-10 |
The PC commits an awful offense.
|
The PC attacks the NPC.
|
AILikeSet() is not a simple function that just instantly changes
the NPC's view of the PC. It handles quite a few smaller details:
-
Calling AILikeSet() will increase or decrease the PC's
like/trust based on the value passed in.
It will not change
the NPC's like/trust immediately to the new values, but
will gradually increase/decrease the NPC's like/trust each time
AILikeSet() is called. Therefore, for a PC to make a NPC a friend,
the PC will need to be repeatedly nice to a NPC.
-
AILikeSet() will not adjust a NPC's like/trust higher than
the like/trust parameter (if the parameter is a positive value),
or lower than the like/trust parameter (if the parameter is
negative). This means that smiling (a +1.0 like parameter) will
only get a player so far, and smilling a thousand times will
not make the player best friends with the NPC. To become best
friends the PC will have to do several best-friends activities
first.
-
Some NPCs will have their like/trust adjusted more quickly
than others, depending upon
their pAILikeChangable attribute. If the values
are high, the NPC will quickly take a liking (or dislking) to
a PC. If they're low, the NPC is slow to change its mind.
-
If the NPC belongs to any factions (which is probable),
then AILikeSet() will subtly affect all NPCs in
the same faction. Word gets around, and being likable
or trustworthy
to a few villagers in town will gradually improve a PC's like/trust
to all viallager.
-
If the PC belongs to any factions (which is probable),
then AILikeSet() will subtly affect the NPC's reaction
to other members of the faction. If a PC is a member
of the "XYZ Guild" and makes a good impression on the NPC,
the other members of the XYZ Guild will get a better
response. This works the opposite way too; making a bad
impression reflects on the entire guild.
-
Likewise, any factions that the NPC belongs to will form
an opinion about any factions that the PC belongs to. If
a NPC from XYZ Guild upsets a NPC in Hermansville, then
all NPCs in Hermansville will have (mildly) negative reactions
to all members of the XYZ Guild.
-
NPCs (and factions) gradually forget about offenses and favors
that a PC (or faction) does. The speed of this forgetfullness
(or forgiveness) is controlled by pAILikeForget.
AILikeGet() also has some intricate behavior that you should
be aware of, especially when the NPC first meets the PC:
-
Some NPCs are more likely to "follow the crowd" while others
are more independent thinkers. This personality trait manifests
itself when a NPC has met several PCs from a faction (XYZ Guild),
and then starts liking/trusting (or disliking/mistrusting) all
members of the guild based on the few meetings. If the
NPC's pAILikeIndividual is high, the NPC will
assume each PC is different and won't stereotype the PCs
in XYZ Guild based on other members of XYZ Guild. If pAILikeIndividual
is low, the NPC assumes that all members of XYZ Guild are
more or less the same as far as likability and trustworthiness goes.
-
If the NPC has never met the PC, the like/trust values
default to pAILikeDefault. Some NPCs are naturally
friendly while others may naturally be untrustworthy.
-
The NPC can also form an opinion based upon what the
PC is carrying,
using pAILikeEquip and pAILikeEquipValue. Some AI's
might like/trust wealthy characters, ones with weapons, or
ones wearing red shoes.
-
If the NPC is in the same faction as the PC, such as
them bothing coming from the same village,
then pAILikeFaction affects how much the
NPC's like/trust is affected by common factions.
-
pAILikeGender lets a NPC be more/less
friendly/trusting with members of the same/opposite gender.
-
pAILikeRace will cause a NPC to like/dislike
and trust/mistrust PCs from other races. Elves might dislike
orcs, and mistrust dwarves.
-
pAILikeRoom causes the NPC to like/trust the
PC more if the NPC is in a specific room, and feels more
comfortable there.
-
pAILikeSkills can be used to make NPCs like/trust
charismatic PCs, strong PCs, or PCs with degrees in
quantum mechanics.
-
If the NPC's factions list, pFactions, includes
"anti-factions", then the more the PC is liked by the anti-faction,
the more the PC will be disliked by the NPC.
Emotes based on like/trust
When a PC says or does something that causes a NPC's perception
of the PC to change, AILikeSet() is called. One of the parameters
allows the NPC to emote based on how much the like/trust changed.
For example: If the PC says something nice and improves their "like"
score with the NPC, the NPC could emote a brief smile, while a
small social mistake might cause a decrease in "like" and make
the NPC purse its lips slightly.
To do this, AILikeSet() calls AILikeEmoteChanged() with
modified versions of the like/trust parameter. The default method
includes a variety of short smiles, lip pursing, and flashes
of anger. You may wish to replace this functionality for some NPCs...
One NPC could clear his throat to indicate displeasure. Another
could mutter something under his breath.
A NPC's like/trust is also shown when the NPC sees a PC
enter the room. This calls AILikeEmoteFirstMeet().
If a PC is universally disliked within the town he will get
glares as he walked through the streets.
Similarly, if the NPC walks into a room with other PCs, the NPC will
find the most liked/trusted (or least liked/trusted) PC in
the room and call AILikeEmoteFirstMeet() to
emote.
AILikeEmoteFirstMeet() is also called when a conversation between
a NPC and a PC is started. The AI's reactions will be more
severe than if the AI is just passing the PC on the street.
As with AILikeEmoteChanged(), you may wish
to override AILikeEmoteFirstMeet() as appropriate
for the NPC.
You may have noticed, but I just mentioned about ten properties
that are "personality traits", such as how quickly the AI forgets
and forgives, whether it likes men more than woman, etc.
More are yet to come.
You can set the properties for NPCs to fine-tune their
personality. However, if you do not specify the
personality properties, random and reasonable values
will be generated when the NPC is created.
Share with your friends: |