Skip to content

Commit

Permalink
Fixed more damage <0 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tondorian committed Mar 14, 2016
1 parent a9fdd28 commit 6cc070f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/game_battlealgorithm.cpp
Expand Up @@ -482,6 +482,10 @@ bool Game_BattleAlgorithm::Normal::Execute() {
}

int effect = (source->GetAtk() / 2 - (*current_target)->GetDef() / 4);

if (effect < 0)
effect = 0;

int act_perc = (rand() % 40) - 20;
// Change rounded up
int change = (int)(std::ceil(effect * act_perc / 100.0));
Expand Down Expand Up @@ -614,6 +618,9 @@ bool Game_BattleAlgorithm::Skill::Execute() {

// TODO: Phys/Magic attribute: Phys.Attribute /100 x Magic.Attribute /100
// see #480
if(effect < 0) {
effect = 0;
}

effect += rand() % (((effect * skill.variance / 10) + 1) - (effect * skill.variance / 20));

Expand Down Expand Up @@ -977,13 +984,18 @@ bool Game_BattleAlgorithm::SelfDestruct::Execute() {
// Like a normal attack, but with double damage and always hitting
// Never crits, ignores charge
int effect = source->GetAtk() - (*current_target)->GetDef() / 2;

if (effect < 0)
effect = 0;

// up to 20% stronger/weaker
int act_perc = (rand() % 40) - 20;
int change = (int)(std::ceil(effect * act_perc / 100.0));
effect += change;

if (effect < 0)
effect = 0;

this->hp = effect / ((*current_target)->IsDefending() ? 2 : 1);;

if ((*current_target)->GetHp() - this->hp <= 0) {
Expand Down

0 comments on commit 6cc070f

Please sign in to comment.