From be8130b621510141f3168bab50379569f13a37de Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 13 Jan 2024 09:33:13 -0800 Subject: [PATCH] handle v1/v2 rare rates properly in map loader --- src/Map.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Map.cc b/src/Map.cc index bc2c38f0..a5337797 100644 --- a/src/Map.cc +++ b/src/Map.cc @@ -745,7 +745,10 @@ bool Map::check_and_log_rare_enemy(bool default_is_rare, uint32_t rare_rate) { // that we have to initialize the entire thing. Find a way to make this // faster. PSOV2Encryption crypt(this->random_crypt->seed() + 0x1000 + this->enemies.size()); - if ((static_cast((crypt.next() >> 16) & 0xFFFF) / 65536.0f) < 0.002f) { + float det = (static_cast((crypt.next() >> 16) & 0xFFFF) / 65536.0f); + // On v1 and v2 (and GC NTE), the rare rate is 0.1% instead of 0.2%. + float threshold = is_v1_or_v2(this->version) ? 0.001f : 0.002f; + if (det < threshold) { this->rare_enemy_indexes.emplace_back(this->enemies.size()); return true; }