Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
/*.sublime-project
/*.sublime-workspace

# VSCode
/.vscode

# Numerous always-ignore extensions
*.a
*.bak
Expand Down
7 changes: 6 additions & 1 deletion src/game/AuctionHouseBot/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ void AuctionHouseBot::Rebuild(bool all)
void AuctionHouseBot::Update()
{
// nothing do...
if (!m_Buyer && !m_Seller)
if (!Enabled())
{
return;
}
Expand Down Expand Up @@ -2250,4 +2250,9 @@ void AuctionHouseBot::Update()
}
}
}

bool AuctionHouseBot::Enabled()
{
return (m_Buyer != NULL || m_Seller != NULL);
}
/** @} */
7 changes: 7 additions & 0 deletions src/game/AuctionHouseBot/AuctionHouseBot.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ class AuctionHouseBot
*
*/
void Initialize();
/**
* @brief Whether the AuctionHouseBot is enabled
*
* @return true if buyer or seller agent exists
* @return false if neither buyer nor seller agents exist
*/
bool Enabled();

// Followed method is mainly used by level3.cpp for ingame/console command
/**
Expand Down
10 changes: 8 additions & 2 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ endif()

if(PLAYERBOTS)

#Base files
#Playerbot Module group
file(GLOB Playerbot_Source ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/*.cpp ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/*.h)
source_group("Player Bot" FILES ${Playerbot_Source})
file(GLOB AHbot_Source ${CMAKE_SOURCE_DIR}/src/modules/Bots/ahbot/*.cpp ${CMAKE_SOURCE_DIR}/src/modules/Bots/ahbot/*.h)
Expand Down Expand Up @@ -135,6 +135,11 @@ source_group("Player Bot\\Strategies\\Values" FILES ${Playerbot_Values})
LIST(APPEND SRC_GRP_BOTS ${Playerbot_Values})

## Class files
#Deathknight AI
file(GLOB Playerbot_Druid ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/strategy/deathknight/*.cpp ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/strategy/deathknight/*.h)
source_group("Player Bot\\Strategies\\Druid" FILES ${Playerbot_Death_Knight})
LIST(APPEND SRC_GRP_BOTS ${Playerbot_Death_Knight})

#Druid AI
file(GLOB Playerbot_Druid ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/strategy/druid/*.cpp ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/strategy/druid/*.h)
source_group("Player Bot\\Strategies\\Druid" FILES ${Playerbot_Druid})
Expand Down Expand Up @@ -180,7 +185,8 @@ file(GLOB Playerbot_Warrior ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/strat
source_group("Player Bot\\Strategies\\Warrior" FILES ${Playerbot_Warrior})
LIST(APPEND SRC_GRP_BOTS ${Playerbot_Warrior})

#configure_file(${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/aiplayerbot.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/aiplayerbot.conf.dist)
configure_file(${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot/aiplayerbot.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/aiplayerbot.conf.dist)
configure_file(${CMAKE_SOURCE_DIR}/src/modules/Bots/ahbot/ahbot.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/AuctionHouseBot/ahplayerbot.conf.dist)

endif()

Expand Down
9 changes: 8 additions & 1 deletion src/game/ChatCommands/AHBotCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include "Chat.h"
#include "AuctionHouseBot/AuctionHouseBot.h"

#ifdef ENABLE_PLAYERBOTS
#include "AhBot.h"
#endif

/**********************************************************************
Useful constants definition
Expand All @@ -48,6 +50,11 @@ static uint32 ahbotQualityIds[MAX_AUCTION_QUALITY] =

bool ChatHandler::HandleAHBotRebuildCommand(char* args)
{
if (!sAuctionBot.Enabled())
{
return false;
}

bool all = false;
if (*args)
{
Expand Down
7 changes: 7 additions & 0 deletions src/game/Object/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,13 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
// time.
void Item::SendTimeUpdate(Player* owner)
{
#ifdef ENABLE_PLAYERBOTS
if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI())
{
return;
}
#endif

uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
if (!duration)
{
Expand Down
40 changes: 40 additions & 0 deletions src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */
#ifdef ENABLE_PLAYERBOTS
#include "playerbot.h"
#endif

#include <cmath>

Expand Down Expand Up @@ -438,6 +441,11 @@ UpdateMask Player::updateVisualBits;

Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_achievementMgr(this), m_reputationMgr(this)
{
#ifdef ENABLE_PLAYERBOTS
m_playerbotAI = 0;
m_playerbotMgr = 0;
#endif

m_transport = 0;

m_speakTime = 0;
Expand Down Expand Up @@ -667,6 +675,11 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_lastFallZ = 0;

m_cachedGS = 0;
#ifdef ENABLE_PLAYERBOTS
m_playerbotAI = NULL;
m_playerbotMgr = NULL;
#endif

}

Player::~Player()
Expand Down Expand Up @@ -713,6 +726,21 @@ Player::~Player()
delete ItemSetEff[x];
}

#ifdef ENABLE_PLAYERBOTS
if (m_playerbotAI) {
{
delete m_playerbotAI;
}
m_playerbotAI = 0;
}
if (m_playerbotMgr) {
{
delete m_playerbotMgr;
}
m_playerbotMgr = 0;
}
#endif

// clean up player-instance binds, may unload some instance saves
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr)
Expand Down Expand Up @@ -1722,6 +1750,18 @@ void Player::Update(uint32 update_diff, uint32 p_time)
{
TeleportTo(m_teleport_dest, m_teleport_options);
}

#ifdef ENABLE_PLAYERBOTS
if (m_playerbotAI)
{
m_playerbotAI->UpdateAI(p_time);
}
if (m_playerbotMgr)
{
m_playerbotMgr->UpdateAI(p_time);
}
#endif

}

void Player::SetDeathState(DeathState s)
Expand Down
22 changes: 22 additions & 0 deletions src/game/Object/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class Item;

struct AreaTrigger;

#ifdef ENABLE_PLAYERBOTS
class PlayerbotAI;
class PlayerbotMgr;
#endif

typedef std::deque<Mail*> PlayerMails;

#define PLAYER_MAX_SKILLS 127
Expand Down Expand Up @@ -2103,6 +2108,9 @@ class Player : public Unit

// Load the player from the database
bool LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder);
#ifdef ENABLE_PLAYERBOTS
bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
#endif

// Get the zone ID from the database
static uint32 GetZoneIdFromDB(ObjectGuid guid);
Expand Down Expand Up @@ -3780,6 +3788,16 @@ class Player : public Unit

bool isAllowedToLoot(Creature* creature);

#ifdef ENABLE_PLAYERBOTS
//EquipmentSets& GetEquipmentSets() { return m_EquipmentSets; }
void SetPlayerbotAI(PlayerbotAI* ai) { assert(!m_playerbotAI && !m_playerbotMgr); m_playerbotAI = ai; }
PlayerbotAI* GetPlayerbotAI() { return m_playerbotAI; }
void SetPlayerbotMgr(PlayerbotMgr* mgr) { assert(!m_playerbotAI && !m_playerbotMgr); m_playerbotMgr = mgr; }
PlayerbotMgr* GetPlayerbotMgr() { return m_playerbotMgr; }
void SetBotDeathTimer() { m_deathTimer = 0; }
//PlayerTalentMap& GetTalentMap(uint8 spec) { return m_talents[spec]; }
#endif

DeclinedName const* GetDeclinedNames() const { return m_declinedname; }

// Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access
Expand Down Expand Up @@ -4166,6 +4184,10 @@ class Player : public Unit
// Map reference for the player
MapReference m_mapRef;

#ifdef ENABLE_PLAYERBOTS
PlayerbotAI* m_playerbotAI;
PlayerbotMgr* m_playerbotMgr;
#endif
// Homebind coordinates
uint32 m_homebindMapId; // Map ID of the homebind location
uint16 m_homebindAreaId; // Area ID of the homebind location
Expand Down
Loading