added training mode

This commit is contained in:
Alexsandro Percy 2023-07-06 21:31:15 -03:00
parent f7065a2766
commit 4f26cbd07d
3 changed files with 25 additions and 14 deletions

View file

@ -241,7 +241,10 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
local retval_accel = accel
--[[local max_autopilot_power = 85
if not self._have_auto_pilot then return end
local max_autopilot_power = 85
local max_attack_angle = 1.8
--climb
local velocity = self.object:get_velocity()
@ -257,14 +260,14 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
local engineacc = (self._power_lever * self._max_engine_acc) / 100;
--self.engine:set_animation_frame_speed(60 + self._power_lever)
local factor = math.abs(climb_rate * 0.1) --getAdjustFactor(curr_pos.y, self._auto_pilot_altitude)
local factor = math.abs(climb_rate * 0.1)
--increase power lever
if climb_rate > 0.2 then
airutils.powerAdjust(self, dtime, factor, -1)
end
--decrease power lever
if climb_rate < 0 then
airutils.powerAdjust(self, dtime, factor, 1, max_autopilot_power)
airutils.powerAdjust(self, dtime, factor, 1)
end
--do not exceed
local max_speed = self._max_speed
@ -279,9 +282,9 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
retval_accel=vector.add(retval_accel,hull_acc)
--pitch
if self._angle_of_attack > self._max_attack_angle then
if self._angle_of_attack > max_attack_angle then
airutils.set_pitch(self, 1, dtime)
elseif self._angle_of_attack < self._max_attack_angle then
elseif self._angle_of_attack < max_attack_angle then
airutils.set_pitch(self, -1, dtime)
end
@ -291,9 +294,9 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
if longit_speed > 0 then
airutils.rudder_auto_correction(self, longit_speed, dtime)
if airutils.elevator_auto_correction then
self._elevator_angle = airutils.elevator_auto_correction(self, longit_speed, self.dtime, airutils.max_speed, self._elevator_angle, airutils.elevator_limit, airutils.ideal_step, self._elevator_auto_estabilize)
self._elevator_angle = airutils.elevator_auto_correction(self, longit_speed, self.dtime, self._max_speed, self._elevator_angle, self._elevator_limit, airutils.ideal_step, 500)
end
end]]--
end
return retval_accel
end

View file

@ -169,7 +169,7 @@ function airutils.logic(self)
---------------------
-- change the driver
---------------------
if co_pilot and self._have_copilot and self._last_time_command >= 1 and self._instruction_mode == true then
if co_pilot and self._have_copilot and self._last_time_command >= 1 then
if self._command_is_given == true then
if ctrl.sneak or ctrl.jump or ctrl.up or ctrl.down or ctrl.right or ctrl.left then
self._last_time_command = 0
@ -177,11 +177,11 @@ function airutils.logic(self)
airutils.transfer_control(self, false)
end
else
--[[if ctrl.sneak == true and ctrl.jump == true then
if ctrl.sneak == true and ctrl.jump == true then
self._last_time_command = 0
--trasnfer the control to student
airutils.transfer_control(self, true)
end]]--
end
end
end
-----------
@ -195,7 +195,7 @@ function airutils.logic(self)
minetest.chat_send_player(self.driver_name," >>> Autopilot deactivated")
end
else
if ctrl.sneak == true and ctrl.jump == true then
if ctrl.sneak == true and ctrl.jump == true and self._have_auto_pilot then
self._last_time_command = 0
self._autopilot = true
self._auto_pilot_altitude = curr_pos.y
@ -771,8 +771,15 @@ function airutils.on_rightclick(self, clicker)
end
--attach player
-- no driver => clicker is new driver
airutils.attach(self, clicker)
if clicker:get_player_control().sneak == true then
-- flight instructor mode
self._instruction_mode = true
airutils.attach(self, clicker, true)
else
-- no driver => clicker is new driver
self._instruction_mode = false
airutils.attach(self, clicker)
end
self._command_is_given = false
end
else

View file

@ -820,7 +820,8 @@ function airutils.rescueConnectionFailedPassengers(self)
if self._passengers[i] then
local player = minetest.get_player_by_name(self._passengers[i])
if player then --we have a player!
if player_api.player_attached[self._passengers[i]] == nil then --but isn't attached?
if player:get_attach() == nil then
--if player_api.player_attached[self._passengers[i]] == nil then --but isn't attached?
--minetest.chat_send_all("okay")
if player:get_hp() > 0 then
self._passengers[i] = nil --clear the slot first