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(); if (ally->GetWeaponId() == 0) { // No Weapon // Todo: Two Sword style animation = &Data::animations[Data::actors[ally->GetId() - 1].unarmed_animation - 1]; } else { animation = &Data::animations[Data::items[ally->GetWeaponId() - 1].animation_id - 1]; hit_chance = Data::items[ally->GetWeaponId() - 1].hit; } to_hit = (int)(100 - (100 - hit_chance) * (1 + (1.0 * (*current_target)->GetAgi() / ally->GetAgi() - 1) / 2)); } else { // Source is Enemy //int hit = src->IsMissingOften() ? 70 : 90; int hit = source->GetHitChance(); to_hit = (int)(100 - (100 - hit) * (1 + (1.0 * (*current_target)->GetAgi() / source->GetAgi() - 1) / 2)); } // Damage calculation if (rand() % 100 < to_hit) { if (!source->IsCharged() && rand() % 100 < source->GetCriticalHitChance()) { critical_hit = true; } 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; this->hp = (effect * (critical_hit ? 3 : 1) * (source->IsCharged() ? 2 : 1)) / ((*current_target)->IsDefending() ? 2 : 1); if ((*current_target)->GetHp() - this->hp <= 0) { // Death state killed_by_attack_damage = true; conditions.push_back(Data::states[0]); } } else { this->success = false; return this->success; } this->success = true; return this->success; }
void Scene_Equip::Start() { Game_Actor* actor = Main_Data::game_party->GetActors()[actor_index]; // Create the windows help_window.reset(new Window_Help(0, 0, 320, 32)); equipstatus_window.reset(new Window_EquipStatus(0, 32, 124, 96, actor->GetId())); equip_window.reset(new Window_Equip(124, 32, 196, 96, actor->GetId())); equip_window->SetIndex(equip_index); for (int i = 0; i < 5; ++i) { item_windows.push_back(EASYRPG_MAKE_SHARED<Window_EquipItem>(actor->GetId(), i)); } // Assign the help windows equip_window->SetHelpWindow(help_window.get()); for (size_t i = 0; i < item_windows.size(); ++i) { item_windows[i]->SetHelpWindow(help_window.get()); item_windows[i]->SetActive(false); item_windows[i]->Refresh(); } }
bool Game_BattleAlgorithm::Normal::Execute() { Reset(); int to_hit; float multiplier = 1; int crit_chance = source->GetCriticalHitChance(); if (source->GetType() == Game_Battler::Type_Ally) { Game_Actor* ally = static_cast<Game_Actor*>(source); int hit_chance = source->GetHitChance(); int weaponID = ally->GetWeaponId() - 1; if (weaponID == -1) { // No Weapon // Todo: Two Sword style animation = &Data::animations[Data::actors[ally->GetId() - 1].unarmed_animation - 1]; } else { animation = &Data::animations[Data::items[weaponID].animation_id - 1]; RPG::Item weapon = Data::items[weaponID]; hit_chance = weapon.hit; crit_chance += weapon.critical_hit; multiplier = GetAttributeMultiplier(weapon.attribute_set); } to_hit = (int)(100 - (100 - hit_chance)); if(weaponID != -1 && !Data::items[weaponID].ignore_evasion) { to_hit *= (1 + (1.0 * (*current_target)->GetAgi() / ally->GetAgi() - 1) / 2); } } else { // Source is Enemy int hit = source->GetHitChance(); to_hit = (int)(100 - (100 - hit) * (1 + (1.0 * (*current_target)->GetAgi() / source->GetAgi() - 1) / 2)); } // Damage calculation if (rand() % 100 < to_hit) { if (!source->IsCharged() && rand() % 100 < crit_chance) { critical_hit = true; } 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; effect *= multiplier; if(effect < 0) { effect = 0; } this->hp = (effect * (critical_hit ? 3 : 1) * (source->IsCharged() ? 2 : 1)) / ((*current_target)->IsDefending() ? 2 : 1); if ((*current_target)->GetHp() - this->hp <= 0) { // Death state killed_by_attack_damage = true; conditions.push_back(Data::states[0]); } else { if (source->GetType() == Game_Battler::Type_Ally) { int weaponID = static_cast<Game_Actor*>(source)->GetWeaponId() - 1; if (weaponID != -1) { RPG::Item item = Data::items[static_cast<Game_Actor*>(source)->GetWeaponId() - 1]; for (int i = 0; i < item.state_set.size(); i++) { if (item.state_set[i] && rand() % 100 < (item.state_chance * (*current_target)->GetStateProbability(Data::states[i].ID) / 100)) { if (item.state_effect) { healing = true; } conditions.push_back(Data::states[i]); } } } } } } else { this->success = false; return this->success; } this->success = true; return this->success; }