Enhance equip upgrade

This commit is contained in:
Yunfan Li
2024-03-19 17:06:14 +08:00
parent 59eddc7f98
commit 68fdf57c3c
7 changed files with 62 additions and 5 deletions

View File

@@ -3370,8 +3370,11 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld)
if (!spellInfo)
continue;
uint32 requiredLevel = spellInfo->BaseLevel;
if (!item->IsFitToSpellRequirements(spellInfo)) {
continue;
}
uint32 requiredLevel = spellInfo->BaseLevel;
if (requiredLevel > bot->GetLevel()) {
continue;
}
@@ -3385,9 +3388,6 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld)
continue;
}
if (!item->IsFitToSpellRequirements(spellInfo)) {
continue;
}
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
@@ -3604,6 +3604,32 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot)
break;
}
}
for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; j++)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(proto->Spells[j].SpellId);
if (!spellInfo)
continue;
for (uint8 i = 0 ; i < 3; i++)
{
if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA)
{
switch (spellInfo->Effects[i].ApplyAuraName)
{
case SPELL_AURA_MOD_DAMAGE_DONE:
// case SPELL_AURA_MOD_HEALING_DONE: duplicated
spell_power += spellInfo->Effects[i].BasePoints + 1;
break;
case SPELL_AURA_MOD_ATTACK_POWER:
attack_power += spellInfo->Effects[i].BasePoints + 1;
case SPELL_AURA_MOD_SHIELD_BLOCKVALUE:
block += spellInfo->Effects[i].BasePoints + 1;
default:
break;
}
}
}
}
// Basic score
float score = (agility + strength + intellect + spirit + stamina + defense + dodge + parry + block +
resilience + hit + crit + haste + expertise + attack_power + mana_regeneration + spell_power + armor_penetration +

View File

@@ -115,6 +115,7 @@ class ChatActionContext : public NamedObjectContext<Action>
creators["de"] = &ChatActionContext::dead;
creators["trainer"] = &ChatActionContext::trainer;
creators["maintenance"] = &ChatActionContext::maintenance;
creators["equip upgrade"] = &ChatActionContext::equip_upgrade;
creators["attack my target"] = &ChatActionContext::attack_my_target;
creators["chat"] = &ChatActionContext::chat;
creators["home"] = &ChatActionContext::home;
@@ -213,6 +214,7 @@ class ChatActionContext : public NamedObjectContext<Action>
static Action* attack_my_target(PlayerbotAI* botAI) { return new AttackMyTargetAction(botAI); }
static Action* trainer(PlayerbotAI* botAI) { return new TrainerAction(botAI); }
static Action* maintenance(PlayerbotAI* botAI) { return new MaintenanceAction(botAI); }
static Action* equip_upgrade(PlayerbotAI* botAI) { return new EquipUpgradeAction(botAI); }
static Action* co(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI); }
static Action* nc(PlayerbotAI* botAI) { return new ChangeNonCombatStrategyAction(botAI); }
static Action* dead(PlayerbotAI* botAI) { return new ChangeDeadStrategyAction(botAI); }

View File

@@ -129,3 +129,20 @@ bool EquipUpgradesAction::Execute(Event event)
return true;
}
bool EquipUpgradeAction::Execute(Event event)
{
ListItemsVisitor visitor;
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
ItemIds items;
for (std::map<uint32, uint32>::iterator i = visitor.items.begin(); i != visitor.items.end(); ++i)
{
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
items.insert(i->first);
}
}
EquipItems(items);
return true;
}

View File

@@ -34,4 +34,13 @@ class EquipUpgradesAction : public EquipAction
bool Execute(Event event) override;
};
class EquipUpgradeAction : public EquipAction
{
public:
EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) { }
bool Execute(Event event) override;
};
#endif

View File

@@ -89,6 +89,7 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("de");
supported.push_back("trainer");
supported.push_back("maintenance");
supported.push_back("equip upgrade");
supported.push_back("chat");
supported.push_back("home");
supported.push_back("destroy");

View File

@@ -26,7 +26,7 @@ class RacialsStrategyActionNodeFactory : public NamedObjectFactory<ActionNode>
void RacialsStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
{
triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("lifeblood", 71.0f), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("war stomp", 71.0f), nullptr)));
// triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("war stomp", 71.0f), nullptr)));
/*triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("war stomp", 71.0f), nullptr)));*/
/*triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("arcane torrent", ACTION_EMERGENCY + 6), nullptr)));
triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("mana tap", ACTION_EMERGENCY + 6), nullptr)));*/

View File

@@ -55,6 +55,7 @@ class ChatTriggerContext : public NamedObjectContext<Trigger>
creators["de"] = &ChatTriggerContext::dead;
creators["trainer"] = &ChatTriggerContext::trainer;
creators["maintenance"] = &ChatTriggerContext::maintenance;
creators["equip upgrade"] = &ChatTriggerContext::equip_upgrade;
creators["attack"] = &ChatTriggerContext::attack;
creators["chat"] = &ChatTriggerContext::chat;
creators["accept"] = &ChatTriggerContext::accept;
@@ -166,6 +167,7 @@ class ChatTriggerContext : public NamedObjectContext<Trigger>
static Trigger* attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attack"); }
static Trigger* trainer(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "trainer"); }
static Trigger* maintenance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "maintenance"); }
static Trigger* equip_upgrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "equip upgrade"); }
static Trigger* co(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "co"); }
static Trigger* nc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "nc"); }
static Trigger* dead(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "de"); }