| 118 | } |
| 119 | |
| 120 | int ApplyAttributeNormalAttackMultiplier(int effect, const Game_Battler& source_battler, const Game_Battler& target, Game_Battler::Weapon weapon) { |
| 121 | if (source_battler.GetType() != Game_Battler::Type_Ally && source_battler.GetType() != Game_Battler::Type_Enemy) { |
| 122 | return effect; |
| 123 | } |
| 124 | |
| 125 | std::array<const lcf::DBBitArray*, 2> attribute_sets = {{}}; |
| 126 | |
| 127 | size_t n = 0; |
| 128 | auto add = [&](int i) { |
| 129 | if (source_battler.GetType() == Game_Battler::Type_Ally) { |
| 130 | auto& source = static_cast<const Game_Actor&>(source_battler); |
| 131 | if (source.GetWeapon() == nullptr && source.Get2ndWeapon() == nullptr) { |
| 132 | lcf::rpg::Actor* allydata = lcf::ReaderUtil::GetElement(lcf::Data::actors, source.GetId()); |
| 133 | attribute_sets[n++] = &allydata->easyrpg_unarmed_attribute_set; |
| 134 | } else { |
| 135 | if (weapon == Game_Battler::Weapon(i + 1) || weapon == Game_Battler::WeaponAll) { |
| 136 | auto* item = source.GetEquipment(i + 1); |
| 137 | if (item && item->type == lcf::rpg::Item::Type_weapon) { |
| 138 | attribute_sets[n++] = &item->attribute_set; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | } else if (source_battler.GetType() == Game_Battler::Type_Enemy) { |
| 143 | auto& source = static_cast<const Game_Enemy&>(source_battler); |
| 144 | lcf::rpg::Enemy* enemydata = lcf::ReaderUtil::GetElement(lcf::Data::enemies, source.GetId()); |
| 145 | attribute_sets[n++] = &enemydata->easyrpg_attribute_set; |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | for (int i = 0; i < static_cast<int>(attribute_sets.size()); ++i) { |
| 150 | add(i); |
| 151 | } |
| 152 | |
| 153 | return ApplyAttributeMultiplier(effect, target, Span<const lcf::DBBitArray*>(attribute_sets.data(), n)); |
| 154 | } |
| 155 | |
| 156 | int ApplyAttributeSkillMultiplier(int effect, const Game_Battler& target, const lcf::rpg::Skill& skill) { |
| 157 | auto attribute_sets = Utils::MakeArray(&skill.attribute_effects); |
no test coverage detected