Create different scores?

I have a game where I would like for the player to do certain actions to other npc's but it will affect their relationship. For example:
(both friends are relationship 0)
Player: Hits friend 1
"Your relationship has gone down, 2 points to be specific."
{Player loses 2 points in relationship to friend 1}
Player: Hugs friend 2
"Friend 2 liked that, you gained 2 points in your friendship"
{Player gains 2 points to friend 2 relationship}

I also want their relationship levels to determine choices they can make for instance:
Need friend 1 for [random task] if relationship is 0 then task can not be completed
Need friend 2 for {different random task} if relationship is equal or more than 2 then task is completed

The closest code I can come to is using a score but I can't find a way to make more than one score. Is there an easier way to do this or can it even be done? If it can't be done is there another software like Quest that will allow this?


It sounds like you want to give each NPC an attribute to hold their relationship score.

On the desktop version of the editor, you can create an attribute on an object's "Attributes" tab. I'd suggest making an attribute named relationship, with type "int" and initial value 0.

If you're using the web editor there isn't an Attributes tab, so instead you'd put something like this in your start script:

friend1.relationship = 0
friend2.relationship = 0

(replacing friend1 and friend2 with the object names, of course)

Then when you want to change them:

Player: Hits friend 1
"Your relationship has gone down, 2 points to be specific."

friend1.relationship = friend1.relationship - 2

"Friend 2 liked that, you gained 2 points in your friendship"
{Player gains 2 points to friend 2 relationship}

friend2.relationship = friend2.relationship + 2

I also want their relationship levels to determine choices they can make for instance:
Need friend 1 for [random task] if relationship is 0 then task can not be completed

if (friend1.relationship > 0) {
  msg ("Friend1 helps you and the task goes smoothly.")
  // code here for the task's results
}
else {
  msg ("“Why would I help you?” Friend1 scoffs. “You've never done anything for me.” Disheartened, you try the task on your own but it doesn't help.")
}


Wait… I just realised I'm assuming this is a text adventure.

If you're making a gamebook, what you need are called counters. They're basically the same as int attributes, but gamebook mode provides a few functions like SetCounter and IncreaseCounter to make it easier.


Thank you so much!


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

Support

Forums