mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add settings to enable/disable camera tilt and flash effects from damage
Added a setting to enable and disable camera tilt and flash. Added settings to control the duration and strength of camera tilt.
This commit is contained in:
parent
7ac5502fdf
commit
ac57714ba0
4 changed files with 41 additions and 5 deletions
|
@ -130,6 +130,11 @@ local function load()
|
|||
{ heading = fgettext_ne("Movement") },
|
||||
"arm_inertia",
|
||||
"view_bobbing_amount",
|
||||
{ heading = fgettext_ne("Damage") },
|
||||
"damage_flash_enable",
|
||||
"damage_tilt_enable",
|
||||
"damage_tilt_strength",
|
||||
"damage_tilt_duration",
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -556,6 +556,26 @@ arm_inertia (Arm inertia) bool true
|
|||
# For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
|
||||
view_bobbing_amount (View bobbing factor) float 1.0 0.0 7.9
|
||||
|
||||
[**Damage]
|
||||
|
||||
# Damage flash, causes the screen to flash reduce
|
||||
# when the player takes damage.
|
||||
damage_flash_enable (Damage flash) bool true
|
||||
|
||||
# Damage tilt, causes the screen to shake
|
||||
# when the player takes damage
|
||||
damage_tilt_enable (Damage shake) bool true
|
||||
|
||||
# Damage tilt strength. Controls the force of
|
||||
# camera shakes from taking damage
|
||||
damage_tilt_strength (Damage shake strength) float 1.0 0.0 2.0
|
||||
|
||||
# Damage tilt duration modifier. Controls the duration of
|
||||
# camera shakes from taking damage.
|
||||
# 0.0 for no time, 1.0 for normal time, 2.0 for twice as long.
|
||||
damage_tilt_duration (Damage shake duration) float 1.0 0.0 2.0
|
||||
|
||||
|
||||
[**Camera]
|
||||
|
||||
# Field of view in degrees.
|
||||
|
|
|
@ -2687,12 +2687,19 @@ void Game::handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation
|
|||
player->getCAO()->getProperties().hp_max : PLAYER_MAX_HP_DEFAULT;
|
||||
f32 damage_ratio = event->player_damage.amount / hp_max;
|
||||
|
||||
runData.damage_flash += 95.0f + 64.f * damage_ratio;
|
||||
runData.damage_flash = MYMIN(runData.damage_flash, 127.0f);
|
||||
if(g_settings->getBool("damage_flash_enable")) {
|
||||
runData.damage_flash += 95.0f + 64.f * damage_ratio;
|
||||
runData.damage_flash = MYMIN(runData.damage_flash, 127.0f);
|
||||
}
|
||||
|
||||
player->hurt_tilt_timer = 1.5f;
|
||||
player->hurt_tilt_strength =
|
||||
rangelim(damage_ratio * 5.0f, 1.0f, 4.0f);
|
||||
f32 tilt_duration = g_settings->getFloat("damage_tilt_duration");
|
||||
if (tilt_duration > 0 && g_settings->getBool("damage_tilt_enable")) {
|
||||
player->hurt_tilt_timer = 1.5f * tilt_duration;
|
||||
|
||||
f32 tilt_strength = g_settings->getFloat("damage_tilt_strength");
|
||||
player->hurt_tilt_strength =
|
||||
rangelim(damage_ratio * 5.0f, 1.0f, 4.0f) * tilt_strength;
|
||||
}
|
||||
}
|
||||
|
||||
// Play damage sound
|
||||
|
|
|
@ -306,6 +306,10 @@ void set_default_settings()
|
|||
settings->setDefault("show_entity_selectionbox", "false");
|
||||
settings->setDefault("ambient_occlusion_gamma", "1.8");
|
||||
settings->setDefault("arm_inertia", "true");
|
||||
settings->setDefault("damage_flash_enable", "true");
|
||||
settings->setDefault("damage_tilt_enable", "true");
|
||||
settings->setDefault("damage_tilt_strength", "1.0");
|
||||
settings->setDefault("damage_tilt_duration", "1.0");
|
||||
settings->setDefault("show_nametag_backgrounds", "true");
|
||||
settings->setDefault("show_block_bounds_radius_near", "4");
|
||||
settings->setDefault("transparency_sorting_group_by_buffers", "true");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue