Skip to content

Commit

Permalink
Ike3 playerbots module
Browse files Browse the repository at this point in the history
Core changes for playerbots

Update Bots

Update Bots
  • Loading branch information
celguar committed Nov 26, 2023
1 parent 48c44d0 commit 22aa8e0
Show file tree
Hide file tree
Showing 40 changed files with 1,507 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/modules/Bots"]
path = src/modules/Bots
url = https://github.com/celguar/mangosbot-bots.git
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ if(NOT BUILD_GAME_SERVER AND BUILD_PLAYERBOT)
message(STATUS "BUILD_PLAYERBOT forced to OFF due to BUILD_GAME_SERVER is not set")
endif()

if(NOT BUILD_GAME_SERVER AND BUILD_IKE3_BOTS)
set(BUILD_IKE3_BOTS OFF)
message(STATUS "BUILD_PLAYERBOTS forced to OFF due to BUILD_GAME_SERVER is not set")
endif()

if(BUILD_IKE3_BOTS)
set(BUILD_PLAYERBOT OFF)
message(STATUS "CMaNGOS bots DISABLED because Ike3 bots enabled")
endif()

if(BUILD_PLAYERBOT)
set(BUILD_IKE3_BOTS OFF)
message(STATUS "Ike3 bots DISABLED because CMaNGOS bots enabled")
endif()

if(PCH)
if(${CMAKE_VERSION} VERSION_LESS "3.16")
message("PCH is not supported by your CMake version")
Expand Down
2 changes: 2 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option(BUILD_LOGIN_SERVER "Build login server" ON)
option(BUILD_EXTRACTORS "Build map/dbc/vmap/mmap extractors" OFF)
option(BUILD_SCRIPTDEV "Build ScriptDev. (OFF Speedup build)" ON)
option(BUILD_PLAYERBOT "Build Playerbot mod" OFF)
option(BUILD_IKE3_BOTS "Build ike3 Playerbots" OFF)
option(BUILD_AHBOT "Build Auction House Bot mod" OFF)
option(BUILD_METRICS "Build Metrics, generate data for Grafana" OFF)
option(BUILD_RECASTDEMOMOD "Build map/vmap/mmap viewer" OFF)
Expand Down Expand Up @@ -35,6 +36,7 @@ message(STATUS
BUILD_EXTRACTORS Build map/dbc/vmap/mmap extractor
BUILD_SCRIPTDEV Build scriptdev. (Disable it to speedup build in dev mode by not including scripts)
BUILD_PLAYERBOT Build Playerbot mod
BUILD_IKE3_BOTS Build Ike3 Playerbot mod
BUILD_AHBOT Build Auction House Bot mod
BUILD_METRICS Build Metrics, generate data for Grafana
BUILD_RECASTDEMOMOD Build map/vmap/mmap viewer
Expand Down
6 changes: 6 additions & 0 deletions cmake/showoptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ else()
message(STATUS "Build Playerbot : No (default)")
endif()

if(BUILD_IKE3_BOTS)
message(STATUS "Build ike3 Playerbots : Yes")
else()
message(STATUS "Build ike3 Playerbots : No (default)")
endif()

if(BUILD_EXTRACTORS)
message(STATUS "Build extractors : Yes")
else()
Expand Down
31 changes: 31 additions & 0 deletions contrib/mmap/src/MapBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,36 @@

using namespace VMAP;

void rcModAlmostUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle,
const float* verts, int /*nv*/,
const int* tris, int nt,
unsigned char* areas)
{
rcIgnoreUnused(ctx);

const float walkableThr = cosf(walkableSlopeAngle / 180.0f * RC_PI);

float norm[3];

for (int i = 0; i < nt; ++i)
{
if (areas[i] & RC_WALKABLE_AREA)
{
const int* tri = &tris[i * 3];

float e0[3], e1[3];
rcVsub(e0, &verts[tri[1] * 3], &verts[tri[0] * 3]);
rcVsub(e1, &verts[tri[2] * 3], &verts[tri[0] * 3]);
rcVcross(norm, e0, e1);
rcVnormalize(norm);

// Check if the face is walkable.
if (norm[1] <= walkableThr)
areas[i] = NAV_GROUND_STEEP; //Slopes between 50 and 60. Walkable for mobs, unwalkable for players.
}
}
}

void from_json(const json& j, rcConfig& config)
{
config.tileSize = MMAP::VERTEX_PER_TILE;
Expand Down Expand Up @@ -997,6 +1027,7 @@ namespace MMAP
unsigned char* triFlags = new unsigned char[tTriCount];
memset(triFlags, NAV_AREA_GROUND, tTriCount * sizeof(unsigned char));
rcClearUnwalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngle, tVerts, tVertCount, tTris, tTriCount, triFlags);
rcModAlmostUnwalkableTriangles(m_rcContext, 50.0f, tVerts, tVertCount, tTris, tTriCount, triFlags);
rcRasterizeTriangles(m_rcContext, tVerts, tVertCount, tTris, triFlags, tTriCount, *tile.solid, tileCfg.walkableClimb);
delete[] triFlags;

Expand Down
4 changes: 4 additions & 0 deletions sql/create/db_create_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CREATE DATABASE `classiccharacters` DEFAULT CHARACTER SET utf8 COLLATE utf8_gene

CREATE DATABASE `classicrealmd` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE DATABASE `classicplayerbots` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE USER IF NOT EXISTS 'mangos'@'localhost' IDENTIFIED BY 'mangos';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `classicmangos`.* TO 'mangos'@'localhost';
Expand All @@ -15,3 +17,5 @@ GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE T
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `classiccharacters`.* TO 'mangos'@'localhost';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `classicrealmd`.* TO 'mangos'@'localhost';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `classicplayerbots`.* TO 'mangos'@'localhost';
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ endif()
if(BUILD_LOGIN_SERVER)
add_subdirectory(realmd)
endif()

if(BUILD_IKE3_BOTS)
add_subdirectory(modules)
endif()
2 changes: 1 addition & 1 deletion src/game/BattleGround/BattleGroundWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class BattleGroundWS : public BattleGround

// Flag interactions
void ClearDroppedFlagGuid(Team team) { m_droppedFlagGuid[GetTeamIndexByTeamId(team)].Clear();}
ObjectGuid const& GetDroppedFlagGuid(Team team) const { return m_droppedFlagGuid[GetTeamIndexByTeamId(team)];}
ObjectGuid const& GetDroppedFlagGuid(Team team) const { return m_droppedFlagGuid[GetTeamIndexByTeamId(team)]; }

void RespawnFlagAtBase(Team team, bool wasCaptured);
void RespawnDroppedFlag(Team team);
Expand Down
89 changes: 89 additions & 0 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ if(NOT BUILD_PLAYERBOT)
endforeach()
endif()

if(NOT BUILD_IKE3_BOTS)
# exclude Ike3 Playerbots folder
set (EXCLUDE_DIR "Bots/")
foreach (TMP_PATH ${LIBRARY_SRCS})
string (FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM LIBRARY_SRCS ${TMP_PATH})
endif ()
endforeach()
endif()

set(PCH_BASE_FILENAME "pchdef")
# exclude pchdef files
set (EXCLUDE_FILE "${PCH_BASE_FILENAME}")
Expand Down Expand Up @@ -84,6 +95,7 @@ target_link_libraries(${LIBRARY_NAME}
)

# include additionals headers
if(NOT BUILD_IKE3_BOTS)
set(ADDITIONAL_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vmap
Expand All @@ -93,13 +105,85 @@ set(ADDITIONAL_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/PlayerBot
${CMAKE_BINARY_DIR}
)
else()
set(ADDITIONAL_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vmap
${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouseBot
${CMAKE_CURRENT_SOURCE_DIR}/BattleGround
${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP
${CMAKE_BINARY_DIR}
)
endif()

target_include_directories(${LIBRARY_NAME}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${ADDITIONAL_INCLUDE_DIRS}
PRIVATE ${Boost_INCLUDE_DIRS}
)

if(BUILD_IKE3_BOTS)
include_directories(
${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot
${CMAKE_SOURCE_DIR}/src/modules/Bots/ahbot
${CMAKE_SOURCE_DIR}/src/game
${CMAKE_SOURCE_DIR}/src/game/AI
${CMAKE_SOURCE_DIR}/src/game/Accounts
${CMAKE_SOURCE_DIR}/src/game/Addons
${CMAKE_SOURCE_DIR}/src/game/Arena
${CMAKE_SOURCE_DIR}/src/game/AuctionHouse
${CMAKE_SOURCE_DIR}/src/game/BattleGround
${CMAKE_SOURCE_DIR}/src/game/Chat
${CMAKE_SOURCE_DIR}/src/game/ChatCommands
${CMAKE_SOURCE_DIR}/src/game/Combat
${CMAKE_SOURCE_DIR}/src/game/DBScripts
${CMAKE_SOURCE_DIR}/src/game/Entities
${CMAKE_SOURCE_DIR}/src/game/GMTickets
${CMAKE_SOURCE_DIR}/src/game/GameEvents
${CMAKE_SOURCE_DIR}/src/game/Globals
${CMAKE_SOURCE_DIR}/src/game/Grids
${CMAKE_SOURCE_DIR}/src/game/Groups
${CMAKE_SOURCE_DIR}/src/game/Guilds
${CMAKE_SOURCE_DIR}/src/game/LFG
${CMAKE_SOURCE_DIR}/src/game/Loot
${CMAKE_SOURCE_DIR}/src/game/Mails
${CMAKE_SOURCE_DIR}/src/game/Maps
${CMAKE_SOURCE_DIR}/src/game/MotionGenerators
${CMAKE_SOURCE_DIR}/src/game/Movement
${CMAKE_SOURCE_DIR}/src/game/Object
${CMAKE_SOURCE_DIR}/src/game/OutdoorPvP
${CMAKE_SOURCE_DIR}/src/game/Pools
${CMAKE_SOURCE_DIR}/src/game/Quests
${CMAKE_SOURCE_DIR}/src/game/References
${CMAKE_SOURCE_DIR}/src/game/Reputation
${CMAKE_SOURCE_DIR}/src/game/Server
${CMAKE_SOURCE_DIR}/src/game/Server
${CMAKE_SOURCE_DIR}/src/game/Skills
${CMAKE_SOURCE_DIR}/src/game/Social
${CMAKE_SOURCE_DIR}/src/game/Spells
${CMAKE_SOURCE_DIR}/src/game/Tools
${CMAKE_SOURCE_DIR}/src/game/Trade
${CMAKE_SOURCE_DIR}/src/game/VoiceChat
${CMAKE_SOURCE_DIR}/src/game/Warden
${CMAKE_SOURCE_DIR}/src/game/Weather
${CMAKE_SOURCE_DIR}/src/game/World
${CMAKE_SOURCE_DIR}/src/game/WorldHandlers
${CMAKE_SOURCE_DIR}/src/game/movement
${CMAKE_SOURCE_DIR}/src/game/vmap
${CMAKE_SOURCE_DIR}/src/shared
${CMAKE_SOURCE_DIR}/src/shared/Auth
${CMAKE_SOURCE_DIR}/src/shared/Config
${CMAKE_SOURCE_DIR}/src/shared/Common
${CMAKE_SOURCE_DIR}/src/shared/Database
${CMAKE_SOURCE_DIR}/src/shared/DataStores
${CMAKE_SOURCE_DIR}/src/shared/Utilities
${CMAKE_SOURCE_DIR}/src/shared/Log
${CMAKE_SOURCE_DIR}/src/shared/Threading
)
target_link_libraries(${LIBRARY_NAME} PUBLIC Bots)
add_dependencies(${LIBRARY_NAME} Bots)
endif()

if(UNIX)
# Both systems don't have libdl and don't need them
if (NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD"))
Expand Down Expand Up @@ -127,6 +211,11 @@ if (BUILD_PLAYERBOT)
add_definitions(-DBUILD_PLAYERBOT)
endif()

# Define Ike3 Bots ENABLE_PLAYERBOTS if need
if (BUILD_IKE3_BOTS)
add_definitions(-DENABLE_PLAYERBOTS)
endif()

if (MSVC)
set_target_properties(${LIBRARY_NAME} PROPERTIES PROJECT_LABEL "Game")
endif()
Expand Down
16 changes: 16 additions & 0 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
#include "Pools/PoolManager.h"
#include "GameEvents/GameEventMgr.h"

#ifdef ENABLE_PLAYERBOTS
#include "AhBot.h"
#include "playerbot.h"
#include "PlayerbotAIConfig.h"
#include "GuildTaskMgr.h"
#endif

#include <cstdarg>

// Supported shift-links (client generated and server side)
Expand Down Expand Up @@ -893,6 +900,15 @@ ChatCommand* ChatHandler::getCommandTable()
{ "auction", SEC_ADMINISTRATOR, false, nullptr, "", auctionCommandTable },
#ifdef BUILD_AHBOT
{ "ahbot", SEC_ADMINISTRATOR, true, nullptr, "", ahbotCommandTable },
#endif
#ifdef ENABLE_PLAYERBOTS
#ifndef BUILD_AHBOT
{ "ahbot", SEC_GAMEMASTER, true, &ChatHandler::HandleAhBotCommand, "", NULL },
#endif
{ "rndbot", SEC_GAMEMASTER, true, &ChatHandler::HandleRandomPlayerbotCommand, "", NULL },
{ "bot", SEC_PLAYER, false, &ChatHandler::HandlePlayerbotCommand, "", NULL },
{ "gtask", SEC_GAMEMASTER, true, &ChatHandler::HandleGuildTaskCommand, "", NULL },
{ "pmon", SEC_GAMEMASTER, true, &ChatHandler::HandlePerfMonCommand, "" },
#endif
{ "cast", SEC_ADMINISTRATOR, false, nullptr, "", castCommandTable },
{ "character", SEC_GAMEMASTER, true, nullptr, "", characterCommandTable},
Expand Down
12 changes: 12 additions & 0 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class ChatHandler

bool HasSentErrorMessage() const { return sentErrorMessage;}

#ifdef ENABLE_PLAYERBOTS
WorldSession* GetSession() { return m_session; }
#endif

/**
* \brief Prepare SMSG_GM_MESSAGECHAT/SMSG_MESSAGECHAT
*
Expand Down Expand Up @@ -748,6 +752,14 @@ class ChatHandler
bool HandlePlayerbotCommand(char* args);
#endif

#ifdef ENABLE_PLAYERBOTS
bool HandlePlayerbotCommand(char* args);
bool HandleRandomPlayerbotCommand(char* args);
bool HandleAhBotCommand(char* args);
bool HandleGuildTaskCommand(char* args);
bool HandlePerfMonCommand(char* args);
#endif

bool HandleMmapPathCommand(char* args);
bool HandleMmapLocCommand(char* args);
bool HandleMmapLoadedTilesCommand(char* args);
Expand Down
Loading

0 comments on commit 22aa8e0

Please sign in to comment.