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

Method ApplyConditions

src/game_battler.cpp:432–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432int Game_Battler::ApplyConditions() {
433 int damageTaken = 0;
434 for (int16_t inflicted : GetInflictedStates()) {
435 // States are guaranteed to be valid
436 lcf::rpg::State& state = *lcf::ReaderUtil::GetElement(lcf::Data::states, inflicted);
437 int hp = state.hp_change_val + (GetMaxHp() * state.hp_change_max / 100);
438 int sp = state.sp_change_val + (GetMaxSp() * state.sp_change_max / 100);
439 int src_hp = 0;
440 int src_sp = 0;
441 if (state.hp_change_type == state.ChangeType_lose) {
442 src_hp = -hp;
443 if(src_hp > 0) {
444 src_hp = 0;
445 }
446 }
447 else if(state.hp_change_type == state.ChangeType_gain) {
448 src_hp = hp;
449 if(src_hp < 0) {
450 src_hp = 0;
451 }
452 }
453 else {
454 src_hp = 0;
455 }
456 if (state.sp_change_type == state.ChangeType_lose) {
457 src_sp = -sp;
458 if(src_sp > 0) {
459 src_sp = 0;
460 }
461
462 }
463 else if (state.sp_change_type == state.ChangeType_gain) {
464 src_sp = sp;
465 if(src_sp < 0) {
466 src_sp = 0;
467 }
468 }
469 else {
470 src_sp = 0;
471 }
472 this->ChangeHp(src_hp, false);
473 this->ChangeSp(src_sp);
474 damageTaken += src_hp;
475 }
476
477 return damageTaken;
478}
479
480int Game_Battler::ChangeHp(int hp, bool lethal) {
481 if (IsDead()) {

Callers 2

Calls 2

ChangeHpMethod · 0.95
ChangeSpMethod · 0.95

Tested by

no test coverage detected