"Affection" Meters
withoutmalice
13 Nov 2014, 22:23Hey, all! I'm in the process of coding my first text adventure and so far I seem to be managing everything alright. However, I can't seem to figure out exactly how I would go about creating something of an "Affection meter" that would rise for certain characters when a certain topic is discussed or certain events take place. It doesn't matter whether or not it is visible in the "Stats" section, it's just imperative to the various paths the game will go in. Any information would be greatly appreciated!
Thanks so much!!
-Annemarie
Thanks so much!!
-Annemarie
george
14 Nov 2014, 02:16There's a few ways to do it but you want to start with custom attributes, see here,
http://docs.textadventures.co.uk/quest/ ... butes.html
Basically you want an attribute 'affection' on the character and you can increase or decrease its value with scripts whenever you want. Then you can look up its value in other scripts when necessary.
http://docs.textadventures.co.uk/quest/ ... butes.html
Basically you want an attribute 'affection' on the character and you can increase or decrease its value with scripts whenever you want. Then you can look up its value in other scripts when necessary.
withoutmalice
14 Nov 2014, 04:16george wrote:There's a few ways to do it but you want to start with custom attributes, see here,
http://docs.textadventures.co.uk/quest/ ... butes.html
Basically you want an attribute 'affection' on the character and you can increase or decrease its value with scripts whenever you want. Then you can look up its value in other scripts when necessary.
Thank you so, so much! You're a lifesaver, friend.
HegemonKhan
14 Nov 2014, 22:53this is mostly done in code (much faster~easier~quicker for me), but~so, just ask if you need help with how to do this stuff in the GUI~Editor (all the friendly windows and buttons, drop down choices, and etc stuff), as code<->GUI~Editor isn't very intuitive (argh, it's a pain trying to match up code with GUI~Editor, or vice-versa, laughs).
------------
the two super scripts (especially when used together, they can do 90% of everything that you want to do in your game):
the code + 'if' mindset mentality, which takes awhile to train your brain to think in this way, lol:
1. the 'if' script; in code: if (Object_name.Attribute_name = Value_or_Expression) { script1 ] else if (Object_name.Attribute_name = Value_or_Expression) { script2 } else { script3 }
2. the 'set a variable or attribute' script; in code: Object_name.Attribute_name = Value_or_Expression
Object_name.Attribute_name = Value_or_Expression
examples (using my own labeling system):
as Values:
HK.strength_integer = 100
player.affection_integer = 100
player.affection_string = "irresistable"
player.head_object = tiara
player.gender_string = "female"
player.favorite_animal_string = "cat"
orc.dead_boolean = false
player.damage_double = 72.904
as Expressions:
player.favorite_cat_colors_stringlist = split ("black;white", ";")
HK.damage_integer = HK.weapon_damage_integer + HK.weapon_damage_integer * HK.strength_integer / 100 - orc.armor_class_integer - orc.armor_class_integer * orc.endurance_integer / 100
--------------
(see above for an example of a complex expression: HK.damage_integer = ...blah...)
Basic Math Computation Expressions, examples:
Addition:
player.strength_integer = player.strength_integer + 10
Subtraction:
player.strength_integer = player.strength_integer - 8
Multiplication:
player.strength_integer = player.strength_integer * 3
Division:
player.strength_integer = player.strength_integer / 2
---------------
conceptually (algebraic substitution), using addition:
initial~old: player.strength = 0
player.strength (new) = player.strength (old: 0) + 5
player.strength (new) = 0 + 5
player.strength (new) = 5
new: player.strength = 5
old: player.strength = 5
player.strength (new) = player.strength (old: 5) + 5
player.strength (new) = 5 + 5
player.strength (new) = 10
new: player.strength = 10
old: player.strength = 10
etc etc etc
-------------------
example of buying something:
----------------------------
'if' script + 'set a variable or attribute' script:
Conceptually:
if (attribute = X), then do script 1
else if (attribute = Y), then do script 2
examples (in code):
------------
the two super scripts (especially when used together, they can do 90% of everything that you want to do in your game):
the code + 'if' mindset mentality, which takes awhile to train your brain to think in this way, lol:
1. the 'if' script; in code: if (Object_name.Attribute_name = Value_or_Expression) { script1 ] else if (Object_name.Attribute_name = Value_or_Expression) { script2 } else { script3 }
2. the 'set a variable or attribute' script; in code: Object_name.Attribute_name = Value_or_Expression
Object_name.Attribute_name = Value_or_Expression
examples (using my own labeling system):
as Values:
HK.strength_integer = 100
player.affection_integer = 100
player.affection_string = "irresistable"
player.head_object = tiara
player.gender_string = "female"
player.favorite_animal_string = "cat"
orc.dead_boolean = false
player.damage_double = 72.904
as Expressions:
player.favorite_cat_colors_stringlist = split ("black;white", ";")
HK.damage_integer = HK.weapon_damage_integer + HK.weapon_damage_integer * HK.strength_integer / 100 - orc.armor_class_integer - orc.armor_class_integer * orc.endurance_integer / 100
--------------
(see above for an example of a complex expression: HK.damage_integer = ...blah...)
Basic Math Computation Expressions, examples:
Addition:
player.strength_integer = player.strength_integer + 10
Subtraction:
player.strength_integer = player.strength_integer - 8
Multiplication:
player.strength_integer = player.strength_integer * 3
Division:
player.strength_integer = player.strength_integer / 2
---------------
conceptually (algebraic substitution), using addition:
initial~old: player.strength = 0
player.strength (new) = player.strength (old: 0) + 5
player.strength (new) = 0 + 5
player.strength (new) = 5
new: player.strength = 5
old: player.strength = 5
player.strength (new) = player.strength (old: 5) + 5
player.strength (new) = 5 + 5
player.strength (new) = 10
new: player.strength = 10
old: player.strength = 10
etc etc etc
-------------------
example of buying something:
if (player.cash_integer >= shoe.price_integer) {
player.cash_integer = player.cash_integer - shoe.price_integer
shoe_store.cash_integer = shoe_store.cash_integer + shoe.price_integer
shoe.parent = player
msg ("You bought the shoe for " + shoe.price_integer + ", leaving you with only " + player.cash_integer + " cash left.")
} else if (player.cash_integer < shoe.price_integer) {
msg ("Sorry, but you don't have enough to buy the shoe.")
}
----------------------------
'if' script + 'set a variable or attribute' script:
Conceptually:
if (attribute = X), then do script 1
else if (attribute = Y), then do script 2
examples (in code):
if (player.gender_string = "male") {
player.intelligence_string = "stupid"
player.attractiveness_string = "ugly"
} else if (player.gender_string = "female") {
player.intelligence_string = "smart"
player.attractiveness_string = "beautiful"
}
if (orc.dead_boolean = true) {
msg ("The orc is already dead, silly.")
} else if (orc.dead_boolean = false) {
orc.dead_boolean = true
msg ("You kill the orc.")
}