mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
added training mode
This commit is contained in:
parent
f7065a2766
commit
4f26cbd07d
3 changed files with 25 additions and 14 deletions
|
@ -241,7 +241,10 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
|
||||||
|
|
||||||
local retval_accel = accel
|
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
|
--climb
|
||||||
local velocity = self.object:get_velocity()
|
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;
|
local engineacc = (self._power_lever * self._max_engine_acc) / 100;
|
||||||
--self.engine:set_animation_frame_speed(60 + self._power_lever)
|
--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
|
--increase power lever
|
||||||
if climb_rate > 0.2 then
|
if climb_rate > 0.2 then
|
||||||
airutils.powerAdjust(self, dtime, factor, -1)
|
airutils.powerAdjust(self, dtime, factor, -1)
|
||||||
end
|
end
|
||||||
--decrease power lever
|
--decrease power lever
|
||||||
if climb_rate < 0 then
|
if climb_rate < 0 then
|
||||||
airutils.powerAdjust(self, dtime, factor, 1, max_autopilot_power)
|
airutils.powerAdjust(self, dtime, factor, 1)
|
||||||
end
|
end
|
||||||
--do not exceed
|
--do not exceed
|
||||||
local max_speed = self._max_speed
|
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)
|
retval_accel=vector.add(retval_accel,hull_acc)
|
||||||
|
|
||||||
--pitch
|
--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)
|
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)
|
airutils.set_pitch(self, -1, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -291,9 +294,9 @@ function airutils.autopilot(self, dtime, hull_direction, longit_speed, accel, cu
|
||||||
if longit_speed > 0 then
|
if longit_speed > 0 then
|
||||||
airutils.rudder_auto_correction(self, longit_speed, dtime)
|
airutils.rudder_auto_correction(self, longit_speed, dtime)
|
||||||
if airutils.elevator_auto_correction then
|
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]]--
|
end
|
||||||
|
|
||||||
return retval_accel
|
return retval_accel
|
||||||
end
|
end
|
||||||
|
|
|
@ -169,7 +169,7 @@ function airutils.logic(self)
|
||||||
---------------------
|
---------------------
|
||||||
-- change the driver
|
-- 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 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
|
if ctrl.sneak or ctrl.jump or ctrl.up or ctrl.down or ctrl.right or ctrl.left then
|
||||||
self._last_time_command = 0
|
self._last_time_command = 0
|
||||||
|
@ -177,11 +177,11 @@ function airutils.logic(self)
|
||||||
airutils.transfer_control(self, false)
|
airutils.transfer_control(self, false)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--[[if ctrl.sneak == true and ctrl.jump == true then
|
if ctrl.sneak == true and ctrl.jump == true then
|
||||||
self._last_time_command = 0
|
self._last_time_command = 0
|
||||||
--trasnfer the control to student
|
--trasnfer the control to student
|
||||||
airutils.transfer_control(self, true)
|
airutils.transfer_control(self, true)
|
||||||
end]]--
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-----------
|
-----------
|
||||||
|
@ -195,7 +195,7 @@ function airutils.logic(self)
|
||||||
minetest.chat_send_player(self.driver_name," >>> Autopilot deactivated")
|
minetest.chat_send_player(self.driver_name," >>> Autopilot deactivated")
|
||||||
end
|
end
|
||||||
else
|
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._last_time_command = 0
|
||||||
self._autopilot = true
|
self._autopilot = true
|
||||||
self._auto_pilot_altitude = curr_pos.y
|
self._auto_pilot_altitude = curr_pos.y
|
||||||
|
@ -771,8 +771,15 @@ function airutils.on_rightclick(self, clicker)
|
||||||
end
|
end
|
||||||
|
|
||||||
--attach player
|
--attach player
|
||||||
-- no driver => clicker is new driver
|
if clicker:get_player_control().sneak == true then
|
||||||
airutils.attach(self, clicker)
|
-- 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
|
self._command_is_given = false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -820,7 +820,8 @@ function airutils.rescueConnectionFailedPassengers(self)
|
||||||
if self._passengers[i] then
|
if self._passengers[i] then
|
||||||
local player = minetest.get_player_by_name(self._passengers[i])
|
local player = minetest.get_player_by_name(self._passengers[i])
|
||||||
if player then --we have a player!
|
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")
|
--minetest.chat_send_all("okay")
|
||||||
if player:get_hp() > 0 then
|
if player:get_hp() > 0 then
|
||||||
self._passengers[i] = nil --clear the slot first
|
self._passengers[i] = nil --clear the slot first
|
||||||
|
|
Loading…
Add table
Reference in a new issue