mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 09:50:27 +00:00
Rogue poison
This commit is contained in:
@@ -86,7 +86,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
if (item->GetTemplate()->Spells[i].SpellId > 0)
|
||||
{
|
||||
spellId = item->GetTemplate()->Spells[i].SpellId;
|
||||
if (!botAI->CanCastSpell(spellId, bot, false, item)) {
|
||||
if (!botAI->CanCastSpell(spellId, bot, false, itemTarget, item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,29 @@
|
||||
#include "GenericRogueNonCombatStrategy.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
|
||||
class GenericRogueNonCombatStrategyActionNodeFactory : public NamedObjectFactory<ActionNode>
|
||||
{
|
||||
public:
|
||||
GenericRogueNonCombatStrategyActionNodeFactory()
|
||||
{
|
||||
creators["use deadly poison on off hand"] = &use_deadly_poison_on_off_hand;
|
||||
}
|
||||
|
||||
private:
|
||||
static ActionNode* use_deadly_poison_on_off_hand(PlayerbotAI* botAI)
|
||||
{
|
||||
return new ActionNode ("use deadly poison on off hand",
|
||||
/*P*/ nullptr,
|
||||
/*A*/ NextAction::array(0, new NextAction("use instant poison on off hand"), nullptr),
|
||||
/*C*/ nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
GenericRogueNonCombatStrategy::GenericRogueNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {
|
||||
actionNodeFactories.Add(new GenericRogueNonCombatStrategyActionNodeFactory());
|
||||
}
|
||||
|
||||
void GenericRogueNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
NonCombatStrategy::InitTriggers(triggers);
|
||||
|
||||
@@ -12,7 +12,7 @@ class PlayerbotAI;
|
||||
class GenericRogueNonCombatStrategy : public NonCombatStrategy
|
||||
{
|
||||
public:
|
||||
GenericRogueNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { }
|
||||
GenericRogueNonCombatStrategy(PlayerbotAI* botAI);
|
||||
|
||||
std::string const getName() override { return "nc"; }
|
||||
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
||||
|
||||
@@ -51,7 +51,7 @@ bool UseDeadlyPoisonAction::Execute(Event event) {
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = getName() + suffix;
|
||||
poison_name = "Deadly Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
@@ -70,7 +70,7 @@ bool UseDeadlyPoisonAction::isPossible() {
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = getName() + suffix;
|
||||
poison_name = "Deadly Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
@@ -84,7 +84,7 @@ bool UseInstantPoisonAction::Execute(Event event) {
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = getName() + suffix;
|
||||
poison_name = "Instant Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
@@ -102,11 +102,43 @@ bool UseInstantPoisonAction::isPossible() {
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = getName() + suffix;
|
||||
poison_name = "Instant Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return !items.empty();
|
||||
}
|
||||
}
|
||||
|
||||
bool UseInstantPoisonOffHandAction::Execute(Event event) {
|
||||
std::vector<std::string> poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""};
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = "Instant Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (items.empty()) {
|
||||
return false;
|
||||
}
|
||||
Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND );
|
||||
return UseItem(*items.begin(), ObjectGuid::Empty, itemForSpell);
|
||||
}
|
||||
|
||||
bool UseInstantPoisonOffHandAction::isPossible() {
|
||||
std::vector<std::string> poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""};
|
||||
std::vector<Item*> items;
|
||||
std::string poison_name;
|
||||
for (std::string& suffix: poison_suffixs) {
|
||||
poison_name = "Instant Poison" + suffix;
|
||||
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||
if (!items.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return !items.empty();
|
||||
}
|
||||
|
||||
@@ -149,6 +149,14 @@ class UseInstantPoisonAction : public UseItemAction
|
||||
virtual bool isPossible() override;
|
||||
};
|
||||
|
||||
class UseInstantPoisonOffHandAction : public UseItemAction
|
||||
{
|
||||
public:
|
||||
UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {}
|
||||
virtual bool Execute(Event event) override;
|
||||
virtual bool isPossible() override;
|
||||
};
|
||||
|
||||
class FanOfKnivesAction : public CastMeleeSpellAction
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -133,6 +133,7 @@ class RogueAiObjectContextInternal : public NamedObjectContext<Action>
|
||||
creators["tricks of the trade on main tank"] = &RogueAiObjectContextInternal::tricks_of_the_trade_on_main_tank;
|
||||
creators["use instant poison on main hand"] = &RogueAiObjectContextInternal::use_instant_poison;
|
||||
creators["use deadly poison on off hand"] = &RogueAiObjectContextInternal::use_deadly_poison;
|
||||
creators["use instant poison on off hand"] = &RogueAiObjectContextInternal::use_instant_poison_off_hand;
|
||||
creators["fan of knives"] = &RogueAiObjectContextInternal::fan_of_knives;
|
||||
creators["killing spree"] = &RogueAiObjectContextInternal::killing_spree;
|
||||
}
|
||||
@@ -169,6 +170,7 @@ class RogueAiObjectContextInternal : public NamedObjectContext<Action>
|
||||
static Action* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) { return new CastTricksOfTheTradeOnMainTankAction(ai); }
|
||||
static Action* use_instant_poison(PlayerbotAI* ai) { return new UseInstantPoisonAction(ai); }
|
||||
static Action* use_deadly_poison(PlayerbotAI* ai) { return new UseDeadlyPoisonAction(ai); }
|
||||
static Action* use_instant_poison_off_hand(PlayerbotAI* ai) { return new UseInstantPoisonOffHandAction(ai); }
|
||||
static Action* fan_of_knives(PlayerbotAI* ai) { return new FanOfKnivesAction(ai); }
|
||||
static Action* killing_spree(PlayerbotAI* ai) { return new CastKillingSpreeAction(ai); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user