| 557 | } |
| 558 | |
| 559 | void Game_BattleAlgorithm::AlgorithmBase::BattlePhysicalStateHeal(int physical_rate, std::vector<int16_t>& target_states, const PermanentStates& ps) { |
| 560 | if (physical_rate <= 0) { |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | for (int i = 0; i < (int)target_states.size(); ++i) { |
| 565 | auto state_id = i + 1; |
| 566 | if (!State::Has(state_id, target_states)) { |
| 567 | continue; |
| 568 | } |
| 569 | |
| 570 | auto* state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id); |
| 571 | if (state == nullptr) { |
| 572 | continue; |
| 573 | } |
| 574 | if (state->release_by_damage > 0) { |
| 575 | int release_chance = state->release_by_damage * physical_rate / 100; |
| 576 | |
| 577 | if (!Rand::ChanceOf(release_chance, 100)) { |
| 578 | continue; |
| 579 | } |
| 580 | |
| 581 | if (State::Remove(state_id, target_states, ps)) { |
| 582 | AddAffectedState(StateEffect{state_id, Game_BattleAlgorithm::StateEffect::HealedByAttack}); |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | |
| 589 | |