Hello developers!
I want to make a game which has a date system, the player has limited “Energy Value” , he need to sleep to refresh everyday.
There are NPCs that have many conversations——like in day1 conversation1 is triggered,I want conversation2 to be triggered in day2 or day3 or……day1+n.
I plan to make it this way, is it possible?:
Set a globle variable :day=0.
after converstion1 has run——save day variable to a commponet variable.
check variable day>commonent variable
And there are also shops that sell limited items and I want the inventory to refresh every day.
how do you suggest to do?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @slime777.
The Player's Energy value is best stored in a Global Integer variable, so that it can be easily accessed from anywhere. When he sleeps, you can use the Variable: Set Action to reset this to some default value.
You shouldn't need to copy the Global variable to a Component variable - you can check the value of the Global variable directly.
If you need to check each Variable value to work out which Conversation to run, it's also easiest to rely on custom scripting instead of an ActionList. This script, for example, picks out a Conversation from an array based on the value of a "Day" Global Integer variable. It then updates the value of an ActionList's "GameObject" parameter value, which can be used in that ActionList to override the Dialogue: Start conversation Action's Conversation field:
More on ActionList parameters can be found in the Manual's "ActionList parameters" chapter.
A shop's inventory can be stored in a Container. To alter what items are on sale, you can either use a different Container on a given day, or use the Container: Add or remove Action to add specific items on a given day, and remove those items afterwards.
Hi Chris!Thank you for your speedy reply.
I'm really poor at coding so I want to rely more on the Actionlist.
I think I didn't explain clearly about the conversations:
In this game the player can choose to visit the NPC on any day they want. I want to insure conversation2 will be triggered afterwards( after the day conversation1 is triggered).
About the shop stock , I want to limit to sell ,e.g. 1 apple a day , if the player has bought 1 on day1,it's out of stock. Then on day2 the player can buy another apple.How can I check the stock every day?
Thanks for the elaboration. Yes, in that case, you'd need to record the Day you last speak to the NPC as a Component Variable.
In the NPC's interaction, you'd then check if the Global "Day" variable matches the NPC's Component "Day" variable. If they don't, update the Component to match the Global, and then increase a separate Integer variable on the same Component by one.
This variable would keep track of how many separate days you've spoken to that NPC, and can then be checked to determine which Conversation to then run.
You can use the Container: Check Action beforehand to determine if it's carrying a specific item, and follow it up with a Container: Add or remove Action to add the item if missing.