This commit is contained in:
ElCeejo 2022-09-26 00:43:47 -07:00
parent 40f842d9f3
commit 5f48a07665
2 changed files with 18 additions and 34 deletions

24
api.lua
View file

@ -449,18 +449,20 @@ function creatura.basic_punch_func(self, puncher, tflp, tool_caps, dir)
and contains_val(self.immune_to, tool_name)) then and contains_val(self.immune_to, tool_name)) then
return return
end end
self:apply_knockback(dir, 12) local damage = 0
if not tool_caps local armor_grps = self.object:get_armor_groups() or self.armor_groups or {}
or not tool_caps.damage_groups for group, val in pairs(tool_caps.damage_groups or {}) do
or not tool_caps.damage_groups.fleshy then local dmg_x = tflp / (tool_caps.full_punch_interval or 1.4)
tool_caps = { damage = damage + val * clamp(dmg_x, 0, 1) * ((armor_grps[group] or 0) / 100.0)
damage_groups = { end
fleshy = 2 if damage > 0 then
}, local dist = vec_dist(self.object:get_pos(), puncher:get_pos())
full_punch_interval = 1.4 dir.y = 0.2
} if self.touching_ground then
self:apply_knockback(dir, (damage / dist) * 8)
end
self:hurt(damage)
end end
self:hurt(tool_caps.damage_groups.fleshy)
if add_wear then if add_wear then
local wear = floor((tool_caps.full_punch_interval / 75) * 9000) local wear = floor((tool_caps.full_punch_interval / 75) * 9000)
tool:add_wear(wear) tool:add_wear(wear)

View file

@ -219,11 +219,7 @@ end
function mob:apply_knockback(dir, power) function mob:apply_knockback(dir, power)
if not dir then return end if not dir then return end
power = power or 6 power = power or 6
if not self.touching_ground then
power = power * 0.8
end
local knockback = vec_multi(dir, power) local knockback = vec_multi(dir, power)
knockback.y = abs(power * 0.22)
self.object:add_velocity(knockback) self.object:add_velocity(knockback)
end end
@ -1000,25 +996,11 @@ function mob:_physics()
--and not move_data.func --and not move_data.func
and move_data.gravity ~= 0 then and move_data.gravity ~= 0 then
local vel = self.object:get_velocity() local vel = self.object:get_velocity()
if on_ground then local friction = self.dtime * 10
local nvel = vector.multiply(vel, 0.2) if friction > 0.5 then friction = 0.5 end
if nvel.x < 0.2 if not on_ground then friction = 0.25 end
and nvel.z < 0.2 then local nvel = {x = vel.x * (1 - friction), y = vel.y, z = vel.z * (1 - friction)}
nvel.x = 0
nvel.z = 0
end
nvel.y = vel.y
self.object:set_velocity(nvel) self.object:set_velocity(nvel)
else
local nvel = vector.multiply(vel, 0.1)
if nvel.x < 0.2
and nvel.z < 0.2 then
nvel.x = 0
nvel.z = 0
end
nvel.y = vel.y
self.object:set_velocity(nvel)
end
end end
end end