Jump to content
Ainz Ooal Gown

[AOG] Hunger / Thirst System

Recommended Posts

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.

7441b341e34cda812bbdf27d9dac2538.jpg

 

Next we have the player Warnings. I have increased the speed of the system to get the read outs faster to do this tutorial.

a34ab71486468af978965f611c044102.jpg

 

0dea97c6fd1fdcedcce725305ba6a65f.jpg

 

1475ea143f596471060192bc7b4e23c5.jpg

 

37394696fce88c87d081f96181342fe8.jpg

 

324dd94485c1a305ca8f8463129244c8.jpg

 

Using a consumable to recover hunger and thirst:

83500deefde390df63eb6a801234cb68.jpg

 

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:

  1. Name: Player Hunger - Text Id: hunger
  2. Name: Player Thirst- Text Id: thirst
  3. Name: Hunger State - Text Id: hungerstate
  4. 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.

76c1c344fde59f634e9e3c5e0f37a7f2.jpg

 

Now don't worry they aren't that big on the inside :P

 

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:

80a762d30edbc3ee86f0344b12c147fd.jpg

 

Thirst Tick:

1ae726e090b76ac8d8b55f96076cf1a9.jpg

 

Now the States

Spoiler

Hunger State:

8300ac43f910212377b29477a8ea9470.jpg

 

Thirst State:

bc4cb09e812f82643475fcc4d06d50e0.jpg

 

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:

fbbefb560fd0de536fb54273846e3e1b.jpg

 

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:

ad7b0e24ccee3cc6e7ba686d9bcd3a28.jpg

 

75452c5713781f1ec14af65008fb35bf.jpg

 

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.

f54881bbc44c0deb3808a1773a3c73a3.jpg

 

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:

fa6071718b070140fd256db45d162f7b.jpg

 

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:

5b01cc2343fd990130474af8cd2f2402.jpg

 

03e32eda7c88fa12a4a45d0202916208.jpg

 

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.

434668ea63c839a6fdf1071e59eecdec.jpg

 

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)

38ebc2ca3bd0dd09e5ce904bb498d9fe.jpg

 

Drink to recover. This is +10 Thirst, also add +25, +50, +75, +100 (or change to what ever you would like)

71cf0a76467e8cd059f7cc1686503bb5.jpg

 

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.

4082637b7ed67d923dedfd11e9c10966.jpg

 

Drink a player can consume, some "Grape Pop", restores +10 Thirst.

b9052bc62e0abba712d74b05d9d08863.jpg

 

Consuming the items will show in chat

Spoiler

83500deefde390df63eb6a801234cb68.jpg

 

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 :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×