From eef4715a3ac41960e4403ca34217ee6a35a7bc8d Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Wed, 13 Sep 2023 18:59:44 -0300 Subject: [PATCH] fix passenger collision when jumping from plane --- lib_planes/entities.lua | 2 +- lib_planes/forms.lua | 2 +- lib_planes/utilities.lua | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index cb6b65c..d4a08a8 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -43,7 +43,7 @@ function airutils.on_activate(self, staticdata, dtime_s) self.driver_name = data.stored_driver_name self._last_accell = data.stored_last_accell self._inv_id = data.stored_inv_id - self._flap = data.stored_flap + if self._wing_angle_extra_flaps then self._flap = data.stored_flap end self._passengers = data.stored_passengers or {} self._adf_destiny = data.stored_adf_destiny or vector.new() self._skin = data.stored_skin diff --git a/lib_planes/forms.lua b/lib_planes/forms.lua index e957fe7..e917c68 100644 --- a/lib_planes/forms.lua +++ b/lib_planes/forms.lua @@ -213,7 +213,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local ent = plane_obj:get_luaentity() if ent then if fields.yes then - airutils.dettach_pax(ent, player) + airutils.dettach_pax(ent, player, true) end end minetest.close_formspec(name, "lib_planes:go_out_confirmation_form") diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index 97fd844..bceb2a5 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -195,7 +195,8 @@ function airutils.attach_pax(self, player, is_copilot) end end -function airutils.dettach_pax(self, player) +function airutils.dettach_pax(self, player, is_flying) + is_flying = is_flying or false local name = player:get_player_name() --self._passenger -- passenger clicked the object => driver gets off the vehicle @@ -215,7 +216,12 @@ function airutils.dettach_pax(self, player) -- detach the player if player then + local pos = player:get_pos() player:set_detach() + if is_flying then + pos.y = pos.y - self.initial_properties.collisionbox[2] - 2 + player:set_pos(pos) + end if airutils.is_minetest then player_api.player_attached[name] = nil @@ -939,6 +945,12 @@ function airutils.seats_destroy(self) end function airutils.flap_on(self) + if not self._wing_angle_extra_flaps then + self._flap = false + self._wing_configuration = self._wing_angle_of_attack + return + end + if self._wing_angle_extra_flaps == nil then self._wing_angle_extra_flaps = 0 end --if not, just keep the same as normal angle of attack local flap_limit = 15 if self._flap_limit then flap_limit = self._flap_limit end