mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
1st commit
This commit is contained in:
@@ -1038,6 +1038,11 @@ void Item::SendUpdateSockets()
|
||||
// time.
|
||||
void Item::SendTimeUpdate(Player* owner)
|
||||
{
|
||||
#ifdef PLAYERBOTS
|
||||
if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI())
|
||||
return;
|
||||
#endif
|
||||
|
||||
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
|
||||
if (!duration)
|
||||
return;
|
||||
|
||||
@@ -260,7 +260,7 @@ enum SocketColor
|
||||
|
||||
#define SOCKET_COLOR_ALL (SOCKET_COLOR_META | SOCKET_COLOR_RED | SOCKET_COLOR_YELLOW | SOCKET_COLOR_BLUE)
|
||||
|
||||
enum InventoryType
|
||||
enum InventoryType : uint32
|
||||
{
|
||||
INVTYPE_NON_EQUIP = 0,
|
||||
INVTYPE_HEAD = 1,
|
||||
|
||||
@@ -92,6 +92,10 @@
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
#include "Playerbot.h"
|
||||
#endif
|
||||
|
||||
enum CharacterFlags
|
||||
{
|
||||
CHARACTER_FLAG_NONE = 0x00000000,
|
||||
@@ -410,6 +414,11 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
|
||||
|
||||
m_isInstantFlightOn = true;
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
_playerbotAI = nullptr;
|
||||
_playerbotMgr = nullptr;
|
||||
#endif
|
||||
|
||||
sScriptMgr->OnConstructPlayer(this);
|
||||
}
|
||||
|
||||
@@ -461,6 +470,14 @@ Player::~Player()
|
||||
u->RemovePlayerFromVision(this);
|
||||
} while (!m_isInSharedVisionOf.empty());
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
delete _playerbotAI;
|
||||
_playerbotAI = nullptr;
|
||||
|
||||
delete _playerbotMgr;
|
||||
_playerbotMgr = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::CleanupsBeforeDelete(bool finalCleanup)
|
||||
@@ -15435,3 +15452,34 @@ std::string Player::GetPlayerName()
|
||||
|
||||
return "|Hplayer:" + name + "|h" + color + name + "|h|r";
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
void Player::SetPlayerbotAI(PlayerbotAI* ai)
|
||||
{
|
||||
ASSERT(!_playerbotAI && !_playerbotMgr);
|
||||
|
||||
_playerbotAI = ai;
|
||||
}
|
||||
|
||||
PlayerbotAI* Player::GetPlayerbotAI()
|
||||
{
|
||||
return _playerbotAI;
|
||||
}
|
||||
|
||||
void Player::SetPlayerbotMgr(PlayerbotMgr* mgr)
|
||||
{
|
||||
ASSERT(!_playerbotAI && !_playerbotMgr);
|
||||
|
||||
_playerbotMgr = mgr;
|
||||
}
|
||||
|
||||
PlayerbotMgr* Player::GetPlayerbotMgr()
|
||||
{
|
||||
return _playerbotMgr;
|
||||
}
|
||||
|
||||
void Player::SetBotDeathTimer()
|
||||
{
|
||||
m_deathTimer = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,6 +60,9 @@ class PlayerSocial;
|
||||
class SpellCastTargets;
|
||||
class UpdateMask;
|
||||
|
||||
class PlayerbotAI;
|
||||
class PlayerbotMgr;
|
||||
|
||||
typedef std::deque<Mail*> PlayerMails;
|
||||
typedef void(*bgZoneRef)(Battleground*, WorldPacket&);
|
||||
|
||||
@@ -660,7 +663,7 @@ enum PlayerSlots
|
||||
|
||||
#define INVENTORY_SLOT_BAG_0 255
|
||||
|
||||
enum EquipmentSlots // 19 slots
|
||||
enum EquipmentSlots : uint32 // 19 slots
|
||||
{
|
||||
EQUIPMENT_SLOT_START = 0,
|
||||
EQUIPMENT_SLOT_HEAD = 0,
|
||||
@@ -1247,7 +1250,7 @@ public:
|
||||
InventoryResult CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading = true) const;
|
||||
InventoryResult CanUseItem(Item* pItem, bool not_loading = true) const;
|
||||
[[nodiscard]] bool HasItemTotemCategory(uint32 TotemCategory) const;
|
||||
bool IsTotemCategoryCompatiableWith(const ItemTemplate* pProto, uint32 requiredTotemCategoryId) const;
|
||||
bool IsTotemCategoryCompatiableWith(ItemTemplate const* pProto, uint32 requiredTotemCategoryId) const;
|
||||
InventoryResult CanUseItem(ItemTemplate const* pItem) const;
|
||||
[[nodiscard]] InventoryResult CanUseAmmo(uint32 item) const;
|
||||
InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const;
|
||||
@@ -1274,7 +1277,7 @@ public:
|
||||
void SetAmmo(uint32 item);
|
||||
void RemoveAmmo();
|
||||
[[nodiscard]] float GetAmmoDPS() const { return m_ammoDPS; }
|
||||
bool CheckAmmoCompatibility(const ItemTemplate* ammo_proto) const;
|
||||
bool CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const;
|
||||
void QuickEquipItem(uint16 pos, Item* pItem);
|
||||
void VisualizeItem(uint8 slot, Item* pItem);
|
||||
void SetVisibleItemSlot(uint8 slot, Item* pItem);
|
||||
@@ -2589,15 +2592,16 @@ public:
|
||||
std::string GetMapAreaAndZoneString();
|
||||
std::string GetCoordsMapAreaAndZoneString();
|
||||
|
||||
void SetFarSightDistance(float radius);
|
||||
void ResetFarSightDistance();
|
||||
Optional<float> GetFarSightDistance() const;
|
||||
// Playerbot mod
|
||||
// A Player can either have a playerbotMgr (to manage its bots), or have playerbotAI (if it is a bot), or
|
||||
// neither. Code that enables bots must create the playerbotMgr and set it using SetPlayerbotMgr.
|
||||
void SetPlayerbotAI(PlayerbotAI* ai);
|
||||
PlayerbotAI* GetPlayerbotAI();
|
||||
void SetPlayerbotMgr(PlayerbotMgr* mgr);
|
||||
PlayerbotMgr* GetPlayerbotMgr();
|
||||
void SetBotDeathTimer();
|
||||
|
||||
float GetSightRange(const WorldObject* target = nullptr) const override;
|
||||
|
||||
std::string GetPlayerName();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// Gamemaster whisper whitelist
|
||||
WhisperListContainer WhisperList;
|
||||
|
||||
@@ -2952,6 +2956,10 @@ private:
|
||||
WorldLocation _corpseLocation;
|
||||
|
||||
Optional<float> _farSightDistance = { };
|
||||
|
||||
// Playerbot mod
|
||||
PlayerbotAI* _playerbotAI;
|
||||
PlayerbotMgr* _playerbotMgr;
|
||||
};
|
||||
|
||||
void AddItemsSetItem(Player* player, Item* item);
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#include "Vehicle.h"
|
||||
#include "WeatherMgr.h"
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
#include "Playerbot.h"
|
||||
#endif
|
||||
|
||||
// Zone Interval should be 1 second
|
||||
constexpr auto ZONE_UPDATE_INTERVAL = 1000;
|
||||
|
||||
@@ -434,6 +438,18 @@ void Player::Update(uint32 p_time)
|
||||
m_delayed_unit_relocation_timer = 0;
|
||||
RemoveFromNotify(NOTIFY_VISIBILITY_CHANGED);
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
if (_playerbotAI)
|
||||
{
|
||||
_playerbotAI->UpdateAI(p_time);
|
||||
}
|
||||
|
||||
if (_playerbotMgr)
|
||||
{
|
||||
_playerbotMgr->UpdateAI(p_time);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::UpdateMirrorTimers()
|
||||
|
||||
Reference in New Issue
Block a user