| 205 | } |
| 206 | |
| 207 | double CalcNormalAttackAutoBattleTargetRank(const Game_Actor& source, |
| 208 | const Game_Battler& target, |
| 209 | Game_Battler::Weapon weapon, |
| 210 | lcf::rpg::System::BattleCondition cond, |
| 211 | bool apply_variance, |
| 212 | bool emulate_bugs) |
| 213 | { |
| 214 | if (!target.Exists()) { |
| 215 | return 0.0; |
| 216 | } |
| 217 | const bool is_critical_hit = false; |
| 218 | const bool is_charged = false; |
| 219 | |
| 220 | // RPG_RT BUG: Normal damage variance is not used |
| 221 | // Note: RPG_RT does not do the "2k3_enemy_row_bug" when computing autobattle ranks. |
| 222 | double base_effect = Algo::CalcNormalAttackEffect(source, target, weapon, is_critical_hit, is_charged, apply_variance, cond, false); |
| 223 | // RPG_RT BUG: Dual Attack is ignored |
| 224 | if (!emulate_bugs) { |
| 225 | base_effect *= source.GetNumberOfAttacks(weapon); |
| 226 | } |
| 227 | const double tgt_hp = target.GetHp(); |
| 228 | |
| 229 | auto rank = std::min(base_effect, tgt_hp) / tgt_hp; |
| 230 | if (rank == 1.0) { |
| 231 | rank = 1.5; |
| 232 | } |
| 233 | if (!emulate_bugs) { |
| 234 | // EasyRPG customization - include sp cost of weapon attack using same logic as skill attack |
| 235 | const auto cost = std::min(source.CalculateWeaponSpCost(weapon), source.GetSp()); |
| 236 | if (cost > 0) { |
| 237 | const double src_max_sp = source.GetMaxSp(); |
| 238 | rank -= static_cast<double>(cost) / src_max_sp / 4.0; |
| 239 | rank = std::max(rank, 0.0); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // Bonus if the target is the first existing enemy? |
| 244 | for (auto* enemy: Main_Data::game_enemyparty->GetEnemies()) { |
| 245 | if (enemy->Exists()) { |
| 246 | if (enemy == &target) { |
| 247 | rank = rank * 1.5 + 0.5; |
| 248 | } |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | if (rank > 0.0) { |
| 253 | rank = Rand::GetRandomNumber(0, 99) / 100.0 + rank * 1.5; |
| 254 | } |
| 255 | return rank; |
| 256 | } |
| 257 | |
| 258 | double CalcNormalAttackAutoBattleRank(const Game_Actor& source, Game_Battler::Weapon weapon, const lcf::rpg::System::BattleCondition cond, bool apply_variance, bool emulate_bugs) { |
| 259 | double rank = 0.0; |
no test coverage detected