From 14639c63e3d24f5095f2d0dd8f5d08646a023b47 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 10 Dec 2022 21:48:09 -0800 Subject: [PATCH] name interference functions appropriately --- src/Episode3/Card.cc | 4 ++-- src/Episode3/CardSpecial.cc | 34 ++++++++++++++-------------------- src/Episode3/CardSpecial.hh | 15 +++++++-------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/Episode3/Card.cc b/src/Episode3/Card.cc index ff224734..378d468f 100644 --- a/src/Episode3/Card.cc +++ b/src/Episode3/Card.cc @@ -470,7 +470,7 @@ void Card::execute_attack(shared_ptr attacker_card) { if (!(this->card_flags & 2) && (!attacker_card || !(attacker_card->card_flags & 2))) { - this->server()->card_special->unknown_80244E20( + this->server()->card_special->check_for_defense_interference( attacker_card, this->shared_from_this(), &preliminary_damage); } @@ -1208,7 +1208,7 @@ void Card::unknown_80237734() { } if (!(this->card_flags & 2)) { this->compute_action_chain_results(1, 0); - this->server()->card_special->unknown_8024504C(this->shared_from_this()); + this->server()->card_special->check_for_attack_interference(this->shared_from_this()); } this->compute_action_chain_results(1, 0); this->unknown_80236374(this->shared_from_this(), nullptr); diff --git a/src/Episode3/CardSpecial.cc b/src/Episode3/CardSpecial.cc index 9abc0404..b917a15d 100644 --- a/src/Episode3/CardSpecial.cc +++ b/src/Episode3/CardSpecial.cc @@ -3366,7 +3366,7 @@ void CardSpecial::unknown_80244AA8(shared_ptr card) { this->unknown_8024C2B0(0x13, card->get_card_ref(), as, 0xFFFF); } -void CardSpecial::unknown_80244E20( +void CardSpecial::check_for_defense_interference( shared_ptr attacker_card, shared_ptr target_card, int16_t* inout_unknown_p4) { @@ -3420,12 +3420,9 @@ void CardSpecial::unknown_80244E20( if (target_ps->unknown_a17 >= 1) { return; } - auto entry = unknown_8024DAFC(target_card_id, ally_sc_card_id, false); - if (!entry) { - return; - } - uint8_t rand_v = this->server()->get_random(99); - if (rand_v >= entry->unknown_v2) { + auto entry = get_interference_probability_entry( + target_card_id, ally_sc_card_id, false); + if (!entry || (this->server()->get_random(99) >= entry->defense_probability)) { return; } @@ -3694,12 +3691,11 @@ void CardSpecial::clear_invalid_conditions_on_card( } } -const UnknownMatrixEntry* unknown_8024DAFC( +const InterferenceProbabilityEntry* get_interference_probability_entry( uint16_t row_card_id, uint16_t column_card_id, - bool use_entry_v1, - size_t* out_entry_index) { - static const UnknownMatrixEntry entries[] = { + bool is_attack) { + static const InterferenceProbabilityEntry entries[] = { {0x0004, 0xFF, 0xFF}, {0x0002, 0x04, 0x00}, {0x0002, 0x00, 0x0F}, @@ -3849,23 +3845,20 @@ const UnknownMatrixEntry* unknown_8024DAFC( }; constexpr size_t num_entries = sizeof(entries) / sizeof(entries[0]); - const UnknownMatrixEntry* ret_entry = nullptr; + const InterferenceProbabilityEntry* ret_entry = nullptr; int16_t current_max = -1; size_t logical_index = 0; uint16_t current_row_card_id = 0xFFFF; for (size_t z = 0; z < num_entries; z++) { const auto& entry = entries[z]; uint16_t current_column_card_id = entry.card_id; - if ((entry.unknown_v1 != 0xFF) || (entry.unknown_v2 != 0xFF)) { + if ((entry.attack_probability != 0xFF) || (entry.defense_probability != 0xFF)) { if ((row_card_id == current_row_card_id) && (column_card_id == current_column_card_id)) { - uint8_t v = use_entry_v1 ? entry.unknown_v1 : entry.unknown_v2; + uint8_t v = is_attack ? entry.attack_probability : entry.defense_probability; if (current_max <= v) { ret_entry = &entry; current_max = v; - if (out_entry_index) { - *out_entry_index = logical_index; - } } } logical_index++; @@ -4325,7 +4318,7 @@ void CardSpecial::unknown_8024A9D8(const ActionState& pa, uint16_t action_card_r } } -void CardSpecial::unknown_8024504C(shared_ptr unknown_p2) { +void CardSpecial::check_for_attack_interference(shared_ptr unknown_p2) { if (unknown_p2->action_chain.chain.damage <= 0) { return; } @@ -4376,8 +4369,9 @@ void CardSpecial::unknown_8024504C(shared_ptr unknown_p2) { return; } - const auto* entry = unknown_8024DAFC(row_card_id, ally_sc_card_id, true); - if (!entry || (this->server()->get_random(99) >= entry->unknown_v1)) { + const auto* entry = get_interference_probability_entry( + row_card_id, ally_sc_card_id, true); + if (!entry || (this->server()->get_random(99) >= entry->attack_probability)) { return; } diff --git a/src/Episode3/CardSpecial.hh b/src/Episode3/CardSpecial.hh index a8841b0e..aedf3354 100644 --- a/src/Episode3/CardSpecial.hh +++ b/src/Episode3/CardSpecial.hh @@ -11,17 +11,16 @@ namespace Episode3 { -struct UnknownMatrixEntry { +struct InterferenceProbabilityEntry { uint16_t card_id; - uint8_t unknown_v1; - uint8_t unknown_v2; + uint8_t attack_probability; + uint8_t defense_probability; }; -const UnknownMatrixEntry* unknown_8024DAFC( +const InterferenceProbabilityEntry* get_interference_probability_entry( uint16_t row_card_id, uint16_t column_card_id, - bool use_entry_v1, - size_t* out_entry_index = nullptr); + bool is_attack); @@ -276,7 +275,7 @@ public: void update_condition_orders(std::shared_ptr card); int16_t max_all_attack_bonuses(size_t* out_count) const; void unknown_80244AA8(std::shared_ptr card); - void unknown_80244E20( + void check_for_defense_interference( std::shared_ptr attacker_card, std::shared_ptr target_card, int16_t* inout_unknown_p4); @@ -324,7 +323,7 @@ public: void unknown_8024966C(std::shared_ptr unknown_p2, const ActionState* existing_as); static std::shared_ptr sc_card_for_card(std::shared_ptr unknown_p2); void unknown_8024A9D8(const ActionState& pa, uint16_t action_card_ref); - void unknown_8024504C(std::shared_ptr unknown_p2); + void check_for_attack_interference(std::shared_ptr unknown_p2); template void unknown_t2(std::shared_ptr unknown_p2); void unknown_8024997C(std::shared_ptr card);