MCPcopy Create free account
hub / github.com/EasyRPG/Player / ApplyStateDamage

Method ApplyStateDamage

src/game_party.cpp:723–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721}
722
723bool Game_Party::ApplyStateDamage() {
724 bool damage = false;
725 std::vector<int16_t> states = GetInflictedStates();
726
727 const auto steps = GetSteps();
728
729 for (auto state_id : states) {
730 lcf::rpg::State *state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id);
731
732 if (state->hp_change_map_steps > 0
733 && state->hp_change_map_val > 0
734 && ((steps % state->hp_change_map_steps) == 0)
735 ) {
736 for (auto actor : GetActors()) {
737 if (actor->HasState(state_id)) {
738 if (state->hp_change_type == lcf::rpg::State::ChangeType_lose) {
739 actor->ChangeHp(-state->hp_change_map_val, false);
740 damage = true;
741 }
742 else if (state->hp_change_type == lcf::rpg::State::ChangeType_gain) {
743 actor->ChangeHp(state->hp_change_map_val, false);
744 }
745 }
746 }
747 }
748
749 if (state->sp_change_map_steps > 0
750 && state->sp_change_map_val > 0
751 && ((steps % state->sp_change_map_steps) == 0)
752 ){
753 for (auto actor : GetActors()) {
754 if (actor->HasState(state_id)) {
755 if (state->sp_change_type == lcf::rpg::State::ChangeType_lose) {
756 actor->ChangeSp(-state->sp_change_map_val);
757 damage = true;
758 }
759 else if (state->sp_change_type == lcf::rpg::State::ChangeType_gain) {
760 actor->ChangeSp(state->sp_change_map_val);
761 }
762 }
763 }
764 }
765 }
766
767 return damage;
768}
769
770bool Game_Party::IsAnyControllable() {
771 for (auto& actor: GetActors()) {

Callers 1

Calls 3

HasStateMethod · 0.80
ChangeHpMethod · 0.80
ChangeSpMethod · 0.80

Tested by

no test coverage detected