Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oil issue #445

Merged
merged 6 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions src/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4372,43 +4372,50 @@ Item* PlayerbotAI::FindStoneFor(Item* weapon) const
return stone;
}

static const uint32 uPriorizedWizardOilIds[5] = {MINOR_WIZARD_OIL, LESSER_WIZARD_OIL, BRILLIANT_WIZARD_OIL, WIZARD_OIL,
SUPERIOR_WIZARD_OIL};

static const uint32 uPriorizedManaOilIds[4] = {
MINOR_MANA_OIL,
LESSER_MANA_OIL,
BRILLIANT_MANA_OIL,
SUPERIOR_MANA_OIL,
};

Item* PlayerbotAI::FindOilFor(Item* weapon) const
{
if (!weapon)
return nullptr;

const ItemTemplate* item_template = weapon->GetTemplate();
if (!item_template)
return nullptr;

// static const will only get created once whatever the call amout
static const std::vector<uint32_t> uPriorizedWizardOilIds =
{
MINOR_WIZARD_OIL, MINOR_MANA_OIL,
LESSER_WIZARD_OIL, LESSER_MANA_OIL,
BRILLIANT_WIZARD_OIL, BRILLIANT_MANA_OIL,
WIZARD_OIL, SUPERIOR_MANA_OIL, SUPERIOR_WIZARD_OIL
};

// static const will only get created once whatever the call amout
static const std::vector<uint32_t> uPriorizedManaOilIds =
{
MINOR_MANA_OIL, MINOR_WIZARD_OIL,
LESSER_MANA_OIL, LESSER_WIZARD_OIL,
BRILLIANT_MANA_OIL, BRILLIANT_WIZARD_OIL,
SUPERIOR_MANA_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL
};

Item* oil = nullptr;
ItemTemplate const* pProto = weapon->GetTemplate();
if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ||
pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER))
if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_SWORD ||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
{
for (uint8 i = 0; i < std::size(uPriorizedWizardOilIds); ++i)
for (const auto& id : uPriorizedWizardOilIds)
{
oil = FindConsumable(uPriorizedWizardOilIds[i]);
if (!oil)
oil = FindConsumable(uPriorizedManaOilIds[i]);

if (oil)
if (oil = FindConsumable(id))
return oil;
}
}
else if (pProto &&
(pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2))
else if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE ||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)
{
for (uint8 i = 0; i < std::size(uPriorizedManaOilIds); ++i)
for (const auto& id : uPriorizedManaOilIds)
{
oil = FindConsumable(uPriorizedManaOilIds[i]);
if (!oil)
oil = FindConsumable(uPriorizedWizardOilIds[i]);

if (oil)
if (oil = FindConsumable(id))
return oil;
}
}
Expand Down Expand Up @@ -4908,4 +4915,4 @@ uint8 PlayerbotAI::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool sw

// no free position
return NULL_SLOT;
}
}
Loading