Disable clientside "death" prediction, fix animation
This commit is contained in:
parent
9e1a830cf9
commit
7c1b91e647
@ -122,6 +122,7 @@ local function killMob(me, def)
|
|||||||
end
|
end
|
||||||
local pos = me:getpos()
|
local pos = me:getpos()
|
||||||
me:setvelocity(nullVec)
|
me:setvelocity(nullVec)
|
||||||
|
me:set_properties({collisionbox = nullVec})
|
||||||
me:set_hp(0)
|
me:set_hp(0)
|
||||||
|
|
||||||
if def.sounds and def.sounds.on_death then
|
if def.sounds and def.sounds.on_death then
|
||||||
@ -147,6 +148,28 @@ local function killMob(me, def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function limit(value, min, max)
|
||||||
|
if value < min then
|
||||||
|
return min
|
||||||
|
end
|
||||||
|
if value > max then
|
||||||
|
return max
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
local function calcPunchDamage(obj, actual_interval, tool_caps)
|
||||||
|
local damage = 0
|
||||||
|
if not tool_caps or not actual_interval then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
local my_armor = obj:get_armor_groups() or {}
|
||||||
|
for group,_ in pairs(tool_caps.damage_groups) do
|
||||||
|
damage = damage + (tool_caps.damage_groups[group] or 0) * limit(actual_interval / tool_caps.full_punch_interval, 0.0, 1.0) * ((my_armor[group] or 0) / 100.0)
|
||||||
|
end
|
||||||
|
return (damage * -1)
|
||||||
|
end
|
||||||
|
|
||||||
local function onDamage(self, hp)
|
local function onDamage(self, hp)
|
||||||
local me = self.object
|
local me = self.object
|
||||||
local def = core.registered_entities[self.mob_name]
|
local def = core.registered_entities[self.mob_name]
|
||||||
@ -168,8 +191,8 @@ local function changeHP(self, value)
|
|||||||
local me = self.object
|
local me = self.object
|
||||||
local hp = me:get_hp()
|
local hp = me:get_hp()
|
||||||
hp = hp + math.floor(value)
|
hp = hp + math.floor(value)
|
||||||
|
me:set_hp(hp)
|
||||||
if value < 0 then
|
if value < 0 then
|
||||||
me:set_hp(hp)
|
|
||||||
onDamage(self, hp)
|
onDamage(self, hp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -235,6 +258,8 @@ creatures.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
|
|||||||
|
|
||||||
local me = self.object
|
local me = self.object
|
||||||
local mypos = me:getpos()
|
local mypos = me:getpos()
|
||||||
|
|
||||||
|
changeHP(self, calcPunchDamage(me, time_from_last_punch, tool_capabilities))
|
||||||
if puncher then
|
if puncher then
|
||||||
if self.hostile then
|
if self.hostile then
|
||||||
self.target = puncher
|
self.target = puncher
|
||||||
@ -252,14 +277,11 @@ creatures.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
|
|||||||
|
|
||||||
-- add wearout to weapons/tools
|
-- add wearout to weapons/tools
|
||||||
addWearout(puncher, tool_capabilities)
|
addWearout(puncher, tool_capabilities)
|
||||||
onDamage(self)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
creatures.on_rightclick = function(self, clicker)
|
creatures.on_rightclick = function(self, clicker)
|
||||||
-- do sth
|
|
||||||
core.chat_send_all("Hey, i got clicked!")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
creatures.on_step = function(self, dtime)
|
creatures.on_step = function(self, dtime)
|
||||||
|
@ -174,6 +174,8 @@ local function translate_def(def)
|
|||||||
self.hostile = false
|
self.hostile = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- immortal is needed to disable clientside smokepuff shit
|
||||||
|
self.object:set_armor_groups({fleshy = 100, immortal = 1})
|
||||||
|
|
||||||
-- call custom on_activate if defined
|
-- call custom on_activate if defined
|
||||||
if def.on_activate then
|
if def.on_activate then
|
||||||
|
@ -56,8 +56,8 @@ local def = {
|
|||||||
animations = {
|
animations = {
|
||||||
idle = {start = 0, stop = 80, speed = 15},
|
idle = {start = 0, stop = 80, speed = 15},
|
||||||
walk = {start = 102, stop = 122, speed = 15.5},
|
walk = {start = 102, stop = 122, speed = 15.5},
|
||||||
attack = {start = 168, stop = 188, speed = 25},
|
attack = {start = 102, stop = 122, speed = 25},
|
||||||
death = {start = 81, stop = 101, speed = 25, loop = false, duration = 1.92},
|
death = {start = 81, stop = 101, speed = 28, loop = false, duration = 2.12},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user