mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 00:58:33 +00:00
Rogue poison
This commit is contained in:
@@ -2125,7 +2125,7 @@ bool PlayerbotAI::CanCastSpell(std::string const name, Unit* target, Item* itemT
|
|||||||
return CanCastSpell(aiObjectContext->GetValue<uint32>("spell id", name)->Get(), target, true, itemTarget);
|
return CanCastSpell(aiObjectContext->GetValue<uint32>("spell id", name)->Get(), target, true, itemTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, Item* itemTarget)
|
bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, Item* itemTarget, Item* castItem)
|
||||||
{
|
{
|
||||||
if (!spellid) {
|
if (!spellid) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
|
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
|
||||||
@@ -2249,9 +2249,11 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE);
|
Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE);
|
||||||
|
|
||||||
spell->m_targets.SetUnitTarget(target);
|
spell->m_targets.SetUnitTarget(target);
|
||||||
|
spell->m_CastItem = castItem;
|
||||||
spell->m_CastItem = itemTarget ? itemTarget : aiObjectContext->GetValue<Item*>("item for spell", spellid)->Get();
|
if (itemTarget == nullptr) {
|
||||||
spell->m_targets.SetItemTarget(spell->m_CastItem);
|
itemTarget = aiObjectContext->GetValue<Item*>("item for spell", spellid)->Get();;
|
||||||
|
}
|
||||||
|
spell->m_targets.SetItemTarget(itemTarget);
|
||||||
|
|
||||||
SpellCastResult result = spell->CheckCast(true);
|
SpellCastResult result = spell->CheckCast(true);
|
||||||
delete spell;
|
delete spell;
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ class PlayerbotAI : public PlayerbotAIBase
|
|||||||
|
|
||||||
virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell);
|
virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell);
|
||||||
virtual bool HasAuraToDispel(Unit* player, uint32 dispelType);
|
virtual bool HasAuraToDispel(Unit* player, uint32 dispelType);
|
||||||
bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr);
|
bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr, Item* castItem = nullptr);
|
||||||
bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true);
|
bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true);
|
||||||
bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = nullptr);
|
bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
|||||||
if (item->GetTemplate()->Spells[i].SpellId > 0)
|
if (item->GetTemplate()->Spells[i].SpellId > 0)
|
||||||
{
|
{
|
||||||
spellId = item->GetTemplate()->Spells[i].SpellId;
|
spellId = item->GetTemplate()->Spells[i].SpellId;
|
||||||
if (!botAI->CanCastSpell(spellId, bot, false, item)) {
|
if (!botAI->CanCastSpell(spellId, bot, false, itemTarget, item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,29 @@
|
|||||||
#include "GenericRogueNonCombatStrategy.h"
|
#include "GenericRogueNonCombatStrategy.h"
|
||||||
#include "Playerbots.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)
|
void GenericRogueNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||||
{
|
{
|
||||||
NonCombatStrategy::InitTriggers(triggers);
|
NonCombatStrategy::InitTriggers(triggers);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class PlayerbotAI;
|
|||||||
class GenericRogueNonCombatStrategy : public NonCombatStrategy
|
class GenericRogueNonCombatStrategy : public NonCombatStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenericRogueNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { }
|
GenericRogueNonCombatStrategy(PlayerbotAI* botAI);
|
||||||
|
|
||||||
std::string const getName() override { return "nc"; }
|
std::string const getName() override { return "nc"; }
|
||||||
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ bool UseDeadlyPoisonAction::Execute(Event event) {
|
|||||||
std::vector<Item*> items;
|
std::vector<Item*> items;
|
||||||
std::string poison_name;
|
std::string poison_name;
|
||||||
for (std::string& suffix: poison_suffixs) {
|
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);
|
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||||
if (!items.empty()) {
|
if (!items.empty()) {
|
||||||
break;
|
break;
|
||||||
@@ -70,7 +70,7 @@ bool UseDeadlyPoisonAction::isPossible() {
|
|||||||
std::vector<Item*> items;
|
std::vector<Item*> items;
|
||||||
std::string poison_name;
|
std::string poison_name;
|
||||||
for (std::string& suffix: poison_suffixs) {
|
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);
|
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||||
if (!items.empty()) {
|
if (!items.empty()) {
|
||||||
break;
|
break;
|
||||||
@@ -84,7 +84,7 @@ bool UseInstantPoisonAction::Execute(Event event) {
|
|||||||
std::vector<Item*> items;
|
std::vector<Item*> items;
|
||||||
std::string poison_name;
|
std::string poison_name;
|
||||||
for (std::string& suffix: poison_suffixs) {
|
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);
|
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||||
if (!items.empty()) {
|
if (!items.empty()) {
|
||||||
break;
|
break;
|
||||||
@@ -102,11 +102,43 @@ bool UseInstantPoisonAction::isPossible() {
|
|||||||
std::vector<Item*> items;
|
std::vector<Item*> items;
|
||||||
std::string poison_name;
|
std::string poison_name;
|
||||||
for (std::string& suffix: poison_suffixs) {
|
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);
|
items = AI_VALUE2(std::vector<Item*>, "inventory items", poison_name);
|
||||||
if (!items.empty()) {
|
if (!items.empty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !items.empty();
|
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;
|
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
|
class FanOfKnivesAction : public CastMeleeSpellAction
|
||||||
{
|
{
|
||||||
public:
|
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["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 instant poison on main hand"] = &RogueAiObjectContextInternal::use_instant_poison;
|
||||||
creators["use deadly poison on off hand"] = &RogueAiObjectContextInternal::use_deadly_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["fan of knives"] = &RogueAiObjectContextInternal::fan_of_knives;
|
||||||
creators["killing spree"] = &RogueAiObjectContextInternal::killing_spree;
|
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* 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_instant_poison(PlayerbotAI* ai) { return new UseInstantPoisonAction(ai); }
|
||||||
static Action* use_deadly_poison(PlayerbotAI* ai) { return new UseDeadlyPoisonAction(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* fan_of_knives(PlayerbotAI* ai) { return new FanOfKnivesAction(ai); }
|
||||||
static Action* killing_spree(PlayerbotAI* ai) { return new CastKillingSpreeAction(ai); }
|
static Action* killing_spree(PlayerbotAI* ai) { return new CastKillingSpreeAction(ai); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user