diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/heli_control.lua b/heli_control.lua old mode 100644 new mode 100755 diff --git a/heli_fuel_management.lua b/heli_fuel_management.lua old mode 100644 new mode 100755 diff --git a/heli_hud.lua b/heli_hud.lua old mode 100644 new mode 100755 diff --git a/init.lua b/init.lua index d234cb1..7b7cd21 100755 --- a/init.lua +++ b/init.lua @@ -82,14 +82,15 @@ end -- attach player function helicopter.attach(self, player) local name = player:get_player_name() + self.driver_name = name -- sound and animation self.sound_handle = minetest.sound_play({name = "helicopter_motor"}, {object = self.object, gain = 2.0, max_hear_distance = 32, loop = true,}) self.object:set_animation_frame_speed(30) -- attach the driver - player:set_attach(self.object, "", {x = 0, y = 10.5, z = 2}, {x = 0, y = 0, z = 0}) - player:set_eye_offset({x = 0, y = 7, z = 3}, {x = 0, y = 8, z = -5}) + player:set_attach(self.object, "", {x = 4.2, y = 10.5, z = 2}, {x = 0, y = 0, z = 0}) + player:set_eye_offset({x = 4.2, y = 7, z = 2}, {x = 0, y = 8, z = -5}) player_api.player_attached[name] = true -- make the driver sit minetest.after(0.2, function() @@ -103,6 +104,62 @@ function helicopter.attach(self, player) self.object:set_acceleration(vector.new()) end +-- dettach player +function helicopter.dettach(self, player) + local name = player:get_player_name() + + -- driver clicked the object => driver gets off the vehicle + self.driver_name = nil + -- sound and animation + if self.sound_handle then + minetest.sound_stop(self.sound_handle) + self.sound_handle = nil + end + self.object:set_animation_frame_speed(0) + -- detach the player + player:set_detach() + player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) + player_api.player_attached[name] = nil + -- player should stand again + player_api.set_animation(player, "stand") + -- gravity + self.object:set_acceleration(vector.multiply(helicopter.vector_up, -helicopter.gravity)) + + --remove hud + if player then remove_heli_hud(player) end +end + +-- attach passenger +function helicopter.attach_pax(self, player) + local name = player:get_player_name() + self._passenger = name + -- attach the passenger + player:set_attach(self.object, "", {x = -4.2, y = 10.5, z = 2}, {x = 0, y = 0, z = 0}) + player:set_eye_offset({x = -4.2, y = 7, z = 3}, {x = 0, y = 8, z = -5}) + player_api.player_attached[name] = true + -- make the driver sit + minetest.after(0.2, function() + local player = minetest.get_player_by_name(name) + if player then + player_api.set_animation(player, "sit") + end + end) +end + +-- dettach passenger +function helicopter.dettach_pax(self, player) + local name = player:get_player_name() + + -- driver clicked the object => driver gets off the vehicle + self._passenger = nil + -- detach the player + player:set_detach() + player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) + player_api.player_attached[name] = nil + -- player should stand again + player_api.set_animation(player, "stand") +end + -- destroy the helicopter function helicopter.destroy(self) if self.sound_handle then @@ -161,7 +218,11 @@ minetest.register_entity("helicopter:heli", { selectionbox = {-1,0,-1, 1,0.3,1}, visual = "mesh", mesh = "helicopter_heli.b3d", - textures = {"helicopter_interior_black.png", "helicopter_metal.png", "helicopter_strips.png", "helicopter_painting.png", "helicopter_black.png", "helicopter_aluminum.png", "helicopter_glass.png", "helicopter_glass.png", "helicopter_interior.png", "helicopter_panel.png", "helicopter_colective.png", "helicopter_painting.png", "helicopter_rotors.png", "helicopter_interior_black.png",}, + backface_culling = false, + textures = {"helicopter_interior_black.png", "helicopter_metal.png", "helicopter_strips.png", + "helicopter_painting.png", "helicopter_black.png", "helicopter_aluminum.png", "helicopter_glass.png", + "helicopter_interior.png", "helicopter_panel.png", "helicopter_colective.png", "helicopter_painting.png", + "helicopter_rotors.png", "helicopter_interior_black.png",}, }, driver_name = nil, @@ -174,6 +235,7 @@ minetest.register_entity("helicopter:heli", { last_vel = vector.new(), hp = 50, color = "#0063b0", + _passenger = nil, get_staticdata = function(self) -- unloaded/unloads ... is now saved return minetest.serialize({ @@ -390,35 +452,6 @@ minetest.register_entity("helicopter:heli", { helicopter.destroy(self) end - --[[remove only when the pilot is not attached to the helicopter - if self.sound_handle then - minetest.sound_stop(self.sound_handle) - self.sound_handle = nil - end - if self.driver_name then - -- detach the driver first (puncher must be driver) - puncher:set_detach() - puncher:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) - player_api.player_attached[name] = nil - -- player should stand again - player_api.set_animation(puncher, "stand") - self.driver_name = nil - end - - if self.pointer then self.pointer:remove() end - self.object:remove() - - minetest.handle_node_drops(self.object:get_pos(), {"helicopter:heli"}, puncher)]]-- - --[[local inv = puncher:get_inventory() - if inv then - for _, item in ipairs({"helicopter:heli"}) do - local itemstack = inv:add_item("main", item) - local imeta = itemstack:get_meta() - imeta:set_int("damage", self.damage) - imeta:set_int("energy", self.energy) - end - end]]-- - end end, @@ -429,46 +462,39 @@ minetest.register_entity("helicopter:heli", { end local name = clicker:get_player_name() - if self.owner and self.owner ~= name and self.owner ~= "" then return end + if self.owner == "" then self.owner = name end - if name == self.driver_name then + if self.owner == name then + if name == self.driver_name then + -- driver clicked the object => driver gets off the vehicle + helicopter.dettach(self, clicker) + elseif not self.driver_name then + local is_under_water = helicopter.check_is_under_water(self.object) + if is_under_water then return end + -- temporary------ + self.hp = 50 -- why? cause I can desist from destroy + ------------------ - -- driver clicked the object => driver gets off the vehicle - self.driver_name = nil - -- sound and animation - if self.sound_handle then - minetest.sound_stop(self.sound_handle) - self.sound_handle = nil + helicopter.attach(self, clicker) + end + else + --passenger section + --only can enter when the pilot is inside + if self.driver_name then + if self._passenger == nil then + helicopter.attach_pax(self, clicker) + else + helicopter.detach_pax(self, clicker) + end + else + if self._passenger then + helicopter.detach_pax(self, clicker) + end end - self.object:set_animation_frame_speed(0) - -- detach the player - clicker:set_detach() - clicker:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) - player_api.player_attached[name] = nil - -- player should stand again - player_api.set_animation(clicker, "stand") - -- gravity - self.object:set_acceleration(vector.multiply(helicopter.vector_up, -helicopter.gravity)) - - --remove hud - if clicker then remove_heli_hud(clicker) end - - elseif not self.driver_name then - local is_under_water = helicopter.check_is_under_water(self.object) - if is_under_water then return end - - -- no driver => clicker is new driver - self.driver_name = name - - -- temporary------ - self.hp = 50 -- why? cause I can desist from destroy - ------------------ - - helicopter.attach(self, clicker) - end + end end, }) diff --git a/matrix.lua b/matrix.lua old mode 100644 new mode 100755 diff --git a/models/helicopter_heli.b3d b/models/helicopter_heli.b3d index 40c7533..f58cab6 100755 Binary files a/models/helicopter_heli.b3d and b/models/helicopter_heli.b3d differ diff --git a/models/pointer.b3d b/models/pointer.b3d old mode 100644 new mode 100755 diff --git a/models/src/heli_glass.png b/models/src/heli_glass.png index 2291acb..f396908 100755 Binary files a/models/src/heli_glass.png and b/models/src/heli_glass.png differ diff --git a/models/src/helicopter.blend b/models/src/helicopter.blend old mode 100644 new mode 100755 index c667b83..c97e487 Binary files a/models/src/helicopter.blend and b/models/src/helicopter.blend differ diff --git a/models/src/helicopter.blend1 b/models/src/helicopter.blend1 old mode 100644 new mode 100755 index d86e09c..2af6e1a Binary files a/models/src/helicopter.blend1 and b/models/src/helicopter.blend1 differ diff --git a/models/src/panel.xcf b/models/src/panel.xcf old mode 100644 new mode 100755 diff --git a/models/src/pointer.blend b/models/src/pointer.blend old mode 100644 new mode 100755 diff --git a/models/src/rotors.png b/models/src/rotors.png old mode 100644 new mode 100755 diff --git a/models/src/textures/heli_glass.png b/models/src/textures/heli_glass.png new file mode 100755 index 0000000..406b290 Binary files /dev/null and b/models/src/textures/heli_glass.png differ diff --git a/screenshot.png b/screenshot.png old mode 100644 new mode 100755 diff --git a/sounds/collision.ogg b/sounds/collision.ogg old mode 100644 new mode 100755 diff --git a/sounds/helicopter_motor.ogg b/sounds/helicopter_motor.ogg old mode 100644 new mode 100755 diff --git a/textures/flight_info_bg.png b/textures/flight_info_bg.png old mode 100644 new mode 100755 diff --git a/textures/helicopter_glass.png b/textures/helicopter_glass.png index 2291acb..f396908 100755 Binary files a/textures/helicopter_glass.png and b/textures/helicopter_glass.png differ diff --git a/textures/helicopter_rotors.png b/textures/helicopter_rotors.png old mode 100644 new mode 100755