Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate quick light red translucid flash when step on damaged terrain. #1389

Merged
merged 2 commits into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/game_party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ int Game_Party::GetRunCount() {
return data.escapes;
}

void Game_Party::ApplyDamage(int damage) {
void Game_Party::ApplyDamage(int damage, bool lethal) {
if (damage <= 0) {
return;
}
Expand All @@ -420,7 +420,7 @@ void Game_Party::ApplyDamage(int damage) {

for (std::vector<Game_Actor*>::iterator i = actors.begin(); i != actors.end(); ++i) {
Game_Actor* actor = *i;
actor->SetHp(actor->GetHp() - damage);
actor->ChangeHp(lethal? -damage : - std::max<int>(0, std::min<int>(damage, actor->GetHp() - 1)));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/game_party.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ class Game_Party : public Game_Party_Base {
* Used by damage terrain on the map.
*
* @param damage How many damage to apply
* @param lethal If the damage can be lethal (kill a character) or not
*/
void ApplyDamage(int damage);
void ApplyDamage(int damage, bool lethal);

/**
* Gets average level of the party (for battle)
Expand Down
5 changes: 4 additions & 1 deletion src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ void Game_Player::BeginMove() {
if (!terrain->on_damage_se || (terrain->on_damage_se && (terrain->damage > 0))) {
Game_System::SePlay(terrain->footstep);
}
Main_Data::game_party->ApplyDamage(terrain->damage);
if (terrain->damage > 0) {
Main_Data::game_screen->FlashOnce(31, 10, 10, 19, 1);
Main_Data::game_party->ApplyDamage(terrain->damage, false);
}
} else {
Output::Warning("Player BeginMove: Invalid terrain ID %d at (%d, %d)", terrain_id, GetX(), GetY());
}
Expand Down