aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2016-10-05 01:25:02 +0100
committerparamat <mat.gregory@virginmedia.com>2016-10-21 05:48:53 +0100
commit0c76303186d968db89d699d9e512aea9904378bc (patch)
tree79b85d905cb457d87f24761082fa72e3523551e7
parent63a3bb229a9ff288ab01e3e80c8477da5e84ee1e (diff)
downloadminetest-0c76303186d968db89d699d9e512aea9904378bc.tar.gz
minetest-0c76303186d968db89d699d9e512aea9904378bc.tar.bz2
minetest-0c76303186d968db89d699d9e512aea9904378bc.zip
Damage flash: Reduce maximum alpha. Avoid fade overload
Flash alpha maximum is reduced from 180 to 127 to avoid player blindness in combat. Flash alpha minimum is unchanged. The 'damage_flash' value is now limited to max alpha, to avoid multiple hits creating a huge value that causes flash to stay at maximum alpha for a long period. Now alpha always starts to fade immediately after taking damage. Both problems can be seen in Minetest let's play videos. Simplify and optimise some code.
-rw-r--r--src/game.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 3ba600ed5..1e4464cc4 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3374,12 +3374,12 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
//u16 damage = event.player_damage.amount;
//infostream<<"Player damage: "<<damage<<std::endl;
- *damage_flash += 100.0;
- *damage_flash += 8.0 * event.player_damage.amount;
+ *damage_flash += 95.0 + 3.2 * event.player_damage.amount;
+ *damage_flash = MYMIN(*damage_flash, 127.0);
player->hurt_tilt_timer = 1.5;
- player->hurt_tilt_strength = event.player_damage.amount / 4;
- player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 1.0, 4.0);
+ player->hurt_tilt_strength =
+ rangelim(event.player_damage.amount / 4, 1.0, 4.0);
MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
gamedef->event()->put(e);
@@ -4285,10 +4285,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats,
Damage flash
*/
if (runData->damage_flash > 0.0) {
- video::SColor color(std::min(runData->damage_flash, 180.0f),
- 180,
- 0,
- 0);
+ video::SColor color(runData->damage_flash, 180, 0, 0);
driver->draw2DRectangle(color,
core::rect<s32>(0, 0, screensize.X, screensize.Y),
NULL);