1
0
Fork 0

Compare commits

...

9 Commits

Author SHA1 Message Date
Eliy21 00165959af Fix held attack key not hitting mobs bug (this time for sure)
Reverting to old code in the previous PR but with the new optimizations kept
2023-11-12 12:51:31 +00:00
Eliy21 4cd2962a87 Add mob's last invulnerability time variable (preparing for held attack key not hitting mobs bugfix) 2023-11-12 12:42:19 +00:00
Eliy21 be2fcc925a Optimize code by checking invulnerability1st before the rest and drop checking the others when true 2023-11-12 06:30:57 +00:00
Eliy21 5ebe9f549b Reduce knockback floatiness 2023-11-11 16:42:06 +00:00
Eliy21 107fb0b082 Fix a bug that prevents continuous attacks on mobs when the attack key is held 2023-11-11 16:20:06 +00:00
Eliy21 91a3f11689 Reduce default hand reach to prevent "sniping" mobs using meele
Balance adjustment to prevent newly added Minecraft-like meele juggle (with the increased mob knockback) from being overpowered by having a reach advantage that leads to be able to "juggle lock" mobs from afar.

Existing players will not be affected and new players can adjust it back manually if preferred. This is just setting proper balanced gameplay by default with the option to change available afterwards.
2023-11-11 15:30:15 +00:00
Eliy21 72768d9191 Reduce default hand reach to prevent "sniping" mobs using meele
Balance adjustment to prevent newly added Minecraft-like meele juggle (with the increased mob knockback) from being overpowered by having a reach advantage that leads to be able to "juggle lock" mobs from afar.

Existing players will not be affected and new players can adjust it back manually if preferred. This is just setting proper balanced gameplay by default with the option to change available afterwards.
2023-11-11 15:28:22 +00:00
Eliy21 98a61ec0be Make health regen from food not almost instant to balance spam eating
This came from testing the new mob combat balance that I noticed I can spam eat food and regen very quickly.

This health regen time change is actually the same as Minecraft.

"Whenever a player's hunger is 18 (🍗 × 9) or higher, they regenerate 1♥ every 4 seconds."

https://minecraft.wiki/w/Healing
2023-11-11 15:25:55 +00:00
Eliy21 b2da2b2f63 Give mobs invulnerability for 0.4 seconds after getting hit 2023-11-11 15:23:17 +00:00
5 changed files with 18 additions and 7 deletions

View File

@ -532,6 +532,13 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
return
end
local time_now = minetest.get_us_time()
-- check for invulnerability time in microseconds (0.5 second)
if time_now - self.last_invul_time <= 500000 then
return
end
local is_player = hitter:is_player()
if is_player then
@ -657,6 +664,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
-- do damage
self.health = self.health - damage
-- give invulnerability
self.last_invul_time = time_now
-- skip future functions if dead, except alerting others
if self:check_for_death( "hit", {type = "punch", puncher = hitter}) then
die = true
@ -672,7 +682,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
if not v then return end
local r = 1.4 - math.min(punch_interval, 1.4)
local kb = r * (math.abs(v.x)+math.abs(v.z))
local up = 2
local up = 2.5
if die==true then
kb=kb*2
@ -689,7 +699,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
if tool_capabilities.damage_groups["knockback"] then
kb = tool_capabilities.damage_groups["knockback"]
else
kb = kb * 1.5
kb = kb * 2.5
end
@ -699,7 +709,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
end
if hitter and is_player then
local wielditem = hitter:get_wielded_item()
kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
kb = kb + 10 * mcl_enchanting.get_enchantment(wielditem, "knockback")
elseif luaentity and luaentity._knockback then
kb = kb + luaentity._knockback
end

View File

@ -220,6 +220,7 @@ function mcl_mobs.register_mob(name, def)
replace_delay = def.replace_delay or 0,
timer = 0,
env_damage_timer = 0,
last_invul_time = 0,
tamed = false,
pause_timer = 0,
horny = false,

View File

@ -173,7 +173,7 @@ minetest.register_globalstep(function(dtime)
end
end
elseif food_tick_timer > 0.5 and food_level == 20 and food_saturation_level > 0 then -- fast regeneration
elseif food_tick_timer > 4 and food_level == 20 and food_saturation_level > 0 then -- fast regeneration
if player_health > 0 and player_health < 20 then
food_tick_timer = 0
player:set_hp(player_health+1)

View File

@ -39,7 +39,7 @@ local node_def = {
shearsy_wool = { speed = 1, level = 0, uses = 0 },
shearsy_cobweb = { speed = 1, level = 0, uses = 0 },
},
range = tonumber(minetest.settings:get("mcl_hand_range")) or 4.5
range = tonumber(minetest.settings:get("mcl_hand_range")) or 3.5
}
-- This is for _mcl_autogroup to know about the survival hand tool capabilites

View File

@ -82,8 +82,8 @@ mcl_craftguide_progressive_mode (Learn crafting recipes progressively) bool true
mcl_enable_skin_customization (Enable player skin customization) bool true
# How far the player hand can reach
# Default:4.5
mcl_hand_range (Hand range) float 4.5 1 128
# Default:3.5
mcl_hand_range (Hand range) float 3.5 1 128
# How far the player hand can reach in creative mode
# Default:10