Page 1 of 2

[SCRIPT] Simple hunger system

Posted: Tue May 26, 2015 5:54 pm
by st1nger
Hello everyone.

Here is a simple example for a hunger system wich deals damage to champions if the food bar falls to 0.

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
			class = "Timer",
			name = "foodtimer",
			timerInterval = 10.0, -- check every 10 seconds for food / deals damage
			triggerOnStart = true,
			onActivate = function(self)
				for i = 1, 4, 1 do
					local food = party.party:getChampion(i):getFood()
					if food == 0 then
						local h = party.party:getChampion(i):getMaxHealth()
						local dmg = (h/24) -- the champion has 4 minutes to life
						party.party:getChampion(i):damage(dmg, "physical")
					end
				end
			end
		}
	}
}

Re: simple hunger script

Posted: Wed May 27, 2015 2:06 am
by Eleven Warrior
Awesome script man :) Thxs for the help I was thinking of this and totally forgot about the party at the imam hungry stage :)

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 2:19 pm
by Drakkan
definitely wonderful idea ! Do you think it is possible to expand it a little (or make another possible version), which works following way -- After starving trait appears for some champion (food = 0), champion start to be damaged lets say every 10 seconds for some dmg (like 5-10 dmg).
Also the damaging should start NOT immediately when food = 0 but lets say after one minute of gameplay.

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 2:49 pm
by st1nger
Drakkan wrote:definitely wonderful idea ! Do you think it is possible to expand it a little (or make another possible version), which works following way -- After starving trait appears for some champion (food = 0), champion start to be damaged lets say every 10 seconds for some dmg (like 5-10 dmg).
Also the damaging should start NOT immediately when food = 0 but lets say after one minute of gameplay.
Sure, almost everything is possible.

The original hunger system in LoG2 is the following:

The hunger bar has 1000 units = Full bar
At 349 units the bar is yellow and no effect to champions.
At 249 units the bar is red and starving effect to the champion. With this effect the champion does not regen health and energy when resting.
At 0 units the bar is empty but no other effect, still starving.

The player has enough time if the champion are starving before the bar reach 0 units.

you can change the units in my script if you just want to start damage at a specific value.


timerInterval = 10.0, <- how often to check food or deals damage.

if food == 0 then <- damage starts at here. change as you wish. 1000 is full bar, 349 is yellow bar, 249 is red bar.

local dmg = (h/24) <- value of damage. with h/24 the champion has 4 minutes to life. or change as you wish.


Tell me what exactly you want to change and i look what i can do

st1nger

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 6:55 pm
by Drakkan
st1nger wrote:
Drakkan wrote:definitely wonderful idea ! Do you think it is possible to expand it a little (or make another possible version), which works following way -- After starving trait appears for some champion (food = 0), champion start to be damaged lets say every 10 seconds for some dmg (like 5-10 dmg).
Also the damaging should start NOT immediately when food = 0 but lets say after one minute of gameplay.
Sure, almost everything is possible.

The original hunger system in LoG2 is the following:

The hunger bar has 1000 units = Full bar
At 349 units the bar is yellow and no effect to champions.
At 249 units the bar is red and starving effect to the champion. With this effect the champion does not regen health and energy when resting.
At 0 units the bar is empty but no other effect, still starving.

The player has enough time if the champion are starving before the bar reach 0 units.

you can change the units in my script if you just want to start damage at a specific value.


timerInterval = 10.0, <- how often to check food or deals damage.

if food == 0 then <- damage starts at here. change as you wish. 1000 is full bar, 349 is yellow bar, 249 is red bar.

local dmg = (h/24) <- value of damage. with h/24 the champion has 4 minutes to life. or change as you wish.


Tell me what exactly you want to change and i look what i can do

st1nger
local dmg = (h/24) <- value of damage. with h/24 the champion has 4 minutes to life. or change as you wish.

I dont get this - it means champion will be killed after 4 minutes ? Thats quite drastic. Id rather champion to be dealed some minor damage every lets say 30 seconds if he/she is starving.

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 8:04 pm
by st1nger
Drakkan wrote: local dmg = (h/24) <- value of damage. with h/24 the champion has 4 minutes to life. or change as you wish.

I dont get this - it means champion will be killed after 4 minutes ? Thats quite drastic. Id rather champion to be dealed some minor damage every lets say 30 seconds if he/she is starving.
How long it takes from starving to 0? maybe 10 minutes?
Starving begins at 249. The damage begins at 0.

For me, this is enough time to react.

If you want a 30 second timer, just change the code to this one: timerInterval = 30.0,
And for damage you can use any number you want:

local dmg = (h/24) <- 3,75 damage if the champion has 90 hp, this means 4 minutes to life.
local dmg = 1 <- 1 damage per check. if 10 second timer, the champion hast 15 minutes to life with 90 hp for example.

st1nger

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 8:47 pm
by minmay
st1nger wrote:How long it takes from starving to 0? maybe 10 minutes?
Food consumption doesn't occur with time at all unless you are resting.

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 8:58 pm
by AndakRainor
Is there an event corresponding to food consumption when the party moves or rests ? If there is it could be another way to deal some damage without using directly time.

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 10:10 pm
by Isaac
Why not use OnMove() ?

Re: [SCRIPT] Simple hunger system

Posted: Thu May 28, 2015 10:24 pm
by AndakRainor
Isaac wrote:Why not use OnMove() ?
Yes, that and onRest() could be used as an alternative to damage over time. But do we know the formulas used by the game to calculate food consumption ? I'm just curious here, this system does not need to exactly match for health what the game does for food to be a good addition to immersion in a mod. But it could be nice if it took into account the minotaur, fast_metabolism and endurance traits for example.