improved water collision, flaps fixed

This commit is contained in:
Alexsandro Percy 2023-07-03 18:37:55 -03:00
parent 21c949db88
commit 95087601fa
3 changed files with 29 additions and 7 deletions

View file

@ -86,6 +86,8 @@ function airutils.on_activate(self, staticdata, dtime_s)
self._passengers = {} self._passengers = {}
if not self._vehicle_custom_data then self._vehicle_custom_data = {} end --initialize when it does not exists if not self._vehicle_custom_data then self._vehicle_custom_data = {} end --initialize when it does not exists
if self._flap then airutils.flap_on(self) end
airutils.setText(self, self.infotext) airutils.setText(self, self.infotext)
end end
@ -244,6 +246,13 @@ function airutils.logic(self)
self._custom_step_additional_function(self) self._custom_step_additional_function(self)
end end
if self._wing_configuration == self._wing_angle_of_attack and self._flap then
airutils.flap_on(self)
end
if self._wing_configuration ~= self._wing_angle_of_attack and self._flap == false then
airutils.flap_off(self)
end
if longit_speed == 0 and is_flying == false and is_attached == false and self._engine_running == false then if longit_speed == 0 and is_flying == false and is_attached == false and self._engine_running == false then
return return
end end
@ -497,13 +506,6 @@ function airutils.logic(self)
self.object:set_rotation({x=newpitch,y=newyaw,z=newroll}) self.object:set_rotation({x=newpitch,y=newyaw,z=newroll})
--end --end
if self._wing_configuration == self._wing_angle_of_attack and self._flap then
airutils.flap_on(self)
end
if self._wing_configuration ~= self._wing_angle_of_attack and self._flap == false then
airutils.flap_off(self)
end
if longit_speed > self._max_speed and self._flap == true then if longit_speed > self._max_speed and self._flap == true then
if is_attached and self.driver_name then if is_attached and self.driver_name then
minetest.chat_send_player(self.driver_name, core.colorize('#ff0000', " >>> Flaps retracted due for overspeed")) minetest.chat_send_player(self.driver_name, core.colorize('#ff0000', " >>> Flaps retracted due for overspeed"))

View file

@ -307,6 +307,26 @@ function airutils.testImpact(self, velocity, position)
end end
end end
if self._last_water_touch == nil then self._last_water_touch = 3 end
if self._last_water_touch <= 3 then self._last_water_touch = self._last_water_touch + self.dtime end
if impact > 0.2 and self._longit_speed > 0.6 and self._last_water_touch >=3 then
self._last_water_touch = 0
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point}))
if (noded and noded.drawtype ~= 'airlike') then
if noded.drawtype == 'liquid' then
minetest.sound_play("airutils_touch_water", {
--to_player = self.driver_name,
object = self.object,
max_hear_distance = 15,
gain = 1.0,
fade = 0.0,
pitch = 1.0,
}, true)
return
end
end
end
if vertical_impact > 0.5 and self._longit_speed > self._min_speed/2 then if vertical_impact > 0.5 and self._longit_speed > self._min_speed/2 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

Binary file not shown.