Ainz Ooal Gown Posted April 10, 2019 Share Posted April 10, 2019 Description: This will enable a hunger and thirst system in your game. Players will then have to find food and water to recover hunger and thirst, but if they don't the character will stop (twice in total) saying you have to wait to recover for a bit (3 seconds). This puts the player in a vulnerable situation in game. If the player still does not get some food or water, they will die and re spawn (Warp / re spawn which ever way you have in your game). Players hunger and thirst will then be reset to 100.  Video: None  Chat Screenshots (System speed increased to get all text reads) Spoiler This below is a /check command so a player can see there player info, including Hunger and Thirst. If you have my Journal System installed you can put this info on "Player Information" page.  Next we have the player Warnings. I have increased the speed of the system to get the read outs faster to do this tutorial.      Using a consumable to recover hunger and thirst:  Process: Player have 100 Hunger and 100 Thirst. Players loses hunger and thirst over time: Player loses 1 hunger every 30 seconds. Player loses 2 thirst every 30 seconds. When players hunger or thirst gets to low warning messages start appearing in chat every so often (Doesn't spam). Players have 4 states of hunger and thirst: 0 = Fine 1 = Getting Hunger 2 = Need to find some food 3 = You are starving to death Players in state 3 will stop moving for a short time to recover a bit, this happens twice (stops for 3 seconds). If player does not replenish they will then die and states will be set back to normal: "State 0 - 100 Hunger - 100 Thirst".  Issue: Sometimes one of the warnings runs after death. Editing the "Waits" in Hunger Warning Events can solve this.  Build:  Lets start with the variables, we need to create 4 for them, each one with a Text Id: Name: Player Hunger - Text Id: hunger Name: Player Thirst- Text Id: thirst Name: Hunger State - Text Id: hungerstate Name: Thirst State - Text Id: thirststate  Now for the Common Events, this system has lets say, a few of them... Spoiler I always layout my event system like this, makes it easier to find events later down the line.  Now don't worry they aren't that big on the inside  First thing that is needed is a "New Player" Common Event. I have one is all my games to set the player variables on a new player joining the game, but people might do something different in there games, but this how I do it: Creating a player variable or switch. Create a common event "New Player", trigger = autorun, condition = run if New Player Variable is equal to 0 In common event set variable player Hunger and Thirst to 100 End event with set variable New Player to 1  Lets move on with the Hunger and Thirst Ticks Spoiler The ticks are the speed in which players hunger and thirst is reduced and the amount.  I have it set up like this: Hunger Tick 30000ms (30 seconds) Subtract 1 from Player Hunger Variable Thirst Tick 30000ms (30 seconds) Subtract 2 from Player Thirst Variable  These variables can be changed to suit your game. I believe if my math is correct a player will die in 50 minutes if he does not eat, half that for thirst.  Hunger Tick:  Thirst Tick:  Now the States Spoiler Hunger State:  Thirst State:  Time to do the warnings.  Hunger Warnings Spoiler Each page of the "Warnings" has a condition to run. Each page needs to only run when the hunger state is equal to the state the player is on.  This is the condition to run page 1:  So page 2 will only run is Hunger State is equal to 2 and page 3 will only run is Hunger State is equal to 3  Here are the pages:   Page 3 does most the work as this is when the player stops 2 times then dies if he doesn't find food. Also here is where you set where the player warps to when he dies.  Thirst Warnings Spoiler Exactly the same as Hunger warning just changed to suit Thirst. Will run through again:  Each page of the "Warnings" has a condition to run. Each page needs to only run when the thirst state is equal to the state the player is on.  This is the condition to run page 1:  So page 2 will only run is Thirst State is equal to 2 and page 3 will only run is Thirst State is equal to 3  Here are the pages:   Page 3 does most the work as this is when the player stops 2 times then dies if he doesn't find water. Also here is where you set where the player warps to when he dies.  That is the main bulk of the system. Now we just have to add food and water for the players to consume to recover stats. Spoiler Eat food to recover. This is +10 Hunger, also add +25, +50, +75, +100 (or change to what ever you would like)  Drink to recover. This is +10 Thirst, also add +25, +50, +75, +100 (or change to what ever you would like)  Now make an item and change its type to "Event" Spoiler Food a player can consume, some "Cheese Crisps", restores +10 Hunger. Notice the Event we point to is the common event +10 Hunger.  Drink a player can consume, some "Grape Pop", restores +10 Thirst.  Consuming the items will show in chat Spoiler  Complete!  You should now have a fully working hunger and thirst system. This can be changed easily be changed to make a stamina system or something along those lines.  Enjoy Zetasis, Justn, Vus and 5 others 8 Link to comment Share on other sites More sharing options...
Stx Posted April 10, 2019 Share Posted April 10, 2019 This is a really good in-depth and useful tutorial, thank you very much! Link to comment Share on other sites More sharing options...
Ainz Ooal Gown Posted April 10, 2019 Author Share Posted April 10, 2019 54 minutes ago, Essence said: This is a really good in-depth and useful tutorial, thank you very much!  No problem hope you enjoy it! Stx 1 Link to comment Share on other sites More sharing options...
Habib Posted August 5, 2021 Share Posted August 5, 2021 Hi! It all works til message from state 3 appears... "you are dying of thir...", after that, player won't teleport. I'm checking the variables, and they are fine, thirst and hunger are going down to 0, with the tick system. They reach -1, actually. But after that, variables won't reset to 100 nor player will teleport. Wonder why? Link to comment Share on other sites More sharing options...
Ainz Ooal Gown Posted August 6, 2021 Author Share Posted August 6, 2021 19 hours ago, Habib said: Hi! It all works til message from state 3 appears... "you are dying of thir...", after that, player won't teleport. I'm checking the variables, and they are fine, thirst and hunger are going down to 0, with the tick system. They reach -1, actually. But after that, variables won't reset to 100 nor player will teleport. Wonder why? Â Hey, I have not looked at this system in a very long time and it probs needs a total re-write. Link to comment Share on other sites More sharing options...
Habib Posted August 6, 2021 Share Posted August 6, 2021 I see! Could we chat a bit somehow in order to trade some knowledge? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now