Friendship status?

Vetarix
I've been wanting to create a text adventure where the player is able to, in some way, increase the likeness or friendship with another character? Is there any way to make this possible, like a point system?

HegemonKhan
this involves Attributes (Attribute Usage) and the 'if' Script

Attributes and their 'set a variable or attribute' Script, and the 'If' Script, are the two SUPER SCRIPTS, enabling you to do this and 90% of everything else that you want to do in your game

the concept of a personality/relationship/hostility system:

you have a scale (ie: 0-100), and various things happen (or don't happen) based upon that scale's value (ie: 50) and/or range of values (ie: 33-66)*

* In quest's programming, this is how syntax-conceptually you do a(n inclusive) range:

VARIABLE (> or >=) min_range_value and VARIABLE (< or <=) max_range_value

* you can NOT do the more logical-sense-making syntax of:

min_range_value (< or <=) VARIABLE (< or <=) max_range_value

* To do an exclusive range, the syntax-conceptuality is:

VARIABLE (< or <=) min_range_value or VARIABLE (> or >=) max_range_value

* the 'XXX' are values that are NOT a part of your range
* the 'arrows' are the values that ARE a part of your range
* inclusive range definition example: XXX 0 <-----> 100 XXX
* exclusive range definition example: <----- 0 XXXX 100 ----->

each npc needs an Integer (int) Attribute to store/hold their current scale value

you then need scripting that checks (the 'if' Script) this Integer Attribute for what to do or not do

you also need a method that fires/activates the checking of the Integer Attribute when the Integer Attribute has its value altered/changed (the 'Turnscript' Element and/or the special 'changed' Script)

you'll also need scripting that will increase/decrease (addition/multiplication/subtraction/division/modulus) the npcs' Integer Attribute:

(simple) Addition: Object_name.Attribute_name = Object_name.Attribute_name + Number_Value

(simple) Subtraction: Object_name.Attribute_name = Object_name.Attribute_name - Number_Value

(simple) Multiplication: Object_name.Attribute_name = Object_name.Attribute_name * Number_Value

(simple) Division (division that finds the quotient only): Object_name.Attribute_name = Object_name.Attribute_name / Number_Value

(simple) Modulus (division that finds the remainder only): Object_name.Attribute_name = Object_name.Attribute_name % Number_Value

here's a guide on Attributes (Attribute Usage) and the 'If' Script:

viewtopic.php?f=18&t=5559 (about halfway down the link's post, is the part on the two super scripts, bolded and in large font, just got to scroll down a ways, though you should read all of it)

here's a partial initial-setup example:

<object name="npc1">
<inherit name="npc_group_object_type" />
<attr name="alias" type="string">best friend joe</attr>
<attr name="relationship_integer" type="int">100</attr>
<attr name="relationship_string" type="string">positive</attr>
</object>

<object name="npc2">
<inherit name="npc_group_object_type" />
<attr name="alias" type="string">farmer john</attr>
<attr name="relationship_integer" type="int">50</attr>
<attr name="relationship_string" type="string">neutral</attr>
</object>

<object name="npc3">
<inherit name="npc_group_object_type" />
<attr name="alias" type="string">criminal jeff</attr>
<attr name="relationship_integer" type="int">0</attr>
<attr name="relationship_string" type="string">negative</attr>
</object>

<type name="npc_group_object_type">
<attr name="talk" type="script">
if (this.relationship_integer <= 33) {
this.relationship_integer = this.relationship_integer + 1
msg ("You talk to " + this.alias + ", improving your relationship with " + this.article + ".")
} else {
msg ("You talk to " + this.alias + ", but you no longer can improve your relationship with " + this.article + " through talking anymore.")
}
</attr>
<attr name="changedrelationship_integer" type="script">
if (this.relationship_integer > 100) {
this.relationship_integer = 100
if (not this.relationship_string = "positive") {
this.relationship_string = "positive"
}
} else if (this.relationship_integer < 0) {
this.relationship_integer = 0
if (not this.relationship_string = "negative") {
this.relationship_string = "negative"
}
} else if (this.personality_integer > 66 and if (not this.relationship_string = "positive") {
this.relationship_string = "positive"
} else if (this.personality > 33 and if (not this.relationship_string = "neutral") {
this.relationship_string = "neutral"
} else if (not this.relationship_string = "negative") {
this.relationship_string = "negative"
}
</attr>
<attr name="displayverbs" type="simplestringlist">talk</attr>
</type>

<verb>
<property>talk</property>
<pattern>talk</pattern>
<defaultexpression>You can't talk to that.</defaultexpression>
</verb>

XanMag
Here's how a code noob like me would do it.

For every "event" that you would like to increase the friendship status, set a new flag and unset the old one. Then, for each interaction you have with the NPC, use an 'If' script and check for flags in the If/Then, Else If/Then, etc to respond with proper friendship messages.

Anonynn
I have two different ways of going about it. An easy way and a hard way.

Easy Way (very simplistic way)

1. On the person you're trying to be friends with make an "Attribute" and call it something like "relationship" and make it a "integer"
2. Then whenever the player does something for that character you can simply add to the events: person.relationship = person.relationship + 1
3. Afterward, you can have that character respond however you wish. For example: {if person.relationship=1:blah blah}{if person.relationship=2:blah blah}{if person.relationship=3:blah blah}{if person.relationship>=4:blah blah} You can have it go as high as you want.

Hard Way (a lot more options and more complicated)

1. Create a "Function" named GetRelationship or whatever you want it to be. Return Type: String
2. If Script (inside the Function).
Example:
if (relationshipscale=0) {
return ("stranger")
}
if (relationshipscale=1 {
return ("acquaintance")
}
and so on.
3. player.object, new attribute, relationship, string unknown
4. player.object, new attribute, relationshipscale, integer "0"
5. Create a second "Function", SetRelationship, Return Type: None. Script, player.relationshipscale = GetRelationship()
6. player.object, new attribute, "changedrelationshipscale". script, SetRelationship

After that, you should be done. Then you can place in your player.object description. Something like {if player.relationship=stranger:} or {if player.relationship_as_int>=3:}. If you have multiple character you want this to keep track of though, instead of adding these attributes to the player, you can add them to the character they are pertaining to. That should work. So then you'd end up with something like, {if charactername.relationship=stranger:} or {if charactername.relationship_as_int>=3:}.

Then to increase or decrease these scores you can do something like...

charactername.relationship = charactername.relationship + 1 or - 1


Hope that helps!

HegemonKhan
@ Neonayon,

I see you've learned of the concept of "get/get'ers" (official term: Assessors) and "set/set'ers" (official term: Mutators), hehe. You're really learning fast!

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums