mirror of
https://github.com/minetest/minetest.git
synced 2024-11-04 14:53:45 +01:00
Extend pitch fly mode to swimming (#7943)
This commit is contained in:
parent
7d7ccf5c0f
commit
aa5ec2ec02
@ -65,7 +65,7 @@ Some can be changed in the key config dialog in the settings tab.
|
|||||||
| + | Increase view range |
|
| + | Increase view range |
|
||||||
| - | Decrease view range |
|
| - | Decrease view range |
|
||||||
| K | Enable/disable fly mode (needs fly privilege) |
|
| K | Enable/disable fly mode (needs fly privilege) |
|
||||||
| L | Enable/disable pitch fly mode |
|
| L | Enable/disable pitch move mode |
|
||||||
| J | Enable/disable fast mode (needs fast privilege) |
|
| J | Enable/disable fast mode (needs fast privilege) |
|
||||||
| H | Enable/disable noclip mode (needs noclip privilege) |
|
| H | Enable/disable noclip mode (needs noclip privilege) |
|
||||||
| E | Move fast in fast mode |
|
| E | Move fast in fast mode |
|
||||||
|
@ -72,8 +72,8 @@ enable_build_where_you_stand (Build inside player) bool false
|
|||||||
# This requires the "fly" privilege on the server.
|
# This requires the "fly" privilege on the server.
|
||||||
free_move (Flying) bool false
|
free_move (Flying) bool false
|
||||||
|
|
||||||
# If enabled together with fly mode, makes move directions relative to the player's pitch.
|
# If enabled, makes move directions relative to the player's pitch when flying or swimming.
|
||||||
pitch_fly (Pitch fly mode) bool false
|
pitch_move (Pitch move mode) bool false
|
||||||
|
|
||||||
# Fast movement (via the "special" key).
|
# Fast movement (via the "special" key).
|
||||||
# This requires the "fast" privilege on the server.
|
# This requires the "fast" privilege on the server.
|
||||||
@ -211,9 +211,9 @@ keymap_rangeselect (Range select key) key KEY_KEY_R
|
|||||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||||
keymap_freemove (Fly key) key KEY_KEY_K
|
keymap_freemove (Fly key) key KEY_KEY_K
|
||||||
|
|
||||||
# Key for toggling pitch fly mode.
|
# Key for toggling pitch move mode.
|
||||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||||
keymap_pitchfly (Pitch fly key) key KEY_KEY_L
|
keymap_pitchmove (Pitch move key) key KEY_KEY_L
|
||||||
|
|
||||||
# Key for toggling fast mode.
|
# Key for toggling fast mode.
|
||||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
# type: bool
|
# type: bool
|
||||||
# free_move = false
|
# free_move = false
|
||||||
|
|
||||||
# If enabled together with fly mode, makes move directions relative to the player's pitch.
|
# If enabled, makes move directions relative to the player's pitch when flying or swimming.
|
||||||
# type: bool
|
# type: bool
|
||||||
# pitch_fly = false
|
# pitch_move = false
|
||||||
|
|
||||||
# Fast movement (via the "special" key).
|
# Fast movement (via the "special" key).
|
||||||
# This requires the "fast" privilege on the server.
|
# This requires the "fast" privilege on the server.
|
||||||
@ -202,10 +202,10 @@
|
|||||||
# type: key
|
# type: key
|
||||||
# keymap_freemove = KEY_KEY_K
|
# keymap_freemove = KEY_KEY_K
|
||||||
|
|
||||||
# Key for toggling pitch fly mode.
|
# Key for toggling pitch move mode.
|
||||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||||
# type: key
|
# type: key
|
||||||
# keymap_pitchfly = KEY_KEY_L
|
# keymap_pitchmove = KEY_KEY_L
|
||||||
|
|
||||||
# Key for toggling fast mode.
|
# Key for toggling fast mode.
|
||||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||||
|
@ -170,7 +170,8 @@ void ClientEnvironment::step(float dtime)
|
|||||||
lplayer->physics_override_gravity * dtime_part * 2.0f;
|
lplayer->physics_override_gravity * dtime_part * 2.0f;
|
||||||
|
|
||||||
// Liquid floating / sinking
|
// Liquid floating / sinking
|
||||||
if (lplayer->in_liquid && !lplayer->swimming_vertical)
|
if (lplayer->in_liquid && !lplayer->swimming_vertical &&
|
||||||
|
!lplayer->swimming_pitch)
|
||||||
speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
|
speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
|
||||||
|
|
||||||
// Liquid resistance
|
// Liquid resistance
|
||||||
|
@ -702,7 +702,7 @@ protected:
|
|||||||
void openConsole(float scale, const wchar_t *line=NULL);
|
void openConsole(float scale, const wchar_t *line=NULL);
|
||||||
void toggleFreeMove();
|
void toggleFreeMove();
|
||||||
void toggleFreeMoveAlt();
|
void toggleFreeMoveAlt();
|
||||||
void togglePitchFly();
|
void togglePitchMove();
|
||||||
void toggleFast();
|
void toggleFast();
|
||||||
void toggleNoClip();
|
void toggleNoClip();
|
||||||
void toggleCinematic();
|
void toggleCinematic();
|
||||||
@ -1898,8 +1898,8 @@ void Game::processKeyInput()
|
|||||||
toggleFreeMove();
|
toggleFreeMove();
|
||||||
} else if (wasKeyDown(KeyType::JUMP)) {
|
} else if (wasKeyDown(KeyType::JUMP)) {
|
||||||
toggleFreeMoveAlt();
|
toggleFreeMoveAlt();
|
||||||
} else if (wasKeyDown(KeyType::PITCHFLY)) {
|
} else if (wasKeyDown(KeyType::PITCHMOVE)) {
|
||||||
togglePitchFly();
|
togglePitchMove();
|
||||||
} else if (wasKeyDown(KeyType::FASTMOVE)) {
|
} else if (wasKeyDown(KeyType::FASTMOVE)) {
|
||||||
toggleFast();
|
toggleFast();
|
||||||
} else if (wasKeyDown(KeyType::NOCLIP)) {
|
} else if (wasKeyDown(KeyType::NOCLIP)) {
|
||||||
@ -2109,15 +2109,15 @@ void Game::toggleFreeMoveAlt()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Game::togglePitchFly()
|
void Game::togglePitchMove()
|
||||||
{
|
{
|
||||||
bool pitch_fly = !g_settings->getBool("pitch_fly");
|
bool pitch_move = !g_settings->getBool("pitch_move");
|
||||||
g_settings->set("pitch_fly", bool_to_cstr(pitch_fly));
|
g_settings->set("pitch_move", bool_to_cstr(pitch_move));
|
||||||
|
|
||||||
if (pitch_fly) {
|
if (pitch_move) {
|
||||||
m_game_ui->showTranslatedStatusText("Pitch fly mode enabled");
|
m_game_ui->showTranslatedStatusText("Pitch move mode enabled");
|
||||||
} else {
|
} else {
|
||||||
m_game_ui->showTranslatedStatusText("Pitch fly mode disabled");
|
m_game_ui->showTranslatedStatusText("Pitch move mode disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ void KeyCache::populate()
|
|||||||
key[KeyType::CONSOLE] = getKeySetting("keymap_console");
|
key[KeyType::CONSOLE] = getKeySetting("keymap_console");
|
||||||
key[KeyType::MINIMAP] = getKeySetting("keymap_minimap");
|
key[KeyType::MINIMAP] = getKeySetting("keymap_minimap");
|
||||||
key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove");
|
key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove");
|
||||||
key[KeyType::PITCHFLY] = getKeySetting("keymap_pitchfly");
|
key[KeyType::PITCHMOVE] = getKeySetting("keymap_pitchmove");
|
||||||
key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove");
|
key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove");
|
||||||
key[KeyType::NOCLIP] = getKeySetting("keymap_noclip");
|
key[KeyType::NOCLIP] = getKeySetting("keymap_noclip");
|
||||||
key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous");
|
key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous");
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
CONSOLE,
|
CONSOLE,
|
||||||
MINIMAP,
|
MINIMAP,
|
||||||
FREEMOVE,
|
FREEMOVE,
|
||||||
PITCHFLY,
|
PITCHMOVE,
|
||||||
FASTMOVE,
|
FASTMOVE,
|
||||||
NOCLIP,
|
NOCLIP,
|
||||||
HOTBAR_PREV,
|
HOTBAR_PREV,
|
||||||
|
@ -468,6 +468,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
|||||||
{
|
{
|
||||||
// Clear stuff
|
// Clear stuff
|
||||||
swimming_vertical = false;
|
swimming_vertical = false;
|
||||||
|
swimming_pitch = false;
|
||||||
|
|
||||||
setPitch(control.pitch);
|
setPitch(control.pitch);
|
||||||
setYaw(control.yaw);
|
setYaw(control.yaw);
|
||||||
@ -492,7 +493,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
|||||||
|
|
||||||
bool free_move = fly_allowed && player_settings.free_move;
|
bool free_move = fly_allowed && player_settings.free_move;
|
||||||
bool fast_move = fast_allowed && player_settings.fast_move;
|
bool fast_move = fast_allowed && player_settings.fast_move;
|
||||||
bool pitch_fly = free_move && player_settings.pitch_fly;
|
bool pitch_move = (free_move || in_liquid) && player_settings.pitch_move;
|
||||||
// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
|
// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
|
||||||
bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends;
|
bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends;
|
||||||
bool continuous_forward = player_settings.continuous_forward;
|
bool continuous_forward = player_settings.continuous_forward;
|
||||||
@ -685,10 +686,17 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
|||||||
if (!free_move)
|
if (!free_move)
|
||||||
slip_factor = getSlipFactor(env, speedH);
|
slip_factor = getSlipFactor(env, speedH);
|
||||||
|
|
||||||
|
// Don't sink when swimming in pitch mode
|
||||||
|
if (pitch_move && in_liquid) {
|
||||||
|
v3f controlSpeed = speedH + speedV;
|
||||||
|
if (controlSpeed.getLength() > 0.01f)
|
||||||
|
swimming_pitch = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Accelerate to target speed with maximum increment
|
// Accelerate to target speed with maximum increment
|
||||||
accelerate((speedH + speedV) * physics_override_speed,
|
accelerate((speedH + speedV) * physics_override_speed,
|
||||||
incH * physics_override_speed * slip_factor, incV * physics_override_speed,
|
incH * physics_override_speed * slip_factor, incV * physics_override_speed,
|
||||||
pitch_fly);
|
pitch_move);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3s16 LocalPlayer::getStandingNodePos()
|
v3s16 LocalPlayer::getStandingNodePos()
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
u8 liquid_viscosity = 0;
|
u8 liquid_viscosity = 0;
|
||||||
bool is_climbing = false;
|
bool is_climbing = false;
|
||||||
bool swimming_vertical = false;
|
bool swimming_vertical = false;
|
||||||
|
bool swimming_pitch = false;
|
||||||
|
|
||||||
float physics_override_speed = 1.0f;
|
float physics_override_speed = 1.0f;
|
||||||
float physics_override_jump = 1.0f;
|
float physics_override_jump = 1.0f;
|
||||||
|
@ -43,7 +43,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("meshgen_block_cache_size", "20");
|
settings->setDefault("meshgen_block_cache_size", "20");
|
||||||
settings->setDefault("enable_vbo", "true");
|
settings->setDefault("enable_vbo", "true");
|
||||||
settings->setDefault("free_move", "false");
|
settings->setDefault("free_move", "false");
|
||||||
settings->setDefault("pitch_fly", "false");
|
settings->setDefault("pitch_move", "false");
|
||||||
settings->setDefault("fast_move", "false");
|
settings->setDefault("fast_move", "false");
|
||||||
settings->setDefault("noclip", "false");
|
settings->setDefault("noclip", "false");
|
||||||
settings->setDefault("screenshot_path", ".");
|
settings->setDefault("screenshot_path", ".");
|
||||||
@ -81,7 +81,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("keymap_console", "KEY_F10");
|
settings->setDefault("keymap_console", "KEY_F10");
|
||||||
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
||||||
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
||||||
settings->setDefault("keymap_pitchfly", "KEY_KEY_L");
|
settings->setDefault("keymap_pitchmove", "KEY_KEY_L");
|
||||||
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
||||||
settings->setDefault("keymap_noclip", "KEY_KEY_H");
|
settings->setDefault("keymap_noclip", "KEY_KEY_H");
|
||||||
settings->setDefault("keymap_hotbar_next", "KEY_KEY_N");
|
settings->setDefault("keymap_hotbar_next", "KEY_KEY_N");
|
||||||
|
@ -139,7 +139,7 @@ void Player::clearHud()
|
|||||||
void PlayerSettings::readGlobalSettings()
|
void PlayerSettings::readGlobalSettings()
|
||||||
{
|
{
|
||||||
free_move = g_settings->getBool("free_move");
|
free_move = g_settings->getBool("free_move");
|
||||||
pitch_fly = g_settings->getBool("pitch_fly");
|
pitch_move = g_settings->getBool("pitch_move");
|
||||||
fast_move = g_settings->getBool("fast_move");
|
fast_move = g_settings->getBool("fast_move");
|
||||||
continuous_forward = g_settings->getBool("continuous_forward");
|
continuous_forward = g_settings->getBool("continuous_forward");
|
||||||
always_fly_fast = g_settings->getBool("always_fly_fast");
|
always_fly_fast = g_settings->getBool("always_fly_fast");
|
||||||
|
@ -87,7 +87,7 @@ struct PlayerControl
|
|||||||
struct PlayerSettings
|
struct PlayerSettings
|
||||||
{
|
{
|
||||||
bool free_move = false;
|
bool free_move = false;
|
||||||
bool pitch_fly = false;
|
bool pitch_move = false;
|
||||||
bool fast_move = false;
|
bool fast_move = false;
|
||||||
bool continuous_forward = false;
|
bool continuous_forward = false;
|
||||||
bool always_fly_fast = false;
|
bool always_fly_fast = false;
|
||||||
@ -96,7 +96,7 @@ struct PlayerSettings
|
|||||||
bool autojump = false;
|
bool autojump = false;
|
||||||
|
|
||||||
const std::string setting_names[8] = {
|
const std::string setting_names[8] = {
|
||||||
"free_move", "pitch_fly", "fast_move", "continuous_forward", "always_fly_fast",
|
"free_move", "pitch_move", "fast_move", "continuous_forward", "always_fly_fast",
|
||||||
"aux1_descends", "noclip", "autojump"
|
"aux1_descends", "noclip", "autojump"
|
||||||
};
|
};
|
||||||
void readGlobalSettings();
|
void readGlobalSettings();
|
||||||
|
Loading…
Reference in New Issue
Block a user