fix party member dispel.

This commit is contained in:
Yunfan Li
2023-05-29 23:03:21 +08:00
parent aaa358bdbe
commit d45a7dc5b8
27 changed files with 316 additions and 89 deletions

View File

@@ -219,6 +219,8 @@ class ActionContext : public NamedObjectContext<Action>
creators["rpg trade useful"] = &ActionContext::rpg_trade_useful;
creators["rpg duel"] = &ActionContext::rpg_duel;
creators["rpg mount anim"] = &ActionContext::rpg_mount_anim;
creators["toggle pet spell"] = &ActionContext::toggle_pet_spell;
}
private:
@@ -378,6 +380,8 @@ class ActionContext : public NamedObjectContext<Action>
static Action* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulAction(botAI); }
static Action* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelAction(botAI); }
static Action* rpg_mount_anim(PlayerbotAI* botAI) { return new RpgMountAnimAction(botAI); }
static Action* toggle_pet_spell(PlayerbotAI* ai) { return new TogglePetSpellAutoCastAction(ai); }
};
#endif

View File

@@ -85,6 +85,7 @@ class ChatActionContext : public NamedObjectContext<Action>
creators["reputation"] = &ChatActionContext::reputation;
creators["log"] = &ChatActionContext::log;
creators["los"] = &ChatActionContext::los;
creators["aura"] = &ChatActionContext::aura;
creators["drop"] = &ChatActionContext::drop;
creators["clean quest log"] = &ChatActionContext::clean_quest_log;
creators["share"] = &ChatActionContext::share;
@@ -238,6 +239,7 @@ class ChatActionContext : public NamedObjectContext<Action>
static Action* reputation(PlayerbotAI* botAI) { return new TellReputationAction(botAI); }
static Action* log(PlayerbotAI* botAI) { return new LogLevelAction(botAI); }
static Action* los(PlayerbotAI* botAI) { return new TellLosAction(botAI); }
static Action* aura(PlayerbotAI* ai) { return new TellAuraAction(ai); }
static Action* ll(PlayerbotAI* botAI) { return new LootStrategyAction(botAI); }
static Action* ss(PlayerbotAI* botAI) { return new SkipSpellsListAction(botAI); }
static Action* add_all_loot(PlayerbotAI* botAI) { return new AddAllLootAction(botAI); }

View File

@@ -13,3 +13,30 @@ bool MeleeAction::isUseful()
return true;
}
bool TogglePetSpellAutoCastAction::Execute(Event event) {
Pet* pet = bot->GetPet();
if (!pet) {
return false;
}
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
{
if(itr->second.state == PETSPELL_REMOVED)
continue;
uint32 spellId = itr->first;
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (spellInfo->IsPassive())
continue;
// imp's spell, felhunte's intelligence, ghoul's leap
if (spellId == 4511 || spellId == 1742 ||
spellId == 54424 || spellId == 57564 || spellId == 57565 || spellId == 57566 || spellId == 57567 ||
spellId == 47482) {
pet->ToggleAutocast(spellInfo, false);
} else {
pet->ToggleAutocast(spellInfo, true);
}
}
return true;
}

View File

@@ -18,4 +18,11 @@ class MeleeAction : public AttackAction
bool isUseful() override;
};
class TogglePetSpellAutoCastAction: public Action
{
public:
TogglePetSpellAutoCastAction(PlayerbotAI* ai): Action(ai, "toggle pet spell") {}
virtual bool Execute(Event event) override;
};
#endif

View File

@@ -61,3 +61,68 @@ void TellLosAction::ListGameObjects(std::string const title, GuidVector gos)
botAI->TellMaster(chat->FormatGameobject(go));
}
}
bool TellAuraAction::Execute(Event event)
{
botAI->TellMaster("--- Auras ---");
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "--- Auras ---");
Unit::AuraApplicationMap& map = bot->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator i = map.begin(); i != map.end(); ++i)
{
Aura * aura = i->second->GetBase();
if (!aura)
continue;
const std::string auraName = aura->GetSpellInfo()->SpellName[0];
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "Info of Aura - name: " + auraName);
AuraObjectType type = aura->GetType();
WorldObject* owner = aura->GetOwner();
std::string owner_name = owner ? owner->GetName() : "unknown";
float distance = bot->GetDistance2d(owner);
Unit* caster = aura->GetCaster();
std::string caster_name = caster ? caster->GetName() : "unknown";
bool is_area = aura->IsArea();
int32 duration = aura->GetDuration();
const SpellInfo* spellInfo = aura->GetSpellInfo();
int32 spellId = aura->GetSpellInfo()->Id;
bool isPositive = aura->GetSpellInfo()->IsPositive();
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "Info of Aura - name: " + auraName +
" caster: " + caster_name +
" type: " + std::to_string(type) +
" owner: " + owner_name +
" distance: " + std::to_string(distance) +
" isArea: " + std::to_string(is_area) +
" duration: " + std::to_string(duration) +
" spellId: " + std::to_string(spellId) +
" isPositive: " + std::to_string(isPositive));
botAI->TellMaster("Info of Aura - name: " + auraName +
" caster: " + caster_name +
" type: " + std::to_string(type) +
" owner: " + owner_name +
" distance: " + std::to_string(distance) +
" isArea: " + std::to_string(is_area) +
" duration: " + std::to_string(duration) +
" spellId: " + std::to_string(spellId) +
" isPositive: " + std::to_string(isPositive));
if (type == DYNOBJ_AURA_TYPE) {
DynamicObject* dyn_owner = aura->GetDynobjOwner();
float radius = dyn_owner->GetRadius();
int32 spellId = dyn_owner->GetSpellId();
int32 duration = dyn_owner->GetDuration();
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, std::string("Info of DynamicObject -") +
" name: " + dyn_owner->GetName() +
" radius: " + std::to_string(radius) +
" spell id: " + std::to_string(spellId) +
" duration: " + std::to_string(duration));
botAI->TellMaster(std::string("Info of DynamicObject -") +
" name: " + dyn_owner->GetName() +
" radius: " + std::to_string(radius) +
" spell id: " + std::to_string(spellId) +
" duration: " + std::to_string(duration));
}
}
return true;
}

View File

@@ -21,4 +21,11 @@ class TellLosAction : public Action
void ListGameObjects(std::string const title, GuidVector gos);
};
class TellAuraAction : public Action
{
public:
TellAuraAction(PlayerbotAI* ai) : Action(ai, "aura") {}
virtual bool Execute(Event event);
};
#endif