mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-22 04:56:22 +00:00
Enhance equip upgrade
This commit is contained in:
@@ -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); }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user