Run clang-format

This commit is contained in:
Yunfan Li
2024-08-04 10:23:36 +08:00
parent 44da167492
commit 53611c9040
835 changed files with 35085 additions and 31861 deletions

View File

@@ -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 "ActiveSpellValue.h"
#include "Playerbots.h"
uint32 ActiveSpellValue::Calculate()
@@ -21,4 +23,3 @@ uint32 ActiveSpellValue::Calculate()
return 0;
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ACTIVESPELLVALUE_H
@@ -11,10 +12,12 @@ class PlayerbotAI;
class ActiveSpellValue : public CalculatedValue<uint32>
{
public:
ActiveSpellValue(PlayerbotAI* botAI, std::string const name = "active spell") : CalculatedValue<uint32>(botAI, name) { }
public:
ActiveSpellValue(PlayerbotAI* botAI, std::string const name = "active spell") : CalculatedValue<uint32>(botAI, name)
{
}
uint32 Calculate() override;
uint32 Calculate() override;
};
#endif

View File

@@ -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 "AlwaysLootListValue.h"
#include "Playerbots.h"
std::string const AlwaysLootListValue::Save()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ALWAYSLOOTLISTVALUE_H
@@ -11,14 +12,17 @@ class PlayerbotAI;
class AlwaysLootListValue : public ManualSetValue<std::set<uint32>&>
{
public:
AlwaysLootListValue(PlayerbotAI* botAI, std::string const name = "always loot list") : ManualSetValue<std::set<uint32>&>(botAI, list, name) { }
public:
AlwaysLootListValue(PlayerbotAI* botAI, std::string const name = "always loot list")
: ManualSetValue<std::set<uint32>&>(botAI, list, name)
{
}
std::string const Save() override;
bool Load(std::string const value) override;
std::string const Save() override;
bool Load(std::string const value) override;
private:
std::set<uint32> list;
private:
std::set<uint32> list;
};
#endif

View File

@@ -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 "AoeHealValues.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
@@ -10,34 +12,33 @@ uint8 AoeHealValue::Calculate()
{
Group* group = bot->GetGroup();
if (!group)
return 0;
return 0;
float range = 0;
if (qualifier == "low")
range = sPlayerbotAIConfig->lowHealth;
range = sPlayerbotAIConfig->lowHealth;
else if (qualifier == "medium")
range = sPlayerbotAIConfig->mediumHealth;
range = sPlayerbotAIConfig->mediumHealth;
else if (qualifier == "critical")
range = sPlayerbotAIConfig->criticalHealth;
else if (qualifier == "almost full")
range = sPlayerbotAIConfig->almostFullHealth;
range = sPlayerbotAIConfig->criticalHealth;
else if (qualifier == "almost full")
range = sPlayerbotAIConfig->almostFullHealth;
uint8 count = 0;
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player* player = ObjectAccessor::FindPlayer(itr->guid);
if (!player || !player->IsAlive())
continue;
if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance)
continue;
float percent = (static_cast<float> (player->GetHealth()) / player->GetMaxHealth()) * 100;
if (percent <= range)
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player* player = ObjectAccessor::FindPlayer(itr->guid);
if (!player || !player->IsAlive())
continue;
if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance)
continue;
float percent = (static_cast<float>(player->GetHealth()) / player->GetMaxHealth()) * 100;
if (percent <= range)
++count;
}
}
return count;
return count;
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_AOEHEALVALUES_H
@@ -12,10 +13,10 @@ class PlayerbotAI;
class AoeHealValue : public Uint8CalculatedValue, public Qualified
{
public:
AoeHealValue(PlayerbotAI* botAI, std::string const name = "aoe heal") : Uint8CalculatedValue(botAI, name) { }
public:
AoeHealValue(PlayerbotAI* botAI, std::string const name = "aoe heal") : Uint8CalculatedValue(botAI, name) {}
uint8 Calculate() override;
uint8 Calculate() override;
};
#endif

View File

@@ -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 "AoeValues.h"
#include "Playerbots.h"
#include "ServerFacade.h"
#include "SpellAuraEffects.h"
@@ -77,15 +79,13 @@ WorldLocation AoePositionValue::Calculate()
float x = (x1 + x2) / 2;
float y = (y1 + y2) / 2;
float z = bot->GetPositionZ() + CONTACT_DISTANCE;;
float z = bot->GetPositionZ() + CONTACT_DISTANCE;
;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(bot->GetMapId(), x, y, z, 0);
}
uint8 AoeCountValue::Calculate()
{
return FindMaxDensity(bot).size();
}
uint8 AoeCountValue::Calculate() { return FindMaxDensity(bot).size(); }
bool HasAreaDebuffValue::Calculate()
{
@@ -104,7 +104,7 @@ bool HasAreaDebuffValue::Calculate()
continue;
uint32 trigger_spell_id = proto->Effects[aurEff->GetEffIndex()].TriggerSpell;
if (trigger_spell_id == 29767) //Overload
if (trigger_spell_id == 29767) // Overload
{
return true;
}
@@ -122,25 +122,32 @@ Aura* AreaDebuffValue::Calculate()
{
// Unit::AuraApplicationMap& map = bot->GetAppliedAuras();
Unit::AuraEffectList const& aurasPeriodicDamage = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE);
Unit::AuraEffectList const& aurasPeriodicDamagePercent = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
Unit::AuraEffectList const& aurasPeriodicTriggerSpell = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL);
Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE);
Unit::AuraEffectList const& aurasPeriodicDamagePercent =
bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
Unit::AuraEffectList const& aurasPeriodicTriggerSpell =
bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL);
Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell =
bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE);
Unit::AuraEffectList const& aurasDummy = bot->GetAuraEffectsByType(SPELL_AURA_DUMMY);
for (const Unit::AuraEffectList& list : {aurasPeriodicDamage, aurasPeriodicDamagePercent, aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell, aurasDummy}) {
for (const Unit::AuraEffectList& list : {aurasPeriodicDamage, aurasPeriodicDamagePercent, aurasPeriodicTriggerSpell,
aurasPeriodicTriggerWithValueSpell, aurasDummy})
{
for (auto i = list.begin(); i != list.end(); ++i)
{
AuraEffect* aurEff = *i;
Aura *aura = aurEff->GetBase();
Aura* aura = aurEff->GetBase();
AuraObjectType type = aura->GetType();
bool isPositive = aura->GetSpellInfo()->IsPositive();
if (type == DYNOBJ_AURA_TYPE && !isPositive) {
if (type == DYNOBJ_AURA_TYPE && !isPositive)
{
DynamicObject* dynOwner = aura->GetDynobjOwner();
if (!dynOwner) {
if (!dynOwner)
{
continue;
}
return aura;
}
}
}
return nullptr;
return nullptr;
}

View File

@@ -1,54 +1,54 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_AOEVALUES_H
#define _PLAYERBOT_AOEVALUES_H
#include "AiObjectContext.h"
#include "GameObject.h"
#include "Object.h"
#include "Value.h"
#include "AiObjectContext.h"
class PlayerbotAI;
class AoePositionValue : public CalculatedValue<WorldLocation>
{
public:
AoePositionValue(PlayerbotAI* botAI) : CalculatedValue<WorldLocation>(botAI, "aoe position") { }
public:
AoePositionValue(PlayerbotAI* botAI) : CalculatedValue<WorldLocation>(botAI, "aoe position") {}
WorldLocation Calculate() override;
WorldLocation Calculate() override;
};
class AoeCountValue : public CalculatedValue<uint8>
{
public:
AoeCountValue(PlayerbotAI* botAI) : CalculatedValue<uint8>(botAI, "aoe count") { }
public:
AoeCountValue(PlayerbotAI* botAI) : CalculatedValue<uint8>(botAI, "aoe count") {}
uint8 Calculate() override;
uint8 Calculate() override;
};
class HasAreaDebuffValue : public BoolCalculatedValue, public Qualified
{
public:
HasAreaDebuffValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {}
public:
HasAreaDebuffValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {}
Unit* GetTarget()
{
AiObjectContext* ctx = AiObject::context;
Unit* GetTarget()
{
AiObjectContext* ctx = AiObject::context;
return ctx->GetValue<Unit*>(qualifier)->Get();
}
virtual bool Calculate();
return ctx->GetValue<Unit*>(qualifier)->Get();
}
virtual bool Calculate();
};
class AreaDebuffValue : public CalculatedValue<Aura*>
{
public:
AreaDebuffValue(PlayerbotAI* botAI) :
CalculatedValue<Aura*>(botAI, "area debuff", 1) { }
public:
AreaDebuffValue(PlayerbotAI* botAI) : CalculatedValue<Aura*>(botAI, "area debuff", 1) {}
Aura* Calculate() override;
Aura* Calculate() override;
};
#endif

View File

@@ -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 "Arrow.h"
#include "Map.h"
#include "Playerbots.h"
@@ -20,7 +22,8 @@ WorldLocation ArrowFormation::GetLocationInternal()
float offset = 0.f;
Player* master = botAI->GetMaster();
if (!master) {
if (!master)
{
return Formation::NullLocation;
}
float orientation = master->GetOrientation();
@@ -44,7 +47,7 @@ WorldLocation ArrowFormation::GetLocationInternal()
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
@@ -125,7 +128,7 @@ void FormationSlot::PlaceUnits(UnitPlacer* placer)
}
}
UnitPosition MultiLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint32 count)
UnitPosition MultiLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint32 count)
{
SingleLineUnitPlacer placer(orientation);
if (count <= 6)
@@ -139,7 +142,7 @@ UnitPosition MultiLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint3
return placer.Place(unit, indexInLine, lineSize);
}
UnitPosition SingleLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint32 count)
UnitPosition SingleLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint32 count)
{
float angle = orientation - M_PI / 2.0f;
float x = cos(angle) * sPlayerbotAIConfig->followDistance * ((float)index - (float)count / 2);

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ARROW_H
@@ -13,107 +14,114 @@ class PlayerbotAI;
class UnitPosition
{
public:
UnitPosition(float x, float y) : x(x), y(y) { }
UnitPosition(UnitPosition const& other)
{
x = other.x;
y = other.y;
}
public:
UnitPosition(float x, float y) : x(x), y(y) {}
UnitPosition(UnitPosition const& other)
{
x = other.x;
y = other.y;
}
float x, y;
float x, y;
};
class FormationUnit
{
public:
FormationUnit(uint32 groupIndex, bool master) : groupIndex(groupIndex), master(master), position(0, 0) { }
FormationUnit(FormationUnit const& other) : position(other.position.x, other.position.y)
{
groupIndex = other.groupIndex;
master = other.master;
}
public:
FormationUnit(uint32 groupIndex, bool master) : groupIndex(groupIndex), master(master), position(0, 0) {}
FormationUnit(FormationUnit const& other) : position(other.position.x, other.position.y)
{
groupIndex = other.groupIndex;
master = other.master;
}
uint32 GetGroupIdex() { return groupIndex; }
void SetLocation(UnitPosition pos) { position = pos; }
void SetLocation(float x, float y) { position.x = x; position.y = y; }
float GetX() { return position.x; }
float GetY() { return position.y; }
uint32 GetGroupIdex() { return groupIndex; }
void SetLocation(UnitPosition pos) { position = pos; }
void SetLocation(float x, float y)
{
position.x = x;
position.y = y;
}
float GetX() { return position.x; }
float GetY() { return position.y; }
private:
uint32 groupIndex;
bool master;
UnitPosition position;
private:
uint32 groupIndex;
bool master;
UnitPosition position;
};
class UnitPlacer
{
public:
UnitPlacer() { }
public:
UnitPlacer() {}
virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) = 0;
virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) = 0;
};
class FormationSlot
{
public:
FormationSlot() { }
virtual ~FormationSlot();
public:
FormationSlot() {}
virtual ~FormationSlot();
void AddLast(FormationUnit* unit) { units.push_back(unit); }
void InsertAtCenter(FormationUnit* unit) { units.insert(units.begin() + (units.size() + 1) / 2, unit); }
void PlaceUnits(UnitPlacer* placer);
void Move(float dx, float dy);
uint32 Size() const { return units.size(); }
void AddLast(FormationUnit* unit) { units.push_back(unit); }
void InsertAtCenter(FormationUnit* unit) { units.insert(units.begin() + (units.size() + 1) / 2, unit); }
void PlaceUnits(UnitPlacer* placer);
void Move(float dx, float dy);
uint32 Size() const { return units.size(); }
private:
WorldLocation center;
std::vector<FormationUnit*> units;
private:
WorldLocation center;
std::vector<FormationUnit*> units;
};
class MultiLineUnitPlacer : public UnitPlacer
{
public:
MultiLineUnitPlacer(float orientation) : UnitPlacer(), orientation(orientation) { }
public:
MultiLineUnitPlacer(float orientation) : UnitPlacer(), orientation(orientation) {}
UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) override;
UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) override;
private:
float orientation;
private:
float orientation;
};
class SingleLineUnitPlacer
{
public:
SingleLineUnitPlacer(float orientation) : orientation(orientation) { }
public:
SingleLineUnitPlacer(float orientation) : orientation(orientation) {}
virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count);
virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count);
private:
float orientation;
private:
float orientation;
};
class ArrowFormation : public MoveAheadFormation
{
public:
ArrowFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "arrow"), built(false), masterUnit(nullptr), botUnit(nullptr) { }
public:
ArrowFormation(PlayerbotAI* botAI)
: MoveAheadFormation(botAI, "arrow"), built(false), masterUnit(nullptr), botUnit(nullptr)
{
}
WorldLocation GetLocationInternal() override;
WorldLocation GetLocationInternal() override;
private:
void Build();
void FillSlotsExceptMaster();
void AddMasterToSlot();
FormationSlot* FindSlot(Player* member);
private:
void Build();
void FillSlotsExceptMaster();
void AddMasterToSlot();
FormationSlot* FindSlot(Player* member);
private:
FormationSlot tanks;
FormationSlot melee;
FormationSlot ranged;
FormationSlot healers;
FormationUnit* masterUnit;
FormationUnit* botUnit;
bool built;
private:
FormationSlot tanks;
FormationSlot melee;
FormationSlot ranged;
FormationSlot healers;
FormationUnit* masterUnit;
FormationUnit* botUnit;
bool built;
};
#endif

View File

@@ -1,28 +1,31 @@
/*
* 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 "AttackerCountValues.h"
#include "Playerbots.h"
#include "SharedDefines.h"
uint8 MyAttackerCountValue::Calculate()
{
return bot->getAttackers().size();
}
uint8 MyAttackerCountValue::Calculate() { return bot->getAttackers().size(); }
bool HasAggroValue::Calculate()
{
Unit* target = GetTarget();
if (!target) {
if (!target)
{
return true;
}
Unit* victim = target->GetVictim();
if (!victim) {
if (!victim)
{
return true;
}
bool isMT = botAI->IsMainTank(bot);
if (victim && (victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && botAI->IsTank(victim->ToPlayer())))) {
if (victim &&
(victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && botAI->IsTank(victim->ToPlayer()))))
{
return true;
}
return false;
@@ -33,7 +36,7 @@ uint8 AttackerCountValue::Calculate()
uint32 count = 0;
float range = sPlayerbotAIConfig->sightDistance;
GuidVector attackers = context->GetValue<GuidVector >("attackers")->Get();
GuidVector attackers = context->GetValue<GuidVector>("attackers")->Get();
for (ObjectGuid const guid : attackers)
{
Unit* unit = botAI->GetUnit(guid);
@@ -50,15 +53,14 @@ uint8 AttackerCountValue::Calculate()
uint8 BalancePercentValue::Calculate()
{
float playerLevel = 0,
attackerLevel = 0;
float playerLevel = 0, attackerLevel = 0;
if (Group* group = bot->GetGroup())
{
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *player = ObjectAccessor::FindPlayer(itr->guid);
Player* player = ObjectAccessor::FindPlayer(itr->guid);
if (!player || !player->IsAlive())
continue;

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ATTACKERCOUNTVALUES_H
@@ -13,38 +14,47 @@ class Unit;
class AttackerCountValue : public Uint8CalculatedValue, public Qualified
{
public:
AttackerCountValue(PlayerbotAI* botAI, std::string const name = "attackers count") : Uint8CalculatedValue(botAI, name) { }
public:
AttackerCountValue(PlayerbotAI* botAI, std::string const name = "attackers count")
: Uint8CalculatedValue(botAI, name)
{
}
Unit* GetTarget();
uint8 Calculate() override;
Unit* GetTarget();
uint8 Calculate() override;
};
class MyAttackerCountValue : public Uint8CalculatedValue, public Qualified
{
public:
MyAttackerCountValue(PlayerbotAI* botAI, std::string const name = "my attackers count") : Uint8CalculatedValue(botAI, name) { }
public:
MyAttackerCountValue(PlayerbotAI* botAI, std::string const name = "my attackers count")
: Uint8CalculatedValue(botAI, name)
{
}
Unit* GetTarget();
uint8 Calculate() override;
Unit* GetTarget();
uint8 Calculate() override;
};
class HasAggroValue : public BoolCalculatedValue, public Qualified
{
public:
HasAggroValue(PlayerbotAI* botAI, std::string const name = "has aggro") : BoolCalculatedValue(botAI, name) { }
public:
HasAggroValue(PlayerbotAI* botAI, std::string const name = "has aggro") : BoolCalculatedValue(botAI, name) {}
Unit* GetTarget();
bool Calculate() override;
Unit* GetTarget();
bool Calculate() override;
};
class BalancePercentValue : public Uint8CalculatedValue, public Qualified
{
public:
BalancePercentValue(PlayerbotAI* botAI, std::string const name = "balance percentage") : Uint8CalculatedValue(botAI, name) { }
public:
BalancePercentValue(PlayerbotAI* botAI, std::string const name = "balance percentage")
: Uint8CalculatedValue(botAI, name)
{
}
Unit* GetTarget();
uint8 Calculate() override;
Unit* GetTarget();
uint8 Calculate() override;
};
#endif

View File

@@ -1,13 +1,15 @@
/*
* 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 "AttackerWithoutAuraTargetValue.h"
#include "Playerbots.h"
Unit* AttackerWithoutAuraTargetValue::Calculate()
{
GuidVector attackers = botAI->GetAiObjectContext()->GetValue<GuidVector >("attackers")->Get();
GuidVector attackers = botAI->GetAiObjectContext()->GetValue<GuidVector>("attackers")->Get();
// Unit* target = botAI->GetAiObjectContext()->GetValue<Unit*>("current target")->Get();
uint32 max_health = 0;
Unit* result = nullptr;
@@ -20,11 +22,13 @@ Unit* AttackerWithoutAuraTargetValue::Calculate()
if (bot->GetDistance(unit) > botAI->GetRange(range))
continue;
if (unit->GetHealth() < max_health) {
if (unit->GetHealth() < max_health)
{
continue;
}
if (!botAI->HasAura(qualifier, unit, false, true)) {
if (!botAI->HasAura(qualifier, unit, false, true))
{
max_health = unit->GetHealth();
result = unit;
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ATTACKERWITHOUTAURATARGETVALUE_H
@@ -13,18 +14,21 @@ class Unit;
class AttackerWithoutAuraTargetValue : public UnitCalculatedValue, public Qualified
{
public:
AttackerWithoutAuraTargetValue(PlayerbotAI* botAI, std::string range = "spell") : UnitCalculatedValue(botAI, "attacker without aura"), range(range) { }
public:
AttackerWithoutAuraTargetValue(PlayerbotAI* botAI, std::string range = "spell")
: UnitCalculatedValue(botAI, "attacker without aura"), range(range)
{
}
protected:
Unit* Calculate() override;
std::string range;
protected:
Unit* Calculate() override;
std::string range;
};
class MeleeAttackerWithoutAuraTargetValue : public AttackerWithoutAuraTargetValue
{
public:
MeleeAttackerWithoutAuraTargetValue(PlayerbotAI* botAI) : AttackerWithoutAuraTargetValue(botAI, "melee") {}
public:
MeleeAttackerWithoutAuraTargetValue(PlayerbotAI* botAI) : AttackerWithoutAuraTargetValue(botAI, "melee") {}
};
#endif

View File

@@ -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 "AttackersValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -23,27 +25,30 @@ GuidVector AttackersValue::Calculate()
if (Group* group = bot->GetGroup())
AddAttackersOf(group, targets);
RemoveNonThreating(targets);
// prioritized target
GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets");
for (ObjectGuid target : prioritizedTargets) {
for (ObjectGuid target : prioritizedTargets)
{
Unit* unit = botAI->GetUnit(target);
if (unit && IsValidTarget(unit, bot)) {
if (unit && IsValidTarget(unit, bot))
{
targets.insert(unit);
}
}
if (Group* group = bot->GetGroup()) {
if (Group* group = bot->GetGroup())
{
ObjectGuid skullGuid = group->GetTargetIcon(7);
Unit* skullTarget = botAI->GetUnit(skullGuid);
if (skullTarget && IsValidTarget(skullTarget, bot)) {
if (skullTarget && IsValidTarget(skullTarget, bot))
{
targets.insert(skullTarget);
}
}
for (Unit* unit : targets)
result.push_back(unit->GetGUID());
for (Unit* unit : targets)
result.push_back(unit->GetGUID());
if (bot->duel && bot->duel->Opponent)
result.push_back(bot->duel->Opponent->GetGUID());
@@ -55,7 +60,8 @@ GuidVector AttackersValue::Calculate()
for (ObjectGuid const guid : possibleTargets)
{
Unit* unit = botAI->GetUnit(guid);
if (unit && unit->IsPlayer() && IsValidTarget(unit, bot)) {
if (unit && unit->IsPlayer() && IsValidTarget(unit, bot))
{
result.push_back(unit->GetGUID());
}
}
@@ -69,8 +75,9 @@ void AttackersValue::AddAttackersOf(Group* group, std::unordered_set<Unit*>& tar
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() || sServerFacade->GetDistance2d(bot, member) > sPlayerbotAIConfig->sightDistance)
Player* member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() ||
sServerFacade->GetDistance2d(bot, member) > sPlayerbotAIConfig->sightDistance)
continue;
AddAttackersOf(member, targets);
@@ -79,14 +86,11 @@ void AttackersValue::AddAttackersOf(Group* group, std::unordered_set<Unit*>& tar
struct AddGuardiansHelper
{
explicit AddGuardiansHelper(std::vector<Unit*> &units) : units(units) { }
explicit AddGuardiansHelper(std::vector<Unit*>& units) : units(units) {}
void operator()(Unit* target) const
{
units.push_back(target);
}
void operator()(Unit* target) const { units.push_back(target); }
std::vector<Unit*> &units;
std::vector<Unit*>& units;
};
void AttackersValue::AddAttackersOf(Player* player, std::unordered_set<Unit*>& targets)
@@ -94,18 +98,20 @@ void AttackersValue::AddAttackersOf(Player* player, std::unordered_set<Unit*>& t
if (!player || !player->IsInWorld() || player->IsBeingTeleported())
return;
HostileRefMgr& refManager = player->getHostileRefMgr();
HostileReference *ref = refManager.getFirst();
HostileRefMgr& refManager = player->getHostileRefMgr();
HostileReference* ref = refManager.getFirst();
if (!ref)
return;
while( ref )
while (ref)
{
ThreatMgr *threatMgr = ref->GetSource();
Unit *attacker = threatMgr->GetOwner();
Unit *victim = attacker->GetVictim();
ThreatMgr* threatMgr = ref->GetSource();
Unit* attacker = threatMgr->GetOwner();
Unit* victim = attacker->GetVictim();
if (player->IsValidAttackTarget(attacker) && player->GetDistance2d(attacker) < sPlayerbotAIConfig->sightDistance) {
if (player->IsValidAttackTarget(attacker) &&
player->GetDistance2d(attacker) < sPlayerbotAIConfig->sightDistance)
{
targets.insert(attacker);
}
ref = ref->next();
@@ -114,12 +120,12 @@ void AttackersValue::AddAttackersOf(Player* player, std::unordered_set<Unit*>& t
void AttackersValue::RemoveNonThreating(std::unordered_set<Unit*>& targets)
{
for(std::unordered_set<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
for (std::unordered_set<Unit*>::iterator tIter = targets.begin(); tIter != targets.end();)
{
Unit* unit = *tIter;
if(bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot))
if (bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot))
{
std::unordered_set<Unit *>::iterator tIter2 = tIter;
std::unordered_set<Unit*>::iterator tIter2 = tIter;
++tIter;
targets.erase(tIter2);
}
@@ -128,18 +134,14 @@ void AttackersValue::RemoveNonThreating(std::unordered_set<Unit*>& targets)
}
}
bool AttackersValue::hasRealThreat(Unit *attacker)
bool AttackersValue::hasRealThreat(Unit* attacker)
{
return attacker &&
attacker->IsInWorld() &&
attacker->IsAlive() &&
!attacker->IsPolymorphed() &&
// !attacker->isInRoots() &&
!attacker->IsFriendlyTo(bot);
(attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast<Player*>(attacker));
return attacker && attacker->IsInWorld() && attacker->IsAlive() && !attacker->IsPolymorphed() &&
// !attacker->isInRoots() &&
!attacker->IsFriendlyTo(bot);
(attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast<Player*>(attacker));
}
bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
{
Creature* c = attacker->ToCreature();
@@ -148,7 +150,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
rti = bot->GetGroup()->GetTargetIcon(7) == attacker->GetGUID();
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
bool leaderHasThreat = false;
if (attacker && bot->GetGroup() && botAI->GetMaster())
leaderHasThreat = attacker->GetThreatMgr().GetThreat(botAI->GetMaster());
@@ -163,40 +165,48 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
// bool inCannon = botAI->IsInVehicle(false, true);
// bool enemy = botAI->GetAiObjectContext()->GetValue<Unit*>("enemy player target")->Get();
return attacker && attacker->IsVisible() &&
attacker->IsInWorld() &&
attacker->GetMapId() == bot->GetMapId() &&
!attacker->isDead() &&
!attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) &&
// (inCannon || !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) && attacker->CanSeeOrDetect(bot) &&
// !(attacker->HasUnitState(UNIT_STATE_STUNNED) && botAI->HasAura("shackle undead", attacker)) && !((attacker->IsPolymorphed() || botAI->HasAura("sap", attacker) || /*attacker->IsCharmed() ||*/ attacker->isFeared()) && !rti) &&
/*!sServerFacade->IsInRoots(attacker) &&*/
!attacker->IsFriendlyTo(bot) &&
!attacker->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) &&
// !(attacker->GetGUID().IsPet() && enemy) &&
!(attacker->GetCreatureType() == CREATURE_TYPE_CRITTER && !attacker->IsInCombat()) &&
!attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) &&
!attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) &&
bot->CanSeeOrDetect(attacker) &&
!(sPlayerbotAIConfig->IsPvpProhibited(attacker->GetZoneId(), attacker->GetAreaId()) && (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) &&
!(attacker->IsPlayer() && !attacker->IsPvP() && !attacker->IsFFAPvP() && (!bot->duel || bot->duel->Opponent != attacker)) &&
(!c || (!c->IsInEvadeMode() && ((!isMemberBotGroup && botAI->HasStrategy("attack tagged", BOT_STATE_NON_COMBAT)) ||
leaderHasThreat || (!c->hasLootRecipient() && (!c->GetVictim() || (c->GetVictim() && ((!c->GetVictim()->IsPlayer() || bot->IsInSameGroupWith(c->GetVictim()->ToPlayer())) ||
(botAI->GetMaster() && c->GetVictim() == botAI->GetMaster()))))) || c->isTappedBy(bot))));
return attacker && attacker->IsVisible() && attacker->IsInWorld() && attacker->GetMapId() == bot->GetMapId() &&
!attacker->isDead() &&
!attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) &&
// (inCannon || !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) &&
// attacker->CanSeeOrDetect(bot) &&
// !(attacker->HasUnitState(UNIT_STATE_STUNNED) && botAI->HasAura("shackle undead", attacker)) &&
// !((attacker->IsPolymorphed() || botAI->HasAura("sap", attacker) || /*attacker->IsCharmed() ||*/
// attacker->isFeared()) && !rti) &&
/*!sServerFacade->IsInRoots(attacker) &&*/
!attacker->IsFriendlyTo(bot) && !attacker->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) &&
// !(attacker->GetGUID().IsPet() && enemy) &&
!(attacker->GetCreatureType() == CREATURE_TYPE_CRITTER && !attacker->IsInCombat()) &&
!attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && !attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) &&
bot->CanSeeOrDetect(attacker) &&
!(sPlayerbotAIConfig->IsPvpProhibited(attacker->GetZoneId(), attacker->GetAreaId()) &&
(attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) &&
!(attacker->IsPlayer() && !attacker->IsPvP() && !attacker->IsFFAPvP() &&
(!bot->duel || bot->duel->Opponent != attacker)) &&
(!c ||
(!c->IsInEvadeMode() &&
((!isMemberBotGroup && botAI->HasStrategy("attack tagged", BOT_STATE_NON_COMBAT)) || leaderHasThreat ||
(!c->hasLootRecipient() &&
(!c->GetVictim() ||
(c->GetVictim() &&
((!c->GetVictim()->IsPlayer() || bot->IsInSameGroupWith(c->GetVictim()->ToPlayer())) ||
(botAI->GetMaster() && c->GetVictim() == botAI->GetMaster()))))) ||
c->isTappedBy(bot))));
}
bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot)
bool AttackersValue::IsValidTarget(Unit* attacker, Player* bot)
{
return IsPossibleTarget(attacker, bot) && bot->IsWithinLOSInMap(attacker);
// (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
// attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
// (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
// attacker->GetGUID().IsPlayer() || attacker->GetGUID() ==
// GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
}
bool PossibleAddsValue::Calculate()
{
GuidVector possible = botAI->GetAiObjectContext()->GetValue<GuidVector >("possible targets no los")->Get();
GuidVector attackers = botAI->GetAiObjectContext()->GetValue<GuidVector >("attackers")->Get();
GuidVector possible = botAI->GetAiObjectContext()->GetValue<GuidVector>("possible targets no los")->Get();
GuidVector attackers = botAI->GetAiObjectContext()->GetValue<GuidVector>("attackers")->Get();
for (ObjectGuid const guid : possible)
{

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ATTACKERSVALUE_H
@@ -15,32 +16,37 @@ class Unit;
class AttackersValue : public ObjectGuidListCalculatedValue
{
public:
AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 1 * 1000) { }
public:
AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 1 * 1000) {}
GuidVector Calculate();
static bool IsPossibleTarget(Unit* attacker, Player* bot, float range = sPlayerbotAIConfig->sightDistance);
static bool IsValidTarget(Unit* attacker, Player* bot);
GuidVector Calculate();
static bool IsPossibleTarget(Unit* attacker, Player* bot, float range = sPlayerbotAIConfig->sightDistance);
static bool IsValidTarget(Unit* attacker, Player* bot);
private:
void AddAttackersOf(Group* group, std::unordered_set<Unit*>& targets);
void AddAttackersOf(Player* player, std::unordered_set<Unit*>& targets);
void RemoveNonThreating(std::unordered_set<Unit*>& targets);
bool hasRealThreat(Unit* attacker);
private:
void AddAttackersOf(Group* group, std::unordered_set<Unit*>& targets);
void AddAttackersOf(Player* player, std::unordered_set<Unit*>& targets);
void RemoveNonThreating(std::unordered_set<Unit*>& targets);
bool hasRealThreat(Unit* attacker);
};
class PossibleAddsValue : public BoolCalculatedValue
{
public:
PossibleAddsValue(PlayerbotAI* botAI, std::string const name = "possible adds") : BoolCalculatedValue(botAI, name) { }
public:
PossibleAddsValue(PlayerbotAI* botAI, std::string const name = "possible adds") : BoolCalculatedValue(botAI, name)
{
}
bool Calculate() override;
bool Calculate() override;
};
class PrioritizedTargetsValue : public ManualSetValue<GuidVector>
{
public:
PrioritizedTargetsValue(PlayerbotAI* botAI, std::string const name = "prioritized targets"): ManualSetValue(botAI, GuidVector(), name) {}
{
public:
PrioritizedTargetsValue(PlayerbotAI* botAI, std::string const name = "prioritized targets")
: ManualSetValue(botAI, GuidVector(), name)
{
}
};
#endif

View File

@@ -1,23 +1,24 @@
/*
* 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 "AvailableLootValue.h"
#include "LootObjectStack.h"
#include "Playerbots.h"
#include "ServerFacade.h"
AvailableLootValue::AvailableLootValue(PlayerbotAI* botAI, std::string const name) : ManualSetValue<LootObjectStack*>(botAI, nullptr, name)
AvailableLootValue::AvailableLootValue(PlayerbotAI* botAI, std::string const name)
: ManualSetValue<LootObjectStack*>(botAI, nullptr, name)
{
value = new LootObjectStack(botAI->GetBot());
}
AvailableLootValue::~AvailableLootValue()
{
delete value;
}
AvailableLootValue::~AvailableLootValue() { delete value; }
LootTargetValue::LootTargetValue(PlayerbotAI* botAI, std::string const name) : ManualSetValue<LootObject>(botAI, LootObject(), name)
LootTargetValue::LootTargetValue(PlayerbotAI* botAI, std::string const name)
: ManualSetValue<LootObject>(botAI, LootObject(), name)
{
}
@@ -25,5 +26,5 @@ bool CanLootValue::Calculate()
{
LootObject loot = AI_VALUE(LootObject, "loot target");
return !loot.IsEmpty() && loot.GetWorldObject(bot) && loot.IsLootPossible(bot) &&
sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), INTERACTION_DISTANCE);
sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), INTERACTION_DISTANCE);
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_AVAILABLELOOTVALUE_H
@@ -12,23 +13,23 @@ class PlayerbotAI;
class AvailableLootValue : public ManualSetValue<LootObjectStack*>
{
public:
AvailableLootValue(PlayerbotAI* botAI, std::string const name = "available loot");
virtual ~AvailableLootValue();
public:
AvailableLootValue(PlayerbotAI* botAI, std::string const name = "available loot");
virtual ~AvailableLootValue();
};
class LootTargetValue : public ManualSetValue<LootObject>
{
public:
LootTargetValue(PlayerbotAI* botAI, std::string const name = "loot target");
public:
LootTargetValue(PlayerbotAI* botAI, std::string const name = "loot target");
};
class CanLootValue : public BoolCalculatedValue
{
public:
CanLootValue(PlayerbotAI* botAI, std::string const name = "can loot") : BoolCalculatedValue(botAI, name) { }
public:
CanLootValue(PlayerbotAI* botAI, std::string const name = "can loot") : BoolCalculatedValue(botAI, name) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "BudgetValues.h"
#include "Playerbots.h"
uint32 MaxGearRepairCostValue::Calculate()
@@ -22,7 +24,7 @@ uint32 MaxGearRepairCostValue::Calculate()
uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY);
if (i >= EQUIPMENT_SLOT_END && curDurability >= maxDurability) //Only count items equiped or already damanged.
if (i >= EQUIPMENT_SLOT_END && curDurability >= maxDurability) // Only count items equiped or already damanged.
continue;
ItemTemplate const* ditemProto = item->GetTemplate();
@@ -36,11 +38,11 @@ uint32 MaxGearRepairCostValue::Calculate()
if (!dQualitymodEntry)
continue;
uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)];
uint32 dmultiplier =
dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)];
uint32 costs = uint32(maxDurability * dmultiplier * double(dQualitymodEntry->quality_mod));
TotalCost += costs;
}
@@ -80,7 +82,8 @@ uint32 RepairCostValue::Calculate()
if (!dQualitymodEntry)
continue;
uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)];
uint32 dmultiplier =
dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)];
uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod));
TotalCost += costs;
@@ -109,7 +112,8 @@ uint32 TrainCostValue::Calculate()
if (!trainer_spells)
continue;
for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin(); iter != trainer_spells->spellList.end(); ++iter)
for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin();
iter != trainer_spells->spellList.end(); ++iter)
{
TrainerSpell const* tSpell = &iter->second;
if (!tSpell)
@@ -136,14 +140,14 @@ uint32 TrainCostValue::Calculate()
uint32 MoneyNeededForValue::Calculate()
{
NeedMoneyFor needMoneyFor = NeedMoneyFor(stoi(getQualifier()));
NeedMoneyFor needMoneyFor = NeedMoneyFor(stoi(getQualifier()));
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
AiObjectContext* context = botAI->GetAiObjectContext();
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
AiObjectContext* context = botAI->GetAiObjectContext();
uint32 moneyWanted = 0;
uint32 moneyWanted = 0;
uint32 level = bot->GetLevel();
uint32 level = bot->GetLevel();
switch (needMoneyFor)
{
@@ -154,37 +158,49 @@ uint32 MoneyNeededForValue::Calculate()
moneyWanted = AI_VALUE(uint32, "max repair cost");
break;
case NeedMoneyFor::ammo:
moneyWanted = (bot->getClass() == CLASS_HUNTER) ? (level * level * level) / 10 : 0; //Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace (should be best ammo buyable x 8 stacks cost)
moneyWanted = (bot->getClass() == CLASS_HUNTER)
? (level * level * level) / 10
: 0; // Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace
// (should be best ammo buyable x 8 stacks cost)
break;
case NeedMoneyFor::spells:
moneyWanted = AI_VALUE(uint32, "train cost");
break;
case NeedMoneyFor::travel:
moneyWanted = bot->isTaxiCheater() ? 0 : 1500; //15s for traveling half a continent. Todo: Add better calculation (Should be ???)
moneyWanted =
bot->isTaxiCheater()
? 0
: 1500; // 15s for traveling half a continent. Todo: Add better calculation (Should be ???)
break;
case NeedMoneyFor::gear:
moneyWanted = level * level * level; //Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace (Should be ~total cost of all >green gear equiped)
moneyWanted = level * level * level; // Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80):
// Todo replace (Should be ~total cost of all >green gear equiped)
break;
case NeedMoneyFor::consumables:
moneyWanted = (level * level * level) / 10; //Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace (Should be best food/drink x 2 stacks cost)
moneyWanted =
(level * level * level) / 10; // Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo
// replace (Should be best food/drink x 2 stacks cost)
break;
case NeedMoneyFor::guild:
if (botAI->HasStrategy("guild", BOT_STATE_NON_COMBAT))
{
if (bot->GetGuildId())
moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)) ? 0 : 10000; //1g (tabard)
moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)) ? 0 : 10000; // 1g (tabard)
else
moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) ? 0 : 10000; //10s (guild charter)
moneyWanted =
AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) ? 0 : 10000; // 10s (guild charter)
}
break;
case NeedMoneyFor::tradeskill:
moneyWanted = (level * level * level); //Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace (Should be buyable reagents that combined allow crafting of usefull items)
moneyWanted = (level * level *
level); // Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace
// (Should be buyable reagents that combined allow crafting of usefull items)
break;
default:
break;
}
return moneyWanted;
return moneyWanted;
};
uint32 TotalMoneyNeededForValue::Calculate()
@@ -217,7 +233,8 @@ uint32 FreeMoneyForValue::Calculate()
if (botAI->HasActivePlayerMaster())
return money;
uint32 savedMoney = AI_VALUE2(uint32, "total money needed for", getQualifier()) - AI_VALUE2(uint32, "money needed for", getQualifier());
uint32 savedMoney = AI_VALUE2(uint32, "total money needed for", getQualifier()) -
AI_VALUE2(uint32, "money needed for", getQualifier());
if (savedMoney > money)
return 0;
@@ -225,7 +242,4 @@ uint32 FreeMoneyForValue::Calculate()
return money - savedMoney;
};
bool ShouldGetMoneyValue::Calculate()
{
return !AI_VALUE2(uint32, "free money for", (uint32) NeedMoneyFor::anything);
};
bool ShouldGetMoneyValue::Calculate() { return !AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::anything); };

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_BUDGETVALUES_H
@@ -12,75 +13,76 @@ class PlayerbotAI;
enum class NeedMoneyFor : uint32
{
none = 0,
repair = 1,
ammo = 2,
spells = 3,
travel = 4,
none = 0,
repair = 1,
ammo = 2,
spells = 3,
travel = 4,
consumables = 5,
gear = 6,
guild = 7,
tradeskill = 8,
anything = 9
gear = 6,
guild = 7,
tradeskill = 8,
anything = 9
};
class MaxGearRepairCostValue : public Uint32CalculatedValue
{
public:
MaxGearRepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI,"max repair cost", 60) { }
public:
MaxGearRepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "max repair cost", 60) {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class RepairCostValue : public Uint32CalculatedValue
{
public:
RepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "repair cost", 60) { }
public:
RepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "repair cost", 60) {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class TrainCostValue : public Uint32CalculatedValue
{
public:
TrainCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "train cost", 60) { }
public:
TrainCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "train cost", 60) {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class MoneyNeededForValue : public Uint32CalculatedValue, public Qualified
{
public:
MoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "money needed for",60) { }
public:
MoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "money needed for", 60) {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class TotalMoneyNeededForValue : public Uint32CalculatedValue, public Qualified
{
public:
TotalMoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "total money needed for", 60) { }
public:
TotalMoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "total money needed for", 60) {}
uint32 Calculate() override;
uint32 Calculate() override;
private:
std::vector<NeedMoneyFor> saveMoneyFor = { NeedMoneyFor::guild,NeedMoneyFor::repair,NeedMoneyFor::ammo, NeedMoneyFor::spells, NeedMoneyFor::travel };
private:
std::vector<NeedMoneyFor> saveMoneyFor = {NeedMoneyFor::guild, NeedMoneyFor::repair, NeedMoneyFor::ammo,
NeedMoneyFor::spells, NeedMoneyFor::travel};
};
class FreeMoneyForValue : public Uint32CalculatedValue, public Qualified
{
public:
FreeMoneyForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "free money for") { }
public:
FreeMoneyForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "free money for") {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class ShouldGetMoneyValue : public BoolCalculatedValue
{
public:
ShouldGetMoneyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should get money",2) { }
public:
ShouldGetMoneyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should get money", 2) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -1,83 +1,90 @@
/*
* 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 "CcTargetValue.h"
#include "Action.h"
#include "Playerbots.h"
#include "ServerFacade.h"
class FindTargetForCcStrategy : public FindTargetStrategy
{
public:
FindTargetForCcStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell), maxDistance(0.f) { }
public:
FindTargetForCcStrategy(PlayerbotAI* botAI, std::string const spell)
: FindTargetStrategy(botAI), spell(spell), maxDistance(0.f)
{
}
public:
void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override
public:
void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override
{
Player* bot = botAI->GetBot();
if (!botAI->CanCastSpell(spell, creature))
return;
if (*botAI->GetAiObjectContext()->GetValue<Unit*>("rti cc target") == creature)
{
Player* bot = botAI->GetBot();
if (!botAI->CanCastSpell(spell, creature))
return;
if (*botAI->GetAiObjectContext()->GetValue<Unit*>("rti cc target") == creature)
{
result = creature;
return;
}
if (*botAI->GetAiObjectContext()->GetValue<Unit*>("current target") == creature)
return;
uint8 health = static_cast<uint8>(creature->GetHealthPct());
if (health < sPlayerbotAIConfig->mediumHealth)
return;
float minDistance = botAI->GetRange("spell");
Group* group = bot->GetGroup();
if (!group)
return;
if (*botAI->GetAiObjectContext()->GetValue<uint8>("aoe count") > 2)
{
WorldLocation aoe = *botAI->GetAiObjectContext()->GetValue<WorldLocation>("aoe position");
if (sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(creature, aoe.GetPositionX(), aoe.GetPositionY()), sPlayerbotAIConfig->aoeRadius))
return;
}
uint32 tankCount = 0;
uint32 dpsCount = 0;
GetPlayerCount(creature, &tankCount, &dpsCount);
if (!tankCount || !dpsCount)
{
result = creature;
return;
}
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot)
continue;
if (!botAI->IsTank(member))
continue;
float distance = sServerFacade->GetDistance2d(member, creature);
if (distance < minDistance)
minDistance = distance;
}
if (!result || minDistance > maxDistance)
{
result = creature;
maxDistance = minDistance;
}
result = creature;
return;
}
private:
std::string const spell;
float maxDistance;
if (*botAI->GetAiObjectContext()->GetValue<Unit*>("current target") == creature)
return;
uint8 health = static_cast<uint8>(creature->GetHealthPct());
if (health < sPlayerbotAIConfig->mediumHealth)
return;
float minDistance = botAI->GetRange("spell");
Group* group = bot->GetGroup();
if (!group)
return;
if (*botAI->GetAiObjectContext()->GetValue<uint8>("aoe count") > 2)
{
WorldLocation aoe = *botAI->GetAiObjectContext()->GetValue<WorldLocation>("aoe position");
if (sServerFacade->IsDistanceLessOrEqualThan(
sServerFacade->GetDistance2d(creature, aoe.GetPositionX(), aoe.GetPositionY()),
sPlayerbotAIConfig->aoeRadius))
return;
}
uint32 tankCount = 0;
uint32 dpsCount = 0;
GetPlayerCount(creature, &tankCount, &dpsCount);
if (!tankCount || !dpsCount)
{
result = creature;
return;
}
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player* member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot)
continue;
if (!botAI->IsTank(member))
continue;
float distance = sServerFacade->GetDistance2d(member, creature);
if (distance < minDistance)
minDistance = distance;
}
if (!result || minDistance > maxDistance)
{
result = creature;
maxDistance = minDistance;
}
}
private:
std::string const spell;
float maxDistance;
};
Unit* CcTargetValue::Calculate()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_CCTARGETVALUE_H
@@ -13,10 +14,10 @@ class Unit;
class CcTargetValue : public TargetValue, public Qualified
{
public:
CcTargetValue(PlayerbotAI* botAI, std::string const name = "cc target") : TargetValue(botAI, name) { }
public:
CcTargetValue(PlayerbotAI* botAI, std::string const name = "cc target") : TargetValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_CHATVALUE_H
@@ -13,8 +14,11 @@ enum ChatMsg : uint32;
class ChatValue : public ManualSetValue<ChatMsg>
{
public:
ChatValue(PlayerbotAI* botAI, std::string const name = "chat") : ManualSetValue<ChatMsg>(botAI, CHAT_MSG_WHISPER, name) { }
public:
ChatValue(PlayerbotAI* botAI, std::string const name = "chat")
: ManualSetValue<ChatMsg>(botAI, CHAT_MSG_WHISPER, name)
{
}
};
#endif

View File

@@ -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 "CollisionValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_COLLISIONVALUE_H
@@ -12,10 +13,13 @@ class PlayerbotAI;
class CollisionValue : public BoolCalculatedValue, public Qualified
{
public:
CollisionValue(PlayerbotAI* botAI, std::string const name = "collision") : BoolCalculatedValue(botAI, name), Qualified() { }
public:
CollisionValue(PlayerbotAI* botAI, std::string const name = "collision")
: BoolCalculatedValue(botAI, name), Qualified()
{
}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -1,71 +1,72 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_CRAFTVALUE_H
#define _PLAYERBOT_CRAFTVALUE_H
#include "Value.h"
#include <map>
#include "Value.h"
class PlayerbotAI;
class CraftData
{
public:
CraftData() : itemId(0) { }
CraftData(CraftData const& other) : itemId(other.itemId)
public:
CraftData() : itemId(0) {}
CraftData(CraftData const& other) : itemId(other.itemId)
{
required.insert(other.required.begin(), other.required.end());
obtained.insert(other.obtained.begin(), other.obtained.end());
}
uint32 itemId;
std::map<uint32, uint32> required, obtained;
bool IsEmpty() { return itemId == 0; }
void Reset() { itemId = 0; }
bool IsRequired(uint32 item) { return required.find(item) != required.end(); }
bool IsFulfilled()
{
for (std::map<uint32, uint32>::iterator i = required.begin(); i != required.end(); ++i)
{
required.insert(other.required.begin(), other.required.end());
obtained.insert(other.obtained.begin(), other.obtained.end());
uint32 item = i->first;
if (obtained[item] < i->second)
return false;
}
uint32 itemId;
std::map<uint32, uint32> required, obtained;
bool IsEmpty() { return itemId == 0; }
void Reset() { itemId = 0; }
bool IsRequired(uint32 item) { return required.find(item) != required.end(); }
bool IsFulfilled()
return true;
}
void AddObtained(uint32 itemId, uint32 count)
{
if (IsRequired(itemId))
{
for (std::map<uint32, uint32>::iterator i = required.begin(); i != required.end(); ++i)
{
uint32 item = i->first;
if (obtained[item] < i->second)
return false;
}
return true;
obtained[itemId] += count;
}
void AddObtained(uint32 itemId, uint32 count)
}
void Crafted(uint32 count)
{
for (std::map<uint32, uint32>::iterator i = required.begin(); i != required.end(); ++i)
{
if (IsRequired(itemId))
uint32 item = i->first;
if (obtained[item] >= required[item] * count)
{
obtained[itemId] += count;
}
}
void Crafted(uint32 count)
{
for (std::map<uint32, uint32>::iterator i = required.begin(); i != required.end(); ++i)
{
uint32 item = i->first;
if (obtained[item] >= required[item] * count)
{
obtained[item] -= required[item] * count;
}
obtained[item] -= required[item] * count;
}
}
}
};
class CraftValue : public ManualSetValue<CraftData&>
{
public:
CraftValue(PlayerbotAI* botAI, std::string const name = "craft") : ManualSetValue<CraftData&>(botAI, data, name) { }
public:
CraftValue(PlayerbotAI* botAI, std::string const name = "craft") : ManualSetValue<CraftData&>(botAI, data, name) {}
private:
CraftData data;
private:
CraftData data;
};
#endif

View File

@@ -1,23 +1,27 @@
/*
* 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 "CurrentCcTargetValue.h"
#include "Playerbots.h"
class FindCurrentCcTargetStrategy : public FindTargetStrategy
{
public:
FindCurrentCcTargetStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell) { }
public:
FindCurrentCcTargetStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell)
{
}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (botAI->HasAura(spell, attacker))
result = attacker;
}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (botAI->HasAura(spell, attacker))
result = attacker;
}
private:
std::string const spell;
private:
std::string const spell;
};
Unit* CurrentCcTargetValue::Calculate()

View File

@@ -1,22 +1,23 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_CURRENTCCTARGETVALUE_H
#define _PLAYERBOT_CURRENTCCTARGETVALUE_H
#include "TargetValue.h"
#include "NamedObjectContext.h"
#include "TargetValue.h"
class PlayerbotAI;
class Unit;
class CurrentCcTargetValue : public TargetValue, public Qualified
{
public:
CurrentCcTargetValue(PlayerbotAI* botAI, std::string const name = "current cc target") : TargetValue(botAI, name) { }
public:
CurrentCcTargetValue(PlayerbotAI* botAI, std::string const name = "current cc target") : TargetValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -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 "CurrentTargetValue.h"
#include "Playerbots.h"
Unit* CurrentTargetValue::Get()
@@ -17,7 +19,4 @@ Unit* CurrentTargetValue::Get()
return unit;
}
void CurrentTargetValue::Set(Unit* target)
{
selection = target ? target->GetGUID() : ObjectGuid::Empty;
}
void CurrentTargetValue::Set(Unit* target) { selection = target ? target->GetGUID() : ObjectGuid::Empty; }

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_CURRENTTARGETVALUE_H
@@ -12,14 +13,17 @@ class Unit;
class CurrentTargetValue : public UnitManualSetValue
{
public:
CurrentTargetValue(PlayerbotAI* botAI, std::string const name = "current target") : UnitManualSetValue(botAI, nullptr, name) { }
public:
CurrentTargetValue(PlayerbotAI* botAI, std::string const name = "current target")
: UnitManualSetValue(botAI, nullptr, name)
{
}
Unit* Get() override;
void Set(Unit* unit) override;
Unit* Get() override;
void Set(Unit* unit) override;
private:
ObjectGuid selection;
private:
ObjectGuid selection;
};
#endif

View File

@@ -1,14 +1,16 @@
/*
* 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 "DistanceValue.h"
#include "Formations.h"
#include "PositionValue.h"
#include "Stances.h"
#include "LootObjectStack.h"
#include "Playerbots.h"
#include "PositionValue.h"
#include "ServerFacade.h"
#include "Stances.h"
float DistanceValue::Calculate()
{

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_DISTANCEVALUE_H
@@ -12,18 +13,20 @@ class PlayerbotAI;
class DistanceValue : public FloatCalculatedValue, public Qualified
{
public:
DistanceValue(PlayerbotAI* botAI, std::string const name = "distance") : FloatCalculatedValue(botAI, name) { }
public:
DistanceValue(PlayerbotAI* botAI, std::string const name = "distance") : FloatCalculatedValue(botAI, name) {}
float Calculate() override;
float Calculate() override;
};
class InsideTargetValue : public BoolCalculatedValue, public Qualified
{
public:
InsideTargetValue(PlayerbotAI* botAI, std::string const name = "inside target") : BoolCalculatedValue(botAI, name) { }
public:
InsideTargetValue(PlayerbotAI* botAI, std::string const name = "inside target") : BoolCalculatedValue(botAI, name)
{
}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -1,240 +1,287 @@
/*
* 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 "DpsTargetValue.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
class FindMaxThreatGapTargetStrategy : public FindTargetStrategy
{
public:
FindMaxThreatGapTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), minThreat(0) { }
public:
FindMaxThreatGapTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), minThreat(0) {}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (!attacker->IsAlive())
{
if (!attacker->IsAlive()) {
return;
}
if (foundHighPriority) {
return;
}
if (IsHighPriority(attacker)) {
result = attacker;
foundHighPriority = true;
return;
}
Unit* victim = attacker->GetVictim();
if (!result || CalcThreatGap(attacker, threatMgr) > CalcThreatGap(result, &result->GetThreatMgr()))
result = attacker;
return;
}
float CalcThreatGap(Unit* attacker, ThreatMgr* threatMgr) {
Unit* victim = attacker->GetVictim();
return threatMgr->GetThreat(victim) - threatMgr->GetThreat(attacker);
if (foundHighPriority)
{
return;
}
if (IsHighPriority(attacker))
{
result = attacker;
foundHighPriority = true;
return;
}
Unit* victim = attacker->GetVictim();
if (!result || CalcThreatGap(attacker, threatMgr) > CalcThreatGap(result, &result->GetThreatMgr()))
result = attacker;
}
float CalcThreatGap(Unit* attacker, ThreatMgr* threatMgr)
{
Unit* victim = attacker->GetVictim();
return threatMgr->GetThreat(victim) - threatMgr->GetThreat(attacker);
}
protected:
float minThreat;
protected:
float minThreat;
};
// caster
class CasterFindTargetSmartStrategy : public FindTargetStrategy
{
public:
CasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { }
public:
CasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps)
: FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000)
{
}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (Group* group = botAI->GetBot()->GetGroup())
{
if (Group* group = botAI->GetBot()->GetGroup())
{
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (!attacker->IsAlive()) {
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (foundHighPriority) {
return;
}
if (IsHighPriority(attacker)) {
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result)) {
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit) {
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) {
return true;
}
int32_t level = GetIntervalLevel(new_unit);
if (level % 10 == 2 || level % 10 == 1) {
return new_time < old_time;
}
// dont switch targets when all of them with low health
Unit* currentTarget = botAI->GetAiObjectContext()->GetValue<Unit*>("current target")->Get();
if (currentTarget == new_unit) {
return true;
}
if (currentTarget == old_unit) {
return false;
}
return new_time > old_time;
if (!attacker->IsAlive())
{
return;
}
int32_t GetIntervalLevel(Unit* unit) {
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
if (time >= 3 && time <= 20) {
return level + 2;
}
if (time > 20) {
return level + 1;
}
return level;
if (foundHighPriority)
{
return;
}
if (IsHighPriority(attacker))
{
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result))
{
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit)
{
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit))
{
return true;
}
int32_t level = GetIntervalLevel(new_unit);
if (level % 10 == 2 || level % 10 == 1)
{
return new_time < old_time;
}
// dont switch targets when all of them with low health
Unit* currentTarget = botAI->GetAiObjectContext()->GetValue<Unit*>("current target")->Get();
if (currentTarget == new_unit)
{
return true;
}
if (currentTarget == old_unit)
{
return false;
}
return new_time > old_time;
}
int32_t GetIntervalLevel(Unit* unit)
{
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange =
botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
if (time >= 3 && time <= 20)
{
return level + 2;
}
if (time > 20)
{
return level + 1;
}
return level;
}
protected:
float dps_;
float targetExpectedLifeTime;
protected:
float dps_;
float targetExpectedLifeTime;
};
// non caster
class NonCasterFindTargetSmartStrategy : public FindTargetStrategy
{
public:
NonCasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { }
public:
NonCasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps)
: FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000)
{
}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (Group* group = botAI->GetBot()->GetGroup())
{
if (Group* group = botAI->GetBot()->GetGroup())
{
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (!attacker->IsAlive()) {
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (foundHighPriority) {
return;
}
if (IsHighPriority(attacker)) {
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result)) {
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit) {
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) {
return true;
}
// attack enemy in range and with lowest health
int level = GetIntervalLevel(new_unit);
if (level == 10) {
return new_time < old_time;
}
// all targets are far away, choose the closest one
return botAI->GetBot()->GetDistance(new_unit) < botAI->GetBot()->GetDistance(old_unit);
if (!attacker->IsAlive())
{
return;
}
int32_t GetIntervalLevel(Unit* unit) {
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
return level;
if (foundHighPriority)
{
return;
}
if (IsHighPriority(attacker))
{
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result))
{
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit)
{
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit))
{
return true;
}
// attack enemy in range and with lowest health
int level = GetIntervalLevel(new_unit);
if (level == 10)
{
return new_time < old_time;
}
// all targets are far away, choose the closest one
return botAI->GetBot()->GetDistance(new_unit) < botAI->GetBot()->GetDistance(old_unit);
}
int32_t GetIntervalLevel(Unit* unit)
{
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange =
botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
return level;
}
protected:
float dps_;
float targetExpectedLifeTime;
protected:
float dps_;
float targetExpectedLifeTime;
};
// combo
class ComboFindTargetSmartStrategy : public FindTargetStrategy
{
public:
ComboFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { }
public:
ComboFindTargetSmartStrategy(PlayerbotAI* botAI, float dps)
: FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000)
{
}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (Group* group = botAI->GetBot()->GetGroup())
{
if (Group* group = botAI->GetBot()->GetGroup())
{
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (!attacker->IsAlive()) {
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (foundHighPriority) {
return;
}
if (IsHighPriority(attacker)) {
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result)) {
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit) {
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) {
if (!attacker->IsAlive())
{
return;
}
if (foundHighPriority)
{
return;
}
if (IsHighPriority(attacker))
{
result = attacker;
foundHighPriority = true;
return;
}
float expectedLifeTime = attacker->GetHealth() / dps_;
// Unit* victim = attacker->GetVictim();
if (!result || IsBetter(attacker, result))
{
targetExpectedLifeTime = expectedLifeTime;
result = attacker;
}
}
bool IsBetter(Unit* new_unit, Unit* old_unit)
{
float new_time = new_unit->GetHealth() / dps_;
float old_time = old_unit->GetHealth() / dps_;
// [5-20] > (5-0] > (20-inf)
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit))
{
return true;
}
// attack enemy in range and with lowest health
int level = GetIntervalLevel(new_unit);
Player* bot = botAI->GetBot();
if (level == 10)
{
Unit* combo_unit = bot->GetComboTarget();
if (new_unit == combo_unit)
{
return true;
}
// attack enemy in range and with lowest health
int level = GetIntervalLevel(new_unit);
Player* bot = botAI->GetBot();
if (level == 10) {
Unit* combo_unit = bot->GetComboTarget();
if (new_unit == combo_unit) {
return true;
}
return new_time < old_time;
}
// all targets are far away, choose the closest one
return bot->GetDistance(new_unit) < bot->GetDistance(old_unit);
}
int32_t GetIntervalLevel(Unit* unit) {
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
return level;
return new_time < old_time;
}
// all targets are far away, choose the closest one
return bot->GetDistance(new_unit) < bot->GetDistance(old_unit);
}
int32_t GetIntervalLevel(Unit* unit)
{
float time = unit->GetHealth() / dps_;
float dis = unit->GetDistance(botAI->GetBot());
float attackRange =
botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance;
attackRange += 5.0f;
int level = dis < attackRange ? 10 : 0;
return level;
}
protected:
float dps_;
float targetExpectedLifeTime;
protected:
float dps_;
float targetExpectedLifeTime;
};
Unit* DpsTargetValue::Calculate()
@@ -245,10 +292,13 @@ Unit* DpsTargetValue::Calculate()
// FindLeastHpTargetStrategy strategy(botAI);
float dps = AI_VALUE(float, "expected group dps");
if (botAI->IsCaster(bot)) {
if (botAI->IsCaster(bot))
{
CasterFindTargetSmartStrategy strategy(botAI, dps);
return TargetValue::FindTarget(&strategy);
} else if (botAI->IsCombo(bot)) {
}
else if (botAI->IsCombo(bot))
{
ComboFindTargetSmartStrategy strategy(botAI, dps);
return TargetValue::FindTarget(&strategy);
}
@@ -258,24 +308,24 @@ Unit* DpsTargetValue::Calculate()
class FindMaxHpTargetStrategy : public FindTargetStrategy
{
public:
FindMaxHpTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), maxHealth(0) { }
public:
FindMaxHpTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), maxHealth(0) {}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
if (Group* group = botAI->GetBot()->GetGroup())
{
if (Group* group = botAI->GetBot()->GetGroup())
{
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
if (!result || result->GetHealth() < attacker->GetHealth())
result = attacker;
ObjectGuid guid = group->GetTargetIcon(4);
if (guid && attacker->GetGUID() == guid)
return;
}
protected:
float maxHealth;
if (!result || result->GetHealth() < attacker->GetHealth())
result = attacker;
}
protected:
float maxHealth;
};
Unit* DpsAoeTargetValue::Calculate()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_DPSTARGETVALUE_H
@@ -11,18 +12,24 @@ class PlayerbotAI;
class DpsTargetValue : public RtiTargetValue
{
public:
DpsTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps target") : RtiTargetValue(botAI, type, name) { }
public:
DpsTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps target")
: RtiTargetValue(botAI, type, name)
{
}
Unit* Calculate() override;
Unit* Calculate() override;
};
class DpsAoeTargetValue : public RtiTargetValue
{
public:
DpsAoeTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps aoe target") : RtiTargetValue(botAI, type, name) { }
public:
DpsAoeTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps aoe target")
: RtiTargetValue(botAI, type, name)
{
}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -1,11 +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 "DuelTargetValue.h"
#include "Playerbots.h"
Unit* DuelTargetValue::Calculate()
{
return bot->duel ? bot->duel->Opponent : nullptr;
}
Unit* DuelTargetValue::Calculate() { return bot->duel ? bot->duel->Opponent : nullptr; }

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_DUELTARGETVALUE_H
@@ -12,10 +13,10 @@ class Unit;
class DuelTargetValue : public TargetValue
{
public:
DuelTargetValue(PlayerbotAI* botAI, std::string const name = "duel target") : TargetValue(botAI, name) { }
public:
DuelTargetValue(PlayerbotAI* botAI, std::string const name = "duel target") : TargetValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -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 "EnemyHealerTargetValue.h"
#include "Playerbots.h"
#include "ServerFacade.h"

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ENEMYHEALERTARGETVALUE_H
@@ -13,11 +14,11 @@ class Unit;
class EnemyHealerTargetValue : public UnitCalculatedValue, public Qualified
{
public:
EnemyHealerTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "enemy healer target") { }
public:
EnemyHealerTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "enemy healer target") {}
protected:
Unit* Calculate() override;
protected:
Unit* Calculate() override;
};
#endif

View File

@@ -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 "EnemyPlayerValue.h"
#include "Playerbots.h"
#include "ServerFacade.h"
@@ -10,9 +12,12 @@ bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
{
bool inCannon = botAI->IsInVehicle(false, true);
Player* enemy = dynamic_cast<Player*>(unit);
if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() && !sPlayerbotAIConfig->IsPvpProhibited(enemy->GetZoneId(), enemy->GetAreaId()) &&
!enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && ((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) &&
/*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) && !(enemy->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)))
if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() &&
!sPlayerbotAIConfig->IsPvpProhibited(enemy->GetZoneId(), enemy->GetAreaId()) &&
!enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) &&
((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) &&
/*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) &&
!(enemy->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)))
return true;
return false;
@@ -31,7 +36,8 @@ Unit* EnemyPlayerValue::Calculate()
ThreatMgr* threatMgr = pReference->GetSource();
if (Unit* pTarget = threatMgr->GetOwner())
{
if (pTarget != pVictim && pTarget->IsPlayer() && pTarget->CanSeeOrDetect(bot) && bot->IsWithinDist(pTarget, VISIBILITY_DISTANCE_NORMAL))
if (pTarget != pVictim && pTarget->IsPlayer() && pTarget->CanSeeOrDetect(bot) &&
bot->IsWithinDist(pTarget, VISIBILITY_DISTANCE_NORMAL))
{
if (bot->GetTeamId() == TEAM_HORDE)
{
@@ -53,10 +59,9 @@ Unit* EnemyPlayerValue::Calculate()
if (!targets.empty())
{
std::sort(targets.begin(), targets.end(), [&](Unit const* pUnit1, Unit const* pUnit2)
{
return bot->GetDistance(pUnit1) < bot->GetDistance(pUnit2);
});
std::sort(targets.begin(), targets.end(),
[&](Unit const* pUnit1, Unit const* pUnit2)
{ return bot->GetDistance(pUnit1) < bot->GetDistance(pUnit2); });
return *targets.begin();
}
@@ -94,7 +99,8 @@ Unit* EnemyPlayerValue::Calculate()
if (!bot->IsWithinDist(pTarget, aggroDistance))
continue;
if (bot->IsWithinLOSInMap(pTarget) && (inCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f)))
if (bot->IsWithinLOSInMap(pTarget) &&
(inCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f)))
return pTarget;
}
@@ -113,8 +119,8 @@ Unit* EnemyPlayerValue::Calculate()
continue;
if (Unit* pAttacker = pMember->getAttackerForHelper())
if (pAttacker->IsPlayer() && bot->IsWithinDist(pAttacker, maxAggroDistance * 2.0f) && bot->IsWithinLOSInMap(pAttacker) && pAttacker != pVictim
&& pAttacker->CanSeeOrDetect(bot))
if (pAttacker->IsPlayer() && bot->IsWithinDist(pAttacker, maxAggroDistance * 2.0f) &&
bot->IsWithinLOSInMap(pAttacker) && pAttacker != pVictim && pAttacker->CanSeeOrDetect(bot))
return pAttacker;
}
}

View File

@@ -1,36 +1,42 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ENEMYPLAYERVALUE_H
#define _PLAYERBOT_ENEMYPLAYERVALUE_H
#include "PlayerbotAIConfig.h"
#include "TargetValue.h"
#include "PossibleTargetsValue.h"
#include "TargetValue.h"
class PlayerbotAI;
class Unit;
class NearestEnemyPlayersValue : public PossibleTargetsValue
{
public:
NearestEnemyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) :
PossibleTargetsValue(botAI, "nearest enemy players", range) { }
public:
NearestEnemyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance)
: PossibleTargetsValue(botAI, "nearest enemy players", range)
{
}
public:
bool AcceptUnit(Unit* unit) override;
public:
bool AcceptUnit(Unit* unit) override;
};
class EnemyPlayerValue : public UnitCalculatedValue
{
public:
EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player") : UnitCalculatedValue(botAI, name, 1 * 1000) { }
public:
EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player")
: UnitCalculatedValue(botAI, name, 1 * 1000)
{
}
Unit* Calculate() override;
Unit* Calculate() override;
private:
float GetMaxAttackDistance();
private:
float GetMaxAttackDistance();
};
#endif

View File

@@ -1,4 +1,5 @@
#include "ExpectedLifetimeValue.h"
#include "AiFactory.h"
#include "PlayerbotAI.h"
#include "Playerbots.h"
@@ -7,7 +8,8 @@
float ExpectedLifetimeValue::Calculate()
{
Unit* target = AI_VALUE(Unit*, qualifier);
if (!target || !target->IsAlive()) {
if (!target || !target->IsAlive())
{
return 0.0f;
}
float dps = AI_VALUE(float, "expected group dps");
@@ -20,9 +22,12 @@ float ExpectedGroupDpsValue::Calculate()
{
float dps_num;
Group* group = bot->GetGroup();
if (!group) {
if (!group)
{
dps_num = 0.7;
} else {
}
else
{
dps_num = group->GetMembersCount() * 0.7;
}
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(bot, true, false, 12);
@@ -31,40 +36,64 @@ float ExpectedGroupDpsValue::Calculate()
float basic_dps;
int32 basic_gs;
int32 level = bot->GetLevel();
if (level <= 15) {
if (level <= 15)
{
basic_dps = 5 + level * 1;
} else if (level <= 25) {
}
else if (level <= 25)
{
basic_dps = 20 + (level - 15) * 2;
} else if (level <= 40) {
}
else if (level <= 40)
{
basic_dps = 40 + (level - 30) * 4;
} else if (level <= 55) {
}
else if (level <= 55)
{
basic_dps = 100 + (level - 45) * 20;
} else if (level <= 60) {
}
else if (level <= 60)
{
basic_dps = 300 + (level - 55) * 50;
} else if (level <= 70) {
}
else if (level <= 70)
{
basic_dps = 450 + (level - 60) * 40;
} else {
}
else
{
basic_dps = 750 + (level - 70) * 175;
}
if (level <= 8) {
if (level <= 8)
{
basic_gs = (level + 5) * 2;
} else if (level <= 15) {
}
else if (level <= 15)
{
basic_gs = (level + 5) * 3;
} else if (level <= 60) {
}
else if (level <= 60)
{
basic_gs = (level + 5) * 4;
} else if (level <= 70) {
}
else if (level <= 70)
{
basic_gs = (85 + (level - 60) * 3) * 4;
} else {
}
else
{
basic_gs = (155 + (level - 70) * 4) * 4;
}
float gap = mixedGearScore - basic_gs;
float gs_modifier = (float)mixedGearScore / basic_gs - 1;
gs_modifier = gs_modifier * 3 + 1;
if (gs_modifier < 0.75) gs_modifier = 0.75;
if (gs_modifier > 4) gs_modifier = 4;
if (gs_modifier < 0.75)
gs_modifier = 0.75;
if (gs_modifier > 4)
gs_modifier = 4;
return dps_num * basic_dps * gs_modifier;
}

View File

@@ -1,13 +1,14 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H
#define _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H
#include "NamedObjectContext.h"
#include "TargetValue.h"
#include "PossibleTargetsValue.h"
#include "TargetValue.h"
#include "Value.h"
class PlayerbotAI;
@@ -16,22 +17,20 @@ class Unit;
// [target health] / [expected group single target dps] = [expected lifetime]
class ExpectedLifetimeValue : public FloatCalculatedValue, public Qualified
{
public:
ExpectedLifetimeValue(PlayerbotAI* botAI) :
FloatCalculatedValue(botAI, "expected lifetime") { }
public:
ExpectedLifetimeValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected lifetime") {}
public:
float Calculate() override;
public:
float Calculate() override;
};
class ExpectedGroupDpsValue : public FloatCalculatedValue
{
public:
ExpectedGroupDpsValue(PlayerbotAI* botAI) :
FloatCalculatedValue(botAI, "expected group dps", 20 * 1000) { }
public:
ExpectedGroupDpsValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected group dps", 20 * 1000) {}
public:
float Calculate() override;
public:
float Calculate() override;
};
#endif

View File

@@ -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 "Formations.h"
#include "Arrow.h"
#include "Event.h"
#include "Playerbots.h"
@@ -10,15 +12,13 @@
WorldLocation Formation::NullLocation = WorldLocation();
bool IsSameLocation(WorldLocation const &a, WorldLocation const &b)
bool IsSameLocation(WorldLocation const& a, WorldLocation const& b)
{
return a.GetPositionX() == b.GetPositionX() && a.GetPositionY() == b.GetPositionY() && a.GetPositionZ() == b.GetPositionZ() && a.GetMapId() == b.GetMapId();
return a.GetPositionX() == b.GetPositionX() && a.GetPositionY() == b.GetPositionY() &&
a.GetPositionZ() == b.GetPositionZ() && a.GetMapId() == b.GetMapId();
}
bool Formation::IsNullLocation(WorldLocation const& loc)
{
return IsSameLocation(loc, Formation::NullLocation);
}
bool Formation::IsNullLocation(WorldLocation const& loc) { return IsSameLocation(loc, Formation::NullLocation); }
WorldLocation MoveAheadFormation::GetLocation()
{
@@ -51,315 +51,317 @@ WorldLocation MoveAheadFormation::GetLocation()
// if (ground <= INVALID_HEIGHT)
// return Formation::NullLocation;
//z += CONTACT_DISTANCE;
//bot->UpdateAllowedPositionZ(x, y, z);
// z += CONTACT_DISTANCE;
// bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
}
class MeleeFormation : public FollowFormation
{
public:
MeleeFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "melee") { }
public:
MeleeFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "melee") {}
std::string const GetTargetName() override { return "master target"; }
std::string const GetTargetName() override { return "master target"; }
};
class QueueFormation : public FollowFormation
{
public:
QueueFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "queue") { }
public:
QueueFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "queue") {}
std::string const GetTargetName() override { return "line target"; }
std::string const GetTargetName() override { return "line target"; }
};
class NearFormation : public MoveAheadFormation
{
public:
NearFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "near") { }
public:
NearFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "near") {}
WorldLocation GetLocationInternal() override
{
Player* master = GetMaster();
if (!master)
return WorldLocation();
WorldLocation GetLocationInternal() override
{
Player* master = GetMaster();
if (!master)
return WorldLocation();
float range = sPlayerbotAIConfig->followDistance;
float angle = GetFollowAngle();
float x = master->GetPositionX() + cos(angle) * range;
float y = master->GetPositionY() + sin(angle) * range;
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
float range = sPlayerbotAIConfig->followDistance;
float angle = GetFollowAngle();
float x = master->GetPositionX() + cos(angle) * range;
float y = master->GetPositionY() + sin(angle) * range;
float z = master->GetPositionZ();
//z += CONTACT_DISTANCE;
//bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
}
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; }
// z += CONTACT_DISTANCE;
// bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
}
float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; }
};
class ChaosFormation : public MoveAheadFormation
{
public:
ChaosFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "chaos"), lastChangeTime(0) { }
public:
ChaosFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "chaos"), lastChangeTime(0) {}
WorldLocation GetLocationInternal() override
WorldLocation GetLocationInternal() override
{
Player* master = botAI->GetGroupMaster();
if (!master)
return WorldLocation();
float range = sPlayerbotAIConfig->followDistance;
float angle = GetFollowAngle();
time_t now = time(nullptr);
if (!lastChangeTime || now - lastChangeTime >= 3)
{
Player* master = botAI->GetGroupMaster();
if (!master)
return WorldLocation();
float range = sPlayerbotAIConfig->followDistance;
float angle = GetFollowAngle();
time_t now = time(nullptr);
if (!lastChangeTime || now - lastChangeTime >= 3)
{
lastChangeTime = now;
dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance;
dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance;
dr = sqrt(dx*dx + dy*dy);
}
float x = master->GetPositionX() + cos(angle) * range + dx;
float y = master->GetPositionY() + sin(angle) * range + dy;
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
lastChangeTime = now;
dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance;
dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance;
dr = sqrt(dx * dx + dy * dy);
}
float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance + dr; }
float x = master->GetPositionX() + cos(angle) * range + dx;
float y = master->GetPositionY() + sin(angle) * range + dy;
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
private:
time_t lastChangeTime;
float dx = 0.f;
float dy = 0.f;
float dr = 0.f;
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
}
float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance + dr; }
private:
time_t lastChangeTime;
float dx = 0.f;
float dy = 0.f;
float dr = 0.f;
};
class CircleFormation : public MoveFormation
{
public:
CircleFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "circle") { }
public:
CircleFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "circle") {}
WorldLocation GetLocation() override
WorldLocation GetLocation() override
{
float range = 2.0f;
Unit* target = AI_VALUE(Unit*, "current target");
Player* master = botAI->GetGroupMaster();
if (!target && target != bot)
target = master;
if (!target)
return Formation::NullLocation;
switch (bot->getClass())
{
float range = 2.0f;
Unit* target = AI_VALUE(Unit*, "current target");
Player* master = botAI->GetGroupMaster();
if (!target && target != bot)
target = master;
if (!target)
return Formation::NullLocation;
switch (bot->getClass())
{
case CLASS_HUNTER:
case CLASS_MAGE:
case CLASS_PRIEST:
case CLASS_WARLOCK:
case CLASS_HUNTER:
case CLASS_MAGE:
case CLASS_PRIEST:
case CLASS_WARLOCK:
range = botAI->GetRange("flee");
break;
case CLASS_DRUID:
if (!botAI->IsTank(bot))
range = botAI->GetRange("flee");
break;
case CLASS_DRUID:
if (!botAI->IsTank(bot))
range = botAI->GetRange("flee");
break;
case CLASS_SHAMAN:
if (botAI->IsHeal(bot))
range = botAI->GetRange("flee");
break;
}
float angle = GetFollowAngle();
float x = target->GetPositionX() + cos(angle) * range;
float y = target->GetPositionY() + sin(angle) * range;
float z = target->GetPositionZ();
float ground = target->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(bot->GetMapId(), x, y, z);
break;
case CLASS_SHAMAN:
if (botAI->IsHeal(bot))
range = botAI->GetRange("flee");
break;
}
float angle = GetFollowAngle();
float x = target->GetPositionX() + cos(angle) * range;
float y = target->GetPositionY() + sin(angle) * range;
float z = target->GetPositionZ();
float ground = target->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
return Formation::NullLocation;
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(bot->GetMapId(), x, y, z);
}
};
class LineFormation : public MoveAheadFormation
{
public:
LineFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "line") { }
public:
LineFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "line") {}
WorldLocation GetLocationInternal() override
WorldLocation GetLocationInternal() override
{
Group* group = bot->GetGroup();
if (!group)
return Formation::NullLocation;
float range = 2.0f;
Player* master = botAI->GetGroupMaster();
if (!master)
return Formation::NullLocation;
float x = master->GetPositionX();
float y = master->GetPositionY();
float z = master->GetPositionZ();
float orientation = master->GetOrientation();
std::vector<Player*> players;
GroupReference* gref = group->GetFirstMember();
while (gref)
{
Group* group = bot->GetGroup();
if (!group)
return Formation::NullLocation;
Player* member = gref->GetSource();
if (member != master)
players.push_back(member);
float range = 2.0f;
Player* master = botAI->GetGroupMaster();
if (!master)
return Formation::NullLocation;
float x = master->GetPositionX();
float y = master->GetPositionY();
float z = master->GetPositionZ();
float orientation = master->GetOrientation();
std::vector<Player*> players;
GroupReference* gref = group->GetFirstMember();
while (gref)
{
Player* member = gref->GetSource();
if (member != master)
players.push_back(member);
gref = gref->next();
}
players.insert(players.begin() + group->GetMembersCount() / 2, master);
return MoveLine(players, 0.0f, x, y, z, orientation, range);
gref = gref->next();
}
players.insert(players.begin() + group->GetMembersCount() / 2, master);
return MoveLine(players, 0.0f, x, y, z, orientation, range);
}
};
class ShieldFormation : public MoveFormation
{
public:
ShieldFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "shield") { }
WorldLocation GetLocation() override
{
Group* group = bot->GetGroup();
if (!group)
return Formation::NullLocation;
float range = sPlayerbotAIConfig->followDistance;
Player* master = GetMaster();
if (!master)
return Formation::NullLocation;
float x = master->GetPositionX();
float y = master->GetPositionY();
float z = master->GetPositionZ();
float orientation = master->GetOrientation();
std::vector<Player*> tanks;
std::vector<Player*> dps;
GroupReference* gref = group->GetFirstMember();
while (gref)
{
Player* member = gref->GetSource();
if (member != master)
{
if (botAI->IsTank(member))
tanks.push_back(member);
else
dps.push_back(member);
}
gref = gref->next();
}
if (botAI->IsTank(master))
tanks.insert(tanks.begin() + (tanks.size() + 1) / 2, master);
else
dps.insert(dps.begin() + (dps.size() + 1) / 2, master);
if (botAI->IsTank(bot) && botAI->IsTank(master))
{
return MoveLine(tanks, 0.0f, x, y, z, orientation, range);
}
if (!botAI->IsTank(bot) && !botAI->IsTank(master))
{
return MoveLine(dps, 0.0f, x, y, z, orientation, range);
}
if (botAI->IsTank(bot) && !botAI->IsTank(master))
{
float diff = tanks.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f;
return MoveLine(tanks, diff, x + cos(orientation) * range, y + sin(orientation) * range, z, orientation, range);
}
if (!botAI->IsTank(bot) && botAI->IsTank(master))
{
float diff = dps.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f;
return MoveLine(dps, diff, x - cos(orientation) * range, y - sin(orientation) * range, z, orientation, range);
}
public:
ShieldFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "shield") {}
WorldLocation GetLocation() override
{
Group* group = bot->GetGroup();
if (!group)
return Formation::NullLocation;
float range = sPlayerbotAIConfig->followDistance;
Player* master = GetMaster();
if (!master)
return Formation::NullLocation;
float x = master->GetPositionX();
float y = master->GetPositionY();
float z = master->GetPositionZ();
float orientation = master->GetOrientation();
std::vector<Player*> tanks;
std::vector<Player*> dps;
GroupReference* gref = group->GetFirstMember();
while (gref)
{
Player* member = gref->GetSource();
if (member != master)
{
if (botAI->IsTank(member))
tanks.push_back(member);
else
dps.push_back(member);
}
gref = gref->next();
}
if (botAI->IsTank(master))
tanks.insert(tanks.begin() + (tanks.size() + 1) / 2, master);
else
dps.insert(dps.begin() + (dps.size() + 1) / 2, master);
if (botAI->IsTank(bot) && botAI->IsTank(master))
{
return MoveLine(tanks, 0.0f, x, y, z, orientation, range);
}
if (!botAI->IsTank(bot) && !botAI->IsTank(master))
{
return MoveLine(dps, 0.0f, x, y, z, orientation, range);
}
if (botAI->IsTank(bot) && !botAI->IsTank(master))
{
float diff = tanks.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f;
return MoveLine(tanks, diff, x + cos(orientation) * range, y + sin(orientation) * range, z, orientation,
range);
}
if (!botAI->IsTank(bot) && botAI->IsTank(master))
{
float diff = dps.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f;
return MoveLine(dps, diff, x - cos(orientation) * range, y - sin(orientation) * range, z, orientation,
range);
}
return Formation::NullLocation;
}
};
class FarFormation : public FollowFormation
{
public:
FarFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "far") { }
public:
FarFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "far") {}
WorldLocation GetLocation() override
WorldLocation GetLocation() override
{
float range = sPlayerbotAIConfig->farDistance;
float followRange = sPlayerbotAIConfig->followDistance;
Player* master = GetMaster();
if (!master)
return Formation::NullLocation;
if (sServerFacade->GetDistance2d(bot, master) <= range)
return Formation::NullLocation;
float angle = master->GetAngle(bot);
float followAngle = GetFollowAngle();
float x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
{
float range = sPlayerbotAIConfig->farDistance;
float followRange = sPlayerbotAIConfig->followDistance;
Player* master = GetMaster();
if (!master)
return Formation::NullLocation;
if (sServerFacade->GetDistance2d(bot, master) <= range)
return Formation::NullLocation;
float angle = master->GetAngle(bot);
float followAngle = GetFollowAngle();
float x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
float z = master->GetPositionZ();
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground <= INVALID_HEIGHT)
float minDist = 0, minX = 0, minY = 0;
for (float angle = 0.0f; angle <= 2 * M_PI; angle += M_PI / 16.0f)
{
float minDist = 0, minX = 0, minY = 0;
for (float angle = 0.0f; angle <= 2 * M_PI; angle += M_PI / 16.0f)
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
float dist = sServerFacade->GetDistance2d(bot, x, y);
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground > INVALID_HEIGHT && (!minDist || minDist > dist))
{
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
float dist = sServerFacade->GetDistance2d(bot, x, y);
float ground = master->GetMapHeight(x, y, z + 30.0f);
if (ground > INVALID_HEIGHT && (!minDist || minDist > dist))
{
minDist = dist;
minX = x;
minY = y;
}
minDist = dist;
minX = x;
minY = y;
}
if (minDist)
{
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(minX, minY, z);
return WorldLocation(bot->GetMapId(), minX, minY, z);
}
return Formation::NullLocation;
}
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(bot->GetMapId(), x, y, z);
if (minDist)
{
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(minX, minY, z);
return WorldLocation(bot->GetMapId(), minX, minY, z);
}
return Formation::NullLocation;
}
z += CONTACT_DISTANCE;
bot->UpdateAllowedPositionZ(x, y, z);
return WorldLocation(bot->GetMapId(), x, y, z);
}
};
float Formation::GetFollowAngle()
@@ -376,7 +378,8 @@ float Formation::GetFollowAngle()
masterBotMgr = GET_PLAYERBOT_MGR(master);
if (!group && master && !GET_PLAYERBOT_AI(master) && masterBotMgr)
{
for (PlayerBotMap::const_iterator i = masterBotMgr->GetPlayerBotsBegin(); i != masterBotMgr->GetPlayerBotsEnd(); ++i)
for (PlayerBotMap::const_iterator i = masterBotMgr->GetPlayerBotsBegin(); i != masterBotMgr->GetPlayerBotsEnd();
++i)
{
if (i->second == bot)
index = total;
@@ -441,7 +444,8 @@ float Formation::GetFollowAngle()
return start + (0.125f + 1.75f * index / total + (total == 2 ? 0.125f : 0.0f)) * M_PI;
}
FormationValue::FormationValue(PlayerbotAI* botAI) : ManualSetValue<Formation*>(botAI, new NearFormation(botAI), "formation")
FormationValue::FormationValue(PlayerbotAI* botAI)
: ManualSetValue<Formation*>(botAI, new NearFormation(botAI), "formation")
{
}
@@ -454,10 +458,7 @@ FormationValue::~FormationValue()
}
}
std::string const FormationValue::Save()
{
return value ? value->getName() : "?";
}
std::string const FormationValue::Save() { return value ? value->getName() : "?"; }
bool FormationValue::Load(std::string const formation)
{
@@ -557,7 +558,8 @@ bool SetFormationAction::Execute(Event event)
std::ostringstream str;
str << "Invalid formation: |cffff0000" << formation;
botAI->TellMaster(str);
botAI->TellMaster("Please set to any of:|cffffffff near (default), queue, chaos, circle, line, shield, arrow, melee, far");
botAI->TellMaster(
"Please set to any of:|cffffffff near (default), queue, chaos, circle, line, shield, arrow, melee, far");
return false;
}
@@ -567,7 +569,8 @@ bool SetFormationAction::Execute(Event event)
return true;
}
WorldLocation MoveFormation::MoveLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation, float range)
WorldLocation MoveFormation::MoveLine(std::vector<Player*> line, float diff, float cx, float cy, float cz,
float orientation, float range)
{
if (line.size() < 5)
{
@@ -588,7 +591,7 @@ WorldLocation MoveFormation::MoveLine(std::vector<Player*> line, float diff, flo
line.pop_back();
}
WorldLocation loc = MoveSingleLine(singleLine, diff, x, y,cz, orientation, range);
WorldLocation loc = MoveSingleLine(singleLine, diff, x, y, cz, orientation, range);
if (!Formation::IsNullLocation(loc))
return loc;
}
@@ -596,7 +599,8 @@ WorldLocation MoveFormation::MoveLine(std::vector<Player*> line, float diff, flo
return Formation::NullLocation;
}
WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation, float range)
WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float diff, float cx, float cy, float cz,
float orientation, float range)
{
float count = line.size();
float angle = orientation - M_PI / 2.0f;

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_FORMATIONS_H
@@ -15,60 +16,62 @@ class PlayerbotAI;
class Formation : public AiNamedObject
{
public:
Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { }
virtual ~Formation() = default;
virtual std::string const GetTargetName() { return ""; }
virtual WorldLocation GetLocation() { return NullLocation; }
virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; }
static WorldLocation NullLocation;
static bool IsNullLocation(WorldLocation const& loc);
public:
Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) {}
virtual ~Formation() = default;
virtual std::string const GetTargetName() { return ""; }
virtual WorldLocation GetLocation() { return NullLocation; }
virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; }
static WorldLocation NullLocation;
static bool IsNullLocation(WorldLocation const& loc);
protected:
float GetFollowAngle();
protected:
float GetFollowAngle();
};
class FollowFormation : public Formation
{
public:
FollowFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) { }
public:
FollowFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) {}
};
class MoveFormation : public Formation
{
public:
MoveFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) { }
public:
MoveFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) {}
protected:
WorldLocation MoveLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation, float range);
WorldLocation MoveSingleLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation, float range);
protected:
WorldLocation MoveLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation,
float range);
WorldLocation MoveSingleLine(std::vector<Player*> line, float diff, float cx, float cy, float cz, float orientation,
float range);
};
class MoveAheadFormation : public MoveFormation
{
public:
MoveAheadFormation(PlayerbotAI* botAI, std::string const name) : MoveFormation(botAI, name) { }
public:
MoveAheadFormation(PlayerbotAI* botAI, std::string const name) : MoveFormation(botAI, name) {}
WorldLocation GetLocation() override;
virtual WorldLocation GetLocationInternal() { return NullLocation; }
WorldLocation GetLocation() override;
virtual WorldLocation GetLocationInternal() { return NullLocation; }
};
class FormationValue : public ManualSetValue<Formation*>
{
public:
FormationValue(PlayerbotAI* botAI);
~FormationValue();
public:
FormationValue(PlayerbotAI* botAI);
~FormationValue();
std::string const Save() override;
bool Load(std::string const value) override;
std::string const Save() override;
bool Load(std::string const value) override;
};
class SetFormationAction : public Action
{
public:
SetFormationAction(PlayerbotAI* botAI) : Action(botAI, "set formation") { }
public:
SetFormationAction(PlayerbotAI* botAI) : Action(botAI, "set formation") {}
bool Execute(Event event) override;
bool Execute(Event event) override;
};
#endif

View File

@@ -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 "GrindTargetValue.h"
#include "Playerbots.h"
#include "ReputationMgr.h"
#include "SharedDefines.h"
@@ -52,61 +54,66 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount)
for (ObjectGuid const guid : targets)
{
Unit* unit = botAI->GetUnit(guid);
if (!unit)
continue;
auto &rep = bot->ToPlayer()->GetReputationMgr();
if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid && bot->GetReactionTo(unit) >= REP_NEUTRAL) {
auto& rep = bot->ToPlayer()->GetReputationMgr();
if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid &&
bot->GetReactionTo(unit) >= REP_NEUTRAL)
{
continue;
}
if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE) {
if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE)
{
continue;
}
if (!bot->isHonorOrXPTarget(unit)) {
if (!bot->isHonorOrXPTarget(unit))
{
continue;
}
if (abs(bot->GetPositionZ() - unit->GetPositionZ()) > INTERACTION_DISTANCE)
continue;
if (!bot->InBattleground() && GetTargetingPlayerCount(unit) > assistCount)
continue;
//if (!bot->InBattleground() && master && master->GetDistance(unit) >= sPlayerbotAIConfig->grindDistance && !sRandomPlayerbotMgr->IsRandomBot(bot))
//continue;
// if (!bot->InBattleground() && master && master->GetDistance(unit) >= sPlayerbotAIConfig->grindDistance &&
// !sRandomPlayerbotMgr->IsRandomBot(bot)) continue;
if (!bot->InBattleground() && (int)unit->GetLevel() - (int)bot->GetLevel() > 4 && !unit->GetGUID().IsPlayer())
continue;
if (!bot->InBattleground() && (int)unit->GetLevel() - (int)bot->GetLevel() > 4 && !unit->GetGUID().IsPlayer())
continue;
// if (needForQuestMap.find(unit->GetEntry()) == needForQuestMap.end())
// needForQuestMap[unit->GetEntry()] = needForQuest(unit);
// if (!needForQuestMap[unit->GetEntry()])
// if ((urand(0, 100) < 75 || (context->GetValue<TravelTarget*>("travel target")->Get()->isWorking() &&
// context->GetValue<TravelTarget*>("travel target")->Get()->getDestination()->getName() != "GrindTravelDestination")))
// continue;
// context->GetValue<TravelTarget*>("travel target")->Get()->getDestination()->getName() !=
// "GrindTravelDestination"))) continue;
//if (bot->InBattleground() && bot->GetDistance(unit) > 40.0f)
//continue;
// if (bot->InBattleground() && bot->GetDistance(unit) > 40.0f)
// continue;
if (Creature* creature = unit->ToCreature())
if (Creature* creature = unit->ToCreature())
if (CreatureTemplate const* CreatureTemplate = creature->GetCreatureTemplate())
if (CreatureTemplate->rank > CREATURE_ELITE_NORMAL && !AI_VALUE(bool, "can fight elite"))
continue;
if (!bot->IsWithinLOSInMap(unit)) {
if (CreatureTemplate->rank > CREATURE_ELITE_NORMAL && !AI_VALUE(bool, "can fight elite"))
continue;
if (!bot->IsWithinLOSInMap(unit))
{
continue;
}
if (group)
{
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *member = ObjectAccessor::FindPlayer(itr->guid);
Player* member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive())
continue;
@@ -121,7 +128,8 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount)
else
{
float newdistance = bot->GetDistance(unit);
if (!result || (newdistance < distance && urand(0, abs(distance - newdistance)) > sPlayerbotAIConfig->sightDistance * 0.1))
if (!result || (newdistance < distance &&
urand(0, abs(distance - newdistance)) > sPlayerbotAIConfig->sightDistance * 0.1))
{
distance = newdistance;
result = unit;
@@ -160,7 +168,7 @@ bool GrindTargetValue::needForQuest(Unit* target)
{
QuestStatusData* questStatus = sTravelMgr->getQuestStatus(bot, questId);
if (questTemplate->GetQuestLevel() > bot->GetLevel()+5)
if (questTemplate->GetQuestLevel() > bot->GetLevel() + 5)
continue;
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
@@ -218,7 +226,7 @@ uint32 GrindTargetValue::GetTargetingPlayerCount(Unit* unit)
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *member = ObjectAccessor::FindPlayer(itr->guid);
Player* member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot)
continue;

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_GRINDTARGETVALUE_H
@@ -12,15 +13,15 @@ class Unit;
class GrindTargetValue : public TargetValue
{
public:
GrindTargetValue(PlayerbotAI* botAI, std::string const name = "grind target") : TargetValue(botAI, name) { }
public:
GrindTargetValue(PlayerbotAI* botAI, std::string const name = "grind target") : TargetValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
private:
uint32 GetTargetingPlayerCount(Unit* unit);
Unit* FindTargetForGrinding(uint32 assistCount);
bool needForQuest(Unit* target);
private:
uint32 GetTargetingPlayerCount(Unit* unit);
Unit* FindTargetForGrinding(uint32 assistCount);
bool needForQuest(Unit* target);
};
#endif

View File

@@ -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 "GroupValues.h"
#include "Playerbots.h"
#include "ServerFacade.h"
@@ -24,7 +26,6 @@ GuidVector GroupMembersValue::Calculate()
return members;
}
bool IsFollowingPartyValue::Calculate()
{
if (botAI->GetGroupMaster() == bot)
@@ -55,7 +56,7 @@ bool BoolANDValue::Calculate()
for (auto value : values)
{
if(!AI_VALUE(bool, value))
if (!AI_VALUE(bool, value))
return false;
}
@@ -101,7 +102,7 @@ bool GroupBoolANDValue::Calculate()
if (!GET_PLAYERBOT_AI(player))
continue;
if (!PAI_VALUE2(bool,"and", getQualifier()))
if (!PAI_VALUE2(bool, "and", getQualifier()))
return false;
}
@@ -141,7 +142,7 @@ bool GroupReadyValue::Calculate()
if (!member)
continue;
if (inDungeon) //In dungeons all following members need to be alive before continueing.
if (inDungeon) // In dungeons all following members need to be alive before continueing.
{
PlayerbotAI* memberAi = GET_PLAYERBOT_AI(member);
@@ -151,8 +152,10 @@ bool GroupReadyValue::Calculate()
return false;
}
//We only wait for members that are in range otherwise we might be waiting for bots stuck in dead loops forever.
if (botAI->GetGroupMaster() && sServerFacade->GetDistance2d(member, botAI->GetGroupMaster()) > sPlayerbotAIConfig->sightDistance)
// We only wait for members that are in range otherwise we might be waiting for bots stuck in dead loops
// forever.
if (botAI->GetGroupMaster() &&
sServerFacade->GetDistance2d(member, botAI->GetGroupMaster()) > sPlayerbotAIConfig->sightDistance)
continue;
if (member->GetHealthPct() < sPlayerbotAIConfig->almostFullHealth)
@@ -161,7 +164,7 @@ bool GroupReadyValue::Calculate()
if (!member->GetPower(POWER_MANA))
continue;
float mana = (static_cast<float> (member->GetPower(POWER_MANA)) / member->GetMaxPower(POWER_MANA)) * 100;
float mana = (static_cast<float>(member->GetPower(POWER_MANA)) / member->GetMaxPower(POWER_MANA)) * 100;
if (mana < sPlayerbotAIConfig->mediumMana)
return false;

View File

@@ -1,5 +1,6 @@
/*
* 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 "NamedObjectContext.h"
@@ -9,64 +10,64 @@ class PlayerbotAI;
class GroupMembersValue : public ObjectGuidListCalculatedValue
{
public:
GroupMembersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "group members", 2 * 1000) { }
public:
GroupMembersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "group members", 2 * 1000) {}
GuidVector Calculate() override;
GuidVector Calculate() override;
};
class IsFollowingPartyValue : public BoolCalculatedValue
{
public:
IsFollowingPartyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "following party") { }
public:
IsFollowingPartyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "following party") {}
bool Calculate() override;
bool Calculate() override;
};
class IsNearLeaderValue : public BoolCalculatedValue
{
public:
IsNearLeaderValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "near leader") { }
public:
IsNearLeaderValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "near leader") {}
bool Calculate() override;
bool Calculate() override;
};
class BoolANDValue : public BoolCalculatedValue, public Qualified
{
public:
BoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "bool and") { }
public:
BoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "bool and") {}
bool Calculate() override;
bool Calculate() override;
};
class GroupBoolCountValue : public Uint32CalculatedValue, public Qualified
{
public:
GroupBoolCountValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "group count") { }
public:
GroupBoolCountValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "group count") {}
uint32 Calculate() override;
uint32 Calculate() override;
};
class GroupBoolANDValue : public BoolCalculatedValue, public Qualified
{
public:
GroupBoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool and") { }
public:
GroupBoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool and") {}
bool Calculate() override;
bool Calculate() override;
};
class GroupBoolORValue : public BoolCalculatedValue, public Qualified
{
public:
GroupBoolORValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool or") { }
public:
GroupBoolORValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool or") {}
bool Calculate() override;
bool Calculate() override;
};
class GroupReadyValue : public BoolCalculatedValue, public Qualified
{
public:
GroupReadyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group ready", 2 * 2000) { }
public:
GroupReadyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group ready", 2 * 2000) {}
bool Calculate()override;
bool Calculate() override;
};

View File

@@ -1,19 +1,22 @@
/*
* 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 "GuildValues.h"
#include "Playerbots.h"
uint8 PetitionSignsValue::Calculate()
{
if (bot->GetGuildId())
return 0;
return 0;
std::vector<Item*> petitions = AI_VALUE2(std::vector<Item*>, "inventory items", chat->FormatQItem(5863));
if (petitions.empty())
return 0;
QueryResult result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}", petitions.front()->GetGUID().GetCounter());
QueryResult result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}",
petitions.front()->GetGUID().GetCounter());
return result ? (uint8)result->GetRowCount() : 0;
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_GUILDVALUES_H
@@ -11,10 +12,10 @@ class PlayerbotAI;
class PetitionSignsValue : public SingleCalculatedValue<uint8>
{
public:
PetitionSignsValue(PlayerbotAI* botAI) : SingleCalculatedValue<uint8>(botAI, "petition signs") { }
public:
PetitionSignsValue(PlayerbotAI* botAI) : SingleCalculatedValue<uint8>(botAI, "petition signs") {}
uint8 Calculate();
uint8 Calculate();
};
#endif

View File

@@ -1,12 +1,15 @@
/*
* 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 "HasAvailableLootValue.h"
#include "LootObjectStack.h"
#include "Playerbots.h"
bool HasAvailableLootValue::Calculate()
{
return !AI_VALUE(bool, "can loot") && AI_VALUE(LootObjectStack*, "available loot")->CanLoot(sPlayerbotAIConfig->lootDistance);
return !AI_VALUE(bool, "can loot") &&
AI_VALUE(LootObjectStack*, "available loot")->CanLoot(sPlayerbotAIConfig->lootDistance);
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_HASAVAILABLELOOTVALUE_H
@@ -11,10 +12,10 @@ class PlayerbotAI;
class HasAvailableLootValue : public BoolCalculatedValue
{
public:
HasAvailableLootValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) { }
public:
HasAvailableLootValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "HasTotemValue.h"
#include "Playerbots.h"
char* strstri(char const* str1, char const* str2);

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_HASTOTEMVALUE_H
@@ -12,10 +13,10 @@ class PlayerbotAI;
class HasTotemValue : public BoolCalculatedValue, public Qualified
{
public:
HasTotemValue(PlayerbotAI* botAI, std::string const name = "has totem") : BoolCalculatedValue(botAI, name) { }
public:
HasTotemValue(PlayerbotAI* botAI, std::string const name = "has totem") : BoolCalculatedValue(botAI, name) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "InvalidTargetValue.h"
#include "AttackersValue.h"
#include "Playerbots.h"
#include "Unit.h"
@@ -16,17 +18,10 @@ bool InvalidTargetValue::Calculate()
if (target && qualifier == "current target")
{
return target->GetMapId() != bot->GetMapId() ||
target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) ||
target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) ||
target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2) ||
!target->IsVisible() ||
!target->IsAlive() ||
target->IsPolymorphed() ||
target->IsCharmed() ||
target->isFeared() ||
target->HasUnitState(UNIT_STATE_ISOLATED) ||
target->IsFriendlyTo(bot) ||
return target->GetMapId() != bot->GetMapId() || target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) ||
target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) || target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2) ||
!target->IsVisible() || !target->IsAlive() || target->IsPolymorphed() || target->IsCharmed() ||
target->isFeared() || target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsFriendlyTo(bot) ||
!AttackersValue::IsValidTarget(target, bot);
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_INVALIDTARGETVALUE_H
@@ -12,10 +13,12 @@ class PlayerbotAI;
class InvalidTargetValue : public BoolCalculatedValue, public Qualified
{
public:
InvalidTargetValue(PlayerbotAI* botAI, std::string const name = "invalid target") : BoolCalculatedValue(botAI, name) { }
public:
InvalidTargetValue(PlayerbotAI* botAI, std::string const name = "invalid target") : BoolCalculatedValue(botAI, name)
{
}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "IsBehindValue.h"
#include "Playerbots.h"
bool IsBehindValue::Calculate()
@@ -11,7 +13,6 @@ bool IsBehindValue::Calculate()
if (!target)
return false;
float targetOrientation = target->GetOrientation();
float orientation = bot->GetOrientation();
float distance = bot->GetDistance(target);

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ISBEHINDVALUE_H
@@ -12,10 +13,10 @@ class PlayerbotAI;
class IsBehindValue : public BoolCalculatedValue, public Qualified
{
public:
IsBehindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) { }
public:
IsBehindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "IsFacingValue.h"
#include "Playerbots.h"
bool IsFacingValue::Calculate()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ISFACINGVALUE_H
@@ -12,10 +13,10 @@ class PlayerbotAI;
class IsFacingValue : public BoolCalculatedValue, public Qualified
{
public:
IsFacingValue(PlayerbotAI* botAI, std::string const name = "is facing") : BoolCalculatedValue(botAI, name) { }
public:
IsFacingValue(PlayerbotAI* botAI, std::string const name = "is facing") : BoolCalculatedValue(botAI, name) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "IsMovingValue.h"
#include "Playerbots.h"
bool IsMovingValue::Calculate()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ISMOVINGVALUE_H
@@ -12,18 +13,18 @@ class PlayerbotAI;
class IsMovingValue : public BoolCalculatedValue, public Qualified
{
public:
IsMovingValue(PlayerbotAI* botAI, std::string const name = "is moving") : BoolCalculatedValue(botAI, name) { }
public:
IsMovingValue(PlayerbotAI* botAI, std::string const name = "is moving") : BoolCalculatedValue(botAI, name) {}
bool Calculate() override;
bool Calculate() override;
};
class IsSwimmingValue : public BoolCalculatedValue, public Qualified
{
public:
IsSwimmingValue(PlayerbotAI* botAI, std::string const name = "is swimming") : BoolCalculatedValue(botAI, name) { }
public:
IsSwimmingValue(PlayerbotAI* botAI, std::string const name = "is swimming") : BoolCalculatedValue(botAI, name) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "ItemCountValue.h"
#include "Playerbots.h"
std::vector<Item*> InventoryItemValueBase::Find(std::string const qualifier)
@@ -30,7 +32,4 @@ uint32 ItemCountValue::Calculate()
return count;
}
std::vector<Item*> InventoryItemValue::Calculate()
{
return Find(qualifier);
}
std::vector<Item*> InventoryItemValue::Calculate() { return Find(qualifier); }

View File

@@ -1,41 +1,47 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ITEMCOUNTVALUE_H
#define _PLAYERBOT_ITEMCOUNTVALUE_H
#include "InventoryAction.h"
#include "Item.h"
#include "NamedObjectContext.h"
#include "InventoryAction.h"
class PlayerbotAI;
class InventoryItemValueBase : public InventoryAction
{
public:
InventoryItemValueBase(PlayerbotAI* botAI) : InventoryAction(botAI, "empty") { }
public:
InventoryItemValueBase(PlayerbotAI* botAI) : InventoryAction(botAI, "empty") {}
bool Execute(Event event) override { return false; }
bool Execute(Event event) override { return false; }
protected:
std::vector<Item*> Find(std::string const qualifier);
protected:
std::vector<Item*> Find(std::string const qualifier);
};
class ItemCountValue : public Uint32CalculatedValue, public Qualified, InventoryItemValueBase
{
public:
ItemCountValue(PlayerbotAI* botAI, std::string const name = "inventory items") : Uint32CalculatedValue(botAI, name), InventoryItemValueBase(botAI) { }
public:
ItemCountValue(PlayerbotAI* botAI, std::string const name = "inventory items")
: Uint32CalculatedValue(botAI, name), InventoryItemValueBase(botAI)
{
}
uint32 Calculate() override;
uint32 Calculate() override;
};
class InventoryItemValue : public CalculatedValue<std::vector<Item*>>, public Qualified, InventoryItemValueBase
{
public:
InventoryItemValue(PlayerbotAI* botAI) : CalculatedValue<std::vector<Item*>>(botAI), InventoryItemValueBase(botAI) { }
public:
InventoryItemValue(PlayerbotAI* botAI) : CalculatedValue<std::vector<Item*>>(botAI), InventoryItemValueBase(botAI)
{
}
std::vector<Item*> Calculate() override;
std::vector<Item*> Calculate() override;
};
#endif

View File

@@ -1,14 +1,18 @@
/*
* 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 "ItemForSpellValue.h"
#include "Playerbots.h"
#ifndef WIN32
inline int strcmpi(char const* s1, char const* s2)
{
for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) {}
for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2)
{
}
return *s1 - *s2;
}
#endif
@@ -19,7 +23,7 @@ Item* ItemForSpellValue::Calculate()
if (!spellid)
return nullptr;
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellid);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellInfo)
return nullptr;
@@ -45,7 +49,9 @@ Item* ItemForSpellValue::Calculate()
}
// Workaround as some spells have no item mask (e.g. shaman weapon enhancements)
if (!strcmpi(spellInfo->SpellName[0], "rockbiter weapon") || !strcmpi(spellInfo->SpellName[0], "flametongue weapon") || !strcmpi(spellInfo->SpellName[0], "earthliving weapon") ||
if (!strcmpi(spellInfo->SpellName[0], "rockbiter weapon") ||
!strcmpi(spellInfo->SpellName[0], "flametongue weapon") ||
!strcmpi(spellInfo->SpellName[0], "earthliving weapon") ||
!strcmpi(spellInfo->SpellName[0], "frostbrand weapon") || !strcmpi(spellInfo->SpellName[0], "windfury weapon"))
{
itemForSpell = GetItemFitsToSpellRequirements(EQUIPMENT_SLOT_MAINHAND, spellInfo);
@@ -65,7 +71,7 @@ Item* ItemForSpellValue::Calculate()
if (!strcmpi(spellInfo->SpellName[0], "disenchant"))
return nullptr;
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; slot++ )
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; slot++)
{
itemForSpell = GetItemFitsToSpellRequirements(slot, spellInfo);
if (itemForSpell)
@@ -75,9 +81,9 @@ Item* ItemForSpellValue::Calculate()
return nullptr;
}
Item* ItemForSpellValue::GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const *spellInfo)
Item* ItemForSpellValue::GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const* spellInfo)
{
Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, slot );
Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
return nullptr;

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ITEMFORSPELLVALUE_H
@@ -14,13 +15,16 @@ class SpellInfo;
class ItemForSpellValue : public CalculatedValue<Item*>, public Qualified
{
public:
ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell") : CalculatedValue<Item*>(botAI, name, 1) { }
public:
ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell")
: CalculatedValue<Item*>(botAI, name, 1)
{
}
Item* Calculate() override;
Item* Calculate() override;
private:
Item* GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const *spellInfo);
private:
Item* GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const* spellInfo);
};
#endif

View File

@@ -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 "ItemUsageValue.h"
#include "AiFactory.h"
#include "ChatHelper.h"
#include "GuildTaskMgr.h"
@@ -37,7 +39,8 @@ ItemUsage ItemUsageValue::Calculate()
{
bool lowBagSpace = AI_VALUE(uint8, "bag space") > 50;
if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_MISC || proto->Class == ITEM_CLASS_REAGENT)
if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_MISC ||
proto->Class == ITEM_CLASS_REAGENT)
needItem = IsItemNeededForUsefullSpell(proto, lowBagSpace);
else if (proto->Class == ITEM_CLASS_RECIPE)
{
@@ -52,9 +55,9 @@ ItemUsage ItemUsageValue::Calculate()
{
float stacks = CurrentStacks(proto);
if (stacks < 1)
return ITEM_USAGE_SKILL; //Buy more.
return ITEM_USAGE_SKILL; // Buy more.
if (stacks < 2)
return ITEM_USAGE_KEEP; //Keep current amount.
return ITEM_USAGE_KEEP; // Keep current amount.
}
}
@@ -73,13 +76,13 @@ ItemUsage ItemUsageValue::Calculate()
stacks += CurrentStacks(proto);
if (stacks < 2)
return ITEM_USAGE_USE; // Buy some to get to 2 stacks
else if (stacks < 3) // Keep the item if less than 3 stacks
return ITEM_USAGE_USE; // Buy some to get to 2 stacks
else if (stacks < 3) // Keep the item if less than 3 stacks
return ITEM_USAGE_KEEP;
}
}
}
if (bot->GetGuildId() && sGuildTaskMgr->IsGuildTaskItem(itemId, bot->GetGuildId()))
return ITEM_USAGE_GUILD_TASK;
@@ -87,12 +90,14 @@ ItemUsage ItemUsageValue::Calculate()
if (equip != ITEM_USAGE_NONE)
return equip;
if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) && proto->Bonding != BIND_WHEN_PICKED_UP &&
botAI->HasSkill(SKILL_ENCHANTING) && proto->Quality >= ITEM_QUALITY_UNCOMMON)
if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) &&
proto->Bonding != BIND_WHEN_PICKED_UP && botAI->HasSkill(SKILL_ENCHANTING) &&
proto->Quality >= ITEM_QUALITY_UNCOMMON)
return ITEM_USAGE_DISENCHANT;
//While sync is on, do not loot quest items that are also Useful for master. Master
if (!botAI->GetMaster() || !sPlayerbotAIConfig->syncQuestWithPlayer || !IsItemUsefulForQuest(botAI->GetMaster(), proto))
// While sync is on, do not loot quest items that are also Useful for master. Master
if (!botAI->GetMaster() || !sPlayerbotAIConfig->syncQuestWithPlayer ||
!IsItemUsefulForQuest(botAI->GetMaster(), proto))
if (IsItemUsefulForQuest(bot, proto))
return ITEM_USAGE_QUEST;
@@ -118,20 +123,20 @@ ItemUsage ItemUsageValue::Calculate()
float ammo = BetterStacks(proto, "ammo");
float needAmmo = (bot->getClass() == CLASS_HUNTER) ? 8 : 2;
if (ammo < needAmmo) //We already have enough of the current ammo.
if (ammo < needAmmo) // We already have enough of the current ammo.
{
ammo += CurrentStacks(proto);
if (ammo < needAmmo) //Buy ammo to get to the proper supply
if (ammo < needAmmo) // Buy ammo to get to the proper supply
return ITEM_USAGE_AMMO;
else if (ammo < needAmmo + 1)
return ITEM_USAGE_KEEP; // Keep the ammo until we have too much.
return ITEM_USAGE_KEEP; // Keep the ammo until we have too much.
}
}
}
}
//Need to add something like free bagspace or item value.
// Need to add something like free bagspace or item value.
if (proto->SellPrice > 0)
{
if (proto->Quality > ITEM_QUALITY_NORMAL)
@@ -164,7 +169,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
pItem->RemoveFromUpdateQueueOf(bot);
delete pItem;
if (result != EQUIP_ERR_OK )
if (result != EQUIP_ERR_OK)
return ITEM_USAGE_NONE;
if (itemProto->Class == ITEM_CLASS_QUIVER)
@@ -174,7 +179,8 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
if (itemProto->Class == ITEM_CLASS_CONTAINER)
{
if (itemProto->SubClass != ITEM_SUBCLASS_CONTAINER)
return ITEM_USAGE_NONE; //Todo add logic for non-bag containers. We want to look at professions/class and only replace if non-bag is larger than bag.
return ITEM_USAGE_NONE; // Todo add logic for non-bag containers. We want to look at professions/class and
// only replace if non-bag is larger than bag.
if (GetSmallestBagSize() >= itemProto->ContainerSlots)
return ITEM_USAGE_NONE;
@@ -190,16 +196,19 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
if (itemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), itemProto))
shouldEquip = false;
if (itemProto->Class == ITEM_CLASS_ARMOR && !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), itemProto))
if (itemProto->Class == ITEM_CLASS_ARMOR &&
!sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), itemProto))
shouldEquip = false;
Item* oldItem = bot->GetItemByPos(dest);
//No item equiped
if (!oldItem) {
// No item equiped
if (!oldItem)
{
if (shouldEquip)
return ITEM_USAGE_EQUIP;
else {
else
{
return ITEM_USAGE_BAD_EQUIP;
}
}
@@ -216,10 +225,14 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
}
// Bigger quiver
if (itemProto->Class == ITEM_CLASS_QUIVER) {
if (!oldItem || oldItemProto->ContainerSlots < itemProto->ContainerSlots) {
if (itemProto->Class == ITEM_CLASS_QUIVER)
{
if (!oldItem || oldItemProto->ContainerSlots < itemProto->ContainerSlots)
{
return ITEM_USAGE_EQUIP;
} else {
}
else
{
return ITEM_USAGE_NONE;
}
}
@@ -228,41 +241,45 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
if (oldItemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), oldItemProto))
existingShouldEquip = false;
if (oldItemProto->Class == ITEM_CLASS_ARMOR && !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), oldItemProto))
if (oldItemProto->Class == ITEM_CLASS_ARMOR &&
!sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), oldItemProto))
existingShouldEquip = false;
// uint32 oldItemPower = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);
// uint32 newItemPower = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
//Compare items based on item level, quality or itemId.
// Compare items based on item level, quality or itemId.
bool isBetter = false;
if (itemScore > oldScore)
isBetter = true;
// else if (newItemPower == oldScore && itemProto->Quality > oldItemProto->Quality)
// isBetter = true;
// else if (newItemPower == oldScore && itemProto->Quality == oldItemProto->Quality && itemProto->ItemId > oldItemProto->ItemId)
// else if (newItemPower == oldScore && itemProto->Quality == oldItemProto->Quality && itemProto->ItemId >
// oldItemProto->ItemId)
// isBetter = true;
Item* item = CurrentItem(itemProto);
bool itemIsBroken = item && item->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0;
bool oldItemIsBroken = oldItem->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && oldItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0;
bool itemIsBroken =
item && item->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0;
bool oldItemIsBroken =
oldItem->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && oldItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0;
if (itemProto->ItemId != oldItemProto->ItemId && (shouldEquip || !existingShouldEquip) && isBetter)
{
switch (itemProto->Class)
{
case ITEM_CLASS_ARMOR:
if (oldItemProto->SubClass <= itemProto->SubClass)
{
if (itemIsBroken && !oldItemIsBroken)
return ITEM_USAGE_BROKEN_EQUIP;
else if (shouldEquip)
return ITEM_USAGE_REPLACE;
else
return ITEM_USAGE_BAD_EQUIP;
if (oldItemProto->SubClass <= itemProto->SubClass)
{
if (itemIsBroken && !oldItemIsBroken)
return ITEM_USAGE_BROKEN_EQUIP;
else if (shouldEquip)
return ITEM_USAGE_REPLACE;
else
return ITEM_USAGE_BAD_EQUIP;
break;
}
break;
}
default:
{
if (itemIsBroken && !oldItemIsBroken)
@@ -282,7 +299,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
return ITEM_USAGE_NONE;
}
//Return smaltest bag size equipped
// Return smaltest bag size equipped
uint32 ItemUsageValue::GetSmallestBagSize()
{
int8 curSlot = 0;
@@ -318,7 +335,8 @@ bool ItemUsageValue::IsItemUsefulForQuest(Player* player, ItemTemplate const* pr
if (quest->RequiredItemId[i] != proto->ItemId)
continue;
if (GET_PLAYERBOT_AI(player) && AI_VALUE2(uint32, "item count", proto->Name1) >= quest->RequiredItemCount[i])
if (GET_PLAYERBOT_AI(player) &&
AI_VALUE2(uint32, "item count", proto->Name1) >= quest->RequiredItemCount[i])
continue;
return true;
@@ -332,29 +350,29 @@ bool ItemUsageValue::IsItemNeededForSkill(ItemTemplate const* proto)
{
switch (proto->ItemId)
{
case 2901: //Mining pick
case 2901: // Mining pick
return botAI->HasSkill(SKILL_MINING);
case 5956: //Blacksmith Hammer
case 5956: // Blacksmith Hammer
return botAI->HasSkill(SKILL_BLACKSMITHING) || botAI->HasSkill(SKILL_ENGINEERING);
case 6219: //Arclight Spanner
case 6219: // Arclight Spanner
return botAI->HasSkill(SKILL_ENGINEERING);
case 6218: // Runed copper rod
case 6218: // Runed copper rod
return botAI->HasSkill(SKILL_ENCHANTING);
case 6339: // Runed silver rod
case 6339: // Runed silver rod
return botAI->HasSkill(SKILL_ENCHANTING);
case 11130: // Runed golden rod
case 11130: // Runed golden rod
return botAI->HasSkill(SKILL_ENCHANTING);
case 11145: // Runed truesilver rod
case 11145: // Runed truesilver rod
return botAI->HasSkill(SKILL_ENCHANTING);
case 16207: //Runed Arcanite Rod
case 16207: // Runed Arcanite Rod
return botAI->HasSkill(SKILL_ENCHANTING);
case 7005: //Skinning Knife
case 7005: // Skinning Knife
return botAI->HasSkill(SKILL_SKINNING);
case 4471: //Flint and Tinder
case 4471: // Flint and Tinder
return botAI->HasSkill(SKILL_COOKING);
case 4470: //Simple Wood
case 4470: // Simple Wood
return botAI->HasSkill(SKILL_COOKING);
case 6256: //Fishing Rod
case 6256: // Fishing Rod
return botAI->HasSkill(SKILL_FISHING);
}
@@ -390,12 +408,16 @@ bool ItemUsageValue::IsItemUsefulForSkill(ItemTemplate const* proto)
return true;
if (botAI->HasSkill(SKILL_JEWELCRAFTING) && RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING))
return true;
if (botAI->HasSkill(SKILL_MINING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_MINING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_BLACKSMITHING) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_ENGINEERING)))
if (botAI->HasSkill(SKILL_MINING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_MINING) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_BLACKSMITHING) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_ENGINEERING)))
return true;
if (botAI->HasSkill(SKILL_SKINNING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_SKINNING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_LEATHERWORKING)))
if (botAI->HasSkill(SKILL_SKINNING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_SKINNING) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_LEATHERWORKING)))
return true;
if (botAI->HasSkill(SKILL_HERBALISM) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_HERBALISM) || RandomItemMgr::IsUsedBySkill(proto, SKILL_ALCHEMY)))
if (botAI->HasSkill(SKILL_HERBALISM) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_HERBALISM) ||
RandomItemMgr::IsUsedBySkill(proto, SKILL_ALCHEMY)))
return true;
return false;
@@ -451,7 +473,8 @@ bool ItemUsageValue::IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool
{
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", newItemId);
if (usage != ITEM_USAGE_REPLACE && usage != ITEM_USAGE_EQUIP && usage != ITEM_USAGE_AMMO && usage != ITEM_USAGE_QUEST && usage != ITEM_USAGE_SKILL && usage != ITEM_USAGE_USE)
if (usage != ITEM_USAGE_REPLACE && usage != ITEM_USAGE_EQUIP && usage != ITEM_USAGE_AMMO &&
usage != ITEM_USAGE_QUEST && usage != ITEM_USAGE_SKILL && usage != ITEM_USAGE_USE)
continue;
return true;
@@ -470,7 +493,9 @@ bool ItemUsageValue::HasItemsNeededForSpell(uint32 spellId, ItemTemplate const*
for (uint8 i = 0; i < MAX_SPELL_REAGENTS; i++)
if (spellInfo->ReagentCount[i] > 0 && spellInfo->Reagent[i])
{
if (proto && proto->ItemId == spellInfo->Reagent[i] && spellInfo->ReagentCount[i] == 1) //If we only need 1 item then current item does not need to be checked since we are looting/buying or already have it.
if (proto && proto->ItemId == spellInfo->Reagent[i] &&
spellInfo->ReagentCount[i] == 1) // If we only need 1 item then current item does not need to be
// checked since we are looting/buying or already have it.
continue;
ItemTemplate const* reqProto = sObjectMgr->GetItemTemplate(spellInfo->Reagent[i]);
@@ -601,7 +626,9 @@ bool ItemUsageValue::SpellGivesSkillUp(uint32 spellId, Player* bot)
uint32 craft_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_CRAFTING);
if (SkillGainChance(SkillValue, skill->TrivialSkillLineRankHigh, (skill->TrivialSkillLineRankHigh + skill->TrivialSkillLineRankLow) / 2, skill->TrivialSkillLineRankLow) > 0)
if (SkillGainChance(SkillValue, skill->TrivialSkillLineRankHigh,
(skill->TrivialSkillLineRankHigh + skill->TrivialSkillLineRankLow) / 2,
skill->TrivialSkillLineRankLow) > 0)
return true;
}
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_ITEMUSAGEVALUE_H
@@ -16,46 +17,48 @@ struct ItemTemplate;
enum ItemUsage : uint32
{
ITEM_USAGE_NONE = 0,
ITEM_USAGE_EQUIP = 1,
ITEM_USAGE_REPLACE = 2,
ITEM_USAGE_BAD_EQUIP = 3,
ITEM_USAGE_NONE = 0,
ITEM_USAGE_EQUIP = 1,
ITEM_USAGE_REPLACE = 2,
ITEM_USAGE_BAD_EQUIP = 3,
ITEM_USAGE_BROKEN_EQUIP = 4,
ITEM_USAGE_QUEST = 5,
ITEM_USAGE_SKILL = 6,
ITEM_USAGE_USE = 7,
ITEM_USAGE_GUILD_TASK = 8,
ITEM_USAGE_DISENCHANT = 9,
ITEM_USAGE_AH = 10,
ITEM_USAGE_KEEP = 11,
ITEM_USAGE_VENDOR = 12,
ITEM_USAGE_AMMO = 13
ITEM_USAGE_QUEST = 5,
ITEM_USAGE_SKILL = 6,
ITEM_USAGE_USE = 7,
ITEM_USAGE_GUILD_TASK = 8,
ITEM_USAGE_DISENCHANT = 9,
ITEM_USAGE_AH = 10,
ITEM_USAGE_KEEP = 11,
ITEM_USAGE_VENDOR = 12,
ITEM_USAGE_AMMO = 13
};
class ItemUsageValue : public CalculatedValue<ItemUsage>, public Qualified
{
public:
ItemUsageValue(PlayerbotAI* botAI, std::string const name = "item usage") : CalculatedValue<ItemUsage>(botAI, name) { }
public:
ItemUsageValue(PlayerbotAI* botAI, std::string const name = "item usage") : CalculatedValue<ItemUsage>(botAI, name)
{
}
ItemUsage Calculate() override;
ItemUsage Calculate() override;
private:
ItemUsage QueryItemUsageForEquip(ItemTemplate const* proto);
uint32 GetSmallestBagSize();
bool IsItemUsefulForQuest(Player* player, ItemTemplate const* proto);
bool IsItemNeededForSkill(ItemTemplate const* proto);
bool IsItemUsefulForSkill(ItemTemplate const* proto);
bool IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool checkAllReagents = false);
bool HasItemsNeededForSpell(uint32 spellId, ItemTemplate const* proto);
Item* CurrentItem(ItemTemplate const* proto);
float CurrentStacks(ItemTemplate const* proto);
float BetterStacks(ItemTemplate const* proto, std::string const usageType = "");
private:
ItemUsage QueryItemUsageForEquip(ItemTemplate const* proto);
uint32 GetSmallestBagSize();
bool IsItemUsefulForQuest(Player* player, ItemTemplate const* proto);
bool IsItemNeededForSkill(ItemTemplate const* proto);
bool IsItemUsefulForSkill(ItemTemplate const* proto);
bool IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool checkAllReagents = false);
bool HasItemsNeededForSpell(uint32 spellId, ItemTemplate const* proto);
Item* CurrentItem(ItemTemplate const* proto);
float CurrentStacks(ItemTemplate const* proto);
float BetterStacks(ItemTemplate const* proto, std::string const usageType = "");
public:
static std::vector<uint32> SpellsUsingItem(uint32 itemId, Player* bot);
static bool SpellGivesSkillUp(uint32 spellId, Player* bot);
public:
static std::vector<uint32> SpellsUsingItem(uint32 itemId, Player* bot);
static bool SpellGivesSkillUp(uint32 spellId, Player* bot);
static std::string const GetConsumableType(ItemTemplate const* proto, bool hasMana);
static std::string const GetConsumableType(ItemTemplate const* proto, bool hasMana);
};
#endif

View File

@@ -1,17 +1,24 @@
/*
* 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 "LastMovementValue.h"
#include "Playerbots.h"
LastMovement::LastMovement()
{
clear();
}
LastMovement::LastMovement() { clear(); }
LastMovement::LastMovement(LastMovement& other) : taxiNodes(other.taxiNodes), taxiMaster(other.taxiMaster), lastFollow(other.lastFollow), lastAreaTrigger(other.lastAreaTrigger),
lastMoveToX(other.lastMoveToX), lastMoveToY(other.lastMoveToY), lastMoveToZ(other.lastMoveToZ), lastMoveToOri(other.lastMoveToOri), lastFlee(other.lastFlee)
LastMovement::LastMovement(LastMovement& other)
: taxiNodes(other.taxiNodes),
taxiMaster(other.taxiMaster),
lastFollow(other.lastFollow),
lastAreaTrigger(other.lastAreaTrigger),
lastMoveToX(other.lastMoveToX),
lastMoveToY(other.lastMoveToY),
lastMoveToZ(other.lastMoveToZ),
lastMoveToOri(other.lastMoveToOri),
lastFlee(other.lastFlee)
{
lastMoveShort = other.lastMoveShort;
nextTeleport = other.nextTeleport;
@@ -54,10 +61,8 @@ void LastMovement::Set(uint32 mapId, float x, float y, float z, float ori)
void LastMovement::setShort(WorldPosition point)
{
lastMoveShort = point; lastFollow = nullptr;
lastMoveShort = point;
lastFollow = nullptr;
}
void LastMovement::setPath(TravelPath path)
{
lastPath = path;
}
void LastMovement::setPath(TravelPath path) { lastPath = path; }

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LASTMOVEMENTVALUE_H
@@ -14,60 +15,60 @@ class Unit;
class LastMovement
{
public:
LastMovement();
LastMovement(LastMovement& other);
public:
LastMovement();
LastMovement(LastMovement& other);
LastMovement& operator=(LastMovement const& other)
{
taxiNodes = other.taxiNodes;
taxiMaster = other.taxiMaster;
lastFollow = other.lastFollow;
lastAreaTrigger = other.lastAreaTrigger;
lastMoveShort = other.lastMoveShort;
lastPath = other.lastPath;
nextTeleport = other.nextTeleport;
LastMovement& operator=(LastMovement const& other)
{
taxiNodes = other.taxiNodes;
taxiMaster = other.taxiMaster;
lastFollow = other.lastFollow;
lastAreaTrigger = other.lastAreaTrigger;
lastMoveShort = other.lastMoveShort;
lastPath = other.lastPath;
nextTeleport = other.nextTeleport;
return *this;
};
return *this;
};
void clear();
void clear();
void Set(Unit* follow);
void Set(uint32 mapId, float x, float y, float z, float ori);
void Set(Unit* follow);
void Set(uint32 mapId, float x, float y, float z, float ori);
void setShort(WorldPosition point);
void setPath(TravelPath path);
void setShort(WorldPosition point);
void setPath(TravelPath path);
std::vector<uint32> taxiNodes;
ObjectGuid taxiMaster;
Unit* lastFollow;
uint32 lastAreaTrigger;
time_t lastFlee;
uint32 lastMoveToMapId;
float lastMoveToX;
float lastMoveToY;
float lastMoveToZ;
float lastMoveToOri;
WorldPosition lastMoveShort;
TravelPath lastPath;
time_t nextTeleport;
std::future<TravelPath> future;
std::vector<uint32> taxiNodes;
ObjectGuid taxiMaster;
Unit* lastFollow;
uint32 lastAreaTrigger;
time_t lastFlee;
uint32 lastMoveToMapId;
float lastMoveToX;
float lastMoveToY;
float lastMoveToZ;
float lastMoveToOri;
WorldPosition lastMoveShort;
TravelPath lastPath;
time_t nextTeleport;
std::future<TravelPath> future;
};
class LastMovementValue : public ManualSetValue<LastMovement&>
{
public:
LastMovementValue(PlayerbotAI* botAI) : ManualSetValue<LastMovement&>(botAI, data) { }
public:
LastMovementValue(PlayerbotAI* botAI) : ManualSetValue<LastMovement&>(botAI, data) {}
private:
LastMovement data = LastMovement();
private:
LastMovement data = LastMovement();
};
class StayTimeValue : public ManualSetValue<time_t>
{
public:
StayTimeValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, 0) { }
public:
StayTimeValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, 0) {}
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LASTSAIDVALUE_H
@@ -12,14 +13,14 @@ class PlayerbotAI;
class LastSaidValue : public ManualSetValue<time_t>, public Qualified
{
public:
LastSaidValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, time(nullptr) - 120, "last said") { }
public:
LastSaidValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, time(nullptr) - 120, "last said") {}
};
class LastEmoteValue : public ManualSetValue<time_t>, public Qualified
{
public:
LastEmoteValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, time(nullptr) - 120, "last emote") { }
public:
LastEmoteValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, time(nullptr) - 120, "last emote") {}
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LASTSPELLCASTTIMEVALUE_H
@@ -12,8 +13,8 @@ class PlayerbotAI;
class LastSpellCastTimeValue : public ManualSetValue<time_t>, public Qualified
{
public:
LastSpellCastTimeValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, 0), Qualified() { }
public:
LastSpellCastTimeValue(PlayerbotAI* botAI) : ManualSetValue<time_t>(botAI, 0), Qualified() {}
};
#endif

View File

@@ -1,19 +1,19 @@
/*
* 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 "LastSpellCastValue.h"
#include "Playerbots.h"
LastSpellCast::LastSpellCast() : id(0), timer(0)
{
}
LastSpellCast::LastSpellCast() : id(0), timer(0) {}
void LastSpellCast::Set(uint32 newId, ObjectGuid newTarget, time_t newTime)
{
id = newId;
target = newTarget;
timer = newTime;
timer = newTime;
}
void LastSpellCast::Reset()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LASTSPELLCASTVALUE_H
@@ -11,24 +12,27 @@ class PlayerbotAI;
class LastSpellCast
{
public:
LastSpellCast();
public:
LastSpellCast();
void Set(uint32 id, ObjectGuid target, time_t time);
void Reset();
void Set(uint32 id, ObjectGuid target, time_t time);
void Reset();
uint32 id;
ObjectGuid target;
time_t timer;
uint32 id;
ObjectGuid target;
time_t timer;
};
class LastSpellCastValue : public ManualSetValue<LastSpellCast&>
{
public:
LastSpellCastValue(PlayerbotAI* botAI, std::string const name = "last spell cast") : ManualSetValue<LastSpellCast&>(botAI, data, name) { }
public:
LastSpellCastValue(PlayerbotAI* botAI, std::string const name = "last spell cast")
: ManualSetValue<LastSpellCast&>(botAI, data, name)
{
}
private:
LastSpellCast data;
private:
LastSpellCast data;
};
#endif

View File

@@ -1,28 +1,30 @@
/*
* 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 "LeastHpTargetValue.h"
#include "AttackersValue.h"
#include "Playerbots.h"
class FindLeastHpTargetStrategy : public FindNonCcTargetStrategy
{
public:
FindLeastHpTargetStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minHealth(0) { }
public:
FindLeastHpTargetStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minHealth(0) {}
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
Player* bot = botAI->GetBot();
if (IsCcTarget(attacker))
return;
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
{
Player* bot = botAI->GetBot();
if (IsCcTarget(attacker))
return;
if (!result || result->GetHealth() > attacker->GetHealth())
result = attacker;
}
if (!result || result->GetHealth() > attacker->GetHealth())
result = attacker;
}
protected:
float minHealth;
protected:
float minHealth;
};
Unit* LeastHpTargetValue::Calculate()

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LEASTHPTARGETVALUE_H
@@ -12,10 +13,10 @@ class Unit;
class LeastHpTargetValue : public TargetValue
{
public:
LeastHpTargetValue(PlayerbotAI* botAI, std::string const name = "least hp target") : TargetValue(botAI, name) { }
public:
LeastHpTargetValue(PlayerbotAI* botAI, std::string const name = "least hp target") : TargetValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LFGVALUES_H
@@ -11,8 +12,8 @@ class PlayerbotAI;
class LfgProposalValue : public ManualSetValue<uint32>
{
public:
LfgProposalValue(PlayerbotAI* botAI) : ManualSetValue<uint32>(botAI, 0, "lfg proposal") { }
public:
LfgProposalValue(PlayerbotAI* botAI) : ManualSetValue<uint32>(botAI, 0, "lfg proposal") {}
};
#endif

View File

@@ -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 "LineTargetValue.h"
#include "Playerbots.h"
Unit* LineTargetValue::Calculate()
@@ -15,11 +17,11 @@ Unit* LineTargetValue::Calculate()
if (!group)
return nullptr;
Player *prev = master;
Player* prev = master;
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *player = ObjectAccessor::FindPlayer(itr->guid);
Player* player = ObjectAccessor::FindPlayer(itr->guid);
if (!player || !player->IsAlive() || player == master)
continue;
@@ -31,4 +33,3 @@ Unit* LineTargetValue::Calculate()
return master;
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LINETARGETVALUE_H
@@ -12,10 +13,10 @@ class Unit;
class LineTargetValue : public UnitCalculatedValue
{
public:
LineTargetValue(PlayerbotAI* botAI, std::string const name = "line target") : UnitCalculatedValue(botAI, name) { }
public:
LineTargetValue(PlayerbotAI* botAI, std::string const name = "line target") : UnitCalculatedValue(botAI, name) {}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LOGLEVELVALUE_H
@@ -11,8 +12,11 @@ class PlayerbotAI;
class LogLevelValue : public ManualSetValue<LogLevel>
{
public:
LogLevelValue(PlayerbotAI* botAI, std::string const name = "log level") : ManualSetValue<LogLevel>(botAI, LOG_LEVEL_DEBUG, name) { }
public:
LogLevelValue(PlayerbotAI* botAI, std::string const name = "log level")
: ManualSetValue<LogLevel>(botAI, LOG_LEVEL_DEBUG, name)
{
}
};
#endif

View File

@@ -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 "LootStrategyValue.h"
#include "AiObjectContext.h"
#include "ItemUsageValue.h"
#include "LootObjectStack.h"
@@ -10,62 +12,48 @@
class NormalLootStrategy : public LootStrategy
{
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
std::ostringstream out;
out << proto->ItemId;
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", out.str());
return usage != ITEM_USAGE_NONE;
}
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
std::ostringstream out;
out << proto->ItemId;
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", out.str());
return usage != ITEM_USAGE_NONE;
}
std::string const GetName() override
{
return "normal";
}
std::string const GetName() override { return "normal"; }
};
class GrayLootStrategy : public NormalLootStrategy
{
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
return NormalLootStrategy::CanLoot(proto, context) || proto->Quality == ITEM_QUALITY_POOR;
}
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
return NormalLootStrategy::CanLoot(proto, context) || proto->Quality == ITEM_QUALITY_POOR;
}
std::string const GetName() override
{
return "gray";
}
std::string const GetName() override { return "gray"; }
};
class DisenchantLootStrategy : public NormalLootStrategy
{
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
return NormalLootStrategy::CanLoot(proto, context) || (proto->Quality >= ITEM_QUALITY_UNCOMMON && proto->Bonding != BIND_WHEN_PICKED_UP &&
(proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON));
}
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
return NormalLootStrategy::CanLoot(proto, context) ||
(proto->Quality >= ITEM_QUALITY_UNCOMMON && proto->Bonding != BIND_WHEN_PICKED_UP &&
(proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON));
}
std::string const GetName() override
{
return "disenchant";
}
std::string const GetName() override { return "disenchant"; }
};
class AllLootStrategy : public LootStrategy
{
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override
{
return true;
}
public:
bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override { return true; }
std::string const GetName() override
{
return "all";
}
std::string const GetName() override { return "all"; }
};
LootStrategyValue::~LootStrategyValue()
@@ -92,10 +80,7 @@ LootStrategy* LootStrategyValue::instance(std::string const strategy)
return normal;
}
std::string const LootStrategyValue::Save()
{
return value ? value->GetName() : "?";
}
std::string const LootStrategyValue::Save() { return value ? value->GetName() : "?"; }
bool LootStrategyValue::Load(std::string const text)
{

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LOOTSTRATEGYVALUE_H
@@ -12,18 +13,21 @@ class PlayerbotAI;
class LootStrategyValue : public ManualSetValue<LootStrategy*>
{
public:
LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue<LootStrategy*>(botAI, normal, name) { }
virtual ~LootStrategyValue();
public:
LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy")
: ManualSetValue<LootStrategy*>(botAI, normal, name)
{
}
virtual ~LootStrategyValue();
std::string const Save() override;
bool Load(std::string const value) override;
std::string const Save() override;
bool Load(std::string const value) override;
static LootStrategy* normal;
static LootStrategy* gray;
static LootStrategy* all;
static LootStrategy* disenchant;
static LootStrategy* instance(std::string const name);
static LootStrategy* normal;
static LootStrategy* gray;
static LootStrategy* all;
static LootStrategy* disenchant;
static LootStrategy* instance(std::string const name);
};
#endif

View File

@@ -1,67 +1,69 @@
/*
* 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 "LootValues.h"
#include "SharedValueContext.h"
#include "Playerbots.h"
#include "SharedValueContext.h"
LootTemplateAccess const* DropMapValue::GetLootTemplate(ObjectGuid guid, LootType type)
{
LootTemplate const* lTemplate = nullptr;
LootTemplate const* lTemplate = nullptr;
if (guid.IsCreature())
{
CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(guid.GetEntry());
if (guid.IsCreature())
{
CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(guid.GetEntry());
if (info)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Creature.GetLootFor(info->lootid);
else if (type == LOOT_PICKPOCKETING && info->pickpocketLootId)
lTemplate = LootTemplates_Pickpocketing.GetLootFor(info->pickpocketLootId);
else if (type == LOOT_SKINNING && info->SkinLootId)
lTemplate = LootTemplates_Skinning.GetLootFor(info->SkinLootId);
}
}
else if (guid.IsGameObject())
{
GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(guid.GetEntry());
if (info && info->GetLootId() != 0)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Gameobject.GetLootFor(info->GetLootId());
else if (type == LOOT_FISHINGHOLE)
lTemplate = LootTemplates_Fishing.GetLootFor(info->GetLootId());
}
}
else if (guid.IsItem())
{
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry());
if (info)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Creature.GetLootFor(info->lootid);
else if (type == LOOT_PICKPOCKETING && info->pickpocketLootId)
lTemplate = LootTemplates_Pickpocketing.GetLootFor(info->pickpocketLootId);
else if (type == LOOT_SKINNING && info->SkinLootId)
lTemplate = LootTemplates_Skinning.GetLootFor(info->SkinLootId);
}
}
else if (guid.IsGameObject())
{
GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(guid.GetEntry());
if (info && info->GetLootId() != 0)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Gameobject.GetLootFor(info->GetLootId());
else if (type == LOOT_FISHINGHOLE)
lTemplate = LootTemplates_Fishing.GetLootFor(info->GetLootId());
}
}
else if (guid.IsItem())
{
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry());
if (proto)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Item.GetLootFor(proto->ItemId);
else if (type == LOOT_DISENCHANTING && proto->DisenchantID)
lTemplate = LootTemplates_Disenchant.GetLootFor(proto->DisenchantID);
if (type == LOOT_MILLING)
lTemplate = LootTemplates_Milling.GetLootFor(proto->ItemId);
if (type == LOOT_PROSPECTING)
lTemplate = LootTemplates_Prospecting.GetLootFor(proto->ItemId);
}
}
if (proto)
{
if (type == LOOT_CORPSE)
lTemplate = LootTemplates_Item.GetLootFor(proto->ItemId);
else if (type == LOOT_DISENCHANTING && proto->DisenchantID)
lTemplate = LootTemplates_Disenchant.GetLootFor(proto->DisenchantID);
if (type == LOOT_MILLING)
lTemplate = LootTemplates_Milling.GetLootFor(proto->ItemId);
if (type == LOOT_PROSPECTING)
lTemplate = LootTemplates_Prospecting.GetLootFor(proto->ItemId);
}
}
LootTemplateAccess const* lTemplateA = reinterpret_cast<LootTemplateAccess const*>(lTemplate);
LootTemplateAccess const* lTemplateA = reinterpret_cast<LootTemplateAccess const*>(lTemplate);
return lTemplateA;
return lTemplateA;
}
DropMap* DropMapValue::Calculate()
{
DropMap* dropMap = new DropMap;
DropMap* dropMap = new DropMap;
int32 sEntry = 0;
int32 sEntry = 0;
if (CreatureTemplateContainer const* creatures = sObjectMgr->GetCreatureTemplates())
{
@@ -69,75 +71,78 @@ DropMap* DropMapValue::Calculate()
{
sEntry = itr->first;
if (LootTemplateAccess const* lTemplateA = GetLootTemplate(ObjectGuid::Create<HighGuid::Unit>(sEntry, uint32(1)), LOOT_CORPSE))
if (LootTemplateAccess const* lTemplateA =
GetLootTemplate(ObjectGuid::Create<HighGuid::Unit>(sEntry, uint32(1)), LOOT_CORPSE))
for (auto const& lItem : lTemplateA->Entries)
dropMap->insert(std::make_pair(lItem->itemid, sEntry));
}
}
if (GameObjectTemplateContainer const* gameobjects = sObjectMgr->GetGameObjectTemplates())
if (GameObjectTemplateContainer const* gameobjects = sObjectMgr->GetGameObjectTemplates())
{
for (auto const& itr : *gameobjects)
{
sEntry = itr.first;
if (LootTemplateAccess const* lTemplateA = GetLootTemplate(ObjectGuid::Create<HighGuid::GameObject>(sEntry, uint32(1)), LOOT_CORPSE))
if (LootTemplateAccess const* lTemplateA =
GetLootTemplate(ObjectGuid::Create<HighGuid::GameObject>(sEntry, uint32(1)), LOOT_CORPSE))
for (auto const& lItem : lTemplateA->Entries)
dropMap->insert(std::make_pair(lItem->itemid, -sEntry));
}
}
return dropMap;
return dropMap;
}
//What items does this entry have in its loot list?
// What items does this entry have in its loot list?
std::vector<int32> ItemDropListValue::Calculate()
{
uint32 itemId = stoi(getQualifier());
uint32 itemId = stoi(getQualifier());
DropMap* dropMap = GAI_VALUE(DropMap*, "drop map");
DropMap* dropMap = GAI_VALUE(DropMap*, "drop map");
std::vector<int32> entries;
std::vector<int32> entries;
auto range = dropMap->equal_range(itemId);
auto range = dropMap->equal_range(itemId);
for (auto itr = range.first; itr != range.second; ++itr)
entries.push_back(itr->second);
for (auto itr = range.first; itr != range.second; ++itr)
entries.push_back(itr->second);
return entries;
return entries;
}
//What items does this entry have in its loot list?
// What items does this entry have in its loot list?
std::vector<uint32> EntryLootListValue::Calculate()
{
int32 entry = stoi(getQualifier());
int32 entry = stoi(getQualifier());
std::vector<uint32> items;
std::vector<uint32> items;
LootTemplateAccess const* lTemplateA;
LootTemplateAccess const* lTemplateA;
if (entry > 0)
lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create<HighGuid::Unit>(entry, uint32(1)), LOOT_CORPSE);
else
lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create<HighGuid::GameObject>(entry, uint32(1)), LOOT_CORPSE);
if (entry > 0)
lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create<HighGuid::Unit>(entry, uint32(1)), LOOT_CORPSE);
else
lTemplateA =
DropMapValue::GetLootTemplate(ObjectGuid::Create<HighGuid::GameObject>(entry, uint32(1)), LOOT_CORPSE);
if (lTemplateA)
for (auto const& lItem : lTemplateA->Entries)
items.push_back(lItem->itemid);
if (lTemplateA)
for (auto const& lItem : lTemplateA->Entries)
items.push_back(lItem->itemid);
return items;
return items;
}
itemUsageMap EntryLootUsageValue::Calculate()
{
itemUsageMap items;
itemUsageMap items;
for (auto itemId : GAI_VALUE2(std::vector<uint32>, "entry loot list", getQualifier()))
{
items[AI_VALUE2(ItemUsage, "item usage", itemId)].push_back(itemId);
}
for (auto itemId : GAI_VALUE2(std::vector<uint32>, "entry loot list", getQualifier()))
{
items[AI_VALUE2(ItemUsage, "item usage", itemId)].push_back(itemId);
}
return items;
return items;
};
bool HasUpgradeValue::Calculate()

View File

@@ -1,75 +1,76 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_LOOTVALUES_H
#define _PLAYERBOT_LOOTVALUES_H
#include "ItemUsageValue.h"
#include "LootMgr.h"
#include "NamedObjectContext.h"
#include "ItemUsageValue.h"
#include "Value.h"
class PlayerbotAI;
//Cheat class copy to hack into the loot system
// Cheat class copy to hack into the loot system
class LootTemplateAccess
{
public:
class LootGroup; // A set of loot definitions for items (refs are not allowed inside)
typedef std::vector<LootGroup> LootGroups;
LootStoreItemList Entries; // not grouped only
LootGroups Groups; // groups have own (optimized) processing, grouped entries go there
public:
class LootGroup; // A set of loot definitions for items (refs are not allowed inside)
typedef std::vector<LootGroup> LootGroups;
LootStoreItemList Entries; // not grouped only
LootGroups Groups; // groups have own (optimized) processing, grouped entries go there
};
// itemId, entry
typedef std::unordered_map<uint32, int32> DropMap;
//Returns the loot map of all entries
// Returns the loot map of all entries
class DropMapValue : public SingleCalculatedValue<DropMap*>
{
public:
DropMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "drop map") { }
public:
DropMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "drop map") {}
static LootTemplateAccess const* GetLootTemplate(ObjectGuid guid, LootType type = LOOT_CORPSE);
static LootTemplateAccess const* GetLootTemplate(ObjectGuid guid, LootType type = LOOT_CORPSE);
DropMap* Calculate() override;
DropMap* Calculate() override;
};
//Returns the entries that drop a specific item
// Returns the entries that drop a specific item
class ItemDropListValue : public SingleCalculatedValue<std::vector<int32>>, public Qualified
{
public:
ItemDropListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "item drop list") { }
public:
ItemDropListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "item drop list") {}
std::vector<int32> Calculate() override;
std::vector<int32> Calculate() override;
};
//Returns the items a specific entry can drop
// Returns the items a specific entry can drop
class EntryLootListValue : public SingleCalculatedValue<std::vector<uint32>>, public Qualified
{
public:
EntryLootListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry loot list") { }
public:
EntryLootListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry loot list") {}
std::vector<uint32> Calculate() override;
std::vector<uint32> Calculate() override;
};
typedef std::unordered_map<ItemUsage, std::vector<uint32>> itemUsageMap;
class EntryLootUsageValue : public CalculatedValue<itemUsageMap>, public Qualified
{
public:
EntryLootUsageValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "entry loot usage", 2 * 1000) { }
public:
EntryLootUsageValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "entry loot usage", 2 * 1000) {}
itemUsageMap Calculate() override;
itemUsageMap Calculate() override;
};
class HasUpgradeValue : public BoolCalculatedValue, public Qualified
{
public:
HasUpgradeValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "has upgrade", 2 * 1000) { }
public:
HasUpgradeValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "has upgrade", 2 * 1000) {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -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 "MaintenanceValues.h"
#include "BudgetValues.h"
#include "ItemUsageValue.h"
#include "Playerbots.h"
@@ -24,43 +26,35 @@ bool CanMoveAroundValue::Calculate()
return true;
}
bool ShouldHomeBindValue::Calculate()
{
return AI_VALUE2(float, "distance", "home bind") > 1000.0f;
}
bool ShouldHomeBindValue::Calculate() { return AI_VALUE2(float, "distance", "home bind") > 1000.0f; }
bool ShouldRepairValue::Calculate()
{
return AI_VALUE(uint8, "durability") < 80;
}
bool ShouldRepairValue::Calculate() { return AI_VALUE(uint8, "durability") < 80; }
bool CanRepairValue::Calculate()
{
return AI_VALUE(uint8, "durability") < 100 && AI_VALUE(uint32, "repair cost") < AI_VALUE2(uint32, "free money for", (uint32) NeedMoneyFor::repair);
return AI_VALUE(uint8, "durability") < 100 &&
AI_VALUE(uint32, "repair cost") < AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::repair);
}
bool ShouldSellValue::Calculate()
{
return AI_VALUE(uint8, "bag space") > 80;
}
bool ShouldSellValue::Calculate() { return AI_VALUE(uint8, "bag space") > 80; }
bool CanSellValue::Calculate()
{
return (AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_VENDOR)) + AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_AH))) > 1;
return (AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_VENDOR)) +
AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_AH))) > 1;
}
bool CanFightEqualValue::Calculate()
{
return AI_VALUE(uint8, "durability") > 20;
}
bool CanFightEqualValue::Calculate() { return AI_VALUE(uint8, "durability") > 20; }
bool CanFightEliteValue::Calculate()
{
return bot->GetGroup() && AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell");
return bot->GetGroup() && AI_VALUE2(bool, "group and", "can fight equal") &&
AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell");
}
bool CanFightBossValue::Calculate()
{
return bot->GetGroup() && bot->GetGroup()->GetMembersCount() > 3 && AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell");
return bot->GetGroup() && bot->GetGroup()->GetMembersCount() > 3 &&
AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") &&
!AI_VALUE2(bool, "group or", "should sell,can sell");
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_MAINTANCEVALUE_H
@@ -11,74 +12,74 @@ class PlayerbotAI;
class CanMoveAroundValue : public BoolCalculatedValue
{
public:
CanMoveAroundValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can move around", 2 * 2000) { }
public:
CanMoveAroundValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can move around", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class ShouldHomeBindValue : public BoolCalculatedValue
{
public:
ShouldHomeBindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should home bind", 2 * 2000) { }
public:
ShouldHomeBindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should home bind", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class ShouldRepairValue : public BoolCalculatedValue
{
public:
ShouldRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI,"should repair",2 * 2000) { }
public:
ShouldRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should repair", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class CanRepairValue : public BoolCalculatedValue
{
public:
CanRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can repair",2 * 2000) { }
public:
CanRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can repair", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class ShouldSellValue : public BoolCalculatedValue
{
public:
ShouldSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should sell",2 * 2000) { }
public:
ShouldSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should sell", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class CanSellValue : public BoolCalculatedValue
{
public:
CanSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can sell",2 * 2000) { }
public:
CanSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can sell", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class CanFightEqualValue: public BoolCalculatedValue
class CanFightEqualValue : public BoolCalculatedValue
{
public:
CanFightEqualValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight equal",2 * 2000) { }
public:
CanFightEqualValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight equal", 2 * 2000) {}
bool Calculate() override;
bool Calculate() override;
};
class CanFightEliteValue : public BoolCalculatedValue
{
public:
CanFightEliteValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight elite") { }
public:
CanFightEliteValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight elite") {}
bool Calculate() override;
bool Calculate() override;
};
class CanFightBossValue : public BoolCalculatedValue
{
public:
CanFightBossValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight boss") { }
public:
CanFightBossValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight boss") {}
bool Calculate() override;
bool Calculate() override;
};
#endif

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_MANASAVELEVELVALUE_H
@@ -11,21 +12,21 @@ class PlayerbotAI;
class ManaSaveLevelValue : public ManualSetValue<double>
{
public:
ManaSaveLevelValue(PlayerbotAI* botAI) : ManualSetValue<double>(botAI, 1.0, "mana save level") { }
public:
ManaSaveLevelValue(PlayerbotAI* botAI) : ManualSetValue<double>(botAI, 1.0, "mana save level") {}
std::string const Save()
{
std::ostringstream out;
out << value;
return out.str();
}
std::string const Save()
{
std::ostringstream out;
out << value;
return out.str();
}
bool Load(std::string const text)
{
value = atof(text.c_str());
return true;
}
bool Load(std::string const text)
{
value = atof(text.c_str());
return true;
}
};
#endif

View File

@@ -1,11 +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 "MasterTargetValue.h"
#include "Playerbots.h"
Unit* MasterTargetValue::Calculate()
{
return botAI->GetGroupMaster();
}
Unit* MasterTargetValue::Calculate() { return botAI->GetGroupMaster(); }

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_MASTERTARGETVALUE_H
@@ -12,10 +13,12 @@ class Unit;
class MasterTargetValue : public UnitCalculatedValue
{
public:
MasterTargetValue(PlayerbotAI* botAI, std::string const name = "master target") : UnitCalculatedValue(botAI, name) { }
public:
MasterTargetValue(PlayerbotAI* botAI, std::string const name = "master target") : UnitCalculatedValue(botAI, name)
{
}
Unit* Calculate() override;
Unit* Calculate() override;
};
#endif

View File

@@ -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 "NearestAdsValue.h"
#include "Playerbots.h"
bool NearestAddsValue::AcceptUnit(Unit* unit)

View File

@@ -1,22 +1,26 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_NEARESTADSVALUE_H
#define _PLAYERBOT_NEARESTADSVALUE_H
#include "PossibleTargetsValue.h"
#include "PlayerbotAIConfig.h"
#include "PossibleTargetsValue.h"
class PlayerbotAI;
class NearestAddsValue : public PossibleTargetsValue
{
public:
NearestAddsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->tooCloseDistance) : PossibleTargetsValue(botAI, "nearest adds", range, true) { }
public:
NearestAddsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->tooCloseDistance)
: PossibleTargetsValue(botAI, "nearest adds", range, true)
{
}
protected:
bool AcceptUnit(Unit* unit) override;
protected:
bool AcceptUnit(Unit* unit) override;
};
#endif

View File

@@ -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 "NearestCorpsesValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -10,17 +12,14 @@
class AnyDeadUnitInObjectRangeCheck
{
public:
AnyDeadUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { }
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u)
{
return !u->IsAlive();
}
public:
AnyDeadUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) { return !u->IsAlive(); }
private:
WorldObject const* i_obj;
float i_range;
private:
WorldObject const* i_obj;
float i_range;
};
void NearestCorpsesValue::FindUnits(std::list<Unit*>& targets)
@@ -30,7 +29,4 @@ void NearestCorpsesValue::FindUnits(std::list<Unit*>& targets)
Cell::VisitAllObjects(bot, searcher, range);
}
bool NearestCorpsesValue::AcceptUnit(Unit* unit)
{
return true;
}
bool NearestCorpsesValue::AcceptUnit(Unit* unit) { return true; }

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_NEARESTCORPSESVALUE_H
@@ -12,12 +13,15 @@ class PlayerbotAI;
class NearestCorpsesValue : public NearestUnitsValue
{
public:
NearestCorpsesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : NearestUnitsValue(botAI, "nearest corpses", range) { }
public:
NearestCorpsesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance)
: NearestUnitsValue(botAI, "nearest corpses", range)
{
}
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
};
#endif

View File

@@ -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 "NearestFriendlyPlayersValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_NEARESTFRIENDLYPLAYERSVALUES_H
@@ -12,13 +13,15 @@ class PlayerbotAI;
class NearestFriendlyPlayersValue : public NearestUnitsValue
{
public:
NearestFriendlyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) :
NearestUnitsValue(botAI, "nearest friendly players", range) { }
public:
NearestFriendlyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance)
: NearestUnitsValue(botAI, "nearest friendly players", range)
{
}
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
};
#endif

View File

@@ -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 "NearestGameObjects.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -12,20 +14,20 @@
class AnyGameObjectInObjectRangeCheck
{
public:
AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { }
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(GameObject* u)
{
if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo())
return true;
public:
AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(GameObject* u)
{
if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo())
return true;
return false;
}
return false;
}
private:
WorldObject const* i_obj;
float i_range;
private:
WorldObject const* i_obj;
float i_range;
};
GuidVector NearestGameObjects::Calculate()
@@ -75,16 +77,22 @@ GuidVector NearestTrapWithDamageValue::Calculate()
continue;
}
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (spellInfo->IsPositive()) {
if (spellInfo->IsPositive())
{
continue;
}
for (int i = 0; i < MAX_SPELL_EFFECTS; i++) {
if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) {
if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE) {
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
{
if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA)
{
if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE)
{
result.push_back(go->GetGUID());
break;
}
} else if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) {
}
else if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
{
result.push_back(go->GetGUID());
break;
}
@@ -92,4 +100,3 @@ GuidVector NearestTrapWithDamageValue::Calculate()
}
return result;
}

View File

@@ -1,40 +1,46 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_NEARESTGAMEOBJECTS_H
#define _PLAYERBOT_NEARESTGAMEOBJECTS_H
#include "Value.h"
#include "PlayerbotAIConfig.h"
#include "Value.h"
class PlayerbotAI;
class NearestGameObjects : public ObjectGuidListCalculatedValue
{
public:
NearestGameObjects(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false, std::string const name = "nearest game objects") :
ObjectGuidListCalculatedValue(botAI, name, 2 * 1000), range(range) , ignoreLos(ignoreLos) { }
public:
NearestGameObjects(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false,
std::string const name = "nearest game objects")
: ObjectGuidListCalculatedValue(botAI, name, 2 * 1000), range(range), ignoreLos(ignoreLos)
{
}
protected:
GuidVector Calculate() override;
protected:
GuidVector Calculate() override;
private:
float range;
bool ignoreLos;
private:
float range;
bool ignoreLos;
};
class NearestTrapWithDamageValue : public ObjectGuidListCalculatedValue
{
public:
NearestTrapWithDamageValue(PlayerbotAI* botAI, float range = 15.0f) :
ObjectGuidListCalculatedValue(botAI, "nearest trap with damage", 1 * 1000), range(range) { }
public:
NearestTrapWithDamageValue(PlayerbotAI* botAI, float range = 15.0f)
: ObjectGuidListCalculatedValue(botAI, "nearest trap with damage", 1 * 1000), range(range)
{
}
protected:
GuidVector Calculate() override;
private:
float range;
protected:
GuidVector Calculate() override;
private:
float range;
};
#endif

View File

@@ -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 "NearestNonBotPlayersValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -18,6 +20,6 @@ void NearestNonBotPlayersValue::FindUnits(std::list<Unit*>& targets)
bool NearestNonBotPlayersValue::AcceptUnit(Unit* unit)
{
ObjectGuid guid = unit->GetGUID();
return guid.IsPlayer() && !GET_PLAYERBOT_AI(((Player*)unit)) && (!((Player*)unit)->IsGameMaster() || ((Player*)unit)->isGMVisible());
return guid.IsPlayer() && !GET_PLAYERBOT_AI(((Player*)unit)) &&
(!((Player*)unit)->IsGameMaster() || ((Player*)unit)->isGMVisible());
}

View File

@@ -1,5 +1,6 @@
/*
* 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.
*/
#ifndef _PLAYERBOT_NEARESTNONBOTPLAYERSVALUE_H
@@ -12,12 +13,15 @@ class PlayerbotAI;
class NearestNonBotPlayersValue : public NearestUnitsValue
{
public:
NearestNonBotPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) : NearestUnitsValue(botAI, "nearest non bot players", range, true) { }
public:
NearestNonBotPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance)
: NearestUnitsValue(botAI, "nearest non bot players", range, true)
{
}
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
protected:
void FindUnits(std::list<Unit*>& targets) override;
bool AcceptUnit(Unit* unit) override;
};
#endif

View File

@@ -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 "NearestNpcsValue.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -16,10 +18,7 @@ void NearestNpcsValue::FindUnits(std::list<Unit*>& targets)
Cell::VisitAllObjects(bot, searcher, range);
}
bool NearestNpcsValue::AcceptUnit(Unit* unit)
{
return !unit->IsHostileTo(bot) && !unit->IsPlayer();
}
bool NearestNpcsValue::AcceptUnit(Unit* unit) { return !unit->IsHostileTo(bot) && !unit->IsPlayer(); }
void NearestVehiclesValue::FindUnits(std::list<Unit*>& targets)
{
@@ -47,10 +46,7 @@ void NearestTriggersValue::FindUnits(std::list<Unit*>& targets)
Cell::VisitAllObjects(bot, searcher, range);
}
bool NearestTriggersValue::AcceptUnit(Unit* unit)
{
return !unit->IsPlayer();
}
bool NearestTriggersValue::AcceptUnit(Unit* unit) { return !unit->IsPlayer(); }
void NearestTotemsValue::FindUnits(std::list<Unit*>& targets)
{
@@ -59,7 +55,4 @@ void NearestTotemsValue::FindUnits(std::list<Unit*>& targets)
Cell::VisitAllObjects(bot, searcher, range);
}
bool NearestTotemsValue::AcceptUnit(Unit* unit)
{
return unit->IsTotem();
}
bool NearestTotemsValue::AcceptUnit(Unit* unit) { return unit->IsTotem(); }

Some files were not shown because too many files have changed in this diff Show More