Skip to content

Commit

Permalink
feat(skymp5-server): recognize more item types in OnEquip handler (#1731
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Pospelove authored Nov 10, 2023
1 parent f80e8b5 commit ea3186c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions skymp5-server/cpp/server_guest_lib/MpActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,21 @@ bool MpActor::OnEquip(uint32_t baseId)
const bool isIngredient = recordType == "INGR";
const bool isPotion = recordType == "ALCH";

if (!(isSpell || isIngredient || isPotion || isBook)) {
bool isTorch = false;
if (espm::utils::Is<espm::LIGH>(recordType)) {
auto& compressedFieldsCache = GetParent()->GetEspmCache();
auto light = espm::Convert<espm::LIGH>(lookupRes.rec);
auto res = light->GetData(compressedFieldsCache);
isTorch = res.data.flags & espm::LIGH::Flags::CanBeCarried;
}

const bool isScroll = recordType == "SCRL";
const bool isWeapon = recordType == "WEAP";
const bool isArmor = recordType == "ARMO";
const bool isAmmo = recordType == "AMMO";

if (!(isSpell || isIngredient || isPotion || isBook || isTorch || isScroll ||
isWeapon || isArmor || isAmmo)) {
return false;
}

Expand All @@ -288,14 +302,14 @@ bool MpActor::OnEquip(uint32_t baseId)
return false;
}

bool spellLearned = true;
bool spellLearned = false;
if (isIngredient || isPotion) {
EatItem(baseId, recordType);
} else if (isBook) {
spellLearned = ReadBook(baseId);
}

if (!isSpell && spellLearned) {
if (isIngredient || isPotion || spellLearned) {
RemoveItem(baseId, 1, nullptr);
}

Expand Down

0 comments on commit ea3186c

Please sign in to comment.