mirror of
https://github.com/APercy/airutils.git
synced 2025-04-30 08:41:41 -04:00
commit
1bd63a4eb0
2 changed files with 30 additions and 30 deletions
|
@ -108,6 +108,22 @@ function airutils.on_step(self,dtime,colinfo)
|
||||||
|
|
||||||
-- physics comes first
|
-- physics comes first
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local props = self.object:get_properties()
|
||||||
|
|
||||||
|
-- handle visibility on radar
|
||||||
|
if (pos and pos.y < airutils.radarMinHeight and props.show_on_minimap) then
|
||||||
|
props.show_on_minimap = false
|
||||||
|
self.object:set_properties(props)
|
||||||
|
end
|
||||||
|
if (pos and pos.y >= airutils.radarMinHeight and not props.show_on_minimap) then
|
||||||
|
props.show_on_minimap = true
|
||||||
|
self.object:set_properties(props)
|
||||||
|
end
|
||||||
|
if self.isonground and props.show_on_minimap then
|
||||||
|
props.show_on_minimap = false
|
||||||
|
self.object:set_properties(plane_properties)
|
||||||
|
end
|
||||||
|
|
||||||
if colinfo then
|
if colinfo then
|
||||||
self.isonground = colinfo.touching_ground
|
self.isonground = colinfo.touching_ground
|
||||||
|
@ -177,19 +193,6 @@ function airutils.logic(self)
|
||||||
local co_pilot = nil
|
local co_pilot = nil
|
||||||
if self.co_pilot and self._have_copilot then co_pilot = minetest.get_player_by_name(self.co_pilot) end
|
if self.co_pilot and self._have_copilot then co_pilot = minetest.get_player_by_name(self.co_pilot) end
|
||||||
|
|
||||||
local plane_properties = self.object:get_properties()
|
|
||||||
if self.isonground then
|
|
||||||
if plane_properties.show_on_minimap == true then
|
|
||||||
plane_properties.show_on_minimap = false
|
|
||||||
self.object:set_properties(plane_properties)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if plane_properties.show_on_minimap == false then
|
|
||||||
plane_properties.show_on_minimap = true
|
|
||||||
self.object:set_properties(plane_properties)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if player then
|
if player then
|
||||||
local ctrl = player:get_player_control()
|
local ctrl = player:get_player_control()
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -611,20 +614,17 @@ function airutils.logic(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function damage_vehicle(self, toolcaps, ttime, damage)
|
local function damage_vehicle(self, toolcaps, ttime, damage)
|
||||||
for group,_ in pairs( (toolcaps.damage_groups or {}) ) do
|
if (not toolcaps) then
|
||||||
local tmp = ttime / (toolcaps.full_punch_interval or 1.4)
|
return
|
||||||
|
|
||||||
if tmp < 0 then
|
|
||||||
tmp = 0.0
|
|
||||||
elseif tmp > 1 then
|
|
||||||
tmp = 1.0
|
|
||||||
end
|
end
|
||||||
|
value = toolcaps.damage_groups.fleshy or 0
|
||||||
damage = damage + (toolcaps.damage_groups[group] or 0) * tmp
|
if (toolcaps.damage_groups.vehicle) then
|
||||||
|
value = toolcaps.damage_groups.vehicle
|
||||||
|
end
|
||||||
|
damage = damage + value / 10
|
||||||
self.hp_max = self.hp_max - damage
|
self.hp_max = self.hp_max - damage
|
||||||
airutils.setText(self, self._vehicle_name)
|
airutils.setText(self, self._vehicle_name)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
||||||
local name = puncher:get_player_name()
|
local name = puncher:get_player_name()
|
||||||
|
@ -633,13 +633,11 @@ function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
||||||
end
|
end
|
||||||
airutils.setText(self, self._vehicle_name)
|
airutils.setText(self, self._vehicle_name)
|
||||||
|
|
||||||
-- lets permit destroying on the air
|
if (puncher and puncher:is_player() and
|
||||||
local is_flying = not self.colinfo.touching_ground
|
(string.find(puncher:get_wielded_item():get_name(), "rayweapon") or
|
||||||
--if is_flying and not puncher:is_player() then
|
toolcaps.damage_groups.vehicle)) then
|
||||||
if not puncher:is_player() then
|
|
||||||
damage_vehicle(self, toolcaps, ttime, damage)
|
damage_vehicle(self, toolcaps, ttime, damage)
|
||||||
end
|
end
|
||||||
--end
|
|
||||||
|
|
||||||
if not puncher or not puncher:is_player() then
|
if not puncher or not puncher:is_player() then
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
--
|
--
|
||||||
airutils.vector_up = vector.new(0, 1, 0)
|
airutils.vector_up = vector.new(0, 1, 0)
|
||||||
|
|
||||||
|
--set min y-pos above which airplanes are seen on radar
|
||||||
|
airutils.radarMinHeight = 30
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue