forked from MineClone5/MineClone5
Merge branch 'master' into bone_meal
This commit is contained in:
commit
9e4e7f0695
|
@ -67,6 +67,7 @@
|
||||||
* SmallJoker
|
* SmallJoker
|
||||||
* Sven792
|
* Sven792
|
||||||
* aldum
|
* aldum
|
||||||
|
* Dieter44
|
||||||
|
|
||||||
## MineClone5
|
## MineClone5
|
||||||
* kay27
|
* kay27
|
||||||
|
|
|
@ -115,16 +115,22 @@ function place_wet_sponge(itemstack, placer, pointed_thing)
|
||||||
if mcl_worlds.pos_to_dimension(pointed_thing.above) == "nether" then
|
if mcl_worlds.pos_to_dimension(pointed_thing.above) == "nether" then
|
||||||
minetest.item_place_node(ItemStack("mcl_sponges:sponge"), placer, pointed_thing)
|
minetest.item_place_node(ItemStack("mcl_sponges:sponge"), placer, pointed_thing)
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
for n = 0, 25 do
|
|
||||||
minetest.add_particle({
|
for n = 1, 5 do
|
||||||
pos = {x = pos.x + math.random(-1, 1)*math.random()/2, y = pos.y + 0.6, z = pos.z + math.random(-1, 1)*math.random()/2},
|
minetest.add_particlespawner({
|
||||||
velocity = {x = 0, y = math.random(), z = 0},
|
amount = 5,
|
||||||
acceleration = {x=0, y=0, z=0},
|
time = 0.1,
|
||||||
expirationtime = math.random(),
|
minpos = vector.offset(pos, -0.5, 0.6, -0.5),
|
||||||
|
maxpos = vector.offset(pos, 0.5, 0.6, 0.5),
|
||||||
|
minvel = vector.new(0, 0.1, 0),
|
||||||
|
maxvel = vector.new(0, 1, 0),
|
||||||
|
minexptime = 0.1,
|
||||||
|
maxexptime = 1,
|
||||||
|
minsize = 2,
|
||||||
|
maxsize = 5,
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
vertical = false,
|
vertical = false,
|
||||||
size = math.random(2, 5),
|
texture = "mcl_particles_sponge" .. n .. ".png",
|
||||||
texture = "mcl_particles_sponge"..math.random(1, 5)..".png",
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
if not minetest.is_creative_enabled(name) then
|
if not minetest.is_creative_enabled(name) then
|
||||||
|
|
|
@ -91,8 +91,8 @@ end
|
||||||
-- register saturation hudbar
|
-- register saturation hudbar
|
||||||
hb.register_hudbar("hunger", 0xFFFFFF, S("Food"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, 1, 20, 20, false)
|
hb.register_hudbar("hunger", 0xFFFFFF, S("Food"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, 1, 20, 20, false)
|
||||||
if mcl_hunger.debug then
|
if mcl_hunger.debug then
|
||||||
hb.register_hudbar("saturation", 0xFFFFFF, S("Saturation"), { icon = "mcl_hunger_icon_saturation.png", bgicon = "mcl_hunger_bgicon_saturation.png", bar = "mcl_hunger_bar_saturation.png" }, 1, mcl_hunger.SATURATION_INIT, 200, false, S("%s: %.1f/%d"))
|
hb.register_hudbar("saturation", 0xFFFFFF, S("Saturation"), { icon = "mcl_hunger_icon_saturation.png", bgicon = "mcl_hunger_bgicon_saturation.png", bar = "mcl_hunger_bar_saturation.png" }, 1, mcl_hunger.SATURATION_INIT, 200, false)
|
||||||
hb.register_hudbar("exhaustion", 0xFFFFFF, S("Exhaust."), { icon = "mcl_hunger_icon_exhaustion.png", bgicon = "mcl_hunger_bgicon_exhaustion.png", bar = "mcl_hunger_bar_exhaustion.png" }, 1, 0, mcl_hunger.EXHAUST_LVL, false, S("%s: %d/%d"))
|
hb.register_hudbar("exhaustion", 0xFFFFFF, S("Exhaust."), { icon = "mcl_hunger_icon_exhaustion.png", bgicon = "mcl_hunger_bgicon_exhaustion.png", bar = "mcl_hunger_bar_exhaustion.png" }, 1, 0, mcl_hunger.EXHAUST_LVL, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
@ -134,47 +134,46 @@ minetest.register_on_player_hpchange(function(player, hp_change)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local main_timer = 0
|
local food_tick_timers = {} -- one food_tick_timer per player, keys are the player-objects
|
||||||
local timer = 0 -- Half second timer
|
|
||||||
local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
main_timer = main_timer + dtime
|
|
||||||
timer = timer + dtime
|
|
||||||
if main_timer > mcl_hunger.HUD_TICK or timer > 0.25 then
|
|
||||||
if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end
|
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
|
||||||
|
|
||||||
local h = tonumber(mcl_hunger.get_hunger(player))
|
local food_tick_timer = food_tick_timers[player] and food_tick_timers[player] + dtime or 0
|
||||||
local hp = player:get_hp()
|
local player_name = player:get_player_name()
|
||||||
if timer > 0.25 then
|
local food_level = mcl_hunger.get_hunger(player)
|
||||||
-- Slow health regeneration, and hunger damage (every 4s).
|
local food_saturation_level = mcl_hunger.get_saturation(player)
|
||||||
-- Regeneration rate based on tutorial video <https://www.youtube.com/watch?v=zs2t-xCVHBo>.
|
local player_health = player:get_hp()
|
||||||
-- Minecraft Wiki seems to be wrong in claiming that full hunger gives 0.5s regen rate.
|
|
||||||
if timerMult == 0 then
|
if food_tick_timer > 4.0 then
|
||||||
if h >= 18 and hp > 0 and hp < 20 then
|
food_tick_timer = 0
|
||||||
-- +1 HP, +exhaustion
|
|
||||||
player:set_hp(hp+1)
|
if food_level >= 18 then -- slow regenration
|
||||||
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_REGEN)
|
if player_health > 0 and player_health < 20 then
|
||||||
|
player:set_hp(player_health+1)
|
||||||
|
mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN)
|
||||||
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player))
|
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player))
|
||||||
elseif h == 0 then
|
end
|
||||||
-- Damage hungry player down to 1 HP
|
|
||||||
-- TODO: Allow starvation at higher difficulty levels
|
elseif food_level == 0 then -- starvation
|
||||||
if hp-1 > 0 then
|
-- the amount of health at which a player will stop to get
|
||||||
|
-- harmed by starvation (10 for Easy, 1 for Normal, 0 for Hard)
|
||||||
|
local maximum_starvation = 1
|
||||||
|
-- TODO: implement Minecraft-like difficulty modes and the update maximumStarvation here
|
||||||
|
if player_health > maximum_starvation then
|
||||||
mcl_util.deal_damage(player, 1, {type = "starve"})
|
mcl_util.deal_damage(player, 1, {type = "starve"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif food_tick_timer > 0.5 and food_level == 20 and food_saturation_level >= 6 then -- fast regeneration
|
||||||
|
if player_health > 0 and player_health < 20 then
|
||||||
|
food_tick_timer = 0
|
||||||
|
player:set_hp(player_health+1)
|
||||||
|
mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN)
|
||||||
|
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
food_tick_timers[player] = food_tick_timer -- update food_tick_timer table
|
||||||
end
|
|
||||||
end
|
|
||||||
if timer > 0.25 then
|
|
||||||
timer = 0
|
|
||||||
timerMult = timerMult + 2
|
|
||||||
if timerMult > 7 then
|
|
||||||
timerMult = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue