diff --git a/common_entities.lua b/common_entities.lua new file mode 100644 index 0000000..4688b60 --- /dev/null +++ b/common_entities.lua @@ -0,0 +1,24 @@ +-- +-- seat pivot +-- +minetest.register_entity('airutils:seat_base',{ +initial_properties = { + physical = false, + collide_with_objects=false, + pointable=false, + visual = "mesh", + mesh = "airutils_seat_base.b3d", + textures = {"airutils_alpha.png",}, + }, + + on_activate = function(self,std) + self.sdata = minetest.deserialize(std) or {} + if self.sdata.remove then self.object:remove() end + end, + + get_staticdata=function(self) + self.sdata.remove=true + return minetest.serialize(self.sdata) + end, + +}) diff --git a/init.lua b/init.lua index fc1cda5..40d1a07 100644 --- a/init.lua +++ b/init.lua @@ -33,6 +33,7 @@ if not minetest.settings:get_bool('airutils.disable_repair') then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua") end airutils.get_wind = dofile(minetest.get_modpath("airutils") .. DIR_DELIM ..'/wind.lua') +dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "common_entities.lua") dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_wind.lua") dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "inventory_management.lua") dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "light.lua") diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index a049f10..d8f4fe6 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -106,6 +106,24 @@ function airutils.on_step(self,dtime,colinfo) self.time_total=self.time_total+self.dtime end +local function ground_pitch(self, longit_speed, curr_pitch) + newpitch = curr_pitch + -- adjust pitch at ground + if math.abs(longit_speed) < self._tail_lift_max_speed then + --minetest.chat_send_all(math.abs(longit_speed)) + local speed_range = self._tail_lift_max_speed - self._tail_lift_min_speed + local percentage = 1-((math.abs(longit_speed) - self._tail_lift_min_speed)/speed_range) + if percentage > 1 then percentage = 1 end + if percentage < 0 then percentage = 0 end + local angle = self._tail_angle * percentage + local calculated_newpitch = math.rad(angle) + if newpitch < calculated_newpitch then newpitch = calculated_newpitch end --ja aproveita o pitch atual se ja estiver cerrto + if newpitch > math.rad(self._tail_angle) then newpitch = math.rad(self._tail_angle) end --não queremos arrastar o cauda no chão + end + + return newpitch +end + function airutils.logic(self) local velocity = self.object:get_velocity() local curr_pos = self.object:get_pos() @@ -256,17 +274,7 @@ function airutils.logic(self) -- adjust pitch at ground if math.abs(longit_speed) > self._tail_lift_min_speed then - if math.abs(longit_speed) < self._tail_lift_max_speed then - --minetest.chat_send_all(math.abs(longit_speed)) - local speed_range = self._tail_lift_max_speed - self._tail_lift_min_speed - percentage = 1-((math.abs(longit_speed) - self._tail_lift_min_speed)/speed_range) - if percentage > 1 then percentage = 1 end - if percentage < 0 then percentage = 0 end - local angle = self._tail_angle * percentage - local calculated_newpitch = math.rad(angle) - if newpitch < calculated_newpitch then newpitch = calculated_newpitch end --ja aproveita o pitch atual se ja estiver cerrto - if newpitch > math.rad(self._tail_angle) then newpitch = math.rad(self._tail_angle) end --não queremos arrastar o cauda no chão - end + newpitch = ground_pitch(self, longit_speed, newpitch) else if math.abs(longit_speed) < self._tail_lift_min_speed then newpitch = math.rad(self._tail_angle) @@ -351,8 +359,26 @@ function airutils.logic(self) end local new_accel = accel - if longit_speed > 1.5 then - new_accel = airutils.getLiftAccel(self, velocity, new_accel, longit_speed, roll, curr_pos, self._lift, 15000) + if longit_speed > self._min_speed*0.66 then + --[[lets do something interesting: + here I'll fake the longit speed effect for takeoff, to force the airplane + to use more runway + ]]-- + local factorized_longit_speed = longit_speed + if is_flying == false and airutils.quadBezier then + local takeoff_speed = self._min_speed * 4 --so first I'll consider the takeoff speed 4x the minimal flight speed + if longit_speed < takeoff_speed and longit_speed > self._min_speed then -- then if the airplane is above the mininam speed and bellow the take off + local scale = (longit_speed*1)/takeoff_speed --get a scale of current longit speed relative to takeoff speed + if scale == nil then scale = 0 end --lets avoid any nil + factorized_longit_speed = airutils.quadBezier(scale, self._min_speed, longit_speed, longit_speed) --here the magic happens using a bezier curve + --minetest.chat_send_all("factor: " .. factorized_longit_speed .. " - longit: " .. longit_speed .. " - scale: " .. scale) + if factorized_longit_speed < 0 then factorized_longit_speed = 0 end --lets avoid negative numbers + if factorized_longit_speed == nil then factorized_longit_speed = longit_speed end --and nil numbers + end + end + + local ceiling = 15000 + new_accel = airutils.getLiftAccel(self, velocity, new_accel, factorized_longit_speed, roll, curr_pos, self._lift, ceiling, self._wing_span) end -- end lift diff --git a/lib_planes/forms.lua b/lib_planes/forms.lua index 912c7ce..7949365 100644 --- a/lib_planes/forms.lua +++ b/lib_planes/forms.lua @@ -30,7 +30,7 @@ function airutils.pilot_formspec(name) if ent._yaw_by_mouse then yaw = "true" end basic_form = basic_form.."button[1,1.0;4,1;turn_on;Start/Stop Engines]" - basic_form = basic_form.."button[1,2.1;4,1;go_out;Go Offboard]" + basic_form = basic_form.."button[1,2.1;4,1;go_out;Go Out!]" basic_form = basic_form.."button[1,3.2;4,1;hud;Show/Hide Gauges]" basic_form = basic_form.."button[1,4.3;4,1;inventory;Show Inventory]" basic_form = basic_form.."checkbox[1,5.7;yaw;Yaw by mouse;"..yaw.."]" diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index f67dfc1..a9034fd 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -552,6 +552,10 @@ function airutils.paint_with_mask(self, colstr, target_texture, mask_texture) end function airutils.add_destruction_effects(pos, radius) + local node = airutils.nodeatpos(pos) + local is_liquid = false + if (node.drawtype == 'liquid' or node.drawtype == 'flowingliquid') then is_liquid = true end + minetest.sound_play("airutils_explode", { pos = pos, max_hear_distance = 100, @@ -559,32 +563,34 @@ function airutils.add_destruction_effects(pos, radius) fade = 0.0, pitch = 1.0, }, true) - minetest.add_particle({ - pos = pos, - velocity = vector.new(), - acceleration = vector.new(), - expirationtime = 0.4, - size = radius * 10, - collisiondetection = false, - vertical = false, - texture = "airutils_boom.png", - glow = 15, - }) - minetest.add_particlespawner({ - amount = 32, - time = 0.5, - minpos = vector.subtract(pos, radius / 2), - maxpos = vector.add(pos, radius / 2), - minvel = {x = -10, y = -10, z = -10}, - maxvel = {x = 10, y = 10, z = 10}, - minacc = vector.new(), - maxacc = vector.new(), - minexptime = 1, - maxexptime = 2.5, - minsize = radius * 3, - maxsize = radius * 5, - texture = "airutils_boom.png", - }) + if is_liquid == false then + minetest.add_particle({ + pos = pos, + velocity = vector.new(), + acceleration = vector.new(), + expirationtime = 0.4, + size = radius * 10, + collisiondetection = false, + vertical = false, + texture = "airutils_boom.png", + glow = 15, + }) + minetest.add_particlespawner({ + amount = 32, + time = 0.5, + minpos = vector.subtract(pos, radius / 2), + maxpos = vector.add(pos, radius / 2), + minvel = {x = -10, y = -10, z = -10}, + maxvel = {x = 10, y = 10, z = 10}, + minacc = vector.new(), + maxacc = vector.new(), + minexptime = 1, + maxexptime = 2.5, + minsize = radius * 3, + maxsize = radius * 5, + texture = "airutils_boom.png", + }) + end minetest.add_particlespawner({ amount = 64, time = 1.0, diff --git a/textures/airutils_alpha.png b/textures/airutils_alpha.png new file mode 100644 index 0000000..aae5d89 Binary files /dev/null and b/textures/airutils_alpha.png differ