mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
improved vehicle destruction code
This commit is contained in:
parent
758ce12162
commit
59f4865a07
3 changed files with 8 additions and 0 deletions
|
@ -7,6 +7,7 @@ function airutils.physics(self)
|
||||||
local surface = nil
|
local surface = nil
|
||||||
local surfnodename = nil
|
local surfnodename = nil
|
||||||
local spos = airutils.get_stand_pos(self)
|
local spos = airutils.get_stand_pos(self)
|
||||||
|
if not spos then return end
|
||||||
spos.y = spos.y+0.01
|
spos.y = spos.y+0.01
|
||||||
-- get surface height
|
-- get surface height
|
||||||
local snodepos = airutils.get_node_pos(spos)
|
local snodepos = airutils.get_node_pos(spos)
|
||||||
|
|
|
@ -119,6 +119,10 @@ function airutils.on_step(self,dtime,colinfo)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.hp_max <= 0 then
|
||||||
|
airutils.destroy(self)
|
||||||
|
end
|
||||||
|
|
||||||
self:physics()
|
self:physics()
|
||||||
|
|
||||||
if self.logic then
|
if self.logic then
|
||||||
|
@ -214,6 +218,7 @@ function airutils.logic(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not self.object:get_acceleration() then return end
|
||||||
local accel_y = self.object:get_acceleration().y
|
local accel_y = self.object:get_acceleration().y
|
||||||
local rotation = self.object:get_rotation()
|
local rotation = self.object:get_rotation()
|
||||||
local yaw = rotation.y
|
local yaw = rotation.y
|
||||||
|
|
|
@ -42,9 +42,11 @@ function airutils.get_stand_pos(thing) -- thing can be luaentity or objectref.
|
||||||
local colbox = {}
|
local colbox = {}
|
||||||
if type(thing) == 'table' then
|
if type(thing) == 'table' then
|
||||||
pos = thing.object:get_pos()
|
pos = thing.object:get_pos()
|
||||||
|
if not thing.object:get_properties() then return false end
|
||||||
colbox = thing.object:get_properties().collisionbox
|
colbox = thing.object:get_properties().collisionbox
|
||||||
elseif type(thing) == 'userdata' then
|
elseif type(thing) == 'userdata' then
|
||||||
pos = thing:get_pos()
|
pos = thing:get_pos()
|
||||||
|
if not thing:get_properties() then return false end
|
||||||
colbox = thing:get_properties().collisionbox
|
colbox = thing:get_properties().collisionbox
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Reference in a new issue