mirror of
https://github.com/APercy/airutils.git
synced 2025-09-22 11:26:51 -04:00
fix damage over slabs
This commit is contained in:
parent
45d789850b
commit
197b5b6210
1 changed files with 8 additions and 2 deletions
|
@ -444,12 +444,17 @@ function airutils.testImpact(self, velocity, position)
|
||||||
local impact_speed = 2
|
local impact_speed = 2
|
||||||
local p = position --self.object:get_pos()
|
local p = position --self.object:get_pos()
|
||||||
local collision = false
|
local collision = false
|
||||||
if self._last_vel == nil then return end
|
if self._last_vel == nil then
|
||||||
|
self._last_vel = velocity
|
||||||
|
return
|
||||||
|
end
|
||||||
local touch_point = self.initial_properties.collisionbox[2]-0.5
|
local touch_point = self.initial_properties.collisionbox[2]-0.5
|
||||||
--lets calculate the vertical speed, to avoid the bug on colliding on floor with hard lag
|
--lets calculate the vertical speed, to avoid the bug on colliding on floor with hard lag
|
||||||
if math.abs(velocity.y - self._last_vel.y) > impact_speed then
|
local impact_vel = math.abs(velocity.y - self._last_vel.y)
|
||||||
|
if impact_vel > impact_speed then
|
||||||
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point}))
|
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point}))
|
||||||
if (noded and noded.drawtype ~= 'airlike') then
|
if (noded and noded.drawtype ~= 'airlike') then
|
||||||
|
--core.chat_send_all("imp "..impact_vel)
|
||||||
collision = true
|
collision = true
|
||||||
else
|
else
|
||||||
self.object:set_velocity(self._last_vel)
|
self.object:set_velocity(self._last_vel)
|
||||||
|
@ -544,6 +549,7 @@ function airutils.testImpact(self, velocity, position)
|
||||||
end
|
end
|
||||||
|
|
||||||
if collision then
|
if collision then
|
||||||
|
self._last_vel = velocity
|
||||||
local damage = impact/2 --default for basic planes and trainers
|
local damage = impact/2 --default for basic planes and trainers
|
||||||
if self._hard_damage then
|
if self._hard_damage then
|
||||||
damage = impact*3
|
damage = impact*3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue