mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-14 09:29:09 +00:00
Run clang-format
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
||||
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#include "UseItemAction.h"
|
||||
|
||||
#include "ChatHelper.h"
|
||||
#include "Event.h"
|
||||
#include "ItemUsageValue.h"
|
||||
@@ -19,7 +21,8 @@ bool UseItemAction::Execute(Event event)
|
||||
|
||||
if (gos.empty())
|
||||
{
|
||||
if (!items.empty()) {
|
||||
if (!items.empty())
|
||||
{
|
||||
return UseItemAuto(*items.begin());
|
||||
}
|
||||
}
|
||||
@@ -38,7 +41,7 @@ bool UseItemAction::Execute(Event event)
|
||||
bool UseItemAction::UseGameObject(ObjectGuid guid)
|
||||
{
|
||||
GameObject* go = botAI->GetGameObject(guid);
|
||||
if (!go || !go->isSpawned()/* || go->GetGoState() != GO_STATE_READY*/)
|
||||
if (!go || !go->isSpawned() /* || go->GetGoState() != GO_STATE_READY*/)
|
||||
return false;
|
||||
|
||||
go->Use(bot);
|
||||
@@ -49,20 +52,11 @@ bool UseItemAction::UseGameObject(ObjectGuid guid)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UseItemAction::UseItemAuto(Item* item)
|
||||
{
|
||||
return UseItem(item, ObjectGuid::Empty, nullptr);
|
||||
}
|
||||
bool UseItemAction::UseItemAuto(Item* item) { return UseItem(item, ObjectGuid::Empty, nullptr); }
|
||||
|
||||
bool UseItemAction::UseItemOnGameObject(Item* item, ObjectGuid go)
|
||||
{
|
||||
return UseItem(item, go, nullptr);
|
||||
}
|
||||
bool UseItemAction::UseItemOnGameObject(Item* item, ObjectGuid go) { return UseItem(item, go, nullptr); }
|
||||
|
||||
bool UseItemAction::UseItemOnItem(Item* item, Item* itemTarget)
|
||||
{
|
||||
return UseItem(item, ObjectGuid::Empty, itemTarget);
|
||||
}
|
||||
bool UseItemAction::UseItemOnItem(Item* item, Item* itemTarget) { return UseItem(item, ObjectGuid::Empty, itemTarget); }
|
||||
|
||||
bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Unit* unitTarget)
|
||||
{
|
||||
@@ -86,7 +80,8 @@ 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, itemTarget, item)) {
|
||||
if (!botAI->CanCastSpell(spellId, bot, false, itemTarget, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -143,21 +138,22 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
}
|
||||
}
|
||||
|
||||
Player* master = GetMaster();
|
||||
if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && master && botAI->HasActivePlayerMaster() && !selfOnly)
|
||||
{
|
||||
if (ObjectGuid masterSelection = master->GetTarget())
|
||||
{
|
||||
Player* master = GetMaster();
|
||||
if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && master &&
|
||||
botAI->HasActivePlayerMaster() && !selfOnly)
|
||||
{
|
||||
if (ObjectGuid masterSelection = master->GetTarget())
|
||||
{
|
||||
Unit* unit = botAI->GetUnit(masterSelection);
|
||||
if (unit)
|
||||
{
|
||||
targetFlag = TARGET_FLAG_UNIT;
|
||||
packet << targetFlag << masterSelection.WriteAsPacked();
|
||||
out << " on " << unit->GetName();
|
||||
targetSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
targetFlag = TARGET_FLAG_UNIT;
|
||||
packet << targetFlag << masterSelection.WriteAsPacked();
|
||||
out << " on " << unit->GetName();
|
||||
targetSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && unitTarget)
|
||||
{
|
||||
@@ -167,7 +163,6 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
targetSelected = true;
|
||||
}
|
||||
|
||||
|
||||
if (uint32 questid = item->GetTemplate()->StartQuest)
|
||||
{
|
||||
if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid))
|
||||
@@ -204,8 +199,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
if (!botAI->CanCastSpell(spellId, bot, false))
|
||||
continue;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (spellInfo->Targets & TARGET_FLAG_ITEM)
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (spellInfo->Targets & TARGET_FLAG_ITEM)
|
||||
{
|
||||
Item* itemForSpell = AI_VALUE2(Item*, "item for spell", spellId);
|
||||
if (!itemForSpell)
|
||||
@@ -230,7 +225,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
packet << targetFlag;
|
||||
packet << itemForSpell->GetGUID().WriteAsPacked();
|
||||
targetSelected = true;
|
||||
out << " on "<< chat->FormatItem(itemForSpell->GetTemplate());
|
||||
out << " on " << chat->FormatItem(itemForSpell->GetTemplate());
|
||||
}
|
||||
uint32 castTime = spellInfo->CalcCastTime();
|
||||
botAI->SetNextCheckDelay(castTime + sPlayerbotAIConfig->reactDelay);
|
||||
@@ -251,7 +246,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
ItemTemplate const* proto = item->GetTemplate();
|
||||
bool isDrink = proto->Spells[0].SpellCategory == 59;
|
||||
bool isFood = proto->Spells[0].SpellCategory == 11;
|
||||
if (proto->Class == ITEM_CLASS_CONSUMABLE && (proto->SubClass == ITEM_SUBCLASS_FOOD || proto->SubClass == ITEM_SUBCLASS_CONSUMABLE) && (isFood || isDrink))
|
||||
if (proto->Class == ITEM_CLASS_CONSUMABLE &&
|
||||
(proto->SubClass == ITEM_SUBCLASS_FOOD || proto->SubClass == ITEM_SUBCLASS_CONSUMABLE) && (isFood || isDrink))
|
||||
{
|
||||
if (bot->IsInCombat())
|
||||
return false;
|
||||
@@ -281,10 +277,10 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
botAI->SetNextCheckDelay(std::max(10000.0f, 27000.0f * (100 - p) / 100.0f));
|
||||
|
||||
if (!bot->IsInCombat() && bot->InBattleground())
|
||||
botAI->SetNextCheckDelay(std::max(10000.0f,20000.0f * (100 - p) / 100.0f));
|
||||
botAI->SetNextCheckDelay(std::max(10000.0f, 20000.0f * (100 - p) / 100.0f));
|
||||
|
||||
//botAI->SetNextCheckDelay(27000.0f * (100 - p) / 100.0f);
|
||||
// botAI->SetNextCheckDelay(20000);
|
||||
// botAI->SetNextCheckDelay(27000.0f * (100 - p) / 100.0f);
|
||||
// botAI->SetNextCheckDelay(20000);
|
||||
bot->GetSession()->HandleUseItemOpcode(packet);
|
||||
|
||||
return true;
|
||||
@@ -307,7 +303,7 @@ void UseItemAction::TellConsumableUse(Item* item, std::string const action, floa
|
||||
if (item->GetTemplate()->Stackable > 1)
|
||||
out << "/x" << item->GetCount();
|
||||
|
||||
out << " (" << round(percent) << "%)";
|
||||
out << " (" << round(percent) << "%)";
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
}
|
||||
|
||||
@@ -317,7 +313,8 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
||||
*packet << item->GetGUID();
|
||||
|
||||
bool fits = false;
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS;
|
||||
++enchant_slot)
|
||||
{
|
||||
uint8 SocketColor = item->GetTemplate()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color;
|
||||
GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gem->GetTemplate()->GemProperties);
|
||||
@@ -351,7 +348,6 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
||||
fits = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*packet << ObjectGuid::Empty;
|
||||
@@ -370,25 +366,13 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
||||
return fits;
|
||||
}
|
||||
|
||||
bool UseItemAction::isPossible()
|
||||
{
|
||||
return getName() == "use" || AI_VALUE2(uint32, "item count", getName()) > 0;
|
||||
}
|
||||
bool UseItemAction::isPossible() { return getName() == "use" || AI_VALUE2(uint32, "item count", getName()) > 0; }
|
||||
|
||||
bool UseSpellItemAction::isUseful()
|
||||
{
|
||||
return AI_VALUE2(bool, "spell cast useful", getName());
|
||||
}
|
||||
bool UseSpellItemAction::isUseful() { return AI_VALUE2(bool, "spell cast useful", getName()); }
|
||||
|
||||
bool UseHealingPotion::isUseful()
|
||||
{
|
||||
return AI_VALUE2(bool, "combat", "self target");
|
||||
}
|
||||
bool UseHealingPotion::isUseful() { return AI_VALUE2(bool, "combat", "self target"); }
|
||||
|
||||
bool UseManaPotion::isUseful()
|
||||
{
|
||||
return AI_VALUE2(bool, "combat", "self target");
|
||||
}
|
||||
bool UseManaPotion::isUseful() { return AI_VALUE2(bool, "combat", "self target"); }
|
||||
|
||||
bool UseHearthStone::Execute(Event event)
|
||||
{
|
||||
@@ -410,20 +394,14 @@ bool UseHearthStone::Execute(Event event)
|
||||
return used;
|
||||
}
|
||||
|
||||
bool UseHearthStone::isUseful()
|
||||
{
|
||||
return !bot->InBattleground();
|
||||
}
|
||||
bool UseHearthStone::isUseful() { return !bot->InBattleground(); }
|
||||
|
||||
bool UseRandomRecipe::isUseful()
|
||||
{
|
||||
return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground();
|
||||
}
|
||||
|
||||
bool UseRandomRecipe::isPossible()
|
||||
{
|
||||
return AI_VALUE2(uint32, "item count", "recipe") > 0;
|
||||
}
|
||||
bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; }
|
||||
|
||||
bool UseRandomRecipe::Execute(Event event)
|
||||
{
|
||||
@@ -439,7 +417,7 @@ bool UseRandomRecipe::Execute(Event event)
|
||||
if (recipeName.empty())
|
||||
return false;
|
||||
|
||||
bool used = UseItemAction::Execute(Event(name,recipeName));
|
||||
bool used = UseItemAction::Execute(Event(name, recipeName));
|
||||
|
||||
if (used)
|
||||
botAI->SetNextCheckDelay(3.0 * IN_MILLISECONDS);
|
||||
@@ -452,10 +430,7 @@ bool UseRandomQuestItem::isUseful()
|
||||
return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT);
|
||||
}
|
||||
|
||||
bool UseRandomQuestItem::isPossible()
|
||||
{
|
||||
return AI_VALUE2(uint32, "item count", "quest") > 0;
|
||||
}
|
||||
bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; }
|
||||
|
||||
bool UseRandomQuestItem::Execute(Event event)
|
||||
{
|
||||
@@ -542,7 +517,7 @@ bool UseRandomQuestItem::Execute(Event event)
|
||||
bool used = UseItem(item, goTarget, nullptr, unitTarget);
|
||||
|
||||
if (used)
|
||||
botAI->SetNextCheckDelay(delay);
|
||||
botAI->SetNextCheckDelay(delay);
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user