Skip to content

Commit

Permalink
"2.32: RM2000 + RM2003: When throwing an item to a dead character wit…
Browse files Browse the repository at this point in the history
…hout the "only k.o." option, the target is still the dead person, it doesn't change, and the attack can succeed (it can still recover SP and states like Dead for example and resurrect, even if no HP will be taken if it doesn't cure Death). An item fails if "only k.o." is checked and it's thrown to an alive actor, or if it doesn't recover any HP, SP or condition."

Solution:

1. Since in items the target is always valid, we take away the condition that checks medicine during death.
2. We put, in case the "ko_only" attribute is active but the target is alive, that the item misses.
3. We add that a condition to heal is only added if the character suffers that condition. Otherwise, it skips it.
4. We check if the character is dead and the medicine doesn't cure Death. If that's the case, the HP restored will be resetted to -1.
5. In case there's no HP, SP or condition, the attack fails.

We also solve a few things in AlgorithmBase::Apply to ensure consistency:

1. If a character is Dead, then it doesn't restore health.
2. If a character is resurrected, then it restores the amount of HP. If it's 0, then it will restore 1.
  • Loading branch information
Albeleon authored and mateofio committed Dec 6, 2018
1 parent 3bd4306 commit c75fd36
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ void Game_BattleAlgorithm::AlgorithmBase::Apply() {
if (!success)
return;

if (GetAffectedHp() != -1) {
if (GetAffectedHp() != -1 && !GetTarget()->IsDead()) {
int hp = GetAffectedHp();
int target_hp = GetTarget()->GetHp();
GetTarget()->ChangeHp(IsPositive() ? hp : -hp);
Expand Down Expand Up @@ -694,7 +694,7 @@ void Game_BattleAlgorithm::AlgorithmBase::Apply() {
if (IsPositive()) {
if (GetTarget()->IsDead() && it->ID == 1) {
// Was a revive skill with an effect rating of 0
GetTarget()->ChangeHp(1);
GetTarget()->ChangeHp(std::max<int>(1, GetAffectedHp()));
}

GetTarget()->RemoveState(it->ID);
Expand Down Expand Up @@ -1358,14 +1358,6 @@ bool Game_BattleAlgorithm::Item::IsTargetValid() const {
if (current_target == targets.end()) {
return false;
}

if (GetTarget()->IsDead()) {
// Medicine curing death
return item.type == RPG::Item::Type_medicine &&
!item.state_set.empty() &&
item.state_set[0];
}

return item.type == RPG::Item::Type_medicine;
}

Expand All @@ -1391,6 +1383,9 @@ bool Game_BattleAlgorithm::Item::Execute() {
this->success = true;
return this->success;
}
if (item.ko_only && !GetTarget()->IsDead()) {
return this->success;
}

// HP recovery
if (item.recover_hp != 0 || item.recover_hp_rate != 0) {
Expand All @@ -1402,13 +1397,20 @@ bool Game_BattleAlgorithm::Item::Execute() {
this->sp = std::max<int>(0, std::min<int>(item.recover_sp_rate * GetTarget()->GetMaxSp() / 100 + item.recover_sp, GetTarget()->GetMaxSp() - GetTarget()->GetSp()));
}

bool is_dead_cured = false;
for (int i = 0; i < (int)item.state_set.size(); i++) {
if (item.state_set[i]) {
this->conditions.push_back(Data::states[i]);
if (i == 0)
is_dead_cured = true;
if (GetTarget()->HasState(i + 1))
this->conditions.push_back(Data::states[i]);
}
}

this->success = true;
if (GetTarget()->IsDead() && !is_dead_cured)
this->hp = -1;

this->success = this->hp > -1 || this->sp > -1 || !conditions.empty();
}
else if (item.type == RPG::Item::Type_switch) {
switch_id = item.switch_id;
Expand Down

0 comments on commit c75fd36

Please sign in to comment.