Permalink
Browse files

should fix negativ Damage on attack and condition appyement

  • Loading branch information...
Tondorian committed Mar 14, 2016
1 parent 970810d commit a9fdd28966ff871fbacd956848c7b85e4741cb12
Showing with 25 additions and 7 deletions.
  1. +3 −3 src/game_battlealgorithm.cpp
  2. +22 −4 src/game_battler.cpp
@@ -457,7 +457,6 @@ bool Game_BattleAlgorithm::Normal::Execute() {
Reset();
int to_hit;
if (source->GetType() == Game_Battler::Type_Ally) {
Game_Actor* ally = static_cast<Game_Actor*>(source);
int hit_chance = source->GetHitChance();
@@ -483,12 +482,13 @@ 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));
effect += change;
if(effect < 0) {
effect = 0;
}

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry Mar 14, 2016

This change is not required. When effect is set to 0, the change equation will be 0, too.

@Ghabry

Ghabry Mar 14, 2016

This change is not required. When effect is set to 0, the change equation will be 0, too.

this->hp = (effect * (critical_hit ? 3 : 1) * (source->IsCharged() ? 2 : 1)) / ((*current_target)->IsDefending() ? 2 : 1);
if ((*current_target)->GetHp() - this->hp <= 0) {
View
@@ -341,27 +341,45 @@ int Game_Battler::ApplyConditions()
int src_sp = 0;
if (state.hp_change_type == state.ChangeType_lose) {
src_hp = -std::min(source_hp - 1, hp);
if(src_hp > 0) {
src_hp = 0;
}
}
else if(state.hp_change_type == state.ChangeType_gain) {
src_hp = std::min(source_hp, hp);
if(src_hp < 0) {
src_hp = 0;
}
}
else {
src_hp = 0;
}
if (state.sp_change_type == state.ChangeType_lose) {
source_sp = -std::min(source_sp, sp);
src_sp = -std::min(source_sp, sp);
if(src_sp > 0) {
src_sp = 0;
}
}
else if(state.sp_change_type == state.ChangeType_gain) {
source_sp = std::min(source_sp, sp);
src_sp = std::min(source_sp, sp);
if(src_sp < 0 ) {
src_sp = 0;
}
}
else {
source_sp = 0;
src_sp = 0;
}
this->ChangeHp(src_hp);
this->ChangeSp(src_sp);
damageTaken += src_hp;
}
return -damageTaken;
if(damageTaken < 0) {
return -damageTaken;
}
else {
return damageTaken;
}
}

0 comments on commit a9fdd28

Please sign in to comment.