Merge branch '4.3.4' into Gitlab434_4.3.4
This commit is contained in:
commit
bc8f5194c4
859 files changed
+97668
-87701
No files matched your search
@@ -43,6 +43,8 @@ endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/cppformat
|
||||
${CMAKE_SOURCE_DIR}/dep/process
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
@@ -53,6 +55,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Networking
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Updater
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Authentication
|
||||
@@ -63,6 +66,8 @@ include_directories(
|
||||
${VALGRIND_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_executable(authserver
|
||||
${authserver_SRCS}
|
||||
${authserver_PCH_SRC}
|
||||
@@ -78,6 +83,7 @@ endif()
|
||||
|
||||
target_link_libraries(authserver
|
||||
shared
|
||||
format
|
||||
${MYSQL_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
|
||||
+110
-48
@@ -28,14 +28,13 @@
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "Log.h"
|
||||
#include "ProcessPriority.h"
|
||||
#include "RealmList.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "Util.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
@@ -47,25 +46,52 @@ using namespace boost::program_options;
|
||||
# define _TRINITY_REALM_CONFIG "authserver.conf"
|
||||
#endif
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
#include "ServiceWin32.h"
|
||||
char serviceName[] = "authserver";
|
||||
char serviceLongName[] = "TrinityCore auth service";
|
||||
char serviceDescription[] = "TrinityCore World of Warcraft emulator auth service";
|
||||
/*
|
||||
* -1 - not in service mode
|
||||
* 0 - stopped
|
||||
* 1 - running
|
||||
* 2 - paused
|
||||
*/
|
||||
int m_ServiceStatus = -1;
|
||||
|
||||
boost::asio::deadline_timer* _serviceStatusWatchTimer;
|
||||
void ServiceStatusWatcher(boost::system::error_code const& error);
|
||||
#endif
|
||||
|
||||
bool StartDB();
|
||||
void StopDB();
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber);
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile, std::string& configService);
|
||||
|
||||
boost::asio::io_service _ioService;
|
||||
boost::asio::deadline_timer _dbPingTimer(_ioService);
|
||||
boost::asio::io_service* _ioService;
|
||||
boost::asio::deadline_timer* _dbPingTimer;
|
||||
uint32 _dbPingInterval;
|
||||
LoginDatabaseWorkerPool LoginDatabase;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::string configFile = _TRINITY_REALM_CONFIG;
|
||||
auto vm = GetConsoleArguments(argc, argv, configFile);
|
||||
// exit if help is enabled
|
||||
if (vm.count("help"))
|
||||
std::string configService;
|
||||
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
|
||||
// exit if help or version is enabled
|
||||
if (vm.count("help") || vm.count("version"))
|
||||
return 0;
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
if (configService.compare("install") == 0)
|
||||
return WinServiceInstall() == true ? 0 : 1;
|
||||
else if (configService.compare("uninstall") == 0)
|
||||
return WinServiceUninstall() == true ? 0 : 1;
|
||||
else if (configService.compare("run") == 0)
|
||||
return WinServiceRun() ? 0 : 1;
|
||||
#endif
|
||||
|
||||
std::string configError;
|
||||
if (!sConfigMgr->LoadInitial(configFile, configError))
|
||||
{
|
||||
@@ -96,13 +122,16 @@ int main(int argc, char** argv)
|
||||
if (!StartDB())
|
||||
return 1;
|
||||
|
||||
_ioService = new boost::asio::io_service();
|
||||
|
||||
// Get the list of realms for the server
|
||||
sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
sRealmList->Initialize(*_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
|
||||
if (sRealmList->size() == 0)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "No valid realms specified.");
|
||||
StopDB();
|
||||
delete _ioService;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -112,15 +141,16 @@ int main(int argc, char** argv)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Specified port out of allowed range (1-65535)");
|
||||
StopDB();
|
||||
delete _ioService;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
sAuthSocketMgr.StartNetwork(_ioService, bindIp, port);
|
||||
sAuthSocketMgr.StartNetwork(*_ioService, bindIp, port);
|
||||
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
|
||||
boost::asio::signal_set signals(*_ioService, SIGINT, SIGTERM);
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
signals.add(SIGBREAK);
|
||||
#endif
|
||||
@@ -131,52 +161,52 @@ int main(int argc, char** argv)
|
||||
|
||||
// Enabled a timed callback for handling the database keep alive ping
|
||||
_dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
_dbPingTimer = new boost::asio::deadline_timer(*_ioService);
|
||||
_dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer->async_wait(KeepDatabaseAliveHandler);
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
if (m_ServiceStatus != -1)
|
||||
{
|
||||
_serviceStatusWatchTimer = new boost::asio::deadline_timer(*_ioService);
|
||||
_serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1));
|
||||
_serviceStatusWatchTimer->async_wait(ServiceStatusWatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Start the io service worker loop
|
||||
_ioService.run();
|
||||
_ioService->run();
|
||||
|
||||
_dbPingTimer->cancel();
|
||||
|
||||
sAuthSocketMgr.StopNetwork();
|
||||
|
||||
// Close the Database Pool and library
|
||||
StopDB();
|
||||
|
||||
TC_LOG_INFO("server.authserver", "Halting process...");
|
||||
|
||||
signals.cancel();
|
||||
|
||||
delete _dbPingTimer;
|
||||
delete _ioService;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// Initialize connection to the database
|
||||
bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Database not specified");
|
||||
// Load databases
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1.
|
||||
// Increasing it is just silly since only 1 will be used ever.
|
||||
DatabaseLoader loader("server.authserver", DatabaseLoader::DATABASE_NONE);
|
||||
loader
|
||||
.AddDatabase(LoginDatabase, "Login");
|
||||
|
||||
if (!loader.Load())
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
synch_threads = 1;
|
||||
}
|
||||
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1. Increasing it is just silly since only 1 will be used ever.
|
||||
if (!LoginDatabase.Open(dbstring, uint8(worker_threads), uint8(synch_threads)))
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.authserver", "Started auth database connection pool.");
|
||||
sLog->SetRealmId(0); // Enables DB appenders when realm is set.
|
||||
@@ -193,7 +223,7 @@ void StopDB()
|
||||
void SignalHandler(const boost::system::error_code& error, int /*signalNumber*/)
|
||||
{
|
||||
if (!error)
|
||||
_ioService.stop();
|
||||
_ioService->stop();
|
||||
}
|
||||
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error)
|
||||
@@ -203,31 +233,63 @@ void KeepDatabaseAliveHandler(const boost::system::error_code& error)
|
||||
TC_LOG_INFO("server.authserver", "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
|
||||
_dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer.async_wait(KeepDatabaseAliveHandler);
|
||||
_dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer->async_wait(KeepDatabaseAliveHandler);
|
||||
}
|
||||
}
|
||||
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile)
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
void ServiceStatusWatcher(boost::system::error_code const& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
if (m_ServiceStatus == 0)
|
||||
{
|
||||
_ioService->stop();
|
||||
delete _serviceStatusWatchTimer;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1));
|
||||
_serviceStatusWatchTimer->async_wait(ServiceStatusWatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile, std::string& configService)
|
||||
{
|
||||
options_description all("Allowed options");
|
||||
all.add_options()
|
||||
("help,h", "print usage message")
|
||||
("version,v", "print version build info")
|
||||
("config,c", value<std::string>(&configFile)->default_value(_TRINITY_REALM_CONFIG), "use <arg> as configuration file")
|
||||
;
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
options_description win("Windows platform specific options");
|
||||
win.add_options()
|
||||
("service,s", value<std::string>(&configService)->default_value(""), "Windows service options: [install | uninstall]")
|
||||
;
|
||||
|
||||
all.add(win);
|
||||
#else
|
||||
(void)configService;
|
||||
#endif
|
||||
variables_map variablesMap;
|
||||
try
|
||||
{
|
||||
store(command_line_parser(argc, argv).options(all).allow_unregistered().run(), variablesMap);
|
||||
notify(variablesMap);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
|
||||
if (variablesMap.count("help")) {
|
||||
if (variablesMap.count("help"))
|
||||
std::cout << all << "\n";
|
||||
}
|
||||
else if (variablesMap.count("version"))
|
||||
std::cout << _FULLVERSION << "\n";
|
||||
|
||||
return variablesMap;
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
# EXAMPLE CONFIG
|
||||
# AUTH SERVER SETTINGS
|
||||
# MYSQL SETTINGS
|
||||
# UPDATE SETTINGS
|
||||
# LOGGING SYSTEM SETTINGS
|
||||
#
|
||||
###################################################################################################
|
||||
@@ -157,6 +158,89 @@ Wrong.Password.Login.Logging = 0
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# UPDATE SETTINGS
|
||||
#
|
||||
# Updates.EnableDatabases
|
||||
# Description: A mask that describes which databases shall be updated.
|
||||
#
|
||||
# Following flags are available
|
||||
# DATABASE_LOGIN = 1, // Auth database
|
||||
#
|
||||
# Default: 0 - (All Disabled)
|
||||
# 1 - (All Enabled)
|
||||
|
||||
Updates.EnableDatabases = 0
|
||||
|
||||
#
|
||||
# Updates.SourcePath
|
||||
# Description: The path to your TrinityCore source directory.
|
||||
# If the path is left empty, built-in CMAKE_SOURCE_DIR is used.
|
||||
# Example: "../TrinityCore"
|
||||
# Default: ""
|
||||
|
||||
Updates.SourcePath = ""
|
||||
|
||||
#
|
||||
# Updates.SourcePath
|
||||
# Description: The path to your mysql cli binary.
|
||||
# If the path is left empty, built-in path from cmake is used.
|
||||
# Example: "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe"
|
||||
# "mysql.exe"
|
||||
# "/usr/bin/mysql"
|
||||
# Default: ""
|
||||
|
||||
Updates.MySqlCLIPath = ""
|
||||
|
||||
#
|
||||
# Updates.AutoSetup
|
||||
# Description: Auto populate empty databases.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.AutoSetup = 1
|
||||
|
||||
#
|
||||
# Updates.Redundancy
|
||||
# Description: Perform data redundancy checks through hashing
|
||||
# to detect changes on sql updates and reapply it.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.Redundancy = 1
|
||||
|
||||
#
|
||||
# Updates.ArchivedRedundancy
|
||||
# Description: Check hashes of archived updates (slows down startup).
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
|
||||
Updates.ArchivedRedundancy = 0
|
||||
|
||||
#
|
||||
# Updates.AllowRehash
|
||||
# Description: Inserts the current file hash in the database if it is left empty.
|
||||
# Useful if you want to mark a file as applied but you don't know its hash.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.AllowRehash = 1
|
||||
|
||||
#
|
||||
# Updates.CleanDeadRefMaxCount
|
||||
# Description: Cleans dead/ orphaned references that occur if an update was removed or renamed and edited in one step.
|
||||
# It only starts the clean up if the count of the missing updates is below or equal the Updates.CleanDeadRefMaxCount value.
|
||||
# This way prevents erasing of the update history due to wrong source directory state (maybe wrong branch or bad revision).
|
||||
# Disable this if you want to know if the database is in a possible "dirty state".
|
||||
# Default: 3 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
# -1 - (Enabled - unlimited)
|
||||
|
||||
Updates.CleanDeadRefMaxCount = 3
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
#
|
||||
# LOGGING SYSTEM SETTINGS
|
||||
|
||||
@@ -46,6 +46,7 @@ endif()
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/zmqpp
|
||||
${CMAKE_SOURCE_DIR}/dep/cppformat
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
@@ -85,6 +86,7 @@ endif()
|
||||
target_link_libraries(bnetserver
|
||||
ipc
|
||||
shared
|
||||
format
|
||||
zmqpp
|
||||
${MYSQL_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "SystemConfig.h"
|
||||
#include "Util.h"
|
||||
#include "ZmqContext.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
@@ -162,32 +163,13 @@ bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Database not specified");
|
||||
// Load databases
|
||||
DatabaseLoader loader("server.bnetserver", DatabaseLoader::DATABASE_NONE);
|
||||
loader
|
||||
.AddDatabase(LoginDatabase, "Login");
|
||||
|
||||
if (!loader.Load())
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
synch_threads = 1;
|
||||
}
|
||||
|
||||
if (!LoginDatabase.Open(dbstring, uint8(worker_threads), uint8(synch_threads)))
|
||||
{
|
||||
TC_LOG_ERROR("server.bnetserver", "Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.bnetserver", "Started auth database connection pool.");
|
||||
sLog->SetRealmId(0); // Enables DB appenders when realm is set.
|
||||
|
||||
@@ -35,6 +35,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
|
||||
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
|
||||
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include
|
||||
${CMAKE_SOURCE_DIR}/dep/cppformat
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Debugging
|
||||
@@ -80,6 +81,8 @@ include_directories(
|
||||
${VALGRIND_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_library(collision STATIC
|
||||
${collision_STAT_SRCS}
|
||||
${collision_STAT_PCH_SRC}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace MMAP
|
||||
|
||||
delete[] fileName;
|
||||
|
||||
TC_LOG_INFO("maps", "MMAP:loadMapData: Loaded %03i.mmap", mapId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:loadMapData: Loaded %03i.mmap", mapId);
|
||||
|
||||
// store inside our map list
|
||||
MMapData* mmap_data = new MMapData(mesh, mapId);
|
||||
@@ -156,7 +156,7 @@ namespace MMAP
|
||||
{
|
||||
mmap->loadedTileRefs.insert(std::pair<uint32, dtTileRef>(packedGridPos, tileRef));
|
||||
++loadedTiles;
|
||||
TC_LOG_INFO("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i, %02i] into %03i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
|
||||
TC_LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i, %02i] into %03i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
|
||||
|
||||
LoadPhaseTiles(mapId, x, y);
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace MMAP
|
||||
{
|
||||
mmap->loadedTileRefs.erase(packedGridPos);
|
||||
--loadedTiles;
|
||||
TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
|
||||
|
||||
UnloadPhaseTile(mapId, x, y);
|
||||
return true;
|
||||
@@ -332,13 +332,13 @@ namespace MMAP
|
||||
{
|
||||
UnloadPhaseTile(mapId, x, y);
|
||||
--loadedTiles;
|
||||
TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
|
||||
}
|
||||
}
|
||||
|
||||
delete mmap;
|
||||
loadedMMaps.erase(mapId);
|
||||
TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded %03i.mmap", mapId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded %03i.mmap", mapId);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ namespace MMAP
|
||||
|
||||
dtFreeNavMeshQuery(query);
|
||||
mmap->navMeshQueries.erase(instanceId);
|
||||
TC_LOG_INFO("maps", "MMAP:unloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ namespace MMAP
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
|
||||
TC_LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
|
||||
mmap->navMeshQueries.insert(std::pair<uint32, dtNavMeshQuery*>(instanceId, query));
|
||||
}
|
||||
|
||||
|
||||
@@ -236,9 +236,11 @@ namespace VMAP
|
||||
{
|
||||
floor = info.ground_Z;
|
||||
ASSERT(floor < std::numeric_limits<float>::max());
|
||||
ASSERT(info.hitModel);
|
||||
type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
|
||||
if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
|
||||
return false;
|
||||
ASSERT(info.hitInstance);
|
||||
if (info.hitInstance->GetLiquidLevel(pos, info, level))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -386,13 +386,12 @@ namespace VMAP
|
||||
{
|
||||
if (!iLoadedSpawns.count(referencedVal))
|
||||
{
|
||||
#ifdef VMAP_DEBUG
|
||||
if (referencedVal > iNTreeValues)
|
||||
{
|
||||
TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u)", referencedVal, iNTreeValues);
|
||||
VMAP_ERROR_LOG("maps", "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u) referenced in tile %s", referencedVal, iNTreeValues, tilefile.c_str());
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
iTreeValues[referencedVal] = ModelInstance(spawn, model);
|
||||
iLoadedSpawns[referencedVal] = 1;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <set>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
using G3D::Vector3;
|
||||
using G3D::AABox;
|
||||
@@ -394,6 +393,18 @@ namespace VMAP
|
||||
}
|
||||
}
|
||||
|
||||
if (bounds.isEmpty())
|
||||
{
|
||||
std::cout << "\nModel " << std::string(buff, name_length) << " has empty bounding box" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bounds.isFinite())
|
||||
{
|
||||
std::cout << "\nModel " << std::string(buff, name_length) << " has invalid bounding box" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
fwrite(&displayId, sizeof(uint32), 1, model_list_copy);
|
||||
fwrite(&name_length, sizeof(uint32), 1, model_list_copy);
|
||||
fwrite(&buff, sizeof(char), name_length, model_list_copy);
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include "GameObjectModel.h"
|
||||
#include "Log.h"
|
||||
#include "GameObject.h"
|
||||
#include "Creature.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Object.h"
|
||||
#include "DBCStores.h"
|
||||
#include "World.h"
|
||||
@@ -78,6 +76,12 @@ void LoadGameObjectModelList()
|
||||
break;
|
||||
}
|
||||
|
||||
if (v1.isNaN() || v2.isNaN())
|
||||
{
|
||||
VMAP_ERROR_LOG("misc", "File '%s' Model '%s' has invalid v1%s v2%s values!", VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length).c_str(), v1.toString().c_str(), v2.toString().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
model_list.insert
|
||||
(
|
||||
ModelList::value_type( displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2)) )
|
||||
@@ -182,12 +186,12 @@ bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool GameObjectModel::Relocate(const GameObject& go)
|
||||
bool GameObjectModel::UpdatePosition()
|
||||
{
|
||||
if (!iModel)
|
||||
return false;
|
||||
|
||||
ModelList::const_iterator it = model_list.find(go.GetDisplayId());
|
||||
ModelList::const_iterator it = model_list.find(owner->GetDisplayId());
|
||||
if (it == model_list.end())
|
||||
return false;
|
||||
|
||||
@@ -199,9 +203,9 @@ bool GameObjectModel::Relocate(const GameObject& go)
|
||||
return false;
|
||||
}
|
||||
|
||||
iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ());
|
||||
iPos = Vector3(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ());
|
||||
|
||||
G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0);
|
||||
G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(owner->GetOrientation(), 0, 0);
|
||||
iInvRot = iRotation.inverse();
|
||||
// transform bounding box:
|
||||
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
|
||||
@@ -215,7 +219,7 @@ bool GameObjectModel::Relocate(const GameObject& go)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
Vector3 pos(iBound.corner(i));
|
||||
go.SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN);
|
||||
owner->SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
static GameObjectModel* Create(const GameObject& go);
|
||||
|
||||
bool Relocate(GameObject const& go);
|
||||
bool UpdatePosition();
|
||||
};
|
||||
|
||||
#endif // _GAMEOBJECT_MODEL_H
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "ModelInstance.h"
|
||||
#include "WorldModel.h"
|
||||
#include "MapTree.h"
|
||||
#include "VMapDefinitions.h"
|
||||
|
||||
using G3D::Vector3;
|
||||
using G3D::Ray;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "WorldModel.h"
|
||||
#include "ModelInstance.h"
|
||||
#include "VMapDefinitions.h"
|
||||
#include "MapTree.h"
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include "GuardAI.h"
|
||||
#include "Errors.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "World.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
|
||||
int GuardAI::Permissible(Creature const* creature)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "PassiveAI.h"
|
||||
#include "Creature.h"
|
||||
#include "TemporarySummon.h"
|
||||
|
||||
PassiveAI::PassiveAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
|
||||
PossessedAI::PossessedAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
|
||||
|
||||
@@ -20,12 +20,11 @@
|
||||
#include "Errors.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Spell.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Creature.h"
|
||||
#include "World.h"
|
||||
#include "Util.h"
|
||||
#include "Group.h"
|
||||
#include "SpellInfo.h"
|
||||
@@ -148,15 +147,15 @@ void PetAI::UpdateAI(uint32 diff)
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
|
||||
if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
|
||||
if (me->GetCharmInfo() && me->GetSpellHistory()->HasGlobalCooldown(spellInfo))
|
||||
continue;
|
||||
|
||||
if (spellInfo->IsPositive())
|
||||
{
|
||||
if (spellInfo->CanBeUsedInCombat())
|
||||
{
|
||||
// check spell cooldown
|
||||
if (me->HasSpellCooldown(spellInfo->Id))
|
||||
// check spell cooldown & school lock
|
||||
if (!me->GetSpellHistory()->IsReady(spellInfo))
|
||||
continue;
|
||||
|
||||
// Check if we're in combat or commanded to attack
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
#include "ByteBuffer.h"
|
||||
#include "ReactorAI.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
|
||||
int ReactorAI::Permissible(const Creature* creature)
|
||||
{
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
#include "TotemAI.h"
|
||||
#include "Totem.h"
|
||||
#include "Creature.h"
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "CellImpl.h"
|
||||
|
||||
@@ -141,7 +141,7 @@ void UnitAI::DoCast(uint32 spellId)
|
||||
{
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = (spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS) != 0;
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS);
|
||||
target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly);
|
||||
}
|
||||
break;
|
||||
@@ -156,7 +156,7 @@ void UnitAI::DoCast(uint32 spellId)
|
||||
{
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = (spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS) != 0;
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS);
|
||||
float range = spellInfo->GetMaxRange(false);
|
||||
|
||||
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
|
||||
@@ -213,7 +213,7 @@ void UnitAI::FillAISpellInfo()
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD))
|
||||
AIInfo->condition = AICOND_DIE;
|
||||
else if (spellInfo->IsPassive() || spellInfo->GetDuration() == -1)
|
||||
AIInfo->condition = AICOND_AGGRO;
|
||||
|
||||
@@ -128,7 +128,7 @@ class UnitAI
|
||||
|
||||
virtual void InitializeAI() { if (!me->isDead()) Reset(); }
|
||||
|
||||
virtual void Reset() { };
|
||||
virtual void Reset() { }
|
||||
|
||||
// Called when unit is charmed
|
||||
virtual void OnCharmed(bool apply) = 0;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "PassiveAI.h"
|
||||
|
||||
#include "MovementGenerator.h"
|
||||
#include "Pet.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "CreatureAIFactory.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
*/
|
||||
|
||||
#include "ScriptedCreature.h"
|
||||
#include "Item.h"
|
||||
#include "Spell.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
|
||||
// Spell summary for ScriptedAI::SelectSpell
|
||||
struct TSpellSummary
|
||||
@@ -677,3 +675,8 @@ void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject*
|
||||
{
|
||||
source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange);
|
||||
}
|
||||
|
||||
void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange)
|
||||
{
|
||||
source->GetPlayerListInGrid(list, maxSearchRange);
|
||||
}
|
||||
@@ -426,5 +426,6 @@ Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float m
|
||||
GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange);
|
||||
void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
|
||||
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
|
||||
void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange);
|
||||
|
||||
#endif // SCRIPTEDCREATURE_H_
|
||||
@@ -21,11 +21,7 @@
|
||||
#include "GridDefines.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "Group.h"
|
||||
#include "SmartAI.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -585,7 +581,11 @@ void SmartAI::JustDied(Unit* killer)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, killer);
|
||||
if (HasEscortState(SMART_ESCORT_ESCORTING))
|
||||
{
|
||||
EndPath(true);
|
||||
me->StopMoving();//force stop
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
}
|
||||
|
||||
void SmartAI::KilledUnit(Unit* victim)
|
||||
@@ -763,6 +763,9 @@ void SmartAI::SetCombatMove(bool on)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (me->HasUnitState(UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE))
|
||||
return;
|
||||
|
||||
me->GetMotionMaster()->MovementExpired();
|
||||
me->GetMotionMaster()->Clear(true);
|
||||
me->StopMoving();
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "SmartScript.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Vehicle.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "GameEventMgr.h"
|
||||
|
||||
SmartScript::SmartScript()
|
||||
@@ -778,7 +777,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
continue;
|
||||
|
||||
if (e.action.removeAura.spell)
|
||||
(*itr)->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
|
||||
{
|
||||
if (e.action.removeAura.charges)
|
||||
{
|
||||
if (Aura* aur = (*itr)->ToUnit()->GetAura(e.action.removeAura.spell))
|
||||
aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
|
||||
}
|
||||
else
|
||||
(*itr)->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
|
||||
}
|
||||
else
|
||||
(*itr)->ToUnit()->RemoveAllAuras();
|
||||
|
||||
@@ -1325,7 +1332,31 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_SET_COUNTER:
|
||||
{
|
||||
StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset);
|
||||
if (ObjectList* targets = GetTargets(e, unit))
|
||||
{
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (IsCreature(*itr))
|
||||
{
|
||||
if (SmartAI* ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI()))
|
||||
ai->GetScript()->StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset);
|
||||
else
|
||||
TC_LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
|
||||
}
|
||||
else if (IsGameObject(*itr))
|
||||
{
|
||||
if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, (*itr)->ToGameObject()->AI()))
|
||||
ai->GetScript()->StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset);
|
||||
else
|
||||
TC_LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
}
|
||||
else
|
||||
StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset);
|
||||
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_START:
|
||||
@@ -3176,7 +3207,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
std::list<Creature*> list;
|
||||
me->GetCreatureListWithEntryInGrid(list, e.event.distance.entry, (float)e.event.distance.dist);
|
||||
|
||||
if (list.size() > 0)
|
||||
if (!list.empty())
|
||||
creature = list.front();
|
||||
}
|
||||
|
||||
@@ -3207,7 +3238,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
std::list<GameObject*> list;
|
||||
me->GetGameObjectListWithEntryInGrid(list, e.event.distance.entry, (float)e.event.distance.dist);
|
||||
|
||||
if (list.size() > 0)
|
||||
if (!list.empty())
|
||||
gameobject = list.front();
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +247,14 @@ class SmartScript
|
||||
DecPhase(abs(p));
|
||||
}
|
||||
|
||||
void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); }
|
||||
void DecPhase(int32 p = 1)
|
||||
{
|
||||
if(mEventPhase > (uint32)p)
|
||||
mEventPhase -= (uint32)p;
|
||||
else
|
||||
mEventPhase = 0;
|
||||
}
|
||||
|
||||
bool IsInPhase(uint32 p) const { return ((1 << (mEventPhase - 1)) & p) != 0; }
|
||||
void SetPhase(uint32 p = 0) { mEventPhase = p; }
|
||||
|
||||
|
||||
@@ -17,18 +17,12 @@
|
||||
|
||||
#include "DatabaseEnv.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ObjectDefines.h"
|
||||
#include "GridDefines.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
#include "SmartScriptMgr.h"
|
||||
|
||||
@@ -454,7 +454,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_FLEE_FOR_ASSIST = 25, // With Emote
|
||||
SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID
|
||||
// none = 27,
|
||||
SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid, 0 removes all auras
|
||||
SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid (0 removes all auras), charges (0 removes aura)
|
||||
SMART_ACTION_FOLLOW = 29, // Distance (0 = default), Angle (0 = default), EndCreatureEntry, credit, creditType (0monsterkill, 1event)
|
||||
SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3...
|
||||
SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax
|
||||
@@ -666,6 +666,7 @@ struct SmartAction
|
||||
struct
|
||||
{
|
||||
uint32 spell;
|
||||
uint32 charges;
|
||||
} removeAura;
|
||||
|
||||
struct
|
||||
|
||||
@@ -446,7 +446,7 @@ void AccountMgr::LoadRBAC()
|
||||
while (result->NextRow());
|
||||
|
||||
TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading default permissions");
|
||||
result = LoginDatabase.Query("SELECT secId, permissionId FROM rbac_default_permissions ORDER BY secId ASC");
|
||||
result = LoginDatabase.PQuery("SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = %u OR realmId = -1) ORDER BY secId ASC", realmHandle.Index);
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
|
||||
|
||||
@@ -100,6 +100,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMANDS_PINFO_CHECK_PERSONAL_DATA = 48,
|
||||
RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE = 49,
|
||||
RBAC_PERM_MAY_CHECK_OWN_EMAIL = 50,
|
||||
RBAC_PERM_ALLOW_TWO_SIDE_TRADE = 51,
|
||||
|
||||
// Free space for core permissions (till 149)
|
||||
// Roles (Permissions with delegated permissions) use 199 and descending
|
||||
@@ -700,6 +701,8 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_GUILD_INFO = 794,
|
||||
RBAC_PERM_COMMAND_INSTANCE_SET_BOSS_STATE = 795,
|
||||
RBAC_PERM_COMMAND_INSTANCE_GET_BOSS_STATE = 796,
|
||||
RBAC_PERM_COMMAND_PVPSTATS = 797,
|
||||
RBAC_PERM_COMMAND_MODIFY_XP = 798,
|
||||
|
||||
// custom permissions 1000+
|
||||
RBAC_PERM_MAX
|
||||
@@ -808,6 +811,7 @@ class RBACData
|
||||
* @return Success or failure (with reason) to grant the permission
|
||||
*
|
||||
* Example Usage:
|
||||
* @code
|
||||
* // previously defined "RBACData* rbac" with proper initialization
|
||||
* uint32 permissionId = 2;
|
||||
* if (rbac->GrantRole(permissionId) == RBAC_IN_DENIED_LIST)
|
||||
@@ -831,6 +835,7 @@ class RBACData
|
||||
* @return Success or failure (with reason) to deny the permission
|
||||
*
|
||||
* Example Usage:
|
||||
* @code
|
||||
* // previously defined "RBACData* rbac" with proper initialization
|
||||
* uint32 permissionId = 2;
|
||||
* if (rbac->DenyRole(permissionId) == RBAC_ID_DOES_NOT_EXISTS)
|
||||
@@ -855,6 +860,7 @@ class RBACData
|
||||
* @return Success or failure (with reason) to remove the permission
|
||||
*
|
||||
* Example Usage:
|
||||
* @code
|
||||
* // previously defined "RBACData* rbac" with proper initialization
|
||||
* uint32 permissionId = 2;
|
||||
* if (rbac->RevokeRole(permissionId) == RBAC_OK)
|
||||
@@ -945,9 +951,6 @@ class RBACData
|
||||
*
|
||||
* Given a list of permissions, gets all the inherited permissions
|
||||
* @param permissions The list of permissions to expand
|
||||
*
|
||||
* @return new list of permissions containing original permissions and
|
||||
* all other pemissions that are linked to the original ones
|
||||
*/
|
||||
void ExpandPermissions(RBACPermissionContainer& permissions);
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST: // only hardcoded list
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
|
||||
@@ -1165,306 +1166,320 @@ void AchievementMgr<T>::UpdateAchievementCriteria(AchievementCriteriaTypes type,
|
||||
if (!data->Meets(referencePlayer, unit, miscValue1))
|
||||
continue;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
// special cases, db data is checked later
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT:
|
||||
break;
|
||||
default:
|
||||
if (AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria))
|
||||
if (!data->Meets(referencePlayer, unit, miscValue1))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
// std. case: increment at 1
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS: /* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA: // This also behaves like ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN:
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS: /* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA: // This also behaves like ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN:
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
// std case: increment at miscValue1
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS:/* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CURRENCY:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue2, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS:/* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CURRENCY:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue2, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
// std case: high value at miscValue1
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: /* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: /* FIXME: for online player only currently */
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->getLevel(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
|
||||
if (uint32 skillvalue = referencePlayer->GetBaseSkillValue(achievementCriteria->reach_skill_level.skillID))
|
||||
SetCriteriaProgress(achievementCriteria, skillvalue, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
|
||||
if (uint32 maxSkillvalue = referencePlayer->GetPureMaxSkillValue(achievementCriteria->learn_skill_level.skillID))
|
||||
SetCriteriaProgress(achievementCriteria, maxSkillvalue, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetRewardedQuestCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY:
|
||||
{
|
||||
time_t nextDailyResetTime = sWorld->GetNextDailyQuestsResetTime();
|
||||
CriteriaProgress *progress = GetCriteriaProgress(achievementCriteria);
|
||||
|
||||
if (!miscValue1) // Login case.
|
||||
{
|
||||
// reset if player missed one day.
|
||||
if (progress && progress->date < (nextDailyResetTime - 2 * DAY))
|
||||
SetCriteriaProgress(achievementCriteria, 0, referencePlayer, PROGRESS_SET);
|
||||
continue;
|
||||
}
|
||||
|
||||
ProgressType progressType;
|
||||
if (!progress)
|
||||
// 1st time. Start count.
|
||||
progressType = PROGRESS_SET;
|
||||
else if (progress->date < (nextDailyResetTime - 2 * DAY))
|
||||
// last progress is older than 2 days. Player missed 1 day => Restart count.
|
||||
progressType = PROGRESS_SET;
|
||||
else if (progress->date < (nextDailyResetTime - DAY))
|
||||
// last progress is between 1 and 2 days. => 1st time of the day.
|
||||
progressType = PROGRESS_ACCUMULATE;
|
||||
else
|
||||
// last progress is within the day before the reset => Already counted today.
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer, progressType);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
|
||||
{
|
||||
uint32 counter = 0;
|
||||
|
||||
const RewardedQuestSet &rewQuests = referencePlayer->getRewardedQuests();
|
||||
for (RewardedQuestSet::const_iterator itr = rewQuests.begin(); itr != rewQuests.end(); ++itr)
|
||||
{
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(*itr);
|
||||
if (quest && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID)
|
||||
++counter;
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, counter, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING:
|
||||
// miscValue1 is the ingame fallheight*100 as stored in dbc
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetBankBagSlotCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
|
||||
{
|
||||
int32 reputation = referencePlayer->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
|
||||
if (reputation > 0)
|
||||
SetCriteriaProgress(achievementCriteria, reputation, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetExaltedFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
|
||||
{
|
||||
uint32 spellCount = 0;
|
||||
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
|
||||
spellIter != referencePlayer->GetSpellMap().end();
|
||||
++spellIter)
|
||||
{
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
|
||||
for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
|
||||
{
|
||||
if (skillIter->second->skillId == achievementCriteria->learn_skillline_spell.skillLine)
|
||||
spellCount++;
|
||||
}
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, spellCount, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetReveredFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetHonoredFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetVisibleFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
|
||||
{
|
||||
uint32 spellCount = 0;
|
||||
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
|
||||
spellIter != referencePlayer->GetSpellMap().end();
|
||||
++spellIter)
|
||||
{
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
|
||||
for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
|
||||
if (skillIter->second->skillId == achievementCriteria->learn_skill_line.skillLine)
|
||||
spellCount++;
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, spellCount, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetMoney(), referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS:
|
||||
if (!miscValue1)
|
||||
SetCriteriaProgress(achievementCriteria, _achievementPoints, referencePlayer, PROGRESS_SET);
|
||||
else
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING:
|
||||
{
|
||||
uint32 reqTeamType = achievementCriteria->highest_team_rating.teamtype;
|
||||
|
||||
if (miscValue1)
|
||||
{
|
||||
if (miscValue2 != reqTeamType)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->getLevel(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
|
||||
if (uint32 skillvalue = referencePlayer->GetBaseSkillValue(achievementCriteria->reach_skill_level.skillID))
|
||||
SetCriteriaProgress(achievementCriteria, skillvalue, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
|
||||
if (uint32 maxSkillvalue = referencePlayer->GetPureMaxSkillValue(achievementCriteria->learn_skill_level.skillID))
|
||||
SetCriteriaProgress(achievementCriteria, maxSkillvalue, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetRewardedQuestCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY:
|
||||
{
|
||||
time_t nextDailyResetTime = sWorld->GetNextDailyQuestsResetTime();
|
||||
CriteriaProgress *progress = GetCriteriaProgress(achievementCriteria);
|
||||
|
||||
if (!miscValue1) // Login case.
|
||||
{
|
||||
// reset if player missed one day.
|
||||
if (progress && progress->date < (nextDailyResetTime - 2 * DAY))
|
||||
SetCriteriaProgress(achievementCriteria, 0, referencePlayer, PROGRESS_SET);
|
||||
continue;
|
||||
}
|
||||
|
||||
ProgressType progressType;
|
||||
if (!progress)
|
||||
// 1st time. Start count.
|
||||
progressType = PROGRESS_SET;
|
||||
else if (progress->date < (nextDailyResetTime - 2 * DAY))
|
||||
// last progress is older than 2 days. Player missed 1 day => Restart count.
|
||||
progressType = PROGRESS_SET;
|
||||
else if (progress->date < (nextDailyResetTime - DAY))
|
||||
// last progress is between 1 and 2 days. => 1st time of the day.
|
||||
progressType = PROGRESS_ACCUMULATE;
|
||||
else
|
||||
// last progress is within the day before the reset => Already counted today.
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer, progressType);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
|
||||
else // login case
|
||||
{
|
||||
uint32 counter = 0;
|
||||
|
||||
const RewardedQuestSet &rewQuests = referencePlayer->getRewardedQuests();
|
||||
for (RewardedQuestSet::const_iterator itr = rewQuests.begin(); itr != rewQuests.end(); ++itr)
|
||||
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||
{
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(*itr);
|
||||
if (quest && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID)
|
||||
++counter;
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, counter, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING:
|
||||
// miscValue1 is the ingame fallheight*100 as stored in dbc
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
|
||||
SetCriteriaProgress(achievementCriteria, 1, referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetBankBagSlotCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
|
||||
{
|
||||
int32 reputation = referencePlayer->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
|
||||
if (reputation > 0)
|
||||
SetCriteriaProgress(achievementCriteria, reputation, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetExaltedFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
|
||||
{
|
||||
uint32 spellCount = 0;
|
||||
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
|
||||
spellIter != referencePlayer->GetSpellMap().end();
|
||||
++spellIter)
|
||||
{
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
|
||||
for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
|
||||
{
|
||||
if (skillIter->second->skillId == achievementCriteria->learn_skillline_spell.skillLine)
|
||||
spellCount++;
|
||||
}
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, spellCount, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetReveredFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetHonoredFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetVisibleFactionCount(), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
|
||||
{
|
||||
uint32 spellCount = 0;
|
||||
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
|
||||
spellIter != referencePlayer->GetSpellMap().end();
|
||||
++spellIter)
|
||||
{
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
|
||||
for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
|
||||
if (skillIter->second->skillId == achievementCriteria->learn_skill_line.skillLine)
|
||||
spellCount++;
|
||||
}
|
||||
SetCriteriaProgress(achievementCriteria, spellCount, referencePlayer);
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS), referencePlayer);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED:
|
||||
SetCriteriaProgress(achievementCriteria, referencePlayer->GetMoney(), referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS:
|
||||
if (!miscValue1)
|
||||
SetCriteriaProgress(achievementCriteria, _achievementPoints, referencePlayer, PROGRESS_SET);
|
||||
else
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_ACCUMULATE);
|
||||
break;
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING:
|
||||
{
|
||||
uint32 reqTeamType = achievementCriteria->highest_team_rating.teamtype;
|
||||
|
||||
if (miscValue1)
|
||||
{
|
||||
if (miscValue2 != reqTeamType)
|
||||
uint32 teamId = referencePlayer->GetArenaTeamId(arena_slot);
|
||||
if (!teamId)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
|
||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
if (!team || team->GetType() != reqTeamType)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, team->GetStats().Rating, referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
}
|
||||
else // login case
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING:
|
||||
{
|
||||
uint32 reqTeamType = achievementCriteria->highest_personal_rating.teamtype;
|
||||
|
||||
if (miscValue1)
|
||||
{
|
||||
if (miscValue2 != reqTeamType)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
|
||||
}
|
||||
else // login case
|
||||
{
|
||||
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||
{
|
||||
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||
uint32 teamId = referencePlayer->GetArenaTeamId(arena_slot);
|
||||
if (!teamId)
|
||||
continue;
|
||||
|
||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
if (!team || team->GetType() != reqTeamType)
|
||||
continue;
|
||||
|
||||
if (ArenaTeamMember const* member = team->GetMember(referencePlayer->GetGUID()))
|
||||
{
|
||||
uint32 teamId = referencePlayer->GetArenaTeamId(arena_slot);
|
||||
if (!teamId)
|
||||
continue;
|
||||
|
||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
if (!team || team->GetType() != reqTeamType)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, team->GetStats().Rating, referencePlayer, PROGRESS_HIGHEST);
|
||||
SetCriteriaProgress(achievementCriteria, member->PersonalRating, referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING:
|
||||
{
|
||||
uint32 reqTeamType = achievementCriteria->highest_personal_rating.teamtype;
|
||||
|
||||
if (miscValue1)
|
||||
{
|
||||
if (miscValue2 != reqTeamType)
|
||||
continue;
|
||||
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
|
||||
}
|
||||
else // login case
|
||||
{
|
||||
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||
{
|
||||
uint32 teamId = referencePlayer->GetArenaTeamId(arena_slot);
|
||||
if (!teamId)
|
||||
continue;
|
||||
|
||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
if (!team || team->GetType() != reqTeamType)
|
||||
continue;
|
||||
|
||||
if (ArenaTeamMember const* member = team->GetMember(referencePlayer->GetGUID()))
|
||||
{
|
||||
SetCriteriaProgress(achievementCriteria, member->PersonalRating, referencePlayer, PROGRESS_HIGHEST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_GUILD_LEVEL:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_GUILD_LEVEL:
|
||||
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer);
|
||||
break;
|
||||
// FIXME: not triggered in code as result, need to implement
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_SPENT_GOLD_GUILD_REPAIRS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CRAFT_ITEMS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CATCH_FROM_POOL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_GUILD_BANK_SLOTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_GUILD_ACHIEVEMENT_POINTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_BATTLEGROUND:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_BG_RATING:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_GUILD_TABARD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILLS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ARCHAEOLOGY_PROJECTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_GUILD_CHALLENGE_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_GUILD_CHALLENGE:
|
||||
break; // Not implemented yet :(
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_SPENT_GOLD_GUILD_REPAIRS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CRAFT_ITEMS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_CATCH_FROM_POOL:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_GUILD_BANK_SLOTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_EARN_GUILD_ACHIEVEMENT_POINTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_BATTLEGROUND:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_REACH_BG_RATING:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_BUY_GUILD_TABARD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILLS_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE_GUILD:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ARCHAEOLOGY_PROJECTS:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_GUILD_CHALLENGE_TYPE:
|
||||
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_GUILD_CHALLENGE:
|
||||
break; // Not implemented yet :(
|
||||
}
|
||||
|
||||
if (IsCompletedCriteria(achievementCriteria, achievement))
|
||||
@@ -2312,25 +2327,32 @@ bool AchievementMgr<T>::HasAchieved(uint32 achievementId) const
|
||||
template<class T>
|
||||
bool AchievementMgr<T>::CanUpdateCriteria(AchievementCriteriaEntry const* criteria, AchievementEntry const* achievement, uint64 miscValue1, uint64 miscValue2, uint64 miscValue3, Unit const* unit, Player* referencePlayer)
|
||||
{
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, nullptr))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: %s (Id: %u Type %s) Disabled",
|
||||
criteria->name, criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: (Id: %u Type %s) Disabled",
|
||||
criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (achievement->mapID != -1 && referencePlayer->GetMapId() != uint32(achievement->mapID))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: %s (Id: %u Type %s) Wrong map",
|
||||
criteria->name, criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: (Id: %u Type %s Achievement %u) Wrong map",
|
||||
criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type), achievement->ID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((achievement->requiredFaction == ACHIEVEMENT_FACTION_HORDE && referencePlayer->GetTeam() != HORDE) ||
|
||||
(achievement->requiredFaction == ACHIEVEMENT_FACTION_ALLIANCE && referencePlayer->GetTeam() != ALLIANCE))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: %s (Id: %u Type %s) Wrong faction",
|
||||
criteria->name, criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: (Id: %u Type %s Achievement %u) Wrong faction",
|
||||
criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type), achievement->ID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ConditionsSatisfied(criteria, referencePlayer))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: (Id: %u Type %s) Conditions not satisfied",
|
||||
criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2348,19 +2370,9 @@ bool AchievementMgr<T>::CanUpdateCriteria(AchievementCriteriaEntry const* criter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AdditionalRequirementsSatisfied(criteria, miscValue1, miscValue2, unit, referencePlayer))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: %s (Id: %u Type %s) Additional requirements not satisfied",
|
||||
criteria->name, criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
// don't update already completed criteria
|
||||
if (IsCompletedCriteria(criteria, achievement))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ConditionsSatisfied(criteria, referencePlayer))
|
||||
{
|
||||
TC_LOG_TRACE("achievement", "CanUpdateCriteria: %s (Id: %u Type %s) Conditions not satisfied",
|
||||
criteria->name, criteria->ID, AchievementGlobalMgr::GetCriteriaTypeString(criteria->type));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "Item.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include <vector>
|
||||
|
||||
enum eAuctionHouse
|
||||
{
|
||||
@@ -435,7 +434,7 @@ void AuctionHouseObject::AddAuction(AuctionEntry* auction)
|
||||
sScriptMgr->OnAuctionAdd(this, auction);
|
||||
}
|
||||
|
||||
bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction, uint32 /*itemEntry*/)
|
||||
bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction)
|
||||
{
|
||||
bool wasInMap = AuctionsMap.erase(auction->Id) ? true : false;
|
||||
|
||||
@@ -443,8 +442,6 @@ bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction, uint32 /*itemEntry
|
||||
|
||||
// we need to delete the entry, it is not referenced any more
|
||||
delete auction;
|
||||
auction = NULL;
|
||||
|
||||
return wasInMap;
|
||||
}
|
||||
|
||||
@@ -457,25 +454,22 @@ void AuctionHouseObject::Update()
|
||||
if (AuctionsMap.empty())
|
||||
return;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTION_BY_TIME);
|
||||
stmt->setUInt32(0, (uint32)curTime+60);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
do
|
||||
for (AuctionEntryMap::iterator it = AuctionsMap.begin(); it != AuctionsMap.end();)
|
||||
{
|
||||
// from auctionhousehandler.cpp, creates auction pointer & player pointer
|
||||
AuctionEntry* auction = GetAuction(result->Fetch()->GetUInt32());
|
||||
AuctionEntry* auction = it->second;
|
||||
// Increment iterator due to AuctionEntry deletion
|
||||
++it;
|
||||
|
||||
if (!auction)
|
||||
///- filter auctions expired on next update
|
||||
if (auction->expire_time > curTime + 60)
|
||||
continue;
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
///- Either cancel the auction if there was no bidder
|
||||
if (auction->bidder == 0)
|
||||
if (auction->bidder == 0 && auction->bid == 0)
|
||||
{
|
||||
sAuctionMgr->SendAuctionExpiredMail(auction, trans);
|
||||
sScriptMgr->OnAuctionExpire(this, auction);
|
||||
@@ -491,16 +485,15 @@ void AuctionHouseObject::Update()
|
||||
sScriptMgr->OnAuctionSuccessful(this, auction);
|
||||
}
|
||||
|
||||
uint32 itemEntry = auction->itemEntry;
|
||||
|
||||
///- In any case clear the auction
|
||||
auction->DeleteFromDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
sAuctionMgr->RemoveAItem(auction->itemGUIDLow);
|
||||
RemoveAuction(auction, itemEntry);
|
||||
RemoveAuction(auction);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
// Run DB changes
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
|
||||
@@ -595,22 +588,31 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
|
||||
if (propRefID)
|
||||
{
|
||||
// Append the suffix to the name (ie: of the Monkey) if one exists
|
||||
// These are found in ItemRandomProperties.dbc, not ItemRandomSuffix.dbc
|
||||
// These are found in ItemRandomSuffix.dbc and ItemRandomProperties.dbc
|
||||
// even though the DBC names seem misleading
|
||||
const ItemRandomPropertiesEntry* itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
|
||||
|
||||
if (itemRandProp)
|
||||
char* suffix = nullptr;
|
||||
|
||||
if (propRefID < 0)
|
||||
{
|
||||
char* temp = itemRandProp->nameSuffix;
|
||||
const ItemRandomSuffixEntry* itemRandSuffix = sItemRandomSuffixStore.LookupEntry(-propRefID);
|
||||
if (itemRandSuffix)
|
||||
suffix = itemRandSuffix->nameSuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
const ItemRandomPropertiesEntry* itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
|
||||
if (itemRandProp)
|
||||
suffix = itemRandProp->nameSuffix;
|
||||
}
|
||||
|
||||
// dbc local name
|
||||
if (temp)
|
||||
{
|
||||
// Append the suffix (ie: of the Monkey) to the name using localization
|
||||
// or default enUS if localization is invalid
|
||||
name += ' ';
|
||||
name += temp[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
|
||||
}
|
||||
// dbc local name
|
||||
if (suffix)
|
||||
{
|
||||
// Append the suffix (ie: of the Monkey) to the name using localization
|
||||
// or default enUS if localization is invalid
|
||||
name += ' ';
|
||||
name += suffix[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class AuctionHouseObject
|
||||
|
||||
void AddAuction(AuctionEntry* auction);
|
||||
|
||||
bool RemoveAuction(AuctionEntry* auction, uint32 itemEntry);
|
||||
bool RemoveAuction(AuctionEntry* auction);
|
||||
|
||||
void Update();
|
||||
|
||||
|
||||
@@ -204,14 +204,24 @@ void AuctionBotConfig::GetConfigFromFile()
|
||||
SetConfig(CONFIG_AHBOT_MINTIME, "AuctionHouseBot.MinTime", 1);
|
||||
SetConfig(CONFIG_AHBOT_MAXTIME, "AuctionHouseBot.MaxTime", 72);
|
||||
|
||||
SetConfigMinMax(CONFIG_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE, "AuctionHouseBot.Buyer.Alliance.Chance.Ratio", 3, 1, 100);
|
||||
SetConfigMinMax(CONFIG_AHBOT_BUYER_CHANCE_RATIO_HORDE, "AuctionHouseBot.Buyer.Horde.Chance.Ratio", 3, 1, 100);
|
||||
SetConfigMinMax(CONFIG_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL, "AuctionHouseBot.Buyer.Neutral.Chance.Ratio", 3, 1, 100);
|
||||
SetConfigMinMax(CONFIG_AHBOT_BUYER_RECHECK_INTERVAL, "AuctionHouseBot.Buyer.Recheck.Interval", 20, 1, DAY / MINUTE);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_GRAY, "AuctionHouseBot.Buyer.Baseprice.Gray", 3504);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_WHITE, "AuctionHouseBot.Buyer.Baseprice.White", 5429);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_GREEN, "AuctionHouseBot.Buyer.Baseprice.Green", 21752);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_BLUE, "AuctionHouseBot.Buyer.Baseprice.Blue", 36463);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_PURPLE, "AuctionHouseBot.Buyer.Baseprice.Purple", 87124);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_ORANGE, "AuctionHouseBot.Buyer.Baseprice.Orange", 214347);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_YELLOW, "AuctionHouseBot.Buyer.Baseprice.Yellow", 407406);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GRAY, "AuctionHouseBot.Buyer.ChanceMultiplier.Gray", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_WHITE, "AuctionHouseBot.Buyer.ChanceMultiplier.White", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GREEN, "AuctionHouseBot.Buyer.ChanceMultiplier.Green", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_BLUE, "AuctionHouseBot.Buyer.ChanceMultiplier.Blue", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_PURPLE, "AuctionHouseBot.Buyer.ChanceMultiplier.Purple", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_ORANGE, "AuctionHouseBot.Buyer.ChanceMultiplier.Orange", 100);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_YELLOW, "AuctionHouseBot.Buyer.ChanceMultiplier.Yellow", 100);
|
||||
|
||||
SetConfig(CONFIG_AHBOT_SELLER_ENABLED, "AuctionHouseBot.Seller.Enabled", false);
|
||||
SetConfig(CONFIG_AHBOT_BUYER_ENABLED, "AuctionHouseBot.Buyer.Enabled", false);
|
||||
SetConfig(CONFIG_AHBOT_BUYPRICE_BUYER, "AuctionHouseBot.Buyer.Buyprice", true);
|
||||
|
||||
SetConfig(CONFIG_AHBOT_CLASS_MISC_MOUNT_MIN_REQ_LEVEL, "AuctionHouseBot.Class.Misc.Mount.ReqLevel.Min", 0);
|
||||
SetConfig(CONFIG_AHBOT_CLASS_MISC_MOUNT_MAX_REQ_LEVEL, "AuctionHouseBot.Class.Misc.Mount.ReqLevel.Max", 0);
|
||||
@@ -229,7 +239,7 @@ void AuctionBotConfig::GetConfigFromFile()
|
||||
|
||||
char const* AuctionBotConfig::GetHouseTypeName(AuctionHouseType houseType)
|
||||
{
|
||||
static char const* names[MAX_AUCTION_HOUSE_TYPE] = { "Alliance", "Horde", "Neutral" };
|
||||
static char const* names[MAX_AUCTION_HOUSE_TYPE] = { "Neutral", "Alliance", "Horde" };
|
||||
return names[houseType];
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ enum AuctionQuality
|
||||
|
||||
enum AuctionHouseType
|
||||
{
|
||||
AUCTION_HOUSE_ALLIANCE = 0,
|
||||
AUCTION_HOUSE_HORDE = 1,
|
||||
AUCTION_HOUSE_NEUTRAL = 2
|
||||
AUCTION_HOUSE_NEUTRAL = 0,
|
||||
AUCTION_HOUSE_ALLIANCE = 1,
|
||||
AUCTION_HOUSE_HORDE = 2
|
||||
};
|
||||
|
||||
#define MAX_AUCTION_HOUSE_TYPE 3
|
||||
@@ -110,10 +110,21 @@ enum AuctionBotConfigUInt32Values
|
||||
CONFIG_AHBOT_CLASS_PERMANENT_PRICE_RATIO,
|
||||
CONFIG_AHBOT_CLASS_MISC_PRICE_RATIO,
|
||||
CONFIG_AHBOT_CLASS_GLYPH_PRICE_RATIO,
|
||||
CONFIG_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE,
|
||||
CONFIG_AHBOT_BUYER_CHANCE_RATIO_HORDE,
|
||||
CONFIG_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL,
|
||||
CONFIG_AHBOT_BUYER_RECHECK_INTERVAL,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_GRAY,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_WHITE,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_GREEN,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_BLUE,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_PURPLE,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_ORANGE,
|
||||
CONFIG_AHBOT_BUYER_BASEPRICE_YELLOW,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GRAY,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_WHITE,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GREEN,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_BLUE,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_PURPLE,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_ORANGE,
|
||||
CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_YELLOW,
|
||||
CONFIG_AHBOT_CLASS_MISC_MOUNT_MIN_REQ_LEVEL,
|
||||
CONFIG_AHBOT_CLASS_MISC_MOUNT_MAX_REQ_LEVEL,
|
||||
CONFIG_AHBOT_CLASS_MISC_MOUNT_MIN_SKILL_RANK,
|
||||
@@ -143,7 +154,6 @@ enum AuctionBotConfigBoolValues
|
||||
CONFIG_AHBOT_BIND_USE,
|
||||
CONFIG_AHBOT_BIND_QUEST,
|
||||
CONFIG_AHBOT_BUYPRICE_SELLER,
|
||||
CONFIG_AHBOT_BUYPRICE_BUYER,
|
||||
CONFIG_AHBOT_SELLER_ENABLED,
|
||||
CONFIG_AHBOT_BUYER_ENABLED,
|
||||
CONFIG_AHBOT_LOCKBOX_ENABLED,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "ItemPrototype.h"
|
||||
#include "AuctionHouseBotBuyer.h"
|
||||
|
||||
AuctionBotBuyer::AuctionBotBuyer(): _checkInterval(20)
|
||||
AuctionBotBuyer::AuctionBotBuyer() : _checkInterval(20 * MINUTE)
|
||||
{
|
||||
// Define faction for our main data class.
|
||||
for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
|
||||
@@ -48,35 +48,12 @@ bool AuctionBotBuyer::Initialize()
|
||||
if (!activeHouse)
|
||||
return false;
|
||||
|
||||
//load Check interval
|
||||
// load Check interval
|
||||
_checkInterval = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_RECHECK_INTERVAL) * MINUTE;
|
||||
TC_LOG_DEBUG("ahbot", "AHBot buyer interval between 2 check = %u", _checkInterval);
|
||||
TC_LOG_DEBUG("ahbot", "AHBot buyer interval is %u minutes", _checkInterval / MINUTE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AuctionBotBuyer::LoadBuyerValues(BuyerConfiguration& config)
|
||||
{
|
||||
uint32 factionChance;
|
||||
|
||||
switch (config.GetHouseType())
|
||||
{
|
||||
case AUCTION_HOUSE_ALLIANCE:
|
||||
config.BuyerPriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO) + 50;
|
||||
factionChance = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE);
|
||||
break;
|
||||
case AUCTION_HOUSE_HORDE:
|
||||
config.BuyerPriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO) + 50;
|
||||
factionChance = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_RATIO_HORDE);
|
||||
break;
|
||||
default:
|
||||
config.BuyerPriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_NEUTRAL_PRICE_RATIO) + 50;
|
||||
factionChance = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL);
|
||||
break;
|
||||
}
|
||||
|
||||
config.FactionChance = 5000 * factionChance;
|
||||
}
|
||||
|
||||
void AuctionBotBuyer::LoadConfig()
|
||||
{
|
||||
for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
|
||||
@@ -87,352 +64,378 @@ void AuctionBotBuyer::LoadConfig()
|
||||
}
|
||||
}
|
||||
|
||||
uint32 AuctionBotBuyer::GetBuyableEntry(BuyerConfiguration& config)
|
||||
void AuctionBotBuyer::LoadBuyerValues(BuyerConfiguration& /* config */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Makes an AHbot buyer cycle for AH type if necessary
|
||||
bool AuctionBotBuyer::Update(AuctionHouseType houseType)
|
||||
{
|
||||
if (!sAuctionBotConfig->GetConfigBuyerEnabled(houseType))
|
||||
return false;
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %s buying ...", AuctionBotConfig::GetHouseTypeName(houseType));
|
||||
|
||||
BuyerConfiguration& config = _houseConfig[houseType];
|
||||
uint32 eligibleItems = GetItemInformation(config);
|
||||
if (eligibleItems)
|
||||
{
|
||||
// Prepare list of items to bid or buy - remove old items
|
||||
PrepareListOfEntry(config);
|
||||
// Process buying and bidding items
|
||||
BuyAndBidItems(config);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Collects information about item counts and minimum prices to SameItemInfo and updates EligibleItems - a list with new items eligible for bot to buy and bid
|
||||
// Returns count of items in AH that were eligible for being bought or bidded on by ahbot buyer (EligibleItems size)
|
||||
uint32 AuctionBotBuyer::GetItemInformation(BuyerConfiguration& config)
|
||||
{
|
||||
config.SameItemInfo.clear();
|
||||
uint32 count = 0;
|
||||
time_t now = time(nullptr);
|
||||
uint32 count = 0;
|
||||
|
||||
AuctionHouseObject* house = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
|
||||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = house->GetAuctionsBegin(); itr != house->GetAuctionsEnd(); ++itr)
|
||||
{
|
||||
AuctionEntry* entry = itr->second;
|
||||
Item* item = sAuctionMgr->GetAItem(entry->itemGUIDLow);
|
||||
if (item)
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
BuyerItemInfo& itemInfo = config.SameItemInfo[item->GetEntry()];
|
||||
|
||||
// Update item entry's count and total bid prices
|
||||
// This can be used later to determine the prices and chances to bid
|
||||
uint32 itemBidPrice = entry->startbid / item->GetCount();
|
||||
itemInfo.TotalBidPrice = itemInfo.TotalBidPrice + itemBidPrice;
|
||||
itemInfo.BidItemCount++;
|
||||
|
||||
// Set minimum bid price
|
||||
if (!itemInfo.MinBidPrice)
|
||||
itemInfo.MinBidPrice = itemBidPrice;
|
||||
else
|
||||
itemBidPrice = std::min(itemInfo.MinBidPrice, itemBidPrice);
|
||||
|
||||
// Set minimum buyout price if item has buyout
|
||||
if (entry->buyout)
|
||||
{
|
||||
ItemTemplate const * prototype = item->GetTemplate();
|
||||
if (prototype)
|
||||
{
|
||||
++config.SameItemInfo[item->GetEntry()].ItemCount; // Structure constructor will make sure Element are correctly initialized if entry is created here.
|
||||
config.SameItemInfo[item->GetEntry()].BuyPrice = config.SameItemInfo[item->GetEntry()].BuyPrice + (itr->second->buyout / item->GetCount());
|
||||
config.SameItemInfo[item->GetEntry()].BidPrice = config.SameItemInfo[item->GetEntry()].BidPrice + (itr->second->startbid / item->GetCount());
|
||||
if (itr->second->buyout != 0)
|
||||
{
|
||||
if (itr->second->buyout / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBuyPrice)
|
||||
config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
|
||||
else if (config.SameItemInfo[item->GetEntry()].MinBuyPrice == 0)
|
||||
config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
|
||||
}
|
||||
if (itr->second->startbid / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBidPrice)
|
||||
config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();
|
||||
else if (config.SameItemInfo[item->GetEntry()].MinBidPrice == 0)
|
||||
config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();
|
||||
// Update item entry's count and total buyout prices
|
||||
// This can be used later to determine the prices and chances to buyout
|
||||
uint32 itemBuyPrice = entry->buyout / item->GetCount();
|
||||
itemInfo.TotalBuyPrice = itemInfo.TotalBuyPrice + itemBuyPrice;
|
||||
itemInfo.BuyItemCount++;
|
||||
|
||||
if (!entry->owner)
|
||||
{
|
||||
if (!itemInfo.MinBuyPrice)
|
||||
itemInfo.MinBuyPrice = itemBuyPrice;
|
||||
else
|
||||
itemInfo.MinBuyPrice = std::min(itemInfo.MinBuyPrice, itemBuyPrice);
|
||||
}
|
||||
|
||||
if (entry->bid != 0 && entry->bidder) // Add bid by player
|
||||
{
|
||||
config.CheckedEntry[entry->Id].LastExist = now;
|
||||
config.CheckedEntry[entry->Id].AuctionId = entry->Id;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry->bid != 0)
|
||||
{
|
||||
if (entry->bidder)
|
||||
{
|
||||
config.CheckedEntry[entry->Id].LastExist = now;
|
||||
config.CheckedEntry[entry->Id].AuctionId = entry->Id;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
config.CheckedEntry[entry->Id].LastExist = now;
|
||||
config.CheckedEntry[entry->Id].AuctionId = entry->Id;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add/update to EligibleItems if:
|
||||
// has a bid by player or
|
||||
// has no bids and not owned by bot
|
||||
if ((entry->bid && entry->bidder) || (entry->owner && !entry->bid))
|
||||
{
|
||||
config.EligibleItems[entry->Id].LastExist = now;
|
||||
config.EligibleItems[entry->Id].AuctionId = entry->Id;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %u items added to buyable vector for ah type: %u", count, config.GetHouseType());
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %u items added to buyable/biddable vector for ah type: %u", count, config.GetHouseType());
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: SameItemInfo size = %u", (uint32)config.SameItemInfo.size());
|
||||
return count;
|
||||
}
|
||||
|
||||
// ahInfo can be NULL
|
||||
bool AuctionBotBuyer::RollBuyChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 /*bidPrice*/)
|
||||
{
|
||||
if (!auction->buyout)
|
||||
return false;
|
||||
|
||||
uint32 itemBuyPrice = auction->buyout / item->GetCount();
|
||||
uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality);
|
||||
// The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default
|
||||
itemPrice *= 1.4f;
|
||||
|
||||
// This value is between 0 and 100 and is used directly as the chance to buy or bid
|
||||
// Value equal or above 100 means 100% chance and value below 0 means 0% chance
|
||||
float chance = 100 / sqrt(itemBuyPrice / float(itemPrice));
|
||||
|
||||
// If a player has bidded on item, have fifth of normal chance
|
||||
if (auction->bidder)
|
||||
chance = chance / 5;
|
||||
|
||||
if (ahInfo)
|
||||
{
|
||||
float avgBuyPrice = ahInfo->TotalBuyPrice / float(ahInfo->BuyItemCount);
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: buyout average: %.1f items with buyout: %u", avgBuyPrice, ahInfo->BuyItemCount);
|
||||
|
||||
// If there are more than 5 items on AH of this entry, try weigh in the average buyout price
|
||||
if (ahInfo->BuyItemCount > 5)
|
||||
{
|
||||
chance *= 1 / sqrt(itemBuyPrice / avgBuyPrice);
|
||||
}
|
||||
}
|
||||
|
||||
// Add config weigh in for quality
|
||||
chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f;
|
||||
|
||||
float rand = frand(0, 100);
|
||||
bool win = rand <= chance;
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %s BUY! chance = %.2f, price = %u, buyprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBuyPrice);
|
||||
return win;
|
||||
}
|
||||
|
||||
// ahInfo can be NULL
|
||||
bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 bidPrice)
|
||||
{
|
||||
uint32 itemBidPrice = bidPrice / item->GetCount();
|
||||
uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality);
|
||||
// The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default
|
||||
itemPrice *= 1.4f;
|
||||
|
||||
// This value is between 0 and 100 and is used directly as the chance to buy or bid
|
||||
// Value equal or above 100 means 100% chance and value below 0 means 0% chance
|
||||
float chance = 100 / sqrt(itemBidPrice / float(itemPrice));
|
||||
|
||||
if (ahInfo)
|
||||
{
|
||||
float avgBidPrice = ahInfo->TotalBidPrice / float(ahInfo->BidItemCount);
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Bid average: %.1f biddable item count: %u", avgBidPrice, ahInfo->BidItemCount);
|
||||
|
||||
// If there are more than 5 items on AH of this entry, try weigh in the average bid price
|
||||
if (ahInfo->BidItemCount >= 5)
|
||||
{
|
||||
chance *= 1 / sqrt(itemBidPrice / avgBidPrice);
|
||||
}
|
||||
}
|
||||
|
||||
// If a player has bidded on item, have fifth of normal chance
|
||||
if (auction->bidder)
|
||||
chance = chance / 5;
|
||||
|
||||
// Add config weigh in for quality
|
||||
chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f;
|
||||
|
||||
float rand = frand(0, 100);
|
||||
bool win = rand <= chance;
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %s BID! chance = %.2f, price = %u, bidprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBidPrice);
|
||||
return win;
|
||||
}
|
||||
|
||||
// Removes items from EligibleItems that we shouldnt buy or bid on
|
||||
// The last existed time on them should be older than now
|
||||
void AuctionBotBuyer::PrepareListOfEntry(BuyerConfiguration& config)
|
||||
{
|
||||
// now - 5 seconds to leave out all old entries but keep the ones just updated a moment ago
|
||||
time_t now = time(nullptr) - 5;
|
||||
|
||||
for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();)
|
||||
for (CheckEntryMap::iterator itr = config.EligibleItems.begin(); itr != config.EligibleItems.end();)
|
||||
{
|
||||
if (itr->second.LastExist < (now - 5))
|
||||
config.CheckedEntry.erase(itr++);
|
||||
if (itr->second.LastExist < now)
|
||||
config.EligibleItems.erase(itr++);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: CheckedEntry size = %u", (uint32)config.CheckedEntry.size());
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: EligibleItems size = %u", (uint32)config.EligibleItems.size());
|
||||
}
|
||||
|
||||
bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double inGameBuyPrice, uint32 maxBuyablePrice, uint32 minBuyPrice, uint32 maxChance, uint32 chanceRatio)
|
||||
// Tries to bid and buy items based on their prices and chances set in configs
|
||||
void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config)
|
||||
{
|
||||
double ratio = 0;
|
||||
uint32 chance = 0;
|
||||
|
||||
if (buyoutPrice <= minBuyPrice)
|
||||
{
|
||||
if (buyoutPrice <= maxBuyablePrice)
|
||||
chance = maxChance;
|
||||
else
|
||||
{
|
||||
|
||||
if (buyoutPrice > 0 && maxBuyablePrice > 0)
|
||||
{
|
||||
ratio = double(buyoutPrice) / double(maxBuyablePrice);
|
||||
if (ratio < 10)
|
||||
chance = maxChance - (ratio * maxChance / 10);
|
||||
else
|
||||
chance = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buyoutPrice <= inGameBuyPrice)
|
||||
{
|
||||
if (buyoutPrice <= maxBuyablePrice)
|
||||
chance = maxChance / 5;
|
||||
else
|
||||
{
|
||||
|
||||
if (buyoutPrice > 0 && maxBuyablePrice > 0)
|
||||
{
|
||||
ratio = double(buyoutPrice) / double(maxBuyablePrice);
|
||||
if (ratio < 10)
|
||||
chance = (maxChance / 5) - (ratio * maxChance / 50);
|
||||
else
|
||||
chance = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buyoutPrice <= maxBuyablePrice)
|
||||
chance = maxChance / 10;
|
||||
else
|
||||
{
|
||||
if (buyoutPrice > 0 && maxBuyablePrice > 0)
|
||||
{
|
||||
ratio = double(buyoutPrice) / double(maxBuyablePrice);
|
||||
if (ratio < 10)
|
||||
chance = (maxChance / 5) - (ratio* maxChance / 50);
|
||||
else
|
||||
chance = 0;
|
||||
}
|
||||
else
|
||||
chance = 0;
|
||||
}
|
||||
|
||||
if (urand(1, chanceRatio) <= chance)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: WIN BUY! Chance = %u, num = %u.", chance, chanceRatio);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: LOOSE BUY! Chance = %u, num = %u.", chance, chanceRatio);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool AuctionBotBuyer::IsBidableEntry(uint32 bidPrice, double inGameBuyPrice, double maxBidablePrice, uint32 minBidPrice, uint32 maxChance, uint32 chanceRatio)
|
||||
{
|
||||
double ratio = 0;
|
||||
uint32 chance = 0;
|
||||
|
||||
if (bidPrice <= minBidPrice)
|
||||
{
|
||||
if (inGameBuyPrice != 0 && bidPrice < inGameBuyPrice - (inGameBuyPrice / 30))
|
||||
chance = maxChance;
|
||||
else
|
||||
{
|
||||
if (bidPrice < maxBidablePrice)
|
||||
{
|
||||
ratio = maxBidablePrice / bidPrice;
|
||||
if (ratio < 3)
|
||||
chance = maxChance / 500 * ratio;
|
||||
else
|
||||
chance = maxChance / 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bidPrice < (inGameBuyPrice - (inGameBuyPrice / 30)))
|
||||
chance = (maxChance / 10);
|
||||
else
|
||||
{
|
||||
if (bidPrice < maxBidablePrice)
|
||||
{
|
||||
ratio = maxBidablePrice / bidPrice;
|
||||
if (ratio < 4)
|
||||
chance = maxChance / 1000 * ratio;
|
||||
else
|
||||
chance = maxChance / 1000;
|
||||
}
|
||||
}
|
||||
|
||||
if (urand(1, chanceRatio) <= chance)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: WIN BID! Chance = %u, num = %u.", chance, chanceRatio);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: LOOSE BID! Chance = %u, num = %u.", chance, chanceRatio);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AuctionBotBuyer::PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Bid placed to entry %u, %.2fg", auction->Id, float(bidPrice) / 10000.0f);
|
||||
auction->bid = bidPrice;
|
||||
}
|
||||
|
||||
void AuctionBotBuyer::BuyEntry(AuctionEntry* auction)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u bought at %.2fg", auction->Id, float(auction->buyout) / 10000.0f);
|
||||
auction->bid = auction->buyout;
|
||||
}
|
||||
|
||||
void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config)
|
||||
{
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
|
||||
|
||||
PrepareListOfEntry(config);
|
||||
|
||||
time_t now = time(nullptr);
|
||||
uint32 buyCycles;
|
||||
if (config.CheckedEntry.size() > sAuctionBotConfig->GetItemPerCycleBoost())
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
|
||||
CheckEntryMap& items = config.EligibleItems;
|
||||
|
||||
// Max amount of items to buy or bid
|
||||
uint32 cycles = sAuctionBotConfig->GetItemPerCycleNormal();
|
||||
if (items.size() > sAuctionBotConfig->GetItemPerCycleBoost())
|
||||
{
|
||||
buyCycles = sAuctionBotConfig->GetItemPerCycleBoost();
|
||||
// set more cycles if there is a huge influx of items
|
||||
cycles = sAuctionBotConfig->GetItemPerCycleBoost();
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in worldserver.conf)");
|
||||
}
|
||||
else
|
||||
buyCycles = sAuctionBotConfig->GetItemPerCycleNormal();
|
||||
|
||||
for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();)
|
||||
// Process items eligible to be bidded or bought
|
||||
CheckEntryMap::iterator itr = items.begin();
|
||||
while (cycles && itr != items.end())
|
||||
{
|
||||
AuctionEntry* auction = auctionHouse->GetAuction(itr->second.AuctionId);
|
||||
if (!auction) // is auction not active now
|
||||
if (!auction)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u doesn't exists, perhaps bought already?",
|
||||
itr->second.AuctionId);
|
||||
|
||||
config.CheckedEntry.erase(itr++);
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u doesn't exists, perhaps bought already?", itr->second.AuctionId);
|
||||
items.erase(itr++);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itr->second.LastChecked != 0 && (now - itr->second.LastChecked) <= _checkInterval)
|
||||
// Check if the item has been checked once before
|
||||
// If it has been checked and it was recently, skip it
|
||||
if (itr->second.LastChecked && (now - itr->second.LastChecked) <= _checkInterval)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: In time interval wait for entry %u!", auction->Id);
|
||||
++itr;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buyCycles == 0)
|
||||
break;
|
||||
|
||||
uint32 maxChance = 5000;
|
||||
|
||||
Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
|
||||
if (!item) // auction item not accessible, possible auction in payment pending mode
|
||||
if (!item)
|
||||
{
|
||||
config.CheckedEntry.erase(itr++);
|
||||
// auction item not accessible, possible auction in payment pending mode
|
||||
items.erase(itr++);
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemTemplate const* prototype = item->GetTemplate();
|
||||
|
||||
uint32 basePrice = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_BUYER) ? prototype->BuyPrice : prototype->SellPrice;
|
||||
basePrice *= item->GetCount();
|
||||
|
||||
uint32 maxBuyablePrice = (basePrice * config.BuyerPriceRatio) / 100;
|
||||
BuyerItemInfoMap::iterator sameItemItr = config.SameItemInfo.find(item->GetEntry());
|
||||
uint32 buyoutPrice = auction->buyout / item->GetCount();
|
||||
|
||||
// price to bid if bidding
|
||||
uint32 bidPrice;
|
||||
uint32 bidPriceByItem;
|
||||
uint32 minBidPrice;
|
||||
uint32 minBuyPrice;
|
||||
if (auction->bid >= auction->startbid)
|
||||
{
|
||||
bidPrice = auction->GetAuctionOutBid();
|
||||
bidPriceByItem = auction->bid / item->GetCount();
|
||||
// get bid price to outbid previous bidder
|
||||
bidPrice = auction->bid + auction->GetAuctionOutBid();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no previous bidders - use starting bid
|
||||
bidPrice = auction->startbid;
|
||||
bidPriceByItem = auction->startbid / item->GetCount();
|
||||
}
|
||||
|
||||
double inGameBuyPrice;
|
||||
double inGameBidPrice;
|
||||
if (sameItemItr == config.SameItemInfo.end())
|
||||
{
|
||||
inGameBuyPrice = 0;
|
||||
inGameBidPrice = 0;
|
||||
minBidPrice = 0;
|
||||
minBuyPrice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sameItemItr->second.ItemCount == 1)
|
||||
maxBuyablePrice = maxBuyablePrice * 5; // if only one item exist can be bought if the price is high too.
|
||||
inGameBuyPrice = sameItemItr->second.BuyPrice / sameItemItr->second.ItemCount;
|
||||
inGameBidPrice = sameItemItr->second.BidPrice / sameItemItr->second.ItemCount;
|
||||
minBidPrice = sameItemItr->second.MinBidPrice;
|
||||
minBuyPrice = sameItemItr->second.MinBuyPrice;
|
||||
}
|
||||
const BuyerItemInfo* ahInfo = nullptr;
|
||||
BuyerItemInfoMap::const_iterator sameItemItr = config.SameItemInfo.find(item->GetEntry());
|
||||
if (sameItemItr != config.SameItemInfo.end())
|
||||
ahInfo = &sameItemItr->second;
|
||||
|
||||
uint32 maxBidablePrice = maxBuyablePrice - (maxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Rolling for AHentry %u:", auction->Id);
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Auction added with data:");
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, double(maxBuyablePrice) / 10000.0);
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: GamePrice buy=%.1fg, bid=%.1fg.", inGameBuyPrice / 10000, inGameBidPrice / 10000);
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.",
|
||||
minBuyPrice / 10000, minBidPrice / 10000);
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000);
|
||||
// Roll buy and bid chances
|
||||
bool successBuy = RollBuyChance(ahInfo, item, auction, bidPrice);
|
||||
bool successBid = RollBidChance(ahInfo, item, auction, bidPrice);
|
||||
|
||||
if (!auction->owner) // Original auction owner
|
||||
maxChance = maxChance / 5; // if Owner is AHBot this mean player placed bid on this auction. We divide by 5 chance for AhBuyer to place bid on it. (This make more challenge than ignore entry)
|
||||
if (auction->buyout != 0) // Is the item directly buyable?
|
||||
{
|
||||
if (IsBuyableEntry(buyoutPrice, inGameBuyPrice, maxBuyablePrice, minBuyPrice, maxChance, config.FactionChance))
|
||||
{
|
||||
if (IsBidableEntry(bidPriceByItem, inGameBuyPrice, maxBidablePrice, minBidPrice, maxChance / 2, config.FactionChance))
|
||||
{
|
||||
if (urand(0, 5) == 0)
|
||||
PlaceBidToEntry(auction, bidPrice);
|
||||
else
|
||||
BuyEntry(auction);
|
||||
}
|
||||
else
|
||||
BuyEntry(auction);
|
||||
}
|
||||
else if (IsBidableEntry(bidPriceByItem, inGameBuyPrice, maxBidablePrice, minBidPrice, maxChance / 2, config.FactionChance))
|
||||
PlaceBidToEntry(auction, bidPrice);
|
||||
}
|
||||
else if (IsBidableEntry(bidPriceByItem, inGameBuyPrice, maxBidablePrice, minBidPrice, maxChance, config.FactionChance))
|
||||
PlaceBidToEntry(auction, bidPrice);
|
||||
// If roll bidding succesfully and bid price is above buyout -> buyout
|
||||
// If roll for buying was successful but not for bid, buyout directly
|
||||
// If roll bidding was also successful, buy the entry with 20% chance
|
||||
// - Better bid than buy since the item is bought by bot if no player bids after
|
||||
// Otherwise bid if roll for bid was successful
|
||||
if ((auction->buyout && successBid && bidPrice >= auction->buyout) ||
|
||||
(successBuy && (!successBid || urand(1, 5) == 1)))
|
||||
BuyEntry(auction, auctionHouse); // buyout
|
||||
else if (successBid)
|
||||
PlaceBidToEntry(auction, bidPrice); // bid
|
||||
|
||||
itr->second.LastChecked = now;
|
||||
--buyCycles;
|
||||
|
||||
--cycles;
|
||||
++itr;
|
||||
}
|
||||
|
||||
// Clear not needed entries
|
||||
config.SameItemInfo.clear();
|
||||
}
|
||||
|
||||
bool AuctionBotBuyer::Update(AuctionHouseType houseType)
|
||||
uint32 AuctionBotBuyer::GetVendorPrice(uint32 quality)
|
||||
{
|
||||
if (sAuctionBotConfig->GetConfigBuyerEnabled(houseType))
|
||||
switch (quality)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: %s buying ...", AuctionBotConfig::GetHouseTypeName(houseType));
|
||||
if (GetBuyableEntry(_houseConfig[houseType]) > 0)
|
||||
AddNewAuctionBuyerBotBid(_houseConfig[houseType]);
|
||||
return true;
|
||||
case ITEM_QUALITY_POOR:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_GRAY);
|
||||
case ITEM_QUALITY_NORMAL:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_WHITE);
|
||||
case ITEM_QUALITY_UNCOMMON:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_GREEN);
|
||||
case ITEM_QUALITY_RARE:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_BLUE);
|
||||
case ITEM_QUALITY_EPIC:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_PURPLE);
|
||||
case ITEM_QUALITY_LEGENDARY:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_ORANGE);
|
||||
case ITEM_QUALITY_ARTIFACT:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_BASEPRICE_YELLOW);
|
||||
default:
|
||||
return 1 * SILVER;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 AuctionBotBuyer::GetChanceMultiplier(uint32 quality)
|
||||
{
|
||||
switch (quality)
|
||||
{
|
||||
case ITEM_QUALITY_POOR:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GRAY);
|
||||
case ITEM_QUALITY_NORMAL:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_WHITE);
|
||||
case ITEM_QUALITY_UNCOMMON:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_GREEN);
|
||||
case ITEM_QUALITY_RARE:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_BLUE);
|
||||
case ITEM_QUALITY_EPIC:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_PURPLE);
|
||||
case ITEM_QUALITY_LEGENDARY:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_ORANGE);
|
||||
case ITEM_QUALITY_ARTIFACT:
|
||||
return sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCEMULTIPLIER_YELLOW);
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
// Buys the auction and does necessary actions to complete the buyout
|
||||
void AuctionBotBuyer::BuyEntry(AuctionEntry* auction, AuctionHouseObject* auctionHouse)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u bought at %.2fg", auction->Id, float(auction->buyout) / GOLD);
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
// Send mail to previous bidder if any
|
||||
if (auction->bidder)
|
||||
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, NULL, trans);
|
||||
|
||||
// Set bot as bidder and set new bid amount
|
||||
auction->bidder = 0;
|
||||
auction->bid = auction->buyout;
|
||||
|
||||
// Mails must be under transaction control too to prevent data loss
|
||||
sAuctionMgr->SendAuctionSalePendingMail(auction, trans);
|
||||
sAuctionMgr->SendAuctionSuccessfulMail(auction, trans);
|
||||
sAuctionMgr->SendAuctionWonMail(auction, trans);
|
||||
|
||||
// Delete auction from DB
|
||||
auction->DeleteFromDB(trans);
|
||||
|
||||
// Remove auction item and auction from memory
|
||||
sAuctionMgr->RemoveAItem(auction->itemGUIDLow);
|
||||
auctionHouse->RemoveAuction(auction);
|
||||
|
||||
// Run SQLs
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
// Bids on the auction and does the necessary actions for bidding
|
||||
void AuctionBotBuyer::PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice)
|
||||
{
|
||||
TC_LOG_DEBUG("ahbot", "AHBot: Bid placed to entry %u, %.2fg", auction->Id, float(bidPrice) / GOLD);
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
// Send mail to previous bidder if any
|
||||
if (auction->bidder)
|
||||
sAuctionMgr->SendAuctionOutbiddedMail(auction, bidPrice, NULL, trans);
|
||||
|
||||
// Set bot as bidder and set new bid amount
|
||||
auction->bidder = 0;
|
||||
auction->bid = bidPrice;
|
||||
|
||||
// Update auction to DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
|
||||
stmt->setUInt32(0, auction->bidder);
|
||||
stmt->setUInt32(1, auction->bid);
|
||||
stmt->setUInt32(2, auction->Id);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Run SQLs
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
struct BuyerAuctionEval
|
||||
{
|
||||
BuyerAuctionEval(): AuctionId(0), LastChecked(0), LastExist(0) {}
|
||||
BuyerAuctionEval() : AuctionId(0), LastChecked(0), LastExist(0) { }
|
||||
|
||||
uint32 AuctionId;
|
||||
time_t LastChecked;
|
||||
@@ -33,13 +33,14 @@ struct BuyerAuctionEval
|
||||
|
||||
struct BuyerItemInfo
|
||||
{
|
||||
BuyerItemInfo(): ItemCount(0), BuyPrice(0), BidPrice(0), MinBuyPrice(0), MinBidPrice(0) {}
|
||||
BuyerItemInfo() : BidItemCount(0), BuyItemCount(0), MinBuyPrice(0), MinBidPrice(0), TotalBuyPrice(0), TotalBidPrice(0) { }
|
||||
|
||||
uint32 ItemCount;
|
||||
double BuyPrice;
|
||||
double BidPrice;
|
||||
uint32 BidItemCount;
|
||||
uint32 BuyItemCount;
|
||||
uint32 MinBuyPrice;
|
||||
uint32 MinBidPrice;
|
||||
double TotalBuyPrice;
|
||||
double TotalBidPrice;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, BuyerItemInfo> BuyerItemInfoMap;
|
||||
@@ -47,7 +48,7 @@ typedef std::map<uint32, BuyerAuctionEval> CheckEntryMap;
|
||||
|
||||
struct BuyerConfiguration
|
||||
{
|
||||
BuyerConfiguration(): FactionChance(3), BuyerEnabled(false), BuyerPriceRatio(100), _houseType(AUCTION_HOUSE_NEUTRAL) {}
|
||||
BuyerConfiguration() : BuyerEnabled(false), _houseType(AUCTION_HOUSE_NEUTRAL) { }
|
||||
|
||||
void Initialize(AuctionHouseType houseType)
|
||||
{
|
||||
@@ -57,10 +58,8 @@ struct BuyerConfiguration
|
||||
AuctionHouseType GetHouseType() const { return _houseType; }
|
||||
|
||||
BuyerItemInfoMap SameItemInfo;
|
||||
CheckEntryMap CheckedEntry;
|
||||
uint32 FactionChance;
|
||||
CheckEntryMap EligibleItems;
|
||||
bool BuyerEnabled;
|
||||
uint32 BuyerPriceRatio;
|
||||
|
||||
private:
|
||||
AuctionHouseType _houseType;
|
||||
@@ -78,19 +77,23 @@ public:
|
||||
bool Update(AuctionHouseType houseType) override;
|
||||
|
||||
void LoadConfig();
|
||||
void AddNewAuctionBuyerBotBid(BuyerConfiguration& config);
|
||||
void BuyAndBidItems(BuyerConfiguration& config);
|
||||
|
||||
private:
|
||||
uint32 _checkInterval;
|
||||
BuyerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE];
|
||||
|
||||
void LoadBuyerValues(BuyerConfiguration& config);
|
||||
bool IsBuyableEntry(uint32 buyoutPrice, double inGameBuyPrice, uint32 maxBuyablePrice, uint32 minBuyPrice, uint32 maxChance, uint32 chanceRatio);
|
||||
bool IsBidableEntry(uint32 bidPrice, double inGameBuyPrice, double maxBidablePrice, uint32 minBidPrice, uint32 maxChance, uint32 chanceRatio);
|
||||
|
||||
// ahInfo can be NULL
|
||||
bool RollBuyChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 bidPrice);
|
||||
bool RollBidChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 bidPrice);
|
||||
void PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice);
|
||||
void BuyEntry(AuctionEntry* auction);
|
||||
void BuyEntry(AuctionEntry* auction, AuctionHouseObject* auctionHouse);
|
||||
void PrepareListOfEntry(BuyerConfiguration& config);
|
||||
uint32 GetBuyableEntry(BuyerConfiguration& config);
|
||||
uint32 GetItemInformation(BuyerConfiguration& config);
|
||||
uint32 GetVendorPrice(uint32 quality);
|
||||
uint32 GetChanceMultiplier(uint32 quality);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -44,14 +44,14 @@ bool AuctionBotSeller::Initialize()
|
||||
{
|
||||
std::stringstream includeStream(sAuctionBotConfig->GetAHBotIncludes());
|
||||
std::string temp;
|
||||
while (getline(includeStream, temp, ','))
|
||||
while (std::getline(includeStream, temp, ','))
|
||||
includeItems.push_back(atoi(temp.c_str()));
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream excludeStream(sAuctionBotConfig->GetAHBotExcludes());
|
||||
std::string temp;
|
||||
while (getline(excludeStream, temp, ','))
|
||||
while (std::getline(excludeStream, temp, ','))
|
||||
excludeItems.push_back(atoi(temp.c_str()));
|
||||
}
|
||||
|
||||
@@ -76,17 +76,17 @@ bool AuctionBotSeller::Initialize()
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "Loading loot items for filter..");
|
||||
QueryResult result = WorldDatabase.PQuery(
|
||||
"SELECT `item` FROM `creature_loot_template` UNION "
|
||||
"SELECT `item` FROM `disenchant_loot_template` UNION "
|
||||
"SELECT `item` FROM `fishing_loot_template` UNION "
|
||||
"SELECT `item` FROM `gameobject_loot_template` UNION "
|
||||
"SELECT `item` FROM `item_loot_template` UNION "
|
||||
"SELECT `item` FROM `milling_loot_template` UNION "
|
||||
"SELECT `item` FROM `pickpocketing_loot_template` UNION "
|
||||
"SELECT `item` FROM `prospecting_loot_template` UNION "
|
||||
"SELECT `item` FROM `reference_loot_template` UNION "
|
||||
"SELECT `item` FROM `skinning_loot_template` UNION "
|
||||
"SELECT `item` FROM `spell_loot_template`");
|
||||
"SELECT `item` FROM `creature_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `disenchant_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `fishing_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `gameobject_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `item_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `milling_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `pickpocketing_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `prospecting_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `reference_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `skinning_loot_template` WHERE `Reference` = 0 UNION "
|
||||
"SELECT `item` FROM `spell_loot_template` WHERE `Reference` = 0");
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -207,12 +207,12 @@ bool AuctionBotSeller::Initialize()
|
||||
{
|
||||
if (sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_SELLER))
|
||||
{
|
||||
if (prototype->BuyPrice == 0)
|
||||
if (prototype->SellPrice == 0)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prototype->SellPrice == 0)
|
||||
if (prototype->BuyPrice == 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -706,7 +706,7 @@ void AuctionBotSeller::SetPricesOfItem(ItemTemplate const* itemProto, SellerConf
|
||||
if (sellPrice == 0)
|
||||
sellPrice = (buyPrice > 10 ? buyPrice / GetSellModifier(itemProto) : buyPrice);
|
||||
|
||||
if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_SELLER))
|
||||
if (sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_SELLER))
|
||||
buyPrice = sellPrice;
|
||||
|
||||
uint32 basePrice = (buyPrice * stackCount * priceRatio) / (itemProto->Class == 6 ? 200 : itemProto->BuyCount) / 100;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "CellImpl.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
#include "Map.h"
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "BattlefieldWG.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
|
||||
BattlefieldMgr::BattlefieldMgr()
|
||||
|
||||
@@ -179,7 +179,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid)
|
||||
player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
|
||||
}
|
||||
|
||||
TC_LOG_INFO("bg.arena", "Player: %s [%s] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), playerGuid.ToString().c_str(), GetType(), GetId(), GetName().c_str());
|
||||
TC_LOG_DEBUG("bg.arena", "Player: %s [%s] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), playerGuid.ToString().c_str(), GetType(), GetId(), GetName().c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,12 +28,10 @@
|
||||
#include "Group.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Guild.h"
|
||||
#include "MapManager.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Util.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -541,7 +539,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
|
||||
if (!aura->IsPermanent()
|
||||
&& aura->GetDuration() <= 30*IN_MILLISECONDS
|
||||
&& aurApp->IsPositive()
|
||||
&& (!(aura->GetSpellInfo()->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
&& (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
&& (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY)))
|
||||
player->RemoveAura(iter);
|
||||
else
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
#include "ArenaTeam.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "BattlegroundAV.h"
|
||||
#include "BattlegroundAB.h"
|
||||
@@ -39,7 +38,6 @@
|
||||
#include "BattlegroundBFG.h"
|
||||
#include "Chat.h"
|
||||
#include "Map.h"
|
||||
#include "MapInstanced.h"
|
||||
#include "MapManager.h"
|
||||
#include "Player.h"
|
||||
#include "GameEventMgr.h"
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "Group.h"
|
||||
#include "Log.h"
|
||||
#include "Language.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
/*********************************************************/
|
||||
/*** BATTLEGROUND QUEUE SYSTEM ***/
|
||||
@@ -890,7 +890,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
// (after what time the ratings aren't taken into account when making teams) then
|
||||
// the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account
|
||||
// else leave the discard time on 0, this way all ratings will be discarded
|
||||
uint32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer();
|
||||
// this has to be signed value - when the server starts, this value would be negative and thus overflow
|
||||
int32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer();
|
||||
|
||||
// we need to find 2 teams which will play next game
|
||||
GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT];
|
||||
@@ -906,7 +907,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
// if group match conditions, then add it to pool
|
||||
if (!(*itr2)->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr2)->ArenaMatchmakerRating >= arenaMinRating && (*itr2)->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr2)->JoinTime < discardTime))
|
||||
|| (int32)(*itr2)->JoinTime < discardTime))
|
||||
{
|
||||
itr_teams[found++] = itr2;
|
||||
team = i;
|
||||
@@ -924,7 +925,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
{
|
||||
if (!(*itr3)->IsInvitedToBGInstanceGUID
|
||||
&& (((*itr3)->ArenaMatchmakerRating >= arenaMinRating && (*itr3)->ArenaMatchmakerRating <= arenaMaxRating)
|
||||
|| (*itr3)->JoinTime < discardTime)
|
||||
|| (int32)(*itr3)->JoinTime < discardTime)
|
||||
&& (*itr_teams[0])->ArenaTeamId != (*itr3)->ArenaTeamId)
|
||||
{
|
||||
itr_teams[found++] = itr3;
|
||||
|
||||
@@ -106,7 +106,7 @@ class BattlegroundQueue
|
||||
class SelectionPool
|
||||
{
|
||||
public:
|
||||
SelectionPool(): PlayerCount(0) { };
|
||||
SelectionPool(): PlayerCount(0) { }
|
||||
void Init();
|
||||
bool AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount);
|
||||
bool KickGroup(uint32 size);
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "BattlegroundAB.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "Creature.h"
|
||||
#include "Language.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "Language.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
BattlegroundAV::BattlegroundAV()
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "BattlegroundEY.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "Creature.h"
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Transport.h"
|
||||
#include "WorldSession.h"
|
||||
#include "ScriptedCreature.h"
|
||||
|
||||
BattlegroundIC::BattlegroundIC()
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "Player.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
BattlegroundSA::BattlegroundSA()
|
||||
{
|
||||
@@ -100,7 +99,7 @@ bool BattlegroundSA::ResetObjs()
|
||||
for (uint8 i = BG_SA_MAXNPC; i < BG_SA_MAXNPC + BG_SA_MAX_GY; i++)
|
||||
DelCreature(i);
|
||||
|
||||
for (uint8 i = 0; i < 6; i++)
|
||||
for (uint8 i = 0; i < MAX_GATES; ++i)
|
||||
GateStatus[i] = BG_SA_GATE_OK;
|
||||
|
||||
if (!AddCreature(BG_SA_NpcEntries[BG_SA_NPC_KANRETHAD], BG_SA_NPC_KANRETHAD, BG_SA_NpcSpawnlocs[BG_SA_NPC_KANRETHAD]))
|
||||
@@ -180,9 +179,6 @@ bool BattlegroundSA::ResetObjs()
|
||||
GetBGObject(BG_SA_TITAN_RELIC)->SetFaction(atF);
|
||||
GetBGObject(BG_SA_TITAN_RELIC)->Refresh();
|
||||
|
||||
for (uint8 i = 0; i <= 5; i++)
|
||||
GateStatus[i] = BG_SA_GATE_OK;
|
||||
|
||||
TotalTime = 0;
|
||||
ShipsStarted = false;
|
||||
|
||||
@@ -222,6 +218,8 @@ bool BattlegroundSA::ResetObjs()
|
||||
GetBGObject(i)->SetFaction(atF);
|
||||
}
|
||||
|
||||
UpdateObjectInteractionFlags();
|
||||
|
||||
for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++)
|
||||
{
|
||||
if (!AddObject(i, BG_SA_ObjEntries[BG_SA_BOMB], BG_SA_ObjSpawnlocs[i], 0, 0, 0, 0, RESPAWN_ONE_DAY))
|
||||
@@ -482,28 +480,7 @@ void BattlegroundSA::AddPlayer(Player* player)
|
||||
|
||||
SendTransportInit(player);
|
||||
|
||||
if (!ShipsStarted)
|
||||
{
|
||||
if (player->GetTeamId() == Attackers)
|
||||
{
|
||||
//player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
|
||||
if (urand(0, 1))
|
||||
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
|
||||
else
|
||||
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
|
||||
|
||||
}
|
||||
else
|
||||
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player->GetTeamId() == Attackers)
|
||||
player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
|
||||
else
|
||||
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
}
|
||||
TeleportToEntrancePosition(player);
|
||||
}
|
||||
|
||||
void BattlegroundSA::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) { }
|
||||
@@ -534,25 +511,33 @@ void BattlegroundSA::TeleportPlayers()
|
||||
player->ResetAllPowers();
|
||||
player->CombatStopWithPets(true);
|
||||
|
||||
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
if (Player* p = ObjectAccessor::FindPlayer(itr->first))
|
||||
p->CastSpell(p, SPELL_PREPARATION, true);
|
||||
player->CastSpell(player, SPELL_PREPARATION, true);
|
||||
|
||||
if (player->GetTeamId() == Attackers)
|
||||
{
|
||||
//player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
|
||||
if (urand(0, 1))
|
||||
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
|
||||
else
|
||||
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
|
||||
}
|
||||
else
|
||||
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
TeleportToEntrancePosition(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundSA::TeleportToEntrancePosition(Player* player)
|
||||
{
|
||||
if (player->GetTeamId() == Attackers)
|
||||
{
|
||||
if (!ShipsStarted)
|
||||
{
|
||||
//player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
|
||||
if (urand(0, 1))
|
||||
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
|
||||
else
|
||||
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
|
||||
}
|
||||
else
|
||||
player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
|
||||
}
|
||||
else
|
||||
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
}
|
||||
|
||||
void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject* invoker /*= NULL*/)
|
||||
{
|
||||
if (GameObject* go = obj->ToGameObject())
|
||||
@@ -629,6 +614,8 @@ void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateObjectInteractionFlags();
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -712,7 +699,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
|
||||
safeloc = BG_SA_GYEntries[BG_SA_DEFENDER_LAST_GY];
|
||||
|
||||
closest = sWorldSafeLocsStore.LookupEntry(safeloc);
|
||||
nearest = std::sqrt((closest->x - x)*(closest->x - x) + (closest->y - y)*(closest->y - y) + (closest->z - z)*(closest->z - z));
|
||||
nearest = player->GetExactDistSq(closest->x, closest->y, closest->z);
|
||||
|
||||
for (uint8 i = BG_SA_RIGHT_CAPTURABLE_GY; i < BG_SA_MAX_GY; i++)
|
||||
{
|
||||
@@ -720,7 +707,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
|
||||
continue;
|
||||
|
||||
ret = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
|
||||
dist = std::sqrt((ret->x - x)*(ret->x - x) + (ret->y - y)*(ret->y - y) + (ret->z - z)*(ret->z - z));
|
||||
dist = player->GetExactDistSq(ret->x, ret->y, ret->z);
|
||||
if (dist < nearest)
|
||||
{
|
||||
closest = ret;
|
||||
@@ -739,23 +726,66 @@ void BattlegroundSA::SendTime()
|
||||
UpdateWorldState(BG_SA_TIMER_SEC_DECS, ((end_of_round%60000)%10000)/1000);
|
||||
}
|
||||
|
||||
bool BattlegroundSA::CanInteractWithObject(uint32 objectId)
|
||||
{
|
||||
switch (objectId)
|
||||
{
|
||||
case BG_SA_TITAN_RELIC:
|
||||
if (GateStatus[BG_SA_ANCIENT_GATE] != BG_SA_GATE_DESTROYED || GateStatus[BG_SA_YELLOW_GATE] != BG_SA_GATE_DESTROYED)
|
||||
return false;
|
||||
// no break
|
||||
case BG_SA_CENTRAL_FLAG:
|
||||
if (GateStatus[BG_SA_RED_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_PURPLE_GATE] != BG_SA_GATE_DESTROYED)
|
||||
return false;
|
||||
// no break
|
||||
case BG_SA_LEFT_FLAG:
|
||||
case BG_SA_RIGHT_FLAG:
|
||||
if (GateStatus[BG_SA_GREEN_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_BLUE_GATE] != BG_SA_GATE_DESTROYED)
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattlegroundSA::UpdateObjectInteractionFlags(uint32 objectId)
|
||||
{
|
||||
if (GameObject* go = GetBGObject(objectId))
|
||||
{
|
||||
if (CanInteractWithObject(objectId))
|
||||
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
else
|
||||
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundSA::UpdateObjectInteractionFlags()
|
||||
{
|
||||
for (uint8 i = BG_SA_CENTRAL_FLAG; i <= BG_SA_LEFT_FLAG; ++i)
|
||||
UpdateObjectInteractionFlags(i);
|
||||
UpdateObjectInteractionFlags(BG_SA_TITAN_RELIC);
|
||||
}
|
||||
|
||||
void BattlegroundSA::EventPlayerClickedOnFlag(Player* source, GameObject* go)
|
||||
{
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case 191307:
|
||||
case 191308:
|
||||
if (GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED)
|
||||
if (CanInteractWithObject(BG_SA_LEFT_FLAG))
|
||||
CaptureGraveyard(BG_SA_LEFT_CAPTURABLE_GY, source);
|
||||
break;
|
||||
case 191305:
|
||||
case 191306:
|
||||
if (GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED)
|
||||
if (CanInteractWithObject(BG_SA_RIGHT_FLAG))
|
||||
CaptureGraveyard(BG_SA_RIGHT_CAPTURABLE_GY, source);
|
||||
break;
|
||||
case 191310:
|
||||
case 191309:
|
||||
if ((GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED) && (GateStatus[BG_SA_RED_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_PURPLE_GATE] == BG_SA_GATE_DESTROYED))
|
||||
if (CanInteractWithObject(BG_SA_CENTRAL_FLAG))
|
||||
CaptureGraveyard(BG_SA_CENTRAL_CAPTURABLE_GY, source);
|
||||
break;
|
||||
default:
|
||||
@@ -857,10 +887,7 @@ void BattlegroundSA::TitanRelicActivated(Player* clicker)
|
||||
if (!clicker)
|
||||
return;
|
||||
|
||||
if (GateStatus[BG_SA_ANCIENT_GATE] == BG_SA_GATE_DESTROYED &&
|
||||
GateStatus[BG_SA_YELLOW_GATE] == BG_SA_GATE_DESTROYED &&
|
||||
(GateStatus[BG_SA_PURPLE_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_RED_GATE] == BG_SA_GATE_DESTROYED) &&
|
||||
(GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED))
|
||||
if (CanInteractWithObject(BG_SA_TITAN_RELIC))
|
||||
{
|
||||
if (clicker->GetTeamId() == Attackers)
|
||||
{
|
||||
|
||||
@@ -620,6 +620,7 @@ class BattlegroundSA : public Battleground
|
||||
* -Teleport all players to good location
|
||||
*/
|
||||
void TeleportPlayers();
|
||||
void TeleportToEntrancePosition(Player* player);
|
||||
/**
|
||||
* \brief Called on start and between the two round
|
||||
* -Update faction of all vehicle
|
||||
@@ -627,6 +628,11 @@ class BattlegroundSA : public Battleground
|
||||
void OverrideGunFaction();
|
||||
/// Set selectable or not demolisher, called on battle start, when boats arrive to dock
|
||||
void DemolisherStartState(bool start);
|
||||
/// Checks if a player can interact with the given object
|
||||
bool CanInteractWithObject(uint32 objectId);
|
||||
/// Updates interaction flags of specific objects
|
||||
void UpdateObjectInteractionFlags(uint32 objectId);
|
||||
void UpdateObjectInteractionFlags();
|
||||
/**
|
||||
* \brief Called when a gate is destroy
|
||||
* -Give honor to player witch destroy it
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
*/
|
||||
|
||||
#include "BattlegroundWS.h"
|
||||
#include "Creature.h"
|
||||
#include "GameObject.h"
|
||||
#include "Language.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "Player.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
// these variables aren't used outside of this file, so declare them only here
|
||||
@@ -159,7 +157,7 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff)
|
||||
player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
|
||||
_flagDebuffState = 1;
|
||||
}
|
||||
else if (_flagDebuffState == 1 && _flagSpellForceTimer >= 900000) //15 minutes
|
||||
else if (_flagDebuffState == 1 && _flagSpellForceTimer >= 15*MINUTE*IN_MILLISECONDS) //15 minutes
|
||||
{
|
||||
if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
|
||||
{
|
||||
|
||||
@@ -110,6 +110,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast/Include
|
||||
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
|
||||
${CMAKE_SOURCE_DIR}/dep/SFMT
|
||||
${CMAKE_SOURCE_DIR}/dep/cppformat
|
||||
${CMAKE_SOURCE_DIR}/dep/zlib
|
||||
${CMAKE_SOURCE_DIR}/dep/zmqpp
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision
|
||||
@@ -129,6 +130,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Networking
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Updater
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
|
||||
${CMAKE_SOURCE_DIR}/src/server/ipc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
@@ -210,6 +212,8 @@ include_directories(
|
||||
${ZMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_library(game STATIC
|
||||
${game_STAT_SRCS}
|
||||
${game_STAT_PCH_SRC}
|
||||
|
||||
@@ -184,7 +184,7 @@ class Channel
|
||||
void DeVoice(ObjectGuid guid1, ObjectGuid guid2);
|
||||
void JoinNotify(ObjectGuid guid); // invisible notify
|
||||
void LeaveNotify(ObjectGuid guid); // invisible notify
|
||||
void SetOwnership(bool ownership) { _ownership = ownership; };
|
||||
void SetOwnership(bool ownership) { _ownership = ownership; }
|
||||
static void CleanOldChannelsInDB();
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ChatLink.h"
|
||||
|
||||
@@ -79,6 +78,7 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
|
||||
// cache top-level commands
|
||||
size_t added = 0;
|
||||
free(commandTableCache);
|
||||
commandTableCache = (ChatCommand*)malloc(sizeof(ChatCommand) * total);
|
||||
ASSERT(commandTableCache);
|
||||
memset(commandTableCache, 0, sizeof(ChatCommand) * total);
|
||||
@@ -104,17 +104,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
return commandTableCache;
|
||||
}
|
||||
|
||||
std::string ChatHandler::PGetParseString(uint32 entry, ...) const
|
||||
{
|
||||
const char *format = GetTrinityString(entry);
|
||||
char str[1024];
|
||||
va_list ap;
|
||||
va_start(ap, entry);
|
||||
vsnprintf(str, 1024, format, ap);
|
||||
va_end(ap);
|
||||
return std::string(str);
|
||||
}
|
||||
|
||||
char const* ChatHandler::GetTrinityString(uint32 entry) const
|
||||
{
|
||||
return m_session->GetTrinityString(entry);
|
||||
@@ -258,27 +247,6 @@ void ChatHandler::SendSysMessage(uint32 entry)
|
||||
SendSysMessage(GetTrinityString(entry));
|
||||
}
|
||||
|
||||
void ChatHandler::PSendSysMessage(uint32 entry, ...)
|
||||
{
|
||||
const char *format = GetTrinityString(entry);
|
||||
va_list ap;
|
||||
char str [2048];
|
||||
va_start(ap, entry);
|
||||
vsnprintf(str, 2048, format, ap);
|
||||
va_end(ap);
|
||||
SendSysMessage(str);
|
||||
}
|
||||
|
||||
void ChatHandler::PSendSysMessage(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char str [2048];
|
||||
va_start(ap, format);
|
||||
vsnprintf(str, 2048, format, ap);
|
||||
va_end(ap);
|
||||
SendSysMessage(str);
|
||||
}
|
||||
|
||||
bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd)
|
||||
{
|
||||
char const* oldtext = text;
|
||||
@@ -1000,7 +968,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||
if (!idS)
|
||||
return 0;
|
||||
|
||||
uint32 id = (uint32)atol(idS);
|
||||
uint32 id = atoul(idS);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -1013,13 +981,10 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||
if (!talentEntry)
|
||||
return 0;
|
||||
|
||||
int32 rank = param1_str ? (uint32)atol(param1_str) : 0;
|
||||
uint32 rank = param1_str ? atol(param1_str) : 0u;
|
||||
if (rank >= MAX_TALENT_RANK)
|
||||
return 0;
|
||||
|
||||
if (rank < 0)
|
||||
rank = 0;
|
||||
|
||||
return talentEntry->RankID[rank];
|
||||
}
|
||||
case SPELL_LINK_ENCHANT:
|
||||
@@ -1027,7 +992,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||
return id;
|
||||
case SPELL_LINK_GLYPH:
|
||||
{
|
||||
uint32 glyph_prop_id = param1_str ? (uint32)atol(param1_str) : 0;
|
||||
uint32 glyph_prop_id = param1_str ? atoul(param1_str) : 0;
|
||||
|
||||
GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id);
|
||||
if (!glyphPropEntry)
|
||||
@@ -1100,7 +1065,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
|
||||
}
|
||||
case SPELL_LINK_CREATURE:
|
||||
{
|
||||
uint32 lowguid = (uint32)atol(idS);
|
||||
uint32 lowguid = atoul(idS);
|
||||
|
||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
|
||||
return ObjectGuid(HIGHGUID_UNIT, data->id, lowguid);
|
||||
@@ -1109,7 +1074,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
|
||||
}
|
||||
case SPELL_LINK_GAMEOBJECT:
|
||||
{
|
||||
uint32 lowguid = (uint32)atol(idS);
|
||||
uint32 lowguid = atoul(idS);
|
||||
|
||||
if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
|
||||
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define TRINITYCORE_CHAT_H
|
||||
|
||||
#include "SharedDefines.h"
|
||||
#include "StringFormat.h"
|
||||
#include "WorldSession.h"
|
||||
#include "RBAC.h"
|
||||
|
||||
@@ -69,9 +70,24 @@ class ChatHandler
|
||||
virtual void SendSysMessage(char const* str);
|
||||
|
||||
void SendSysMessage(uint32 entry);
|
||||
void PSendSysMessage(char const* format, ...) ATTR_PRINTF(2, 3);
|
||||
void PSendSysMessage(uint32 entry, ...);
|
||||
std::string PGetParseString(uint32 entry, ...) const;
|
||||
|
||||
template<typename... Args>
|
||||
void PSendSysMessage(const char* fmt, Args const&... args)
|
||||
{
|
||||
SendSysMessage(Trinity::StringFormat(fmt, args...).c_str());
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void PSendSysMessage(uint32 entry, Args const&... args)
|
||||
{
|
||||
SendSysMessage(PGetParseString(entry, args...).c_str());
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
std::string PGetParseString(uint32 entry, Args const&... args) const
|
||||
{
|
||||
return Trinity::StringFormat(GetTrinityString(entry), args...);
|
||||
}
|
||||
|
||||
bool ParseCommands(const char* text);
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context)
|
||||
ChatLink::ValidateName(buffer, context);
|
||||
|
||||
// spells with that flag have a prefix of "$PROFESSION: "
|
||||
if (_spell->Attributes & SPELL_ATTR0_TRADESPELL)
|
||||
if (_spell->HasAttribute(SPELL_ATTR0_TRADESPELL))
|
||||
{
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(_spell->Id);
|
||||
if (bounds.first == bounds.second)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "ThreatManager.h"
|
||||
#include "Unit.h"
|
||||
#include "DBCStructure.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
HostileRefManager::~HostileRefManager()
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
#include "ThreatManager.h"
|
||||
#include "Unit.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Map.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "UnitEvents.h"
|
||||
@@ -79,7 +77,7 @@ bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellIn
|
||||
return false;
|
||||
|
||||
// spell not causing threat
|
||||
if (threatSpell && threatSpell->AttributesEx & SPELL_ATTR1_NO_THREAT)
|
||||
if (threatSpell && threatSpell->HasAttribute(SPELL_ATTR1_NO_THREAT))
|
||||
return false;
|
||||
|
||||
ASSERT(hatingUnit->GetTypeId() == TYPEID_UNIT);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,7 @@
|
||||
#include "Errors.h"
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class Player;
|
||||
class Unit;
|
||||
@@ -72,7 +73,9 @@ enum ConditionTypes
|
||||
CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
|
||||
CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
|
||||
CONDITION_TERRAIN_SWAP = 39, // terrainSwap 0 0 true if object is in terrainswap
|
||||
CONDITION_MAX = 40 // MAX
|
||||
CONDITION_REALM_ACHIEVEMENT = 40, // achievement_id 0 0 true if realm achievement is complete
|
||||
CONDITION_IN_WATER = 41, // 0 0 0 true if unit in water
|
||||
CONDITION_MAX = 42 // MAX
|
||||
};
|
||||
|
||||
/*! Documentation on implementing a new ConditionSourceType:
|
||||
@@ -212,6 +215,8 @@ struct Condition
|
||||
uint32 GetSearcherTypeMaskForCondition();
|
||||
bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; }
|
||||
uint32 GetMaxAvailableConditionTargets();
|
||||
|
||||
std::string ToString(bool ext = false) const; /// For logging purpose
|
||||
};
|
||||
|
||||
typedef std::list<Condition*> ConditionList;
|
||||
@@ -230,7 +235,6 @@ class ConditionMgr
|
||||
~ConditionMgr();
|
||||
|
||||
public:
|
||||
|
||||
static ConditionMgr* instance()
|
||||
{
|
||||
static ConditionMgr instance;
|
||||
@@ -245,14 +249,24 @@ class ConditionMgr
|
||||
bool IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions);
|
||||
bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions);
|
||||
bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
|
||||
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const;
|
||||
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const;
|
||||
static bool CanHaveSourceGroupSet(ConditionSourceType sourceType);
|
||||
static bool CanHaveSourceIdSet(ConditionSourceType sourceType);
|
||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
|
||||
ConditionList GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId);
|
||||
ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType);
|
||||
ConditionList GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId);
|
||||
ConditionList GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId);
|
||||
|
||||
struct ConditionTypeInfo
|
||||
{
|
||||
char const* Name;
|
||||
bool HasConditionValue1;
|
||||
bool HasConditionValue2;
|
||||
bool HasConditionValue3;
|
||||
};
|
||||
static char const* StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
|
||||
static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX];
|
||||
|
||||
private:
|
||||
bool isSourceTypeValid(Condition* cond);
|
||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||
@@ -261,6 +275,8 @@ class ConditionMgr
|
||||
bool addToSpellImplicitTargetConditions(Condition* cond);
|
||||
bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
|
||||
|
||||
static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value);
|
||||
|
||||
void Clean(); // free up resources
|
||||
std::list<Condition*> AllocatedMemoryStore; // some garbage collection :)
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ struct WMOAreaTableTripple
|
||||
};
|
||||
|
||||
typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const*> WMOAreaInfoByTripple;
|
||||
typedef std::multimap<uint32, CharSectionsEntry const*> CharSectionsMap;
|
||||
|
||||
DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt);
|
||||
DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt);
|
||||
@@ -69,6 +70,8 @@ DBCStorage <BattlemasterListEntry> sBattlemasterListStore(BattlemasterListEntryf
|
||||
DBCStorage <BarberShopStyleEntry> sBarberShopStyleStore(BarberShopStyleEntryfmt);
|
||||
DBCStorage <CharStartOutfitEntry> sCharStartOutfitStore(CharStartOutfitEntryfmt);
|
||||
std::map<uint32, CharStartOutfitEntry const*> sCharStartOutfitMap;
|
||||
DBCStorage <CharSectionsEntry> sCharSectionsStore(CharSectionsEntryfmt);
|
||||
CharSectionsMap sCharSectionMap;
|
||||
DBCStorage <CharTitlesEntry> sCharTitlesStore(CharTitlesEntryfmt);
|
||||
DBCStorage <ChatChannelsEntry> sChatChannelsStore(ChatChannelsEntryfmt);
|
||||
DBCStorage <ChrClassesEntry> sChrClassesStore(ChrClassesEntryfmt);
|
||||
@@ -360,6 +363,12 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
if (CharStartOutfitEntry const* outfit = sCharStartOutfitStore.LookupEntry(i))
|
||||
sCharStartOutfitMap[outfit->Race | (outfit->Class << 8) | (outfit->Gender << 16)] = outfit;
|
||||
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sCharSectionsStore, dbcPath, "CharSections.dbc");
|
||||
for (uint32 i = 0; i < sCharSectionsStore.GetNumRows(); ++i)
|
||||
if (CharSectionsEntry const* entry = sCharSectionsStore.LookupEntry(i))
|
||||
if (entry->Race && ((1 << (entry->Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0) //ignore Nonplayable races
|
||||
sCharSectionMap.insert({ entry->GenType | (entry->Gender << 8) | (entry->Race << 16), entry });
|
||||
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sCharTitlesStore, dbcPath, "CharTitles.dbc");//15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sChatChannelsStore, dbcPath, "ChatChannels.dbc");//15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sChrClassesStore, dbcPath, "ChrClasses.dbc");//15595
|
||||
@@ -695,8 +704,8 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
|
||||
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
|
||||
{
|
||||
if (pathLength[entry->path] < entry->index + 1)
|
||||
pathLength[entry->path] = entry->index + 1;
|
||||
if (pathLength[entry->PathID] < entry->NodeIndex + 1)
|
||||
pathLength[entry->PathID] = entry->NodeIndex + 1;
|
||||
}
|
||||
// Set path length
|
||||
sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used
|
||||
@@ -705,7 +714,7 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
// fill data
|
||||
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
|
||||
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
|
||||
sTaxiPathNodesByPath[entry->path].set(entry->index, entry);
|
||||
sTaxiPathNodesByPath[entry->PathID].set(entry->NodeIndex, entry);
|
||||
|
||||
// Initialize global taxinodes mask
|
||||
// include existed nodes that have at least single not spell base (scripted) path
|
||||
@@ -1132,6 +1141,18 @@ CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, ui
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
CharSectionsEntry const* GetCharSectionEntry(uint8 race, CharSectionType genType, uint8 gender, uint8 type, uint8 color)
|
||||
{
|
||||
std::pair<CharSectionsMap::const_iterator, CharSectionsMap::const_iterator> eqr = sCharSectionMap.equal_range(uint32(genType) | uint32(gender << 8) | uint32(race << 16));
|
||||
for (CharSectionsMap::const_iterator itr = eqr.first; itr != eqr.second; ++itr)
|
||||
{
|
||||
if (itr->second->Type == type && itr->second->Color == color)
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId)
|
||||
{
|
||||
return PowersByClass[classId][powerType];
|
||||
|
||||
@@ -77,6 +77,7 @@ PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 lev
|
||||
PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id);
|
||||
|
||||
CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender);
|
||||
CharSectionsEntry const* GetCharSectionEntry(uint8 race, CharSectionType genType, uint8 gender, uint8 type, uint8 color);
|
||||
|
||||
uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId);
|
||||
LFGDungeonEntry const* GetLFGDungeon(uint32 mapId, Difficulty difficulty);
|
||||
@@ -103,6 +104,7 @@ extern DBCStorage <BarberShopStyleEntry> sBarberShopStyleStore;
|
||||
extern DBCStorage <BattlemasterListEntry> sBattlemasterListStore;
|
||||
extern DBCStorage <ChatChannelsEntry> sChatChannelsStore;
|
||||
extern DBCStorage <CharStartOutfitEntry> sCharStartOutfitStore;
|
||||
extern DBCStorage <CharSectionsEntry> sCharSectionsStore;
|
||||
extern DBCStorage <CharTitlesEntry> sCharTitlesStore;
|
||||
extern DBCStorage <ChrClassesEntry> sChrClassesStore;
|
||||
extern DBCStorage <ChrRacesEntry> sChrRacesStore;
|
||||
|
||||
@@ -30,13 +30,7 @@
|
||||
#include <vector>
|
||||
|
||||
// Structures using to access raw DBC data and required packing to portability
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#pragma pack(push, 1)
|
||||
#endif
|
||||
|
||||
struct AchievementEntry
|
||||
{
|
||||
@@ -684,6 +678,33 @@ struct CharStartOutfitEntry
|
||||
uint32 PetFamilyEntry; // 78 Pet Family Entry for starting pet
|
||||
};
|
||||
|
||||
enum CharSectionFlags
|
||||
{
|
||||
SECTION_FLAG_PLAYER = 0x01,
|
||||
SECTION_FLAG_DEATH_KNIGHT = 0x04
|
||||
};
|
||||
|
||||
enum CharSectionType
|
||||
{
|
||||
SECTION_TYPE_SKIN = 0,
|
||||
SECTION_TYPE_FACE = 1,
|
||||
SECTION_TYPE_FACIAL_HAIR = 2,
|
||||
SECTION_TYPE_HAIR = 3,
|
||||
SECTION_TYPE_UNDERWEAR = 4
|
||||
};
|
||||
|
||||
struct CharSectionsEntry
|
||||
{
|
||||
//uint32 Id;
|
||||
uint32 Race;
|
||||
uint32 Gender;
|
||||
uint32 GenType;
|
||||
//char* TexturePath[3];
|
||||
uint32 Flags;
|
||||
uint32 Type;
|
||||
uint32 Color;
|
||||
};
|
||||
|
||||
struct CharTitlesEntry
|
||||
{
|
||||
uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId()
|
||||
@@ -2203,17 +2224,17 @@ struct TaxiPathEntry
|
||||
|
||||
struct TaxiPathNodeEntry
|
||||
{
|
||||
// 0 m_ID
|
||||
uint32 path; // 1 m_PathID
|
||||
uint32 index; // 2 m_NodeIndex
|
||||
uint32 mapid; // 3 m_ContinentID
|
||||
float x; // 4 m_LocX
|
||||
float y; // 5 m_LocY
|
||||
float z; // 6 m_LocZ
|
||||
uint32 actionFlag; // 7 m_flags
|
||||
uint32 delay; // 8 m_delay
|
||||
uint32 arrivalEventID; // 9 m_arrivalEventID
|
||||
uint32 departureEventID; // 10 m_departureEventID
|
||||
// 0 ID
|
||||
uint32 PathID; // 1
|
||||
uint32 NodeIndex; // 2
|
||||
uint32 MapID; // 3
|
||||
float LocX; // 4
|
||||
float LocY; // 5
|
||||
float LocZ; // 6
|
||||
uint32 Flags; // 7
|
||||
uint32 Delay; // 8
|
||||
uint32 ArrivalEventID; // 9
|
||||
uint32 DepartureEventID; // 10
|
||||
};
|
||||
|
||||
struct TotemCategoryEntry
|
||||
@@ -2465,12 +2486,7 @@ struct WorldStateUI
|
||||
};
|
||||
*/
|
||||
|
||||
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
struct VectorArray
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ char const BannedAddOnsfmt[] = "nxxxxxxxxxx";
|
||||
char const BarberShopStyleEntryfmt[] = "nixxxiii";
|
||||
char const BattlemasterListEntryfmt[] = "niiiiiiiiixsiiiixxxx";
|
||||
char const CharStartOutfitEntryfmt[] = "dbbbXiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxii";
|
||||
char const CharSectionsEntryfmt[] = "diiixxxiii";
|
||||
char const CharTitlesEntryfmt[] = "nxssix";
|
||||
char const ChatChannelsEntryfmt[] = "nixsx";
|
||||
char const ChrClassesEntryfmt[] = "nixsxxxixiiiii";
|
||||
|
||||
@@ -91,9 +91,6 @@ std::string GetStateString(LfgState state)
|
||||
case LFG_STATE_DUNGEON:
|
||||
entry = LANG_LFG_STATE_DUNGEON;
|
||||
break;
|
||||
case LFG_STATE_BOOT:
|
||||
entry = LANG_LFG_STATE_BOOT;
|
||||
break;
|
||||
case LFG_STATE_FINISHED_DUNGEON:
|
||||
entry = LANG_LFG_STATE_FINISHED_DUNGEON;
|
||||
break;
|
||||
|
||||
@@ -68,8 +68,8 @@ enum LfgState
|
||||
LFG_STATE_ROLECHECK, // Rolecheck active
|
||||
LFG_STATE_QUEUED, // Queued
|
||||
LFG_STATE_PROPOSAL, // Proposal active
|
||||
LFG_STATE_BOOT, // Vote kick active
|
||||
LFG_STATE_DUNGEON, // In LFG Group, in a Dungeon
|
||||
//LFG_STATE_BOOT, // Vote kick active
|
||||
LFG_STATE_DUNGEON = 5, // In LFG Group, in a Dungeon
|
||||
LFG_STATE_FINISHED_DUNGEON, // In LFG Group, in a finished Dungeon
|
||||
LFG_STATE_RAIDBROWSER // Using Raid finder
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace lfg
|
||||
{
|
||||
|
||||
LfgGroupData::LfgGroupData(): m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE),
|
||||
m_Leader(), m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS)
|
||||
m_Leader(), m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS), m_VoteKickActive(false)
|
||||
{ }
|
||||
|
||||
LfgGroupData::~LfgGroupData()
|
||||
@@ -126,4 +126,14 @@ uint8 LfgGroupData::GetKicksLeft() const
|
||||
return m_KicksLeft;
|
||||
}
|
||||
|
||||
void LfgGroupData::SetVoteKick(bool active)
|
||||
{
|
||||
m_VoteKickActive = active;
|
||||
}
|
||||
|
||||
bool LfgGroupData::IsVoteKickActive() const
|
||||
{
|
||||
return m_VoteKickActive;
|
||||
}
|
||||
|
||||
} // namespace lfg
|
||||
@@ -66,6 +66,9 @@ class LfgGroupData
|
||||
// VoteKick
|
||||
uint8 GetKicksLeft() const;
|
||||
|
||||
void SetVoteKick(bool active);
|
||||
bool IsVoteKickActive() const;
|
||||
|
||||
private:
|
||||
// General
|
||||
LfgState m_State; ///< State if group in LFG
|
||||
@@ -76,6 +79,7 @@ class LfgGroupData
|
||||
uint32 m_Dungeon; ///< Dungeon entry
|
||||
// Vote Kick
|
||||
uint8 m_KicksLeft; ///< Number of kicks left
|
||||
bool m_VoteKickActive;
|
||||
};
|
||||
|
||||
} // namespace lfg
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "DisableMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "Language.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "LFGScripts.h"
|
||||
#include "LFGGroupData.h"
|
||||
@@ -33,6 +32,7 @@
|
||||
#include "GroupMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "WorldSession.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
|
||||
namespace lfg
|
||||
{
|
||||
@@ -308,9 +308,8 @@ void LFGMgr::Update(uint32 diff)
|
||||
ObjectGuid pguid = itVotes->first;
|
||||
if (pguid != boot.victim)
|
||||
SendLfgBootProposalUpdate(pguid, boot);
|
||||
SetState(pguid, LFG_STATE_DUNGEON);
|
||||
}
|
||||
SetState(itBoot->first, LFG_STATE_DUNGEON);
|
||||
SetVoteKick(itBoot->first, false);
|
||||
BootsStore.erase(itBoot);
|
||||
}
|
||||
}
|
||||
@@ -409,6 +408,8 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
|
||||
joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
|
||||
else if (dungeons.empty())
|
||||
joinData.result = LFG_JOIN_NOT_MEET_REQS;
|
||||
else if (player->HasAura(9454)) // check Freeze debuff
|
||||
joinData.result = LFG_JOIN_NOT_MEET_REQS;
|
||||
else if (grp)
|
||||
{
|
||||
if (grp->GetMembersCount() > MAXGROUPSIZE)
|
||||
@@ -481,7 +482,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
|
||||
dungeons = GetDungeonsByRandom(rDungeonId);
|
||||
|
||||
// if we have lockmap then there are no compatible dungeons
|
||||
GetCompatibleDungeons(dungeons, players, joinData.lockmap);
|
||||
GetCompatibleDungeons(dungeons, players, joinData.lockmap, isContinue);
|
||||
if (dungeons.empty())
|
||||
joinData.result = grp ? LFG_JOIN_INTERNAL_ERROR : LFG_JOIN_NOT_MEET_REQS;
|
||||
}
|
||||
@@ -640,7 +641,6 @@ void LFGMgr::LeaveLfg(ObjectGuid guid)
|
||||
break;
|
||||
case LFG_STATE_DUNGEON:
|
||||
case LFG_STATE_FINISHED_DUNGEON:
|
||||
case LFG_STATE_BOOT:
|
||||
if (guid != gguid) // Player
|
||||
SetState(guid, LFG_STATE_NONE);
|
||||
break;
|
||||
@@ -746,20 +746,48 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid::
|
||||
@param[in] players Set of players to check their dungeon restrictions
|
||||
@param[out] lockMap Map of players Lock status info of given dungeons (Empty if dungeons is not empty)
|
||||
*/
|
||||
void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap)
|
||||
void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap, bool isContinue)
|
||||
{
|
||||
lockMap.clear();
|
||||
|
||||
std::map<uint32, uint32> lockedDungeons;
|
||||
|
||||
for (GuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
|
||||
{
|
||||
ObjectGuid guid = (*it);
|
||||
LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
|
||||
{
|
||||
uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
|
||||
LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
|
||||
if (itDungeon != dungeons.end())
|
||||
{
|
||||
dungeons.erase(itDungeon);
|
||||
bool eraseDungeon = true;
|
||||
|
||||
// Don't remove the dungeon if team members are trying to continue a locked instance
|
||||
if (it2->second.lockStatus == LFG_LOCKSTATUS_RAID_LOCKED && isContinue)
|
||||
{
|
||||
LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId);
|
||||
ASSERT(dungeon);
|
||||
ASSERT(player);
|
||||
if (InstancePlayerBind* playerBind = player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
|
||||
{
|
||||
if (InstanceSave* playerSave = playerBind->save)
|
||||
{
|
||||
uint32 dungeonInstanceId = playerSave->GetInstanceId();
|
||||
auto itLockedDungeon = lockedDungeons.find(dungeonId);
|
||||
if (itLockedDungeon == lockedDungeons.end() || itLockedDungeon->second == dungeonInstanceId)
|
||||
eraseDungeon = false;
|
||||
|
||||
lockedDungeons[dungeonId] = dungeonInstanceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (eraseDungeon)
|
||||
dungeons.erase(itDungeon);
|
||||
|
||||
lockMap[guid][dungeonId] = it2->second;
|
||||
}
|
||||
}
|
||||
@@ -866,7 +894,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
|
||||
for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it)
|
||||
{
|
||||
ObjectGuid pguid = (*it);
|
||||
Player* player = ObjectAccessor::FindPlayer(pguid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(pguid);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -1129,7 +1157,7 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
|
||||
*/
|
||||
void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason)
|
||||
{
|
||||
SetState(gguid, LFG_STATE_BOOT);
|
||||
SetVoteKick(gguid, true);
|
||||
|
||||
LfgPlayerBoot& boot = BootsStore[gguid];
|
||||
boot.inProgress = true;
|
||||
@@ -1143,7 +1171,6 @@ void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, st
|
||||
for (GuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
{
|
||||
ObjectGuid guid = (*itr);
|
||||
SetState(guid, LFG_STATE_BOOT);
|
||||
boot.votes[guid] = LFG_ANSWER_PENDING;
|
||||
}
|
||||
|
||||
@@ -1200,13 +1227,10 @@ void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept)
|
||||
{
|
||||
ObjectGuid pguid = itVotes->first;
|
||||
if (pguid != boot.victim)
|
||||
{
|
||||
SetState(pguid, LFG_STATE_DUNGEON);
|
||||
SendLfgBootProposalUpdate(pguid, boot);
|
||||
}
|
||||
}
|
||||
|
||||
SetState(gguid, LFG_STATE_DUNGEON);
|
||||
SetVoteKick(gguid, false);
|
||||
if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
|
||||
{
|
||||
if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
|
||||
@@ -1261,6 +1285,8 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
|
||||
error = LFG_TELEPORTERROR_IN_VEHICLE;
|
||||
else if (player->GetCharmGUID())
|
||||
error = LFG_TELEPORTERROR_CHARMING;
|
||||
else if (player->HasAura(9454)) // check Freeze debuff
|
||||
error = LFG_TELEPORTERROR_INVALID_LOCATION;
|
||||
else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
|
||||
{
|
||||
uint32 mapid = dungeon->map;
|
||||
@@ -1468,12 +1494,12 @@ LfgState LFGMgr::GetState(ObjectGuid guid)
|
||||
if (guid.IsGroup())
|
||||
{
|
||||
state = GroupsStore[guid].GetState();
|
||||
TC_LOG_TRACE("lfg.data.group.state.get", "Group: %s, State: %u", guid.ToString().c_str(), state);
|
||||
TC_LOG_TRACE("lfg.data.group.state.get", "Group: %s, State: %s", guid.ToString().c_str(), GetStateString(state).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
state = PlayersStore[guid].GetState();
|
||||
TC_LOG_TRACE("lfg.data.player.state.get", "Player: %s, State: %u", guid.ToString().c_str(), state);
|
||||
TC_LOG_TRACE("lfg.data.player.state.get", "Player: %s, State: %s", guid.ToString().c_str(), GetStateString(state).c_str());
|
||||
}
|
||||
|
||||
return state;
|
||||
@@ -1496,6 +1522,16 @@ LfgState LFGMgr::GetOldState(ObjectGuid guid)
|
||||
return state;
|
||||
}
|
||||
|
||||
bool LFGMgr::IsVoteKickActive(ObjectGuid gguid)
|
||||
{
|
||||
ASSERT(gguid.IsGroup());
|
||||
|
||||
bool active = GroupsStore[gguid].IsVoteKickActive();
|
||||
TC_LOG_TRACE("lfg.data.group.votekick.get", "Group: %s, Active: %d", gguid.ToString().c_str(), active);
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
uint32 LFGMgr::GetDungeon(ObjectGuid guid, bool asId /*= true */)
|
||||
{
|
||||
uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
|
||||
@@ -1539,7 +1575,7 @@ LfgLockMap const LFGMgr::GetLockedDungeons(ObjectGuid guid)
|
||||
{
|
||||
TC_LOG_TRACE("lfg.data.player.dungeons.locked.get", "Player: %s, LockedDungeons.", guid.ToString().c_str());
|
||||
LfgLockMap lock;
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
if (!player)
|
||||
{
|
||||
TC_LOG_WARN("lfg.data.player.dungeons.locked.get", "Player: %s not ingame while retrieving his LockedDungeons.", guid.ToString().c_str());
|
||||
@@ -1656,6 +1692,17 @@ void LFGMgr::SetState(ObjectGuid guid, LfgState state)
|
||||
}
|
||||
}
|
||||
|
||||
void LFGMgr::SetVoteKick(ObjectGuid gguid, bool active)
|
||||
{
|
||||
ASSERT(gguid.IsGroup());
|
||||
|
||||
LfgGroupData& data = GroupsStore[gguid];
|
||||
TC_LOG_TRACE("lfg.data.group.votekick.set", "Group: %s, New state: %d, Previous: %d",
|
||||
gguid.ToString().c_str(), active, data.IsVoteKickActive());
|
||||
|
||||
data.SetVoteKick(active);
|
||||
}
|
||||
|
||||
void LFGMgr::SetDungeon(ObjectGuid guid, uint32 dungeon)
|
||||
{
|
||||
TC_LOG_TRACE("lfg.data.group.dungeon.set", "Group: %s, Dungeon: %u", guid.ToString().c_str(), dungeon);
|
||||
|
||||
@@ -328,6 +328,8 @@ class LFGMgr
|
||||
LfgDungeonSet const& GetSelectedDungeons(ObjectGuid guid);
|
||||
/// Get current lfg state
|
||||
LfgState GetState(ObjectGuid guid);
|
||||
/// Get current vote kick state
|
||||
bool IsVoteKickActive(ObjectGuid gguid);
|
||||
/// Get current dungeon
|
||||
uint32 GetDungeon(ObjectGuid guid, bool asId = true);
|
||||
/// Get the map id of the current dungeon
|
||||
@@ -435,8 +437,9 @@ class LFGMgr
|
||||
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons);
|
||||
void DecreaseKicksLeft(ObjectGuid guid);
|
||||
void SetState(ObjectGuid guid, LfgState state);
|
||||
void SetVoteKick(ObjectGuid gguid, bool active);
|
||||
void RemovePlayerData(ObjectGuid guid);
|
||||
void GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap);
|
||||
void GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap, bool isContinue);
|
||||
void _SaveToDB(ObjectGuid guid, uint32 db_guid);
|
||||
LFGDungeonData const* GetLFGDungeon(uint32 id);
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include "LFGQueue.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "World.h"
|
||||
#include "GroupMgr.h"
|
||||
|
||||
namespace lfg
|
||||
{
|
||||
@@ -377,7 +374,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
|
||||
// Group with less that MAXGROUPSIZE members always compatible
|
||||
if (check.size() == 1 && numPlayers != MAXGROUPSIZE)
|
||||
{
|
||||
TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: (%s) sigle group. Compatibles", strGuids.c_str());
|
||||
TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: (%s) single group. Compatibles", strGuids.c_str());
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front());
|
||||
|
||||
LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS);
|
||||
|
||||
@@ -99,7 +99,17 @@ void LFGPlayerScript::OnMapChanged(Player* player)
|
||||
player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Group* group = player->GetGroup();
|
||||
if (group && group->GetMembersCount() == 1)
|
||||
{
|
||||
sLFGMgr->LeaveLfg(group->GetGUID());
|
||||
group->Disband();
|
||||
TC_LOG_DEBUG("lfg", "LFGPlayerScript::OnMapChanged, Player %s(%s) is last in the lfggroup so we disband the group.",
|
||||
player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||
}
|
||||
player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
|
||||
}
|
||||
}
|
||||
|
||||
LFGGroupScript::LFGGroupScript() : GroupScript("LFGGroupScript") { }
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
#include "UpdateMask.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Opcodes.h"
|
||||
#include "GossipDef.h"
|
||||
#include "World.h"
|
||||
|
||||
Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type)
|
||||
{
|
||||
@@ -195,6 +192,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
|
||||
|
||||
Object::_Create(guid, 0, HIGHGUID_CORPSE);
|
||||
|
||||
SetObjectScale(1.0f);
|
||||
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
|
||||
_LoadIntoDataField(fields[6].GetCString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END);
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
|
||||
|
||||
@@ -34,12 +34,9 @@
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "MapManager.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "Player.h"
|
||||
#include "PoolMgr.h"
|
||||
#include "QuestDef.h"
|
||||
@@ -48,10 +45,8 @@
|
||||
#include "TemporarySummon.h"
|
||||
#include "Util.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
#include "Transport.h"
|
||||
|
||||
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
|
||||
@@ -155,8 +150,6 @@ m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(
|
||||
for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
m_spells[i] = 0;
|
||||
|
||||
m_CreatureSpellCooldowns.clear();
|
||||
m_CreatureCategoryCooldowns.clear();
|
||||
DisableReputationGain = false;
|
||||
|
||||
m_SightDistance = sWorld->getFloatConfig(CONFIG_SIGHT_MONSTER);
|
||||
@@ -1395,9 +1388,12 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
|
||||
if (IsCivilian())
|
||||
return false;
|
||||
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
// This set of checks is should be done only for creatures
|
||||
if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) // flag is valid only for non player characters
|
||||
|| (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER) // immune to PC and target is a player, return false
|
||||
|| (who->GetOwner() && who->GetOwner()->GetTypeId() == TYPEID_PLAYER && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))) // player pets are immune to pc as well
|
||||
return false;
|
||||
|
||||
|
||||
// Do not attack non-combat pets
|
||||
if (who->GetTypeId() == TYPEID_UNIT && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
||||
return false;
|
||||
@@ -1425,9 +1421,29 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
|
||||
if (!CanCreatureAttack(who, force))
|
||||
return false;
|
||||
|
||||
// No aggro from gray creatures
|
||||
if (CheckNoGrayAggroConfig(who->getLevelForTarget(this), getLevelForTarget(who)))
|
||||
return false;
|
||||
|
||||
return IsWithinLOSInMap(who);
|
||||
}
|
||||
|
||||
|
||||
bool Creature::CheckNoGrayAggroConfig(uint32 playerLevel, uint32 creatureLevel) const
|
||||
{
|
||||
if (Trinity::XP::GetColorCode(playerLevel, creatureLevel) != XP_GRAY)
|
||||
return false;
|
||||
|
||||
uint32 notAbove = sWorld->getIntConfig(CONFIG_NO_GRAY_AGGRO_ABOVE);
|
||||
uint32 notBelow = sWorld->getIntConfig(CONFIG_NO_GRAY_AGGRO_BELOW);
|
||||
if (notAbove == 0 && notBelow == 0)
|
||||
return false;
|
||||
|
||||
if (playerLevel <= notBelow || (playerLevel >= notAbove && notAbove > 0))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
float Creature::GetAttackDistance(Unit const* player) const
|
||||
{
|
||||
float aggroRate = sWorld->getRate(RATE_CREATURE_AGGRO);
|
||||
@@ -1515,9 +1531,9 @@ void Creature::setDeathState(DeathState s)
|
||||
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
|
||||
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~UNIT_STATE_IGNORE_PATHFINDING));
|
||||
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
|
||||
LoadCreaturesAddon(true);
|
||||
Motion_Initialize();
|
||||
Unit::setDeathState(ALIVE);
|
||||
LoadCreaturesAddon(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2152,88 +2168,6 @@ void Creature::SetInCombatWithZone()
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = end_time;
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
|
||||
{
|
||||
m_CreatureCategoryCooldowns[category] = apply_time;
|
||||
}
|
||||
|
||||
void Creature::AddCreatureSpellCooldown(uint32 spellid)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||
if (!spellInfo)
|
||||
return;
|
||||
|
||||
uint32 cooldown = spellInfo->GetRecoveryTime();
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
|
||||
|
||||
if (cooldown)
|
||||
_AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILLISECONDS);
|
||||
|
||||
if (spellInfo->GetCategory())
|
||||
_AddCreatureCategoryCooldown(spellInfo->GetCategory(), time(NULL));
|
||||
}
|
||||
|
||||
bool Creature::HasCategoryCooldown(uint32 spell_id) const
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->GetCategory());
|
||||
return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
|
||||
}
|
||||
|
||||
uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
|
||||
time_t t = time(NULL);
|
||||
return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
|
||||
}
|
||||
|
||||
bool Creature::HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
|
||||
return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id);
|
||||
}
|
||||
|
||||
void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs)
|
||||
{
|
||||
time_t curTime = time(NULL);
|
||||
for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
{
|
||||
if (m_spells[i] == 0)
|
||||
continue;
|
||||
|
||||
uint32 unSpellId = m_spells[i];
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
ASSERT(spellInfo);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Not send cooldown for this spells
|
||||
if (spellInfo->IsCooldownStartedOnEvent())
|
||||
continue;
|
||||
|
||||
if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE)
|
||||
continue;
|
||||
|
||||
if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs)
|
||||
{
|
||||
_AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS);
|
||||
if (UnitAI* ai = GetAI())
|
||||
ai->SpellInterrupted(unSpellId, unTimeMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Creature::HasSpell(uint32 spellID) const
|
||||
{
|
||||
uint8 i;
|
||||
@@ -2586,7 +2520,7 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
|
||||
|
||||
_focusSpell = focusSpell;
|
||||
SetGuidValue(UNIT_FIELD_TARGET, target->GetGUID());
|
||||
if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST)
|
||||
if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST))
|
||||
AddUnitState(UNIT_STATE_ROTATING);
|
||||
|
||||
// Set serverside orientation if needed (needs to be after attribute check)
|
||||
@@ -2605,7 +2539,7 @@ void Creature::ReleaseFocus(Spell const* focusSpell)
|
||||
else
|
||||
SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty);
|
||||
|
||||
if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST)
|
||||
if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST))
|
||||
ClearUnitState(UNIT_STATE_ROTATING);
|
||||
}
|
||||
|
||||
@@ -2614,3 +2548,29 @@ void Creature::StartPickPocketRefillTimer()
|
||||
_pickpocketLootRestore = time(NULL) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL);
|
||||
}
|
||||
|
||||
void Creature::SetTextRepeatId(uint8 textGroup, uint8 id)
|
||||
{
|
||||
CreatureTextRepeatIds& repeats = m_textRepeat[textGroup];
|
||||
if (std::find(repeats.begin(), repeats.end(), id) == repeats.end())
|
||||
repeats.push_back(id);
|
||||
else
|
||||
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), GetName().c_str(), GetGUIDLow(), GetEntry(), uint32(id));
|
||||
}
|
||||
|
||||
CreatureTextRepeatIds Creature::GetTextRepeatGroup(uint8 textGroup)
|
||||
{
|
||||
CreatureTextRepeatIds ids;
|
||||
|
||||
CreatureTextRepeatGroup::const_iterator groupItr = m_textRepeat.find(textGroup);
|
||||
if (groupItr != m_textRepeat.end())
|
||||
ids = groupItr->second;
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
void Creature::ClearTextRepeatGroup(uint8 textGroup)
|
||||
{
|
||||
CreatureTextRepeatGroup::iterator groupItr = m_textRepeat.find(textGroup);
|
||||
if (groupItr != m_textRepeat.end())
|
||||
groupItr->second.clear();
|
||||
}
|
||||
@@ -134,7 +134,6 @@ struct CreatureTemplate
|
||||
float ModDamage;
|
||||
float ModExperience;
|
||||
bool RacialLeader;
|
||||
uint32 questItems[MAX_CREATURE_QUEST_ITEMS];
|
||||
uint32 movementId;
|
||||
bool RegenHealth;
|
||||
uint32 MechanicImmuneMask;
|
||||
@@ -171,15 +170,13 @@ struct CreatureTemplate
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<uint32> CreatureQuestItemList;
|
||||
typedef std::unordered_map<uint32, CreatureQuestItemList> CreatureQuestItemMap;
|
||||
|
||||
// Benchmarked: Faster than std::map (insert/find)
|
||||
typedef std::unordered_map<uint32, CreatureTemplate> CreatureTemplateContainer;
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#pragma pack(push, 1)
|
||||
#endif
|
||||
|
||||
// Defines base stats for creatures (used to calculate HP/mana/armor/attackpower/rangedattackpower/all damage).
|
||||
struct CreatureBaseStats
|
||||
@@ -314,12 +311,7 @@ enum ChatType
|
||||
CHAT_TYPE_END = 255
|
||||
};
|
||||
|
||||
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
// `creature_addon` table
|
||||
struct CreatureAddon
|
||||
@@ -422,13 +414,15 @@ struct TrainerSpellData
|
||||
TrainerSpell const* Find(uint32 spell_id) const;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, time_t> CreatureSpellCooldowns;
|
||||
|
||||
// max different by z coordinate for creature aggro reaction
|
||||
#define CREATURE_Z_ATTACK_RANGE 3
|
||||
|
||||
#define MAX_VENDOR_ITEMS 150 // Limitation in 4.x.x item count in SMSG_LIST_INVENTORY
|
||||
|
||||
//used for handling non-repeatable random texts
|
||||
typedef std::vector<uint8> CreatureTextRepeatIds;
|
||||
typedef std::unordered_map<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup;
|
||||
|
||||
class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
{
|
||||
public:
|
||||
@@ -498,7 +492,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
bool HasSpellCooldown(uint32 spell_id) const;
|
||||
bool HasCategoryCooldown(uint32 spell_id) const;
|
||||
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const;
|
||||
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
// virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
|
||||
bool HasSpell(uint32 spellID) const override;
|
||||
|
||||
@@ -573,8 +567,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
SpellInfo const* reachWithSpellCure(Unit* victim);
|
||||
|
||||
uint32 m_spells[CREATURE_MAX_SPELLS];
|
||||
CreatureSpellCooldowns m_CreatureSpellCooldowns;
|
||||
CreatureSpellCooldowns m_CreatureCategoryCooldowns;
|
||||
//CreatureSpellCooldowns m_CreatureSpellCooldowns;
|
||||
//CreatureSpellCooldowns m_CreatureCategoryCooldowns;
|
||||
|
||||
bool CanStartAttack(Unit const* u, bool force) const;
|
||||
float GetAttackDistance(Unit const* player) const;
|
||||
@@ -676,6 +670,10 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
|
||||
void ReleaseFocus(Spell const* focusSpell);
|
||||
|
||||
CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup);
|
||||
void SetTextRepeatId(uint8 textGroup, uint8 id);
|
||||
void ClearTextRepeatGroup(uint8 textGroup);
|
||||
|
||||
protected:
|
||||
bool CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0);
|
||||
bool InitEntry(uint32 entry, CreatureData const* data = nullptr);
|
||||
@@ -729,6 +727,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
|
||||
private:
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0);
|
||||
bool CheckNoGrayAggroConfig(uint32 playerLevel, uint32 creatureLevel) const; // No aggro from gray creatures
|
||||
|
||||
//WaypointMovementGenerator vars
|
||||
uint32 m_waypointID;
|
||||
@@ -739,6 +738,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
|
||||
bool TriggerJustRespawned;
|
||||
|
||||
Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
|
||||
|
||||
CreatureTextRepeatGroup m_textRepeat;
|
||||
};
|
||||
|
||||
class AssistDelayEvent : public BasicEvent
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "Opcodes.h"
|
||||
#include "World.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Transport.h"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "Battleground.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CreatureAISelector.h"
|
||||
#include "DynamicTree.h"
|
||||
#include "GameObjectModel.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
@@ -33,7 +32,6 @@
|
||||
#include "UpdateFieldFlags.h"
|
||||
#include "World.h"
|
||||
#include "Transport.h"
|
||||
#include <G3D/Quat.h>
|
||||
|
||||
GameObject::GameObject() : WorldObject(false), MapObject(),
|
||||
m_model(NULL), m_goValue(), m_AI(NULL)
|
||||
@@ -192,6 +190,12 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 /*phase
|
||||
return false;
|
||||
}
|
||||
|
||||
if (goinfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Gameobject (GUID: %u Entry: %u) not created: gameobject type GAMEOBJECT_TYPE_MO_TRANSPORT cannot be manually created.", guidlow, name_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT)
|
||||
m_updateFlag |= UPDATEFLAG_TRANSPORT;
|
||||
|
||||
@@ -285,6 +289,16 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 /*phase
|
||||
SetGoAnimProgress(animprogress);
|
||||
break;
|
||||
}
|
||||
|
||||
if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(guidlow))
|
||||
{
|
||||
if (addon->InvisibilityValue)
|
||||
{
|
||||
m_invisibility.AddFlag(addon->invisibilityType);
|
||||
m_invisibility.AddValue(addon->invisibilityType, addon->InvisibilityValue);
|
||||
}
|
||||
}
|
||||
|
||||
LastUsedScriptID = GetGOInfo()->ScriptId;
|
||||
AIM_Initialize();
|
||||
|
||||
@@ -1783,6 +1797,9 @@ void GameObject::Use(Unit* user)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player* player = user->ToPlayer())
|
||||
sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
|
||||
|
||||
if (spellCaster)
|
||||
spellCaster->CastSpell(user, spellInfo, triggered);
|
||||
else
|
||||
@@ -2293,8 +2310,11 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
|
||||
}
|
||||
case GAMEOBJECT_TYPE_MO_TRANSPORT:
|
||||
{
|
||||
float timer = float(m_goValue.Transport.PathProgress % GetUInt32Value(GAMEOBJECT_LEVEL));
|
||||
pathProgress = int16(timer / float(GetUInt32Value(GAMEOBJECT_LEVEL)) * 65535.0f);
|
||||
if (uint32 transportPeriod = GetTransportPeriod())
|
||||
{
|
||||
float timer = float(m_goValue.Transport.PathProgress % transportPeriod);
|
||||
pathProgress = int16(timer / float(transportPeriod) * 65535.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -2391,7 +2411,7 @@ void GameObject::UpdateModelPosition()
|
||||
if (GetMap()->ContainsGameObjectModel(*m_model))
|
||||
{
|
||||
GetMap()->RemoveGameObjectModel(*m_model);
|
||||
m_model->Relocate(*this);
|
||||
m_model->UpdatePosition();
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ struct GameObjectTemplate
|
||||
uint32 faction;
|
||||
uint32 flags;
|
||||
float size;
|
||||
uint32 questItems[MAX_GAMEOBJECT_QUEST_ITEMS];
|
||||
int32 unkInt32;
|
||||
union // different GO types have different data field
|
||||
{
|
||||
@@ -585,6 +584,15 @@ struct GameObjectLocale
|
||||
StringVector CastBarCaption;
|
||||
};
|
||||
|
||||
// `gameobject_addon` table
|
||||
struct GameObjectAddon
|
||||
{
|
||||
InvisibilityType invisibilityType;
|
||||
uint32 InvisibilityValue;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<ObjectGuid::LowType, GameObjectAddon> GameObjectAddonContainer;
|
||||
|
||||
// client side GO show states
|
||||
enum GOState
|
||||
{
|
||||
@@ -625,6 +633,9 @@ struct GameObjectData
|
||||
bool dbData;
|
||||
};
|
||||
|
||||
typedef std::vector<uint32> GameObjectQuestItemList;
|
||||
typedef std::unordered_map<uint32, GameObjectQuestItemList> GameObjectQuestItemMap;
|
||||
|
||||
// For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
|
||||
// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
|
||||
// For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
|
||||
@@ -731,7 +742,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
|
||||
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
|
||||
GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
|
||||
void SetGoState(GOState state);
|
||||
uint32 GetTransportPeriod() const;
|
||||
virtual uint32 GetTransportPeriod() const;
|
||||
void SetTransportState(GOState state, uint32 stopFrame = 0);
|
||||
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
|
||||
void SetGoArtKit(uint8 artkit);
|
||||
|
||||
@@ -208,8 +208,6 @@ enum ItemUpdateState
|
||||
ITEM_REMOVED = 3
|
||||
};
|
||||
|
||||
#define MAX_ITEM_SPELLS 5
|
||||
|
||||
bool ItemCanGoIntoBag(ItemTemplate const* proto, ItemTemplate const* pBagProto);
|
||||
|
||||
class Item : public Object
|
||||
|
||||
@@ -675,6 +675,7 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
|
||||
|
||||
uint32* flags = NULL;
|
||||
uint32 visibleFlag = GetUpdateFieldData(target, flags);
|
||||
ASSERT(flags);
|
||||
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
@@ -785,7 +786,7 @@ void Object::_LoadIntoDataField(std::string const& data, uint32 startOffset, uin
|
||||
|
||||
for (uint32 index = 0; index < count; ++index)
|
||||
{
|
||||
m_uint32Values[startOffset + index] = atol(tokens[index]);
|
||||
m_uint32Values[startOffset + index] = atoul(tokens[index]);
|
||||
_changesMask.SetBit(startOffset + index);
|
||||
}
|
||||
}
|
||||
@@ -1193,94 +1194,39 @@ bool Object::PrintIndexError(uint32 index, bool set) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Position::operator==(Position const &a)
|
||||
{
|
||||
return (G3D::fuzzyEq(a.m_positionX, m_positionX) &&
|
||||
G3D::fuzzyEq(a.m_positionY, m_positionY) &&
|
||||
G3D::fuzzyEq(a.m_positionZ, m_positionZ) &&
|
||||
G3D::fuzzyEq(a.m_orientation, m_orientation));
|
||||
}
|
||||
|
||||
bool Position::HasInLine(WorldObject const* target, float width) const
|
||||
{
|
||||
if (!HasInArc(float(M_PI), target))
|
||||
return false;
|
||||
width += target->GetObjectSize();
|
||||
float angle = GetRelativeAngle(target);
|
||||
return std::fabs(std::sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
|
||||
}
|
||||
|
||||
std::string Position::ToString() const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << m_orientation;
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
|
||||
{
|
||||
float x, y, z, o;
|
||||
buf >> x >> y >> z >> o;
|
||||
streamer.m_pos->Relocate(x, y, z, o);
|
||||
return buf;
|
||||
}
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
|
||||
{
|
||||
float x, y, z;
|
||||
streamer.m_pos->GetPosition(x, y, z);
|
||||
buf << x << y << z;
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
|
||||
{
|
||||
float x, y, z;
|
||||
buf >> x >> y >> z;
|
||||
streamer.m_pos->Relocate(x, y, z);
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
|
||||
{
|
||||
float x, y, z, o;
|
||||
streamer.m_pos->GetPosition(x, y, z, o);
|
||||
buf << x << y << z << o;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void MovementInfo::OutDebug()
|
||||
{
|
||||
TC_LOG_INFO("misc", "MOVEMENT INFO");
|
||||
TC_LOG_INFO("misc", "%s", guid.ToString().c_str());
|
||||
TC_LOG_INFO("misc", "flags %s (%u)", Movement::MovementFlags_ToString(flags).c_str(), flags);
|
||||
TC_LOG_INFO("misc", "flags2 %s (%u)", Movement::MovementFlagsExtra_ToString(flags2).c_str(), flags2);
|
||||
TC_LOG_INFO("misc", "time %u current time %u", time, getMSTime());
|
||||
TC_LOG_INFO("misc", "position: `%s`", pos.ToString().c_str());
|
||||
TC_LOG_DEBUG("misc", "MOVEMENT INFO");
|
||||
TC_LOG_DEBUG("misc", "%s", guid.ToString().c_str());
|
||||
TC_LOG_DEBUG("misc", "flags %u", flags);
|
||||
TC_LOG_DEBUG("misc", "flags2 %u", flags2);
|
||||
TC_LOG_DEBUG("misc", "time %u current time " UI64FMTD "", flags2, uint64(::time(NULL)));
|
||||
TC_LOG_DEBUG("misc", "position: `%s`", pos.ToString().c_str());
|
||||
if (transport.guid)
|
||||
{
|
||||
TC_LOG_INFO("misc", "TRANSPORT:");
|
||||
TC_LOG_INFO("misc", "%s", transport.guid.ToString().c_str());
|
||||
TC_LOG_INFO("misc", "position: `%s`", transport.pos.ToString().c_str());
|
||||
TC_LOG_INFO("misc", "seat: %i", transport.seat);
|
||||
TC_LOG_INFO("misc", "time: %u", transport.time);
|
||||
TC_LOG_DEBUG("misc", "TRANSPORT:");
|
||||
TC_LOG_DEBUG("misc", "%s", transport.guid.ToString().c_str());
|
||||
TC_LOG_DEBUG("misc", "position: `%s`", transport.pos.ToString().c_str());
|
||||
TC_LOG_DEBUG("misc", "seat: %i", transport.seat);
|
||||
TC_LOG_DEBUG("misc", "time: %u", transport.time);
|
||||
if (flags2 & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT)
|
||||
TC_LOG_INFO("misc", "time2: %u", transport.time2);
|
||||
TC_LOG_DEBUG("misc", "time2: %u", transport.time2);
|
||||
if (transport.vehicleId)
|
||||
TC_LOG_INFO("misc", "vehicleId: %u", transport.vehicleId);
|
||||
}
|
||||
|
||||
if ((flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
|
||||
TC_LOG_INFO("misc", "pitch: %f", pitch);
|
||||
TC_LOG_DEBUG("misc", "pitch: %f", pitch);
|
||||
|
||||
if (flags & MOVEMENTFLAG_FALLING || jump.fallTime)
|
||||
{
|
||||
TC_LOG_INFO("misc", "fallTime: %u j_zspeed: %f", jump.fallTime, jump.zspeed);
|
||||
if (flags & MOVEMENTFLAG_FALLING)
|
||||
TC_LOG_INFO("misc", "j_sinAngle: %f j_cosAngle: %f j_xyspeed: %f", jump.sinAngle, jump.cosAngle, jump.xyspeed);
|
||||
TC_LOG_DEBUG("misc", "j_zspeed: %f j_sinAngle: %f j_cosAngle: %f j_xyspeed: %f", jump.zspeed, jump.sinAngle, jump.cosAngle, jump.xyspeed);
|
||||
}
|
||||
|
||||
if (flags & MOVEMENTFLAG_SPLINE_ELEVATION)
|
||||
TC_LOG_INFO("misc", "splineElevation: %f", splineElevation);
|
||||
TC_LOG_DEBUG("misc", "splineElevation: %f", splineElevation);
|
||||
}
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(), LastUsedScriptID(0),
|
||||
@@ -1613,85 +1559,6 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
void Position::RelocateOffset(const Position & offset)
|
||||
{
|
||||
m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI)));
|
||||
m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation()));
|
||||
m_positionZ = GetPositionZ() + offset.GetPositionZ();
|
||||
SetOrientation(GetOrientation() + offset.GetOrientation());
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
float dy = endPos.GetPositionY() - GetPositionY();
|
||||
|
||||
retOffset.m_positionX = dx * std::cos(GetOrientation()) + dy * std::sin(GetOrientation());
|
||||
retOffset.m_positionY = dy * std::cos(GetOrientation()) - dx * std::sin(GetOrientation());
|
||||
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
|
||||
retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
|
||||
}
|
||||
|
||||
float Position::GetAngle(const Position* obj) const
|
||||
{
|
||||
if (!obj)
|
||||
return 0;
|
||||
|
||||
return GetAngle(obj->GetPositionX(), obj->GetPositionY());
|
||||
}
|
||||
|
||||
// Return angle in range 0..2*pi
|
||||
float Position::GetAngle(const float x, const float y) const
|
||||
{
|
||||
float dx = x - GetPositionX();
|
||||
float dy = y - GetPositionY();
|
||||
|
||||
float ang = std::atan2(dy, dx);
|
||||
ang = (ang >= 0) ? ang : 2 * float(M_PI) + ang;
|
||||
return ang;
|
||||
}
|
||||
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
|
||||
if (std::fabs(dx) < 0.001f && std::fabs(dy) < 0.001f)
|
||||
{
|
||||
float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
|
||||
vcos = std::cos(angle);
|
||||
vsin = std::sin(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dist = std::sqrt((dx*dx) + (dy*dy));
|
||||
vcos = dx / dist;
|
||||
vsin = dy / dist;
|
||||
}
|
||||
}
|
||||
|
||||
bool Position::HasInArc(float arc, const Position* obj, float border) const
|
||||
{
|
||||
// always have self in arc
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
// move arc to range 0.. 2*pi
|
||||
arc = NormalizeOrientation(arc);
|
||||
|
||||
float angle = GetAngle(obj);
|
||||
angle -= m_orientation;
|
||||
|
||||
// move angle to range -pi ... +pi
|
||||
angle = NormalizeOrientation(angle);
|
||||
if (angle > float(M_PI))
|
||||
angle -= 2.0f * float(M_PI);
|
||||
|
||||
float lborder = -1 * (arc/border); // in range -pi..0
|
||||
float rborder = (arc/border); // in range 0..pi
|
||||
return ((angle >= lborder) && (angle <= rborder));
|
||||
}
|
||||
|
||||
bool WorldObject::IsInBetween(const WorldObject* obj1, const WorldObject* obj2, float size) const
|
||||
{
|
||||
if (!obj1 || !obj2)
|
||||
@@ -1825,11 +1692,6 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Position::IsPositionValid() const
|
||||
{
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
float WorldObject::GetGridActivationRange() const
|
||||
{
|
||||
if (ToPlayer())
|
||||
@@ -2418,6 +2280,13 @@ void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureL
|
||||
cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
|
||||
}
|
||||
|
||||
void WorldObject::GetPlayerListInGrid(std::list<Player*>& playerList, float maxSearchRange) const
|
||||
{
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
|
||||
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerList, checker);
|
||||
this->VisitNearbyWorldObject(maxSearchRange, searcher);
|
||||
}
|
||||
|
||||
/*
|
||||
namespace Trinity
|
||||
{
|
||||
@@ -2914,7 +2783,7 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
if (!player->HaveAtClient(this))
|
||||
continue;
|
||||
|
||||
if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) /// @todo this is for puppet
|
||||
if (isType(TYPEMASK_UNIT) && ToUnit()->GetCharmerGUID() == player->GetGUID()) /// @todo this is for puppet
|
||||
continue;
|
||||
|
||||
DestroyForPlayer(player);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define _OBJECT_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "Position.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "GridReference.h"
|
||||
#include "ObjectDefines.h"
|
||||
@@ -250,140 +251,6 @@ class Object
|
||||
Object& operator=(Object const& right) = delete;
|
||||
};
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position(float x = 0, float y = 0, float z = 0, float o = 0)
|
||||
: m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientation(o)) { }
|
||||
|
||||
Position(const Position &loc) { Relocate(loc); }
|
||||
|
||||
struct PositionXYZStreamer
|
||||
{
|
||||
explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) { }
|
||||
Position* m_pos;
|
||||
};
|
||||
|
||||
struct PositionXYZOStreamer
|
||||
{
|
||||
explicit PositionXYZOStreamer(Position& pos) : m_pos(&pos) { }
|
||||
Position* m_pos;
|
||||
};
|
||||
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
// Better to limit access to m_orientation field, but this will be hard to achieve with many scripts using array initialization for this structure
|
||||
//private:
|
||||
float m_orientation;
|
||||
//public:
|
||||
|
||||
bool operator==(Position const &a);
|
||||
|
||||
inline bool operator!=(Position const &a)
|
||||
{
|
||||
return !(operator==(a));
|
||||
}
|
||||
|
||||
void Relocate(float x, float y)
|
||||
{ m_positionX = x; m_positionY = y;}
|
||||
void Relocate(float x, float y, float z)
|
||||
{ m_positionX = x; m_positionY = y; m_positionZ = z; }
|
||||
void Relocate(float x, float y, float z, float orientation)
|
||||
{ m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); }
|
||||
void Relocate(Position const &pos)
|
||||
{ m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); }
|
||||
void Relocate(Position const* pos)
|
||||
{ m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); }
|
||||
void RelocateOffset(Position const &offset);
|
||||
void SetOrientation(float orientation)
|
||||
{ m_orientation = NormalizeOrientation(orientation); }
|
||||
|
||||
float GetPositionX() const { return m_positionX; }
|
||||
float GetPositionY() const { return m_positionY; }
|
||||
float GetPositionZ() const { return m_positionZ; }
|
||||
float GetOrientation() const { return m_orientation; }
|
||||
|
||||
void GetPosition(float &x, float &y) const
|
||||
{ x = m_positionX; y = m_positionY; }
|
||||
void GetPosition(float &x, float &y, float &z) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
|
||||
void GetPosition(float &x, float &y, float &z, float &o) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; }
|
||||
|
||||
Position GetPosition() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
Position::PositionXYZStreamer PositionXYZStream()
|
||||
{
|
||||
return PositionXYZStreamer(*this);
|
||||
}
|
||||
Position::PositionXYZOStreamer PositionXYZOStream()
|
||||
{
|
||||
return PositionXYZOStreamer(*this);
|
||||
}
|
||||
|
||||
bool IsPositionValid() const;
|
||||
|
||||
float GetExactDist2dSq(float x, float y) const
|
||||
{ float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; }
|
||||
float GetExactDist2d(const float x, const float y) const
|
||||
{ return std::sqrt(GetExactDist2dSq(x, y)); }
|
||||
float GetExactDist2dSq(Position const* pos) const
|
||||
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; }
|
||||
float GetExactDist2d(Position const* pos) const
|
||||
{ return std::sqrt(GetExactDist2dSq(pos)); }
|
||||
float GetExactDistSq(float x, float y, float z) const
|
||||
{ float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; }
|
||||
float GetExactDist(float x, float y, float z) const
|
||||
{ return std::sqrt(GetExactDistSq(x, y, z)); }
|
||||
float GetExactDistSq(Position const* pos) const
|
||||
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; }
|
||||
float GetExactDist(Position const* pos) const
|
||||
{ return std::sqrt(GetExactDistSq(pos)); }
|
||||
|
||||
void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
|
||||
|
||||
float GetAngle(Position const* pos) const;
|
||||
float GetAngle(float x, float y) const;
|
||||
float GetRelativeAngle(Position const* pos) const
|
||||
{ return GetAngle(pos) - m_orientation; }
|
||||
float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; }
|
||||
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
|
||||
|
||||
bool IsInDist2d(float x, float y, float dist) const
|
||||
{ return GetExactDist2dSq(x, y) < dist * dist; }
|
||||
bool IsInDist2d(Position const* pos, float dist) const
|
||||
{ return GetExactDist2dSq(pos) < dist * dist; }
|
||||
bool IsInDist(float x, float y, float z, float dist) const
|
||||
{ return GetExactDistSq(x, y, z) < dist * dist; }
|
||||
bool IsInDist(Position const* pos, float dist) const
|
||||
{ return GetExactDistSq(pos) < dist * dist; }
|
||||
bool HasInArc(float arcangle, Position const* pos, float border = 2.0f) const;
|
||||
bool HasInLine(WorldObject const* target, float width) const;
|
||||
std::string ToString() const;
|
||||
|
||||
// modulos a radian orientation to the range of 0..2PI
|
||||
static float NormalizeOrientation(float o)
|
||||
{
|
||||
// fmod only supports positive numbers. Thus we have
|
||||
// to emulate negative numbers
|
||||
if (o < 0)
|
||||
{
|
||||
float mod = o *-1;
|
||||
mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = -mod + 2.0f * static_cast<float>(M_PI);
|
||||
return mod;
|
||||
}
|
||||
return std::fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
}
|
||||
};
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
|
||||
|
||||
struct MovementInfo
|
||||
{
|
||||
// common
|
||||
@@ -476,12 +343,23 @@ struct MovementInfo
|
||||
class WorldLocation : public Position
|
||||
{
|
||||
public:
|
||||
explicit WorldLocation(uint32 _mapid = MAPID_INVALID, float _x = 0, float _y = 0, float _z = 0, float _o = 0)
|
||||
: m_mapId(_mapid) { Relocate(_x, _y, _z, _o); }
|
||||
WorldLocation(const WorldLocation &loc) : Position(loc) { WorldRelocate(loc); }
|
||||
explicit WorldLocation(uint32 _mapId = MAPID_INVALID, float _x = 0.f, float _y = 0.f, float _z = 0.f, float _o = 0.f)
|
||||
: Position(_x, _y, _z, _o), m_mapId(_mapId) { }
|
||||
|
||||
void WorldRelocate(const WorldLocation &loc)
|
||||
{ m_mapId = loc.GetMapId(); Relocate(loc); }
|
||||
WorldLocation(WorldLocation const& loc)
|
||||
: Position(loc), m_mapId(loc.GetMapId()) { }
|
||||
|
||||
void WorldRelocate(WorldLocation const& loc)
|
||||
{
|
||||
m_mapId = loc.GetMapId();
|
||||
Relocate(loc);
|
||||
}
|
||||
|
||||
void WorldRelocate(uint32 _mapId = MAPID_INVALID, float _x = 0.f, float _y = 0.f, float _z = 0.f, float _o = 0.f)
|
||||
{
|
||||
m_mapId = _mapId;
|
||||
Relocate(_x, _y, _z, _o);
|
||||
}
|
||||
|
||||
WorldLocation GetWorldLocation() const
|
||||
{
|
||||
@@ -705,6 +583,7 @@ class WorldObject : public Object, public WorldLocation
|
||||
|
||||
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
|
||||
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
|
||||
void GetPlayerListInGrid(std::list<Player*>& lList, float fMaxSearchRange) const;
|
||||
|
||||
void DestroyForNearbyPlayers();
|
||||
virtual void UpdateObjectVisibility(bool forced = true);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "ObjectGuid.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
#include <functional>
|
||||
#include <unordered_set>
|
||||
|
||||
enum TypeID
|
||||
{
|
||||
@@ -87,8 +88,10 @@ class ObjectGuid
|
||||
public:
|
||||
static ObjectGuid const Empty;
|
||||
|
||||
typedef uint32 LowType;
|
||||
|
||||
ObjectGuid() { _data._guid = UI64LIT(0); }
|
||||
explicit ObjectGuid(uint64 guid) { _data._guid = guid; }
|
||||
explicit ObjectGuid(uint64 guid) { _data._guid = guid; }
|
||||
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) { _data._guid = counter ? uint64(counter) | (uint64(entry) << 32) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
|
||||
ObjectGuid(HighGuid hi, uint32 counter) { _data._guid = counter ? uint64(counter) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
|
||||
|
||||
@@ -101,36 +104,24 @@ class ObjectGuid
|
||||
PackedGuid WriteAsPacked() const;
|
||||
|
||||
uint64 GetRawValue() const { return _data._guid; }
|
||||
HighGuid GetHigh() const
|
||||
HighGuid GetHigh() const { return HighGuid((_data._guid >> 48) & 0x0000FFFF); }
|
||||
uint32 GetEntry() const { return HasEntry() ? uint32((_data._guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0; }
|
||||
LowType GetCounter() const
|
||||
{
|
||||
uint32 temp = ((uint64(_data._guid) >> 48) & 0x0000FFFF);
|
||||
return HighGuid((temp == HIGHGUID_CORPSE || temp == HIGHGUID_AREATRIGGER) ? temp : ((temp >> 4) & 0x00000FFF));
|
||||
}
|
||||
uint32 GetEntry() const { return HasEntry() ? uint32((_data._guid >> 32) & UI64LIT(0x00000000000FFFFF)) : 0; }
|
||||
uint32 GetCounter() const
|
||||
{
|
||||
return uint32(_data._guid & UI64LIT(0x00000000FFFFFFFF));
|
||||
return HasEntry()
|
||||
? LowType(_data._guid & UI64LIT(0x0000000000FFFFFF))
|
||||
: LowType(_data._guid & UI64LIT(0x00000000FFFFFFFF));
|
||||
}
|
||||
|
||||
static uint32 GetMaxCounter(HighGuid /*high*/)
|
||||
static uint32 GetMaxCounter(HighGuid high)
|
||||
{
|
||||
return uint32(0xFFFFFFFF);
|
||||
return HasEntry(high)
|
||||
? uint32(0x00FFFFFF)
|
||||
: uint32(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
|
||||
|
||||
uint8& operator[](uint32 index)
|
||||
{
|
||||
ASSERT(index < sizeof(uint64));
|
||||
return _data._bytes[index];
|
||||
}
|
||||
|
||||
uint8 const& operator[](uint32 index) const
|
||||
{
|
||||
ASSERT(index < sizeof(uint64));
|
||||
return _data._bytes[index];
|
||||
}
|
||||
|
||||
bool IsEmpty() const { return _data._guid == 0; }
|
||||
bool IsCreature() const { return GetHigh() == HIGHGUID_UNIT; }
|
||||
bool IsPet() const { return GetHigh() == HIGHGUID_PET; }
|
||||
@@ -183,6 +174,17 @@ class ObjectGuid
|
||||
bool operator== (ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); }
|
||||
bool operator!= (ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); }
|
||||
bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
|
||||
uint8& operator[] (uint32 index)
|
||||
{
|
||||
ASSERT(index < sizeof(uint64));
|
||||
return _data._bytes[index];
|
||||
}
|
||||
|
||||
uint8 const& operator[](uint32 index) const
|
||||
{
|
||||
ASSERT(index < sizeof(uint64));
|
||||
return _data._bytes[index];
|
||||
}
|
||||
|
||||
static char const* GetTypeName(HighGuid high);
|
||||
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
|
||||
@@ -229,6 +231,7 @@ typedef std::set<ObjectGuid> GuidSet;
|
||||
typedef std::list<ObjectGuid> GuidList;
|
||||
typedef std::deque<ObjectGuid> GuidDeque;
|
||||
typedef std::vector<ObjectGuid> GuidVector;
|
||||
typedef std::unordered_set<ObjectGuid> GuidUnorderedSet;
|
||||
|
||||
// minimum buffer size for packed guid is 9 bytes
|
||||
#define PACKED_GUID_MIN_BUFFER_SIZE 9
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Position.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "G3D/g3dmath.h"
|
||||
#include "GridDefines.h"
|
||||
|
||||
bool Position::operator==(Position const &a)
|
||||
{
|
||||
return (G3D::fuzzyEq(a.m_positionX, m_positionX) &&
|
||||
G3D::fuzzyEq(a.m_positionY, m_positionY) &&
|
||||
G3D::fuzzyEq(a.m_positionZ, m_positionZ) &&
|
||||
G3D::fuzzyEq(a.m_orientation, m_orientation));
|
||||
}
|
||||
|
||||
void Position::RelocateOffset(const Position & offset)
|
||||
{
|
||||
m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI)));
|
||||
m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation()));
|
||||
m_positionZ = GetPositionZ() + offset.GetPositionZ();
|
||||
SetOrientation(GetOrientation() + offset.GetOrientation());
|
||||
}
|
||||
|
||||
bool Position::IsPositionValid() const
|
||||
{
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
float dy = endPos.GetPositionY() - GetPositionY();
|
||||
|
||||
retOffset.m_positionX = dx * std::cos(GetOrientation()) + dy * std::sin(GetOrientation());
|
||||
retOffset.m_positionY = dy * std::cos(GetOrientation()) - dx * std::sin(GetOrientation());
|
||||
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
|
||||
retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
|
||||
}
|
||||
|
||||
Position Position::GetPositionWithOffset(Position const& offset) const
|
||||
{
|
||||
Position ret(*this);
|
||||
ret.RelocateOffset(offset);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float Position::GetAngle(const Position* obj) const
|
||||
{
|
||||
if (!obj)
|
||||
return 0;
|
||||
|
||||
return GetAngle(obj->GetPositionX(), obj->GetPositionY());
|
||||
}
|
||||
|
||||
// Return angle in range 0..2*pi
|
||||
float Position::GetAngle(float x, float y) const
|
||||
{
|
||||
float dx = x - GetPositionX();
|
||||
float dy = y - GetPositionY();
|
||||
|
||||
float ang = std::atan2(dy, dx);
|
||||
ang = (ang >= 0) ? ang : 2 * float(M_PI) + ang;
|
||||
return ang;
|
||||
}
|
||||
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
|
||||
if (std::fabs(dx) < 0.001f && std::fabs(dy) < 0.001f)
|
||||
{
|
||||
float angle = (float)rand_norm()*static_cast<float>(2 * M_PI);
|
||||
vcos = std::cos(angle);
|
||||
vsin = std::sin(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dist = std::sqrt((dx*dx) + (dy*dy));
|
||||
vcos = dx / dist;
|
||||
vsin = dy / dist;
|
||||
}
|
||||
}
|
||||
|
||||
bool Position::HasInArc(float arc, const Position* obj, float border) const
|
||||
{
|
||||
// always have self in arc
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
// move arc to range 0.. 2*pi
|
||||
arc = NormalizeOrientation(arc);
|
||||
|
||||
float angle = GetAngle(obj);
|
||||
angle -= m_orientation;
|
||||
|
||||
// move angle to range -pi ... +pi
|
||||
angle = NormalizeOrientation(angle);
|
||||
if (angle > float(M_PI))
|
||||
angle -= 2.0f * float(M_PI);
|
||||
|
||||
float lborder = -1 * (arc / border); // in range -pi..0
|
||||
float rborder = (arc / border); // in range 0..pi
|
||||
return ((angle >= lborder) && (angle <= rborder));
|
||||
}
|
||||
|
||||
bool Position::HasInLine(Position const* pos, float width) const
|
||||
{
|
||||
if (!HasInArc(float(M_PI), pos))
|
||||
return false;
|
||||
|
||||
float angle = GetRelativeAngle(pos);
|
||||
return std::fabs(std::sin(angle)) * GetExactDist2d(pos->GetPositionX(), pos->GetPositionY()) < width;
|
||||
}
|
||||
|
||||
std::string Position::ToString() const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << m_orientation;
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYStreamer const& streamer)
|
||||
{
|
||||
buf << streamer.Pos->GetPositionX();
|
||||
buf << streamer.Pos->GetPositionY();
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYStreamer const& streamer)
|
||||
{
|
||||
float x, y;
|
||||
buf >> x >> y;
|
||||
streamer.Pos->Relocate(x, y);
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
|
||||
{
|
||||
buf << streamer.Pos->GetPositionX();
|
||||
buf << streamer.Pos->GetPositionY();
|
||||
buf << streamer.Pos->GetPositionZ();
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
|
||||
{
|
||||
float x, y, z;
|
||||
buf >> x >> y >> z;
|
||||
streamer.Pos->Relocate(x, y, z);
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
|
||||
{
|
||||
buf << streamer.Pos->GetPositionX();
|
||||
buf << streamer.Pos->GetPositionY();
|
||||
buf << streamer.Pos->GetPositionZ();
|
||||
buf << streamer.Pos->GetOrientation();
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
|
||||
{
|
||||
float x, y, z, o;
|
||||
buf >> x >> y >> z >> o;
|
||||
streamer.Pos->Relocate(x, y, z, o);
|
||||
return buf;
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Trinity_game_Position_h__
|
||||
#define Trinity_game_Position_h__
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class ByteBuffer;
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position(float x = 0, float y = 0, float z = 0, float o = 0)
|
||||
: m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientation(o)) { }
|
||||
|
||||
Position(Position const& loc) { Relocate(loc); }
|
||||
|
||||
struct PositionXYStreamer
|
||||
{
|
||||
explicit PositionXYStreamer(Position& pos) : Pos(&pos) { }
|
||||
Position* Pos;
|
||||
};
|
||||
|
||||
struct PositionXYZStreamer
|
||||
{
|
||||
explicit PositionXYZStreamer(Position& pos) : Pos(&pos) { }
|
||||
Position* Pos;
|
||||
};
|
||||
|
||||
struct PositionXYZOStreamer
|
||||
{
|
||||
explicit PositionXYZOStreamer(Position& pos) : Pos(&pos) { }
|
||||
Position* Pos;
|
||||
};
|
||||
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
// Better to limit access to _orientation field, to guarantee the value is normalized
|
||||
private:
|
||||
float m_orientation;
|
||||
|
||||
public:
|
||||
bool operator==(Position const &a);
|
||||
|
||||
inline bool operator!=(Position const &a)
|
||||
{
|
||||
return !(operator==(a));
|
||||
}
|
||||
|
||||
void Relocate(float x, float y)
|
||||
{
|
||||
m_positionX = x; m_positionY = y;
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z)
|
||||
{
|
||||
m_positionX = x; m_positionY = y; m_positionZ = z;
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z, float orientation)
|
||||
{
|
||||
m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation);
|
||||
}
|
||||
|
||||
void Relocate(Position const &pos)
|
||||
{
|
||||
m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation);
|
||||
}
|
||||
|
||||
void Relocate(Position const* pos)
|
||||
{
|
||||
m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation);
|
||||
}
|
||||
|
||||
void RelocateOffset(Position const &offset);
|
||||
|
||||
void SetOrientation(float orientation)
|
||||
{
|
||||
m_orientation = NormalizeOrientation(orientation);
|
||||
}
|
||||
|
||||
float GetPositionX() const { return m_positionX; }
|
||||
float GetPositionY() const { return m_positionY; }
|
||||
float GetPositionZ() const { return m_positionZ; }
|
||||
float GetOrientation() const { return m_orientation; }
|
||||
|
||||
void GetPosition(float &x, float &y) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY;
|
||||
}
|
||||
|
||||
void GetPosition(float &x, float &y, float &z) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY; z = m_positionZ;
|
||||
}
|
||||
|
||||
void GetPosition(float &x, float &y, float &z, float &o) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation;
|
||||
}
|
||||
|
||||
Position GetPosition() const { return *this; }
|
||||
|
||||
Position::PositionXYStreamer PositionXYStream() { return PositionXYStreamer(*this); }
|
||||
Position::PositionXYZStreamer PositionXYZStream() { return PositionXYZStreamer(*this); }
|
||||
Position::PositionXYZOStreamer PositionXYZOStream() { return PositionXYZOStreamer(*this); }
|
||||
|
||||
bool IsPositionValid() const;
|
||||
|
||||
float GetExactDist2dSq(float x, float y) const
|
||||
{
|
||||
float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
float GetExactDist2d(const float x, const float y) const
|
||||
{
|
||||
return std::sqrt(GetExactDist2dSq(x, y));
|
||||
}
|
||||
|
||||
float GetExactDist2dSq(Position const* pos) const
|
||||
{
|
||||
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
float GetExactDist2d(Position const* pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDist2dSq(pos));
|
||||
}
|
||||
|
||||
float GetExactDistSq(float x, float y, float z) const
|
||||
{
|
||||
float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz;
|
||||
}
|
||||
|
||||
float GetExactDist(float x, float y, float z) const
|
||||
{
|
||||
return std::sqrt(GetExactDistSq(x, y, z));
|
||||
}
|
||||
|
||||
float GetExactDistSq(Position const* pos) const
|
||||
{
|
||||
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
float GetExactDist(Position const* pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDistSq(pos));
|
||||
}
|
||||
|
||||
void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
|
||||
Position GetPositionWithOffset(Position const& offset) const;
|
||||
|
||||
float GetAngle(Position const* pos) const;
|
||||
float GetAngle(float x, float y) const;
|
||||
float GetRelativeAngle(Position const* pos) const
|
||||
{
|
||||
return GetAngle(pos) - m_orientation;
|
||||
}
|
||||
|
||||
float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; }
|
||||
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
|
||||
|
||||
bool IsInDist2d(float x, float y, float dist) const
|
||||
{
|
||||
return GetExactDist2dSq(x, y) < dist * dist;
|
||||
}
|
||||
|
||||
bool IsInDist2d(Position const* pos, float dist) const
|
||||
{
|
||||
return GetExactDist2dSq(pos) < dist * dist;
|
||||
}
|
||||
|
||||
bool IsInDist(float x, float y, float z, float dist) const
|
||||
{
|
||||
return GetExactDistSq(x, y, z) < dist * dist;
|
||||
}
|
||||
|
||||
bool IsInDist(Position const* pos, float dist) const
|
||||
{
|
||||
return GetExactDistSq(pos) < dist * dist;
|
||||
}
|
||||
|
||||
bool HasInArc(float arcangle, Position const* pos, float border = 2.0f) const;
|
||||
bool HasInLine(Position const* pos, float width) const;
|
||||
std::string ToString() const;
|
||||
|
||||
// modulos a radian orientation to the range of 0..2PI
|
||||
static float NormalizeOrientation(float o)
|
||||
{
|
||||
// fmod only supports positive numbers. Thus we have
|
||||
// to emulate negative numbers
|
||||
if (o < 0)
|
||||
{
|
||||
float mod = o *-1;
|
||||
mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = -mod + 2.0f * static_cast<float>(M_PI);
|
||||
return mod;
|
||||
}
|
||||
return std::fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
}
|
||||
};
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYStreamer const& streamer);
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYStreamer const& streamer);
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
|
||||
ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
|
||||
|
||||
#endif // Trinity_game_Position_h__
|
||||
@@ -24,9 +24,9 @@
|
||||
#include "SpellMgr.h"
|
||||
#include "Pet.h"
|
||||
#include "Formulas.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
#include "Group.h"
|
||||
@@ -410,7 +410,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||
RemoveAllAuras();
|
||||
|
||||
_SaveSpells(trans);
|
||||
_SaveSpellCooldowns(trans);
|
||||
GetSpellHistory()->SaveToDB<Pet>(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
// current/stable/not_in_slot
|
||||
@@ -1070,77 +1070,11 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const
|
||||
|
||||
void Pet::_LoadSpellCooldowns()
|
||||
{
|
||||
m_CreatureSpellCooldowns.clear();
|
||||
m_CreatureCategoryCooldowns.clear();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_COOLDOWN);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
PreparedQueryResult cooldownsResult = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
time_t curTime = time(NULL);
|
||||
|
||||
PacketCooldowns cooldowns;
|
||||
WorldPacket data;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 spell_id = fields[0].GetUInt32();
|
||||
time_t db_time = time_t(fields[1].GetUInt32());
|
||||
|
||||
if (!sSpellMgr->GetSpellInfo(spell_id))
|
||||
{
|
||||
TC_LOG_ERROR("entities.pet", "Pet %u have unknown spell %u in `pet_spell_cooldown`, skipping.", m_charmInfo->GetPetNumber(), spell_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip outdated cooldown
|
||||
if (db_time <= curTime)
|
||||
continue;
|
||||
|
||||
cooldowns[spell_id] = uint32(db_time - curTime)*IN_MILLISECONDS;
|
||||
|
||||
_AddCreatureSpellCooldown(spell_id, db_time);
|
||||
|
||||
TC_LOG_DEBUG("entities.pet", "Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime));
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
if (!cooldowns.empty())
|
||||
{
|
||||
BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, cooldowns);
|
||||
GetOwner()->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Pet::_SaveSpellCooldowns(SQLTransaction& trans)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_COOLDOWNS);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
time_t curTime = time(NULL);
|
||||
|
||||
// remove oudated and save active
|
||||
for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
|
||||
{
|
||||
if (itr->second <= curTime)
|
||||
m_CreatureSpellCooldowns.erase(itr++);
|
||||
else
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->setUInt32(2, uint32(itr->second));
|
||||
trans->Append(stmt);
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
GetSpellHistory()->LoadFromDB<Pet>(cooldownsResult);
|
||||
}
|
||||
|
||||
void Pet::_LoadSpells()
|
||||
@@ -1277,7 +1211,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
||||
}
|
||||
aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]);
|
||||
aura->ApplyForTargets();
|
||||
TC_LOG_INFO("entities.pet", "Added aura spellid %u, effectmask %u", spellInfo->Id, effmask);
|
||||
TC_LOG_DEBUG("entities.pet", "Added aura spellid %u, effectmask %u", spellInfo->Id, effmask);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
@@ -1990,40 +1924,6 @@ void Pet::SynchronizeLevelWithOwner()
|
||||
}
|
||||
}
|
||||
|
||||
void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs)
|
||||
{
|
||||
PacketCooldowns cooldowns;
|
||||
WorldPacket data;
|
||||
time_t curTime = time(NULL);
|
||||
for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
|
||||
{
|
||||
if (itr->second.state == PETSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
uint32 unSpellId = itr->first;
|
||||
SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(unSpellId);
|
||||
|
||||
// Not send cooldown for this spells
|
||||
if (spellInfo->IsCooldownStartedOnEvent())
|
||||
continue;
|
||||
|
||||
if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE)
|
||||
continue;
|
||||
|
||||
if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs)
|
||||
{
|
||||
cooldowns[unSpellId] = unTimeMs;
|
||||
_AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
if (!cooldowns.empty())
|
||||
{
|
||||
BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, cooldowns);
|
||||
GetOwner()->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
Player* Pet::GetOwner() const
|
||||
{
|
||||
return Minion::GetOwner()->ToPlayer();
|
||||
|
||||
@@ -106,7 +106,6 @@ class Pet : public Guardian
|
||||
bool IsPetAura(Aura const* aura);
|
||||
|
||||
void _LoadSpellCooldowns();
|
||||
void _SaveSpellCooldowns(SQLTransaction& trans);
|
||||
void _LoadAuras(uint32 timediff);
|
||||
void _SaveAuras(SQLTransaction& trans);
|
||||
void _LoadSpells();
|
||||
@@ -119,7 +118,6 @@ class Pet : public Guardian
|
||||
bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true);
|
||||
void CleanupActionBar();
|
||||
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
|
||||
PetSpellMap m_spells;
|
||||
AutoSpellList m_autospells;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -56,6 +56,8 @@ class PlayerSocial;
|
||||
class SpellCastTargets;
|
||||
class UpdateMask;
|
||||
|
||||
struct CharacterCustomizeInfo;
|
||||
|
||||
typedef std::deque<Mail*> PlayerMails;
|
||||
|
||||
#define PLAYER_MAX_SKILLS 128
|
||||
@@ -274,13 +276,6 @@ struct CUFProfile
|
||||
// More fields can be added to BoolOptions without changing DB schema (up to 32, currently 27)
|
||||
};
|
||||
|
||||
struct SpellCooldown
|
||||
{
|
||||
time_t end;
|
||||
uint16 itemid;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, SpellCooldown> SpellCooldowns;
|
||||
typedef std::unordered_map<uint32 /*instanceId*/, time_t/*releaseTime*/> InstanceTimeMap;
|
||||
|
||||
enum TrainerSpellState
|
||||
@@ -487,9 +482,9 @@ struct Runes
|
||||
|
||||
struct EnchantDuration
|
||||
{
|
||||
EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) { };
|
||||
EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) { }
|
||||
EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot),
|
||||
leftduration(_leftduration){ ASSERT(item); };
|
||||
leftduration(_leftduration){ ASSERT(item); }
|
||||
|
||||
Item* item;
|
||||
EnchantmentSlot slot;
|
||||
@@ -1284,7 +1279,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SendInitialPacketsAfterAddToMap();
|
||||
void SendSupercededSpell(uint32 oldSpell, uint32 newSpell);
|
||||
void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0);
|
||||
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
|
||||
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome);
|
||||
|
||||
bool CanInteractWithQuestGiver(Object* questGiver);
|
||||
Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
|
||||
@@ -1681,6 +1676,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid);
|
||||
|
||||
static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
|
||||
static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false);
|
||||
static bool IsValidClass(uint8 Class) { return ((1 << (Class - 1)) & CLASSMASK_ALL_PLAYABLE) != 0; }
|
||||
static bool IsValidRace(uint8 Race) { return ((1 << (Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0; }
|
||||
|
||||
@@ -1694,8 +1690,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value);
|
||||
static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value);
|
||||
static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
|
||||
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid);
|
||||
static void Customize(CharacterCustomizeInfo const* customizeInfo, SQLTransaction& trans);
|
||||
static void SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGuid guid, SQLTransaction& trans);
|
||||
|
||||
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false);
|
||||
static void DeleteOldCharacters();
|
||||
@@ -1855,8 +1851,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
PlayerSpellMap const& GetSpellMap() const { return m_spells; }
|
||||
PlayerSpellMap & GetSpellMap() { return m_spells; }
|
||||
|
||||
SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
|
||||
|
||||
void AddSpellMod(SpellModifier* mod, bool apply);
|
||||
bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = NULL);
|
||||
template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell = NULL);
|
||||
@@ -1866,27 +1860,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void DropModCharge(SpellModifier* mod, Spell* spell);
|
||||
void SetSpellModTakingSpell(Spell* spell, bool apply);
|
||||
|
||||
static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
|
||||
static uint32 const infinityCooldownDelayCheck = MONTH/2;
|
||||
bool HasSpellCooldown(uint32 spell_id) const;
|
||||
uint32 GetSpellCooldownDelay(uint32 spell_id) const;
|
||||
void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false);
|
||||
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
|
||||
void ModifySpellCooldown(uint32 spellId, int32 cooldown);
|
||||
void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true);
|
||||
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
|
||||
void RemoveSpellCooldown(uint32 spell_id, bool update = false);
|
||||
void RemoveSpellCategoryCooldown(uint32 cat, bool update = false);
|
||||
void SendClearCooldown(uint32 spell_id, Unit* target);
|
||||
void SendClearAllCooldowns(Unit* target);
|
||||
|
||||
GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; }
|
||||
|
||||
void RemoveCategoryCooldown(uint32 cat);
|
||||
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
|
||||
void RemoveAllSpellCooldown();
|
||||
void _LoadSpellCooldowns(PreparedQueryResult result);
|
||||
void _SaveSpellCooldowns(SQLTransaction& trans);
|
||||
uint32 GetLastPotionId() { return m_lastPotionId; }
|
||||
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
|
||||
void UpdatePotionCooldown(Spell* spell = NULL);
|
||||
@@ -1936,7 +1910,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
|
||||
void ResetContestedPvP();
|
||||
|
||||
/** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
|
||||
/// @todo: maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler
|
||||
DuelInfo* duel;
|
||||
void UpdateDuelFlag(time_t currTime);
|
||||
void CheckDuelDistance(time_t currTime);
|
||||
@@ -2080,7 +2054,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
|
||||
void UpdateUnderwaterState(Map* m, float x, float y, float z) override;
|
||||
|
||||
void SendMessageToSet(WorldPacket* data, bool self) override {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet
|
||||
void SendMessageToSet(WorldPacket* data, bool self) override {SendMessageToSetInRange(data, GetVisibilityRange(), self); }// overwrite Object::SendMessageToSet
|
||||
void SendMessageToSetInRange(WorldPacket* data, float fist, bool self) override;// overwrite Object::SendMessageToSetInRange
|
||||
void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only);
|
||||
void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr) override;
|
||||
@@ -2175,8 +2149,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
//End of PvP System
|
||||
|
||||
inline SpellCooldowns GetSpellCooldowns() const { return m_spellCooldowns; }
|
||||
|
||||
void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0);
|
||||
uint8 GetDrunkValue() const { return GetByteValue(PLAYER_BYTES_3, 1); }
|
||||
static DrunkenState GetDrunkenstateByValue(uint8 value);
|
||||
@@ -2345,7 +2317,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetFallInformation(uint32 time, float z);
|
||||
void HandleFall(MovementInfo const& movementInfo);
|
||||
|
||||
bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const;
|
||||
bool CanFlyInZone(uint32 mapid, uint32 zone) const;
|
||||
|
||||
void SetClientControl(Unit* target, bool allowMove);
|
||||
|
||||
@@ -2380,7 +2352,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
WorldLocation GetStartPosition() const;
|
||||
|
||||
// currently visible objects at player client
|
||||
GuidSet m_clientGUIDs;
|
||||
GuidUnorderedSet m_clientGUIDs;
|
||||
|
||||
bool HaveAtClient(WorldObject const* u) const;
|
||||
|
||||
@@ -2470,7 +2442,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint64 GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; }
|
||||
void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); }
|
||||
Player* GetNextRandomRaidMember(float radius);
|
||||
PartyResult CanUninviteFromGroup() const;
|
||||
PartyResult CanUninviteFromGroup(ObjectGuid guidMember = ObjectGuid::Empty) const;
|
||||
|
||||
// Battleground / Battlefield Group System
|
||||
void SetBattlegroundOrBattlefieldRaid(Group* group, int8 subgroup = -1);
|
||||
@@ -2751,8 +2723,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
PlayerSpellMap m_spells;
|
||||
uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
|
||||
|
||||
GlobalCooldownMgr m_GlobalCooldownMgr;
|
||||
|
||||
PlayerTalentInfo* _talentMgr;
|
||||
|
||||
ActionButtonList m_actionButtons;
|
||||
@@ -2911,8 +2881,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
AchievementMgr<Player>* m_achievementMgr;
|
||||
ReputationMgr* m_reputationMgr;
|
||||
|
||||
SpellCooldowns m_spellCooldowns;
|
||||
|
||||
uint32 m_ChampioningFaction;
|
||||
|
||||
std::queue<uint32> m_timeSyncQueue;
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
|
||||
#include "Totem.h"
|
||||
#include "Log.h"
|
||||
#include "Group.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -124,7 +123,7 @@ void Totem::UnSummon(uint32 msTime)
|
||||
owner->SendAutoRepeatCancel(this);
|
||||
|
||||
if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(GetUInt32Value(UNIT_CREATED_BY_SPELL)))
|
||||
owner->SendCooldownEvent(spell, 0, NULL, false);
|
||||
GetSpellHistory()->SendCooldownEvent(spell, 0, nullptr, false);
|
||||
|
||||
if (Group* group = owner->GetGroup())
|
||||
{
|
||||
|
||||
@@ -20,14 +20,10 @@
|
||||
#include "Transport.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Path.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "DBCStores.h"
|
||||
#include "World.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "Vehicle.h"
|
||||
#include "MapReference.h"
|
||||
#include "Player.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
@@ -36,7 +32,7 @@
|
||||
Transport::Transport() : GameObject(),
|
||||
_transportInfo(NULL), _isMoving(true), _pendingStop(false),
|
||||
_triggeredArrivalEvent(false), _triggeredDepartureEvent(false),
|
||||
_passengerTeleportItr(_passengers.begin()), _delayedAddModel(false)
|
||||
_passengerTeleportItr(_passengers.begin()), _delayedAddModel(false), _delayedTeleport(false)
|
||||
{
|
||||
m_updateFlag = UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION;
|
||||
}
|
||||
@@ -129,7 +125,7 @@ void Transport::Update(uint32 diff)
|
||||
if (IsMoving() || !_pendingStop)
|
||||
m_goValue.Transport.PathProgress += diff;
|
||||
|
||||
uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();
|
||||
uint32 timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
|
||||
|
||||
// Set current waypoint
|
||||
// Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
|
||||
@@ -151,8 +147,8 @@ void Transport::Update(uint32 diff)
|
||||
if (_pendingStop && GetGoState() != GO_STATE_READY)
|
||||
{
|
||||
SetGoState(GO_STATE_READY);
|
||||
m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
|
||||
m_goValue.Transport.PathProgress *= GetPeriod();
|
||||
m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetTransportPeriod());
|
||||
m_goValue.Transport.PathProgress *= GetTransportPeriod();
|
||||
m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
|
||||
}
|
||||
break; // its a stop frame and we are waiting
|
||||
@@ -177,13 +173,13 @@ void Transport::Update(uint32 diff)
|
||||
|
||||
MoveToNextWaypoint();
|
||||
|
||||
sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
|
||||
sScriptMgr->OnRelocate(this, _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ);
|
||||
|
||||
TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
|
||||
TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ);
|
||||
|
||||
// Departure event
|
||||
if (_currentFrame->IsTeleportFrame())
|
||||
if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z, _nextFrame->InitialOrientation))
|
||||
if (TeleportTransport(_nextFrame->Node->MapID, _nextFrame->Node->LocX, _nextFrame->Node->LocY, _nextFrame->Node->LocZ, _nextFrame->InitialOrientation))
|
||||
return; // Update more in new map thread
|
||||
}
|
||||
|
||||
@@ -230,6 +226,14 @@ void Transport::Update(uint32 diff)
|
||||
sScriptMgr->OnTransportUpdate(this, diff);
|
||||
}
|
||||
|
||||
void Transport::DelayedUpdate(uint32 /*diff*/)
|
||||
{
|
||||
if (GetKeyFrames().size() <= 1)
|
||||
return;
|
||||
|
||||
DelayedTeleportTransport();
|
||||
}
|
||||
|
||||
void Transport::AddPassenger(WorldObject* passenger)
|
||||
{
|
||||
if (!IsInWorld())
|
||||
@@ -340,6 +344,8 @@ GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ASSERT(data);
|
||||
|
||||
float x = data->posX;
|
||||
float y = data->posY;
|
||||
float z = data->posZ;
|
||||
@@ -602,36 +608,8 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, fl
|
||||
|
||||
if (oldMap->GetId() != newMapid)
|
||||
{
|
||||
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
|
||||
_delayedTeleport = true;
|
||||
UnloadStaticPassengers();
|
||||
GetMap()->RemoveFromMap<Transport>(this, false);
|
||||
SetMap(newMap);
|
||||
|
||||
for (_passengerTeleportItr = _passengers.begin(); _passengerTeleportItr != _passengers.end();)
|
||||
{
|
||||
WorldObject* obj = (*_passengerTeleportItr++);
|
||||
|
||||
float destX, destY, destZ, destO;
|
||||
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
|
||||
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
|
||||
|
||||
switch (obj->GetTypeId())
|
||||
{
|
||||
case TYPEID_PLAYER:
|
||||
if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
|
||||
RemovePassenger(obj);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
obj->AddObjectToRemoveList();
|
||||
break;
|
||||
default:
|
||||
RemovePassenger(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Relocate(x, y, z, o);
|
||||
GetMap()->AddToMap<Transport>(this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -654,6 +632,48 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, fl
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::DelayedTeleportTransport()
|
||||
{
|
||||
if (!_delayedTeleport)
|
||||
return;
|
||||
|
||||
_delayedTeleport = false;
|
||||
Map* newMap = sMapMgr->CreateBaseMap(_nextFrame->Node->MapID);
|
||||
GetMap()->RemoveFromMap<Transport>(this, false);
|
||||
SetMap(newMap);
|
||||
|
||||
float x = _nextFrame->Node->LocX,
|
||||
y = _nextFrame->Node->LocY,
|
||||
z = _nextFrame->Node->LocZ,
|
||||
o =_nextFrame->InitialOrientation;
|
||||
|
||||
for (_passengerTeleportItr = _passengers.begin(); _passengerTeleportItr != _passengers.end();)
|
||||
{
|
||||
WorldObject* obj = (*_passengerTeleportItr++);
|
||||
|
||||
float destX, destY, destZ, destO;
|
||||
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
|
||||
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
|
||||
|
||||
switch (obj->GetTypeId())
|
||||
{
|
||||
case TYPEID_PLAYER:
|
||||
if (!obj->ToPlayer()->TeleportTo(_nextFrame->Node->MapID, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
|
||||
RemovePassenger(obj);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
obj->AddObjectToRemoveList();
|
||||
break;
|
||||
default:
|
||||
RemovePassenger(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Relocate(x, y, z, o);
|
||||
GetMap()->AddToMap<Transport>(this);
|
||||
}
|
||||
|
||||
void Transport::UpdatePassengerPositions(PassengerSet& passengers)
|
||||
{
|
||||
for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
|
||||
@@ -708,9 +728,9 @@ void Transport::UpdatePassengerPositions(PassengerSet& passengers)
|
||||
|
||||
void Transport::DoEventIfAny(KeyFrame const& node, bool departure)
|
||||
{
|
||||
if (uint32 eventid = departure ? node.Node->departureEventID : node.Node->arrivalEventID)
|
||||
if (uint32 eventid = departure ? node.Node->DepartureEventID : node.Node->ArrivalEventID)
|
||||
{
|
||||
TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.Node->index, GetName().c_str());
|
||||
TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.Node->NodeIndex, GetName().c_str());
|
||||
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
|
||||
EventInform(eventid);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class Transport : public GameObject, public TransportBase
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true) override;
|
||||
|
||||
void Update(uint32 diff) override;
|
||||
void DelayedUpdate(uint32 diff);
|
||||
|
||||
void BuildUpdate(UpdateDataMapType& data_map) override;
|
||||
|
||||
@@ -79,7 +80,7 @@ class Transport : public GameObject, public TransportBase
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||
}
|
||||
|
||||
uint32 GetPeriod() const { return GetUInt32Value(GAMEOBJECT_LEVEL); }
|
||||
uint32 GetTransportPeriod() const override { return GetUInt32Value(GAMEOBJECT_LEVEL); }
|
||||
void SetPeriod(uint32 period) { SetUInt32Value(GAMEOBJECT_LEVEL, period); }
|
||||
uint32 GetTimer() const { return GetGOValue()->Transport.PathProgress; }
|
||||
|
||||
@@ -103,6 +104,7 @@ class Transport : public GameObject, public TransportBase
|
||||
void MoveToNextWaypoint();
|
||||
float CalculateSegmentPos(float perc);
|
||||
bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o);
|
||||
void DelayedTeleportTransport();
|
||||
void UpdatePassengerPositions(PassengerSet& passengers);
|
||||
void DoEventIfAny(KeyFrame const& node, bool departure);
|
||||
|
||||
@@ -127,6 +129,7 @@ class Transport : public GameObject, public TransportBase
|
||||
PassengerSet _staticPassengers;
|
||||
|
||||
bool _delayedAddModel;
|
||||
bool _delayedTeleport;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -51,6 +50,7 @@
|
||||
#include "SpellAuras.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Totem.h"
|
||||
@@ -164,7 +164,7 @@ Unit::Unit(bool isWorldObject) :
|
||||
i_AI(NULL), i_disabledAI(NULL), m_AutoRepeatFirstCast(false), m_procDeep(0),
|
||||
m_removedAurasCount(0), i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_ThreatManager(this),
|
||||
m_vehicle(NULL), m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE),
|
||||
m_HostileRefManager(this), _lastDamagedTime(0)
|
||||
m_HostileRefManager(this), _lastDamagedTime(0), m_spellHistory(new SpellHistory(this))
|
||||
{
|
||||
m_objectType |= TYPEMASK_UNIT;
|
||||
m_objectTypeId = TYPEID_UNIT;
|
||||
@@ -260,24 +260,6 @@ Unit::Unit(bool isWorldObject) :
|
||||
_meleeAnimKitId = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Methods of class GlobalCooldownMgr
|
||||
bool GlobalCooldownMgr::HasGlobalCooldown(SpellInfo const* spellInfo) const
|
||||
{
|
||||
GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
|
||||
return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, getMSTime()) < itr->second.duration;
|
||||
}
|
||||
|
||||
void GlobalCooldownMgr::AddGlobalCooldown(SpellInfo const* spellInfo, uint32 gcd)
|
||||
{
|
||||
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, getMSTime());
|
||||
}
|
||||
|
||||
void GlobalCooldownMgr::CancelGlobalCooldown(SpellInfo const* spellInfo)
|
||||
{
|
||||
m_GlobalCooldowns[spellInfo->StartRecoveryCategory].duration = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Methods of class Unit
|
||||
Unit::~Unit()
|
||||
@@ -295,6 +277,7 @@ Unit::~Unit()
|
||||
delete i_motionMaster;
|
||||
delete m_charmInfo;
|
||||
delete movespline;
|
||||
delete m_spellHistory;
|
||||
|
||||
ASSERT(!m_duringRemoveFromWorld);
|
||||
ASSERT(!m_attacking);
|
||||
@@ -592,7 +575,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
// interrupting auras with AURA_INTERRUPT_FLAG_DAMAGE before checking !damage (absorbed damage breaks that type of auras)
|
||||
if (spellProto)
|
||||
{
|
||||
if (!(spellProto->AttributesEx4 & SPELL_ATTR4_DAMAGE_DOESNT_BREAK_AURAS))
|
||||
if (!spellProto->HasAttribute(SPELL_ATTR4_DAMAGE_DOESNT_BREAK_AURAS))
|
||||
victim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, spellProto->Id);
|
||||
}
|
||||
else
|
||||
@@ -761,7 +744,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
if (damagetype != NODAMAGE && damage)
|
||||
{
|
||||
if (victim != this && victim->GetTypeId() == TYPEID_PLAYER && // does not support creature push_back
|
||||
(!spellProto || !(spellProto->AttributesEx7 & SPELL_ATTR7_NO_PUSHBACK_ON_DAMAGE)))
|
||||
(!spellProto || !spellProto->HasAttribute(SPELL_ATTR7_NO_PUSHBACK_ON_DAMAGE)))
|
||||
{
|
||||
if (damagetype != DOT)
|
||||
if (Spell* spell = victim->m_currentSpells[CURRENT_GENERIC_SPELL])
|
||||
@@ -964,7 +947,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
|
||||
SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask);
|
||||
|
||||
// Spells with SPELL_ATTR4_FIXED_DAMAGE ignore resilience because their damage is based off another spell's damage.
|
||||
if (!(spellInfo->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE))
|
||||
if (!spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
|
||||
{
|
||||
if (IsDamageReducedByArmor(damageSchoolMask, spellInfo))
|
||||
damage = CalcArmorReducedDamage(victim, damage, spellInfo, attackType);
|
||||
@@ -1423,7 +1406,7 @@ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* s
|
||||
if (spellInfo)
|
||||
{
|
||||
// there are spells with no specific attribute but they have "ignores armor" in tooltip
|
||||
if (spellInfo->AttributesCu & SPELL_ATTR0_CU_IGNORE_ARMOR)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR))
|
||||
return false;
|
||||
|
||||
// bleeding effects are not reduced by armor
|
||||
@@ -1506,7 +1489,7 @@ uint32 Unit::CalcSpellResistance(Unit* victim, SpellSchoolMask schoolMask, Spell
|
||||
return 0;
|
||||
|
||||
// Ignore spells that can't be resisted
|
||||
if (spellInfo && spellInfo->AttributesEx4 & SPELL_ATTR4_IGNORE_RESISTANCES)
|
||||
if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR4_IGNORE_RESISTANCES))
|
||||
return 0;
|
||||
|
||||
uint8 const bossLevel = 83;
|
||||
@@ -1723,6 +1706,7 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
|
||||
{
|
||||
// We're going to call functions which can modify content of the list during iteration over it's elements
|
||||
// Let's copy the list so we can prevent iterator invalidation
|
||||
|
||||
AuraEffectList vSplitDamagePctCopy(victim->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT));
|
||||
for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); itr != vSplitDamagePctCopy.end() && dmgInfo.GetDamage() > 0; ++itr)
|
||||
{
|
||||
@@ -1748,6 +1732,14 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
|
||||
splitDamage = RoundToInterval(splitDamage, uint32(0), uint32(dmgInfo.GetDamage()));
|
||||
|
||||
dmgInfo.AbsorbDamage(splitDamage);
|
||||
|
||||
// check if caster is immune to damage
|
||||
if (caster->IsImmunedToDamage(schoolMask))
|
||||
{
|
||||
victim->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 split_absorb = 0;
|
||||
DealDamageMods(caster, splitDamage, &split_absorb);
|
||||
|
||||
@@ -2133,15 +2125,15 @@ void Unit::SendMeleeAttackStop(Unit* victim)
|
||||
TC_LOG_DEBUG("entities.unit", "WORLD: Sent SMSG_ATTACKSTOP");
|
||||
|
||||
if (victim)
|
||||
TC_LOG_INFO("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
|
||||
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
|
||||
else
|
||||
TC_LOG_INFO("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow());
|
||||
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow());
|
||||
}
|
||||
|
||||
bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType /*attackType*/)
|
||||
{
|
||||
// These spells can't be blocked
|
||||
if (spellProto && spellProto->Attributes & SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK)
|
||||
if (spellProto && spellProto->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK))
|
||||
return false;
|
||||
|
||||
if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(float(M_PI), this))
|
||||
@@ -2206,7 +2198,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
{
|
||||
// Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will additionally fully ignore
|
||||
// resist and deflect chances
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_IGNORE_HIT_RESULT)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
|
||||
return SPELL_MISS_NONE;
|
||||
|
||||
WeaponAttackType attType = BASE_ATTACK;
|
||||
@@ -2245,10 +2237,10 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
|
||||
bool canDodge = true;
|
||||
bool canParry = true;
|
||||
bool canBlock = (spellInfo->AttributesEx3 & SPELL_ATTR3_BLOCKABLE_SPELL) != 0;
|
||||
bool canBlock = spellInfo->HasAttribute(SPELL_ATTR3_BLOCKABLE_SPELL);
|
||||
|
||||
// Same spells cannot be parry/dodge
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK))
|
||||
return SPELL_MISS_NONE;
|
||||
|
||||
// Chance resist mechanic
|
||||
@@ -2288,7 +2280,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
}
|
||||
else // Only deterrence as of 3.3.5
|
||||
{
|
||||
if (spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET))
|
||||
canParry = false;
|
||||
}
|
||||
}
|
||||
@@ -2379,7 +2371,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo)
|
||||
{
|
||||
// Can`t miss on dead target (on skinning for example)
|
||||
if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) || spellInfo->AttributesEx3 & SPELL_ATTR3_IGNORE_HIT_RESULT)
|
||||
if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) || spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
|
||||
return SPELL_MISS_NONE;
|
||||
|
||||
SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
|
||||
@@ -2703,6 +2695,8 @@ void Unit::_UpdateSpells(uint32 time)
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
m_spellHistory->Update();
|
||||
}
|
||||
|
||||
void Unit::_UpdateAutoRepeatSpell()
|
||||
@@ -2868,7 +2862,7 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAu
|
||||
{
|
||||
if (!skipInstant || m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime())
|
||||
{
|
||||
if (!isAutoshoot || !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))
|
||||
if (!isAutoshoot || !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2876,7 +2870,7 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAu
|
||||
if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] &&
|
||||
(m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED))
|
||||
{
|
||||
if (!isAutoshoot || !(m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))
|
||||
if (!isAutoshoot || !(m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS)))
|
||||
return true;
|
||||
}
|
||||
// autorepeat spells may be finished or delayed, but they are still considered cast
|
||||
@@ -3011,7 +3005,7 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8
|
||||
castItemGUID = castItem->GetGUID();
|
||||
|
||||
// find current aura from spell and change it's stackamount, or refresh it's duration
|
||||
if (Aura* foundAura = GetOwnedAura(newAura->Id, casterGUID, (newAura->AttributesCu & SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : ObjectGuid::Empty, 0))
|
||||
if (Aura* foundAura = GetOwnedAura(newAura->Id, casterGUID, newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : ObjectGuid::Empty, 0))
|
||||
{
|
||||
// effect masks do not match
|
||||
// extremely rare case
|
||||
@@ -3366,6 +3360,12 @@ void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode)
|
||||
|
||||
ASSERT(aura->GetOwner() == this);
|
||||
|
||||
if (removeMode == AURA_REMOVE_NONE)
|
||||
{
|
||||
TC_LOG_ERROR("spells", "Unit::RemoveOwnedAura() called with unallowed removeMode AURA_REMOVE_NONE, spellId %u", aura->GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 spellId = aura->GetId();
|
||||
AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
|
||||
|
||||
@@ -3516,7 +3516,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId
|
||||
// Call OnDispel hook on AuraScript
|
||||
aura->CallScriptDispel(&dispelInfo);
|
||||
|
||||
if (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES)
|
||||
if (aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES))
|
||||
aura->ModCharges(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
else
|
||||
aura->ModStackAmount(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
@@ -3561,7 +3561,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, U
|
||||
}
|
||||
}
|
||||
|
||||
bool stealCharge = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0;
|
||||
bool stealCharge = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES);
|
||||
// Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster
|
||||
uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration()));
|
||||
|
||||
@@ -3821,9 +3821,9 @@ void Unit::RemoveArenaAuras()
|
||||
{
|
||||
AuraApplication const* aurApp = iter->second;
|
||||
Aura const* aura = aurApp->GetBase();
|
||||
if (!(aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras
|
||||
if (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras
|
||||
&& !aura->IsPassive() // don't remove passive auras
|
||||
&& (aurApp->IsPositive() || !(aura->GetSpellInfo()->AttributesEx3 & SPELL_ATTR3_DEATH_PERSISTENT))) // not negative death persistent auras
|
||||
&& (aurApp->IsPositive() || !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR3_DEATH_PERSISTENT))) // not negative death persistent auras
|
||||
RemoveAura(iter);
|
||||
else
|
||||
++iter;
|
||||
@@ -4083,7 +4083,7 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges
|
||||
// The charges / stack amounts don't count towards the total number of auras that can be dispelled.
|
||||
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
|
||||
// Polymorph instead of 1 / (5 + 1) -> 16%.
|
||||
bool dispel_charges = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0;
|
||||
bool dispel_charges = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES);
|
||||
uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount();
|
||||
if (charges > 0)
|
||||
dispelList.push_back(std::make_pair(aura, charges));
|
||||
@@ -4636,13 +4636,13 @@ void Unit::AddGameObject(GameObject* gameObj)
|
||||
m_gameObj.push_back(gameObj);
|
||||
gameObj->SetOwnerGUID(GetGUID());
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && gameObj->GetSpellId())
|
||||
if (gameObj->GetSpellId())
|
||||
{
|
||||
SpellInfo const* createBySpell = sSpellMgr->GetSpellInfo(gameObj->GetSpellId());
|
||||
// Need disable spell use for owner
|
||||
if (createBySpell && createBySpell->IsCooldownStartedOnEvent())
|
||||
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
|
||||
ToPlayer()->AddSpellAndCategoryCooldowns(createBySpell, 0, NULL, true);
|
||||
GetSpellHistory()->StartCooldown(createBySpell, 0, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4667,14 +4667,11 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del)
|
||||
{
|
||||
RemoveAurasDueToSpell(spellid);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
SpellInfo const* createBySpell = sSpellMgr->GetSpellInfo(spellid);
|
||||
// Need activate spell use for owner
|
||||
if (createBySpell && createBySpell->IsCooldownStartedOnEvent())
|
||||
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
|
||||
ToPlayer()->SendCooldownEvent(createBySpell);
|
||||
}
|
||||
SpellInfo const* createBySpell = sSpellMgr->GetSpellInfo(spellid);
|
||||
// Need activate spell use for owner
|
||||
if (createBySpell && createBySpell->IsCooldownStartedOnEvent())
|
||||
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
|
||||
GetSpellHistory()->SendCooldownEvent(createBySpell);
|
||||
}
|
||||
|
||||
m_gameObj.remove(gameObj);
|
||||
@@ -5039,7 +5036,7 @@ bool Unit::HandleAuraProcOnPowerAmount(Unit* victim, uint32 /*damage*/, AuraEffe
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(trigger_spell_id))
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSpellHistory()->HasCooldown(trigger_spell_id))
|
||||
return false;
|
||||
|
||||
// try detect target manually if not set
|
||||
@@ -5052,7 +5049,7 @@ bool Unit::HandleAuraProcOnPowerAmount(Unit* victim, uint32 /*damage*/, AuraEffe
|
||||
CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura);
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->AddSpellCooldown(trigger_spell_id, 0, time(NULL) + cooldown);
|
||||
ToPlayer()->GetSpellHistory()->AddCooldown(trigger_spell_id, 0, std::chrono::seconds(cooldown));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -5378,12 +5375,12 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (RandomSpells.empty()) // shouldn't happen
|
||||
return false;
|
||||
|
||||
uint8 rand_spell = irand(0, (RandomSpells.size() - 1));
|
||||
uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
|
||||
CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
|
||||
for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
|
||||
{
|
||||
if (!ToPlayer()->HasSpellCooldown(*itr))
|
||||
ToPlayer()->AddSpellCooldown(*itr, 0, time(NULL) + cooldown);
|
||||
if (!GetSpellHistory()->HasCooldown(*itr))
|
||||
GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -5424,12 +5421,12 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (RandomSpells.empty()) // shouldn't happen
|
||||
return false;
|
||||
|
||||
uint8 rand_spell = irand(0, (RandomSpells.size() - 1));
|
||||
uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
|
||||
CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
|
||||
for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
|
||||
{
|
||||
if (!ToPlayer()->HasSpellCooldown(*itr))
|
||||
ToPlayer()->AddSpellCooldown(*itr, 0, time(NULL) + cooldown);
|
||||
if (!GetSpellHistory()->HasCooldown(*itr))
|
||||
GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -5678,9 +5675,13 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
basepoints0 = int32(CountPctFromMaxHealth(triggerAmount));
|
||||
target = this;
|
||||
triggered_spell_id = 34299;
|
||||
// Regenerate 4% mana
|
||||
int32 mana = CalculatePct(GetCreateMana(), triggerAmount);
|
||||
CastCustomSpell(this, 68285, &mana, NULL, NULL, true, castItem, triggeredByAura);
|
||||
if (triggeredByAura->GetCasterGUID() != GetGUID())
|
||||
break;
|
||||
int32 basepoints1 = CalculatePct(GetMaxPower(Powers(POWER_MANA)), triggerAmount * 2);
|
||||
// Improved Leader of the Pack
|
||||
// Check cooldown of heal spell cooldown
|
||||
if (!GetSpellHistory()->HasCooldown(34299))
|
||||
CastCustomSpell(this, 68285, &basepoints1, 0, 0, true, 0, triggeredByAura);
|
||||
break;
|
||||
}
|
||||
// Healing Touch (Dreamwalker Raiment set)
|
||||
@@ -6017,7 +6018,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
return false;
|
||||
|
||||
// custom cooldown processing case
|
||||
if (cooldown && player->HasSpellCooldown(dummySpell->Id))
|
||||
if (cooldown && GetSpellHistory()->HasCooldown(dummySpell->Id))
|
||||
return false;
|
||||
|
||||
if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
|
||||
@@ -6064,7 +6065,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
|
||||
// apply cooldown before cast to prevent processing itself
|
||||
if (cooldown)
|
||||
player->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown);
|
||||
player->GetSpellHistory()->AddCooldown(dummySpell->Id, 0, std::chrono::seconds(cooldown));
|
||||
|
||||
// Attack Twice
|
||||
for (uint32 i = 0; i < 2; ++i)
|
||||
@@ -6247,8 +6248,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
uint32 spell = 26364;
|
||||
|
||||
// custom cooldown processing case
|
||||
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(spell))
|
||||
ToPlayer()->RemoveSpellCooldown(spell);
|
||||
if (GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(spell))
|
||||
GetSpellHistory()->ResetCooldown(spell);
|
||||
|
||||
CastSpell(target, spell, true, castItem, triggeredByAura);
|
||||
return true;
|
||||
@@ -6395,7 +6396,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (cooldown_spell_id == 0)
|
||||
cooldown_spell_id = triggered_spell_id;
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(cooldown_spell_id))
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(cooldown_spell_id))
|
||||
return false;
|
||||
|
||||
if (basepoints0)
|
||||
@@ -6404,7 +6405,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura, originalCaster);
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->AddSpellCooldown(cooldown_spell_id, 0, time(NULL) + cooldown);
|
||||
GetSpellHistory()->AddCooldown(cooldown_spell_id, 0, std::chrono::seconds(cooldown));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -6591,9 +6592,9 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 /*damage*/, Aura* triggeredByAura
|
||||
*handled = true;
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (ToPlayer()->HasSpellCooldown(100000))
|
||||
if (GetSpellHistory()->HasCooldown(100000))
|
||||
return false;
|
||||
ToPlayer()->AddSpellCooldown(100000, 0, time(NULL) + cooldown);
|
||||
GetSpellHistory()->AddCooldown(100000, 0, std::chrono::seconds(cooldown));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -7120,7 +7121,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(trigger_spell_id))
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(trigger_spell_id))
|
||||
return false;
|
||||
|
||||
// extra attack should hit same target
|
||||
@@ -7137,7 +7138,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura);
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->AddSpellCooldown(trigger_spell_id, 0, time(NULL) + cooldown);
|
||||
GetSpellHistory()->AddCooldown(trigger_spell_id, 0, std::chrono::seconds(cooldown));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -7192,13 +7193,13 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit* victim, uint32 /*damage*/, Au
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(triggered_spell_id))
|
||||
return false;
|
||||
|
||||
CastSpell(victim, triggered_spell_id, true, castItem, triggeredByAura);
|
||||
|
||||
if (cooldown && GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
|
||||
GetSpellHistory()->AddCooldown(triggered_spell_id, 0, std::chrono::seconds(cooldown));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -7929,14 +7930,11 @@ void Unit::SetMinion(Minion *minion, bool apply)
|
||||
if (minion->IsPetGhoul())
|
||||
minion->setPowerType(POWER_ENERGY);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
// Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
// Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
|
||||
if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
|
||||
ToPlayer()->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL, true);
|
||||
}
|
||||
if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
|
||||
GetSpellHistory()->StartCooldown(spellInfo, 0, nullptr, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -7970,13 +7968,10 @@ void Unit::SetMinion(Minion *minion, bool apply)
|
||||
}
|
||||
}
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
// Remove infinity cooldown
|
||||
if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
|
||||
ToPlayer()->SendCooldownEvent(spellInfo);
|
||||
}
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
// Remove infinity cooldown
|
||||
if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
|
||||
GetSpellHistory()->SendCooldownEvent(spellInfo);
|
||||
|
||||
//if (minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
|
||||
{
|
||||
@@ -8159,7 +8154,7 @@ int32 Unit::DealHeal(Unit* victim, uint32 addhealth)
|
||||
|
||||
bool Unit::IsMagnet() const
|
||||
{
|
||||
// Grounding Totem
|
||||
// Grounding Totem
|
||||
if (GetUInt32Value(UNIT_CREATED_BY_SPELL) == 8177) /// @todo: find a more generic solution
|
||||
return true;
|
||||
|
||||
@@ -8169,7 +8164,7 @@ bool Unit::IsMagnet() const
|
||||
Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo)
|
||||
{
|
||||
// Patch 1.2 notes: Spell Reflection no longer reflects abilities
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_ABILITY || spellInfo->AttributesEx & SPELL_ATTR1_CANT_BE_REDIRECTED || spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
return victim;
|
||||
|
||||
Unit::AuraEffectList const& magnetAuras = victim->GetAuraEffectsByType(SPELL_AURA_SPELL_MAGNET);
|
||||
@@ -8421,7 +8416,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
||||
return pdamage;
|
||||
|
||||
// Some spells don't benefit from done mods
|
||||
if (spellProto->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS)
|
||||
if (spellProto->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS))
|
||||
return pdamage;
|
||||
|
||||
// For totems get damage bonus from owner
|
||||
@@ -8537,11 +8532,15 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
|
||||
}
|
||||
|
||||
// Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
|
||||
float tmpDamage = (int32(pdamage) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellDamagePctDone(victim, spellProto, damagetype));
|
||||
// apply spellmod to Done damage (flat and pct)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
|
||||
float tmpDamage = float(int32(pdamage) + DoneTotal);
|
||||
// SPELLMOD_DOT will be applied in AuraEffect::HandlePeriodicDamageAurasTick.
|
||||
if (damagetype != DOT)
|
||||
{
|
||||
tmpDamage *= SpellDamagePctDone(victim, spellProto, damagetype);
|
||||
// apply spellmod to Done damage (flat and pct)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage);
|
||||
}
|
||||
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
@@ -8552,7 +8551,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage
|
||||
return 1.0f;
|
||||
|
||||
// Some spells don't benefit from pct done mods
|
||||
if (spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)
|
||||
if (spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
|
||||
return 1.0f;
|
||||
|
||||
// For totems pct done mods are calculated when its calculation is run on the player in SpellDamageBonusDone.
|
||||
@@ -8576,7 +8575,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage
|
||||
{
|
||||
if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
|
||||
else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
@@ -8769,7 +8768,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
|
||||
}
|
||||
}
|
||||
// Spells with SPELL_ATTR4_FIXED_DAMAGE should only benefit from mechanic damage mod auras.
|
||||
if (!(spellProto->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE))
|
||||
if (!spellProto->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
|
||||
{
|
||||
// get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
|
||||
AuraEffectList const& IgnoreResistAuras = caster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
|
||||
@@ -8899,7 +8898,7 @@ float Unit::GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto
|
||||
return 0.0f;
|
||||
|
||||
// not critting spell
|
||||
if ((spellProto->AttributesEx2 & SPELL_ATTR2_CANT_CRIT))
|
||||
if (spellProto->HasAttribute(SPELL_ATTR2_CANT_CRIT))
|
||||
return 0.0f;
|
||||
|
||||
float crit_chance = 0.0f;
|
||||
@@ -9246,11 +9245,15 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
|
||||
DoneTotal = 0;
|
||||
}
|
||||
|
||||
// Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
|
||||
float heal = float(int32(healamount) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellHealingPctDone(victim, spellProto));
|
||||
// apply spellmod to Done amount
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
|
||||
float heal = float(int32(healamount) + DoneTotal);
|
||||
// SPELLMOD_DOT will be applied in AuraEffect::HandlePeriodicHealAurasTick.
|
||||
if (damagetype != DOT)
|
||||
{
|
||||
heal *= SpellHealingPctDone(victim, spellProto);
|
||||
// apply spellmod to Done amount
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, heal);
|
||||
}
|
||||
|
||||
return uint32(std::max(heal, 0.0f));
|
||||
}
|
||||
@@ -9484,7 +9487,7 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) const
|
||||
|
||||
bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
|
||||
{
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
return false;
|
||||
|
||||
uint32 shoolMask = spellInfo->GetSchoolMask();
|
||||
@@ -9517,7 +9520,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
if (itr->type == spellInfo->Id)
|
||||
return true;
|
||||
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
return false;
|
||||
|
||||
if (spellInfo->Dispel)
|
||||
@@ -9570,12 +9573,32 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 Unit::GetSchoolImmunityMask() const
|
||||
{
|
||||
uint32 mask = 0;
|
||||
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_SCHOOL];
|
||||
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
|
||||
mask |= itr->type;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
uint32 Unit::GetMechanicImmunityMask() const
|
||||
{
|
||||
uint32 mask = 0;
|
||||
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
|
||||
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
|
||||
mask |= (1 << itr->type);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
{
|
||||
if (!spellInfo || !spellInfo->Effects[index].IsEffect())
|
||||
return false;
|
||||
|
||||
if (spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
|
||||
return false;
|
||||
|
||||
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
|
||||
@@ -9598,7 +9621,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
||||
SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE];
|
||||
for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
|
||||
if (itr->type == aura)
|
||||
if (!(spellInfo->AttributesEx3 & SPELL_ATTR3_IGNORE_HIT_RESULT))
|
||||
if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
|
||||
return true;
|
||||
|
||||
// Check for immune to application of harmful magical effects
|
||||
@@ -9673,7 +9696,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
||||
|
||||
// Some spells don't benefit from pct done mods
|
||||
if (spellProto)
|
||||
if (!(spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
|
||||
if (!spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
|
||||
{
|
||||
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
|
||||
@@ -9682,7 +9705,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
||||
{
|
||||
if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
|
||||
else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
|
||||
AddPct(DoneTotalMod, (*i)->GetAmount());
|
||||
@@ -9877,7 +9900,7 @@ void Unit::ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type
|
||||
{
|
||||
ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
|
||||
|
||||
if (apply && spellProto->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)
|
||||
if (apply && spellProto->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
|
||||
{
|
||||
// Create dispel mask by dispel type
|
||||
uint32 dispelMask = SpellInfo::GetDispelMask(type);
|
||||
@@ -10209,7 +10232,7 @@ void Unit::ClearInCombat()
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
|
||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS, creature->GetCreatureTemplate()->dynamicflags);
|
||||
|
||||
if (creature->IsPet())
|
||||
if (creature->IsPet() || creature->IsGuardian())
|
||||
{
|
||||
if (Unit* owner = GetOwner())
|
||||
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||
@@ -10265,7 +10288,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
return false;
|
||||
|
||||
// can't attack invisible (ignore stealth for aoe spells) also if the area being looked at is from a spell use the dynamic object created instead of the casting unit.
|
||||
if ((!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && (obj ? !obj->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()) : !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea())))
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && (obj ? !obj->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()) : !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea())))
|
||||
return false;
|
||||
|
||||
// can't attack dead
|
||||
@@ -10273,7 +10296,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
return false;
|
||||
|
||||
// can't attack untargetable
|
||||
if ((!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
&& target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
|
||||
return false;
|
||||
|
||||
@@ -10386,7 +10409,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
return false;
|
||||
|
||||
// can't assist invisible
|
||||
if ((!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
|
||||
return false;
|
||||
|
||||
// can't assist dead
|
||||
@@ -10394,11 +10417,11 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
return false;
|
||||
|
||||
// can't assist untargetable
|
||||
if ((!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
&& target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
|
||||
return false;
|
||||
|
||||
if (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
|
||||
if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
|
||||
{
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
|
||||
{
|
||||
@@ -10445,7 +10468,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
// PvC case - player can assist creature only if has specific type flags
|
||||
// !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
|
||||
else if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE)
|
||||
&& (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
|
||||
&& (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
|
||||
&& !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)))
|
||||
{
|
||||
if (Creature const* creatureTarget = target->ToCreature())
|
||||
@@ -10712,6 +10735,13 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
/// @todo possible affect only on MOVE_RUN
|
||||
if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED))
|
||||
{
|
||||
if (Creature* creature = ToCreature())
|
||||
{
|
||||
uint32 immuneMask = creature->GetCreatureTemplate()->MechanicImmuneMask;
|
||||
if (immuneMask & (1 << MECHANIC_SNARE) || immuneMask & (1 << MECHANIC_DAZE))
|
||||
break;
|
||||
}
|
||||
|
||||
// Use speed from aura
|
||||
float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
|
||||
if (speed > max_speed)
|
||||
@@ -10733,15 +10763,15 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
// Apply strongest slow aura mod to speed
|
||||
int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED);
|
||||
if (slow)
|
||||
{
|
||||
AddPct(speed, slow);
|
||||
if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED))
|
||||
{
|
||||
float min_speed = minSpeedMod / 100.0f;
|
||||
if (speed < min_speed)
|
||||
speed = min_speed;
|
||||
}
|
||||
|
||||
if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED))
|
||||
{
|
||||
float min_speed = minSpeedMod / 100.0f;
|
||||
if (speed < min_speed)
|
||||
speed = min_speed;
|
||||
}
|
||||
|
||||
SetSpeed(mtype, speed, forced);
|
||||
}
|
||||
|
||||
@@ -11162,7 +11192,7 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in
|
||||
return duration;
|
||||
|
||||
// some auras are not affected by duration modifiers
|
||||
if (spellProto->AttributesEx7 & SPELL_ATTR7_IGNORE_DURATION_MODS)
|
||||
if (spellProto->HasAttribute(SPELL_ATTR7_IGNORE_DURATION_MODS))
|
||||
return duration;
|
||||
|
||||
// cut duration only of negative effects
|
||||
@@ -11252,17 +11282,17 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell*
|
||||
if (!spellInfo || castTime < 0)
|
||||
return;
|
||||
|
||||
if (spellInfo->IsChanneled() && !(spellInfo->AttributesEx5 & SPELL_ATTR5_HASTE_AFFECT_DURATION))
|
||||
if (spellInfo->IsChanneled() && !spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
|
||||
return;
|
||||
|
||||
// called from caster
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell);
|
||||
|
||||
if (!((spellInfo->Attributes & (SPELL_ATTR0_ABILITY | SPELL_ATTR0_TRADESPELL)) || (spellInfo->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS)) &&
|
||||
if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) &&
|
||||
((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
|
||||
castTime = int32(float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED));
|
||||
else if (spellInfo->Attributes & SPELL_ATTR0_REQ_AMMO && !(spellInfo->AttributesEx2 & SPELL_ATTR2_AUTOREPEAT_FLAG))
|
||||
else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
|
||||
castTime = int32(float(castTime) * m_modAttackSpeedPct[RANGED_ATTACK]);
|
||||
else if (spellInfo->SpellVisual[0] == 3881 && HasAura(67556)) // cooking with Chef Hat.
|
||||
castTime = 500;
|
||||
@@ -12085,7 +12115,7 @@ void CharmInfo::InitPossessCreateSpells()
|
||||
{
|
||||
uint32 spellId = _unit->ToCreature()->m_spells[i];
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (spellInfo && !(spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD))
|
||||
if (spellInfo && !spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD))
|
||||
{
|
||||
if (spellInfo->IsPassive())
|
||||
_unit->CastSpell(_unit, spellInfo, true);
|
||||
@@ -12113,7 +12143,7 @@ void CharmInfo::InitCharmCreateSpells()
|
||||
uint32 spellId = _unit->ToCreature()->m_spells[x];
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
|
||||
if (!spellInfo || spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)
|
||||
if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD))
|
||||
{
|
||||
_charmspells[x].SetActionAndType(spellId, ACT_DISABLED);
|
||||
continue;
|
||||
@@ -12232,7 +12262,7 @@ void CharmInfo::LoadPetActionBar(const std::string& data)
|
||||
// use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion
|
||||
ActiveStates type = ActiveStates(atol(*iter));
|
||||
++iter;
|
||||
uint32 action = uint32(atol(*iter));
|
||||
uint32 action = atoul(*iter);
|
||||
|
||||
PetActionBar[index].SetActionAndType(action, type);
|
||||
|
||||
@@ -12490,7 +12520,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
continue;
|
||||
|
||||
// Triggered spells not triggering additional spells
|
||||
bool triggered = !(spellProto->AttributesEx3 & SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED) ?
|
||||
bool triggered = !spellProto->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED) ?
|
||||
(procExtra & PROC_EX_INTERNAL_TRIGGERED && !(procFlag & PROC_FLAG_DONE_TRAP_ACTIVATION)) : false;
|
||||
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
@@ -12547,7 +12577,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
cooldown = i->spellProcEvent->cooldown;
|
||||
|
||||
// Note: must SetCantProc(false) before return
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_DISABLE_PROC)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR3_DISABLE_PROC))
|
||||
SetCantProc(true);
|
||||
|
||||
bool handled = i->aura->CallScriptProcHandlers(aurApp, eventInfo);
|
||||
@@ -12752,7 +12782,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
|
||||
i->aura->CallScriptAfterProcHandlers(aurApp, eventInfo);
|
||||
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_DISABLE_PROC)
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR3_DISABLE_PROC))
|
||||
SetCantProc(false);
|
||||
}
|
||||
|
||||
@@ -13439,7 +13469,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const
|
||||
// Additional checks for triggered spells (ignore trap casts)
|
||||
if (procExtra & PROC_EX_INTERNAL_TRIGGERED && !(procFlag & PROC_FLAG_DONE_TRAP_ACTIVATION))
|
||||
{
|
||||
if (!(spellProto->AttributesEx3 & SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED))
|
||||
if (!spellProto->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13975,18 +14005,11 @@ void Unit::SetControlled(bool apply, UnitState state)
|
||||
{
|
||||
case UNIT_STATE_STUNNED:
|
||||
SetStunned(true);
|
||||
// i need to stop fear on stun and root or i will get teleport to destination issue as MVMGEN for fear keeps going on
|
||||
if (HasUnitState(UNIT_STATE_FLEEING))
|
||||
SetFeared(false);
|
||||
CastStop();
|
||||
break;
|
||||
case UNIT_STATE_ROOT:
|
||||
if (!HasUnitState(UNIT_STATE_STUNNED))
|
||||
{
|
||||
SetRooted(true);
|
||||
if (HasUnitState(UNIT_STATE_FLEEING))
|
||||
SetFeared(false);
|
||||
}
|
||||
break;
|
||||
case UNIT_STATE_CONFUSED:
|
||||
if (!HasUnitState(UNIT_STATE_STUNNED))
|
||||
@@ -14070,10 +14093,9 @@ void Unit::SetStunned(bool apply)
|
||||
SetTarget(ObjectGuid::Empty);
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
|
||||
// Creature specific
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
StopMoving();
|
||||
else
|
||||
StopMoving();
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
SetStandState(UNIT_STAND_STATE_STAND);
|
||||
|
||||
SetRooted(true);
|
||||
@@ -14106,6 +14128,7 @@ void Unit::SetRooted(bool apply, bool packetOnly /*= false*/)
|
||||
// setting MOVEMENTFLAG_ROOT
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING);
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
StopMoving();
|
||||
}
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
|
||||
@@ -14611,7 +14634,7 @@ Aura* Unit::AddAura(uint32 spellId, Unit* target)
|
||||
if (!spellInfo)
|
||||
return NULL;
|
||||
|
||||
if (!target->IsAlive() && !(spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !(spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD))
|
||||
if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_DEAD))
|
||||
return NULL;
|
||||
|
||||
return AddAura(spellInfo, MAX_EFFECT_MASK, target);
|
||||
@@ -14856,6 +14879,9 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
|
||||
float vcos, vsin;
|
||||
GetSinCos(x, y, vsin, vcos);
|
||||
SendMoveKnockBack(player, speedXY, -speedZ, vcos, vsin);
|
||||
|
||||
if (player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || player->HasAuraType(SPELL_AURA_FLY))
|
||||
player->SetCanFly(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16068,30 +16094,30 @@ void Unit::StopAttackFaction(uint32 faction_id)
|
||||
void Unit::OutDebugInfo() const
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "Unit::OutDebugInfo");
|
||||
TC_LOG_INFO("entities.unit", "%s name %s", GetGUID().ToString().c_str(), GetName().c_str());
|
||||
TC_LOG_INFO("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmGUID().ToString().c_str());
|
||||
TC_LOG_INFO("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask);
|
||||
TC_LOG_DEBUG("entities.unit", "%s name %s", GetGUID().ToString().c_str(), GetName().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmGUID().ToString().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask);
|
||||
if (IsInWorld())
|
||||
TC_LOG_INFO("entities.unit", "Mapid %u", GetMapId());
|
||||
TC_LOG_DEBUG("entities.unit", "Mapid %u", GetMapId());
|
||||
|
||||
std::ostringstream o;
|
||||
o << "Summon Slot: ";
|
||||
for (uint32 i = 0; i < MAX_SUMMON_SLOT; ++i)
|
||||
o << m_SummonSlot[i].ToString() << ", ";
|
||||
|
||||
TC_LOG_INFO("entities.unit", "%s", o.str().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
|
||||
o.str("");
|
||||
|
||||
o << "Controlled List: ";
|
||||
for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
o << (*itr)->GetGUID().ToString() << ", ";
|
||||
TC_LOG_INFO("entities.unit", "%s", o.str().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
|
||||
o.str("");
|
||||
|
||||
o << "Aura List: ";
|
||||
for (AuraApplicationMap::const_iterator itr = m_appliedAuras.begin(); itr != m_appliedAuras.end(); ++itr)
|
||||
o << itr->first << ", ";
|
||||
TC_LOG_INFO("entities.unit", "%s", o.str().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
|
||||
o.str("");
|
||||
|
||||
if (IsVehicle())
|
||||
@@ -16100,11 +16126,11 @@ void Unit::OutDebugInfo() const
|
||||
for (SeatMap::iterator itr = GetVehicleKit()->Seats.begin(); itr != GetVehicleKit()->Seats.end(); ++itr)
|
||||
if (Unit* passenger = ObjectAccessor::GetUnit(*GetVehicleBase(), itr->second.Passenger.Guid))
|
||||
o << passenger->GetGUID().ToString() << ", ";
|
||||
TC_LOG_INFO("entities.unit", "%s", o.str().c_str());
|
||||
TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
|
||||
}
|
||||
|
||||
if (GetVehicle())
|
||||
TC_LOG_INFO("entities.unit", "On vehicle %u.", GetVehicleBase()->GetEntry());
|
||||
TC_LOG_DEBUG("entities.unit", "On vehicle %u.", GetVehicleBase()->GetEntry());
|
||||
}
|
||||
|
||||
uint32 Unit::GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex) const
|
||||
@@ -16322,7 +16348,7 @@ bool Unit::SetSwim(bool enable)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unit::SetCanFly(bool enable)
|
||||
bool Unit::SetCanFly(bool enable, bool /*packetOnly = false */)
|
||||
{
|
||||
if (enable == HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY))
|
||||
return false;
|
||||
@@ -16644,27 +16670,6 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
|
||||
data->append(fieldBuffer);
|
||||
}
|
||||
|
||||
void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown)
|
||||
{
|
||||
data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + 4 + 4);
|
||||
data << uint64(GetGUID());
|
||||
data << uint8(flags);
|
||||
data << uint32(spellId);
|
||||
data << uint32(cooldown);
|
||||
}
|
||||
|
||||
void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns)
|
||||
{
|
||||
data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + (4 + 4) * cooldowns.size());
|
||||
data << uint64(GetGUID());
|
||||
data << uint8(flags);
|
||||
for (std::unordered_map<uint32, uint32>::const_iterator itr = cooldowns.begin(); itr != cooldowns.end(); ++itr)
|
||||
{
|
||||
data << uint32(itr->first);
|
||||
data << uint32(itr->second);
|
||||
}
|
||||
}
|
||||
|
||||
int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const
|
||||
{
|
||||
int32 val = 0;
|
||||
|
||||
@@ -274,13 +274,6 @@ enum UnitRename
|
||||
#define MAX_AGGRO_RESET_TIME 10 // in seconds
|
||||
#define MAX_AGGRO_RADIUS 45.0f // yards
|
||||
|
||||
enum Swing
|
||||
{
|
||||
NOSWING = 0,
|
||||
SINGLEHANDEDSWING = 1,
|
||||
TWOHANDEDSWING = 2
|
||||
};
|
||||
|
||||
enum VictimState
|
||||
{
|
||||
VICTIMSTATE_INTACT = 0, // set when attacker misses
|
||||
@@ -340,6 +333,7 @@ class AuraEffect;
|
||||
class Creature;
|
||||
class Spell;
|
||||
class SpellInfo;
|
||||
class SpellHistory;
|
||||
class DynamicObject;
|
||||
class GameObject;
|
||||
class Item;
|
||||
@@ -361,7 +355,7 @@ namespace Movement
|
||||
}
|
||||
|
||||
typedef std::list<Unit*> UnitList;
|
||||
typedef std::list< std::pair<Aura*, uint8> > DispelChargesList;
|
||||
typedef std::list<std::pair<Aura*, uint8>> DispelChargesList;
|
||||
|
||||
struct SpellImmune
|
||||
{
|
||||
@@ -386,13 +380,6 @@ enum WeaponDamageRange
|
||||
MAXDAMAGE
|
||||
};
|
||||
|
||||
enum DamageTypeToSchool
|
||||
{
|
||||
RESISTANCE,
|
||||
DAMAGE_DEALT,
|
||||
DAMAGE_TAKEN
|
||||
};
|
||||
|
||||
enum AuraRemoveMode
|
||||
{
|
||||
AURA_REMOVE_NONE = 0,
|
||||
@@ -1047,30 +1034,6 @@ enum CurrentSpellTypes
|
||||
#define CURRENT_FIRST_NON_MELEE_SPELL 1
|
||||
#define CURRENT_MAX_SPELL 4
|
||||
|
||||
struct GlobalCooldown
|
||||
{
|
||||
explicit GlobalCooldown(uint32 _dur = 0, uint32 _time = 0) : duration(_dur), cast_time(_time) { }
|
||||
|
||||
uint32 duration;
|
||||
uint32 cast_time;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32 /*category*/, GlobalCooldown> GlobalCooldownList;
|
||||
|
||||
class GlobalCooldownMgr // Shared by Player and CharmInfo
|
||||
{
|
||||
public:
|
||||
GlobalCooldownMgr() { }
|
||||
|
||||
public:
|
||||
bool HasGlobalCooldown(SpellInfo const* spellInfo) const;
|
||||
void AddGlobalCooldown(SpellInfo const* spellInfo, uint32 gcd);
|
||||
void CancelGlobalCooldown(SpellInfo const* spellInfo);
|
||||
|
||||
private:
|
||||
GlobalCooldownList m_GlobalCooldowns;
|
||||
};
|
||||
|
||||
enum ActiveStates
|
||||
{
|
||||
ACT_PASSIVE = 0x01, // 0x01 - passive
|
||||
@@ -1188,8 +1151,6 @@ struct CharmInfo
|
||||
|
||||
CharmSpellInfo* GetCharmSpell(uint8 index) { return &(_charmspells[index]); }
|
||||
|
||||
GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; }
|
||||
|
||||
void SetIsCommandAttack(bool val);
|
||||
bool IsCommandAttack();
|
||||
void SetIsCommandFollow(bool val);
|
||||
@@ -1222,8 +1183,6 @@ struct CharmInfo
|
||||
float _stayX;
|
||||
float _stayY;
|
||||
float _stayZ;
|
||||
|
||||
GlobalCooldownMgr m_GlobalCooldownMgr;
|
||||
};
|
||||
|
||||
// for clearing special attacks
|
||||
@@ -1254,16 +1213,6 @@ enum PlayerTotemType
|
||||
SUMMON_TYPE_TOTEM_AIR = 83
|
||||
};
|
||||
|
||||
/// Spell cooldown flags sent in SMSG_SPELL_COOLDOWN
|
||||
enum SpellCooldownFlags
|
||||
{
|
||||
SPELL_COOLDOWN_FLAG_NONE = 0x0,
|
||||
SPELL_COOLDOWN_FLAG_INCLUDE_GCD = 0x1, ///< Starts GCD in addition to normal cooldown specified in the packet
|
||||
SPELL_COOLDOWN_FLAG_INCLUDE_EVENT_COOLDOWNS = 0x2 ///< Starts GCD for spells that should start their cooldown on events, requires SPELL_COOLDOWN_FLAG_INCLUDE_GCD set
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, uint32> PacketCooldowns;
|
||||
|
||||
// delay time next attack to prevent client attack animation problems
|
||||
#define ATTACK_DISPLAY_DELAY 200
|
||||
#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player
|
||||
@@ -1600,8 +1549,6 @@ class Unit : public WorldObject
|
||||
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
|
||||
void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
|
||||
void SendPlaySpellVisualKit(uint32 id, uint32 unkParam);
|
||||
void BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown);
|
||||
void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns);
|
||||
|
||||
void DeMorph();
|
||||
|
||||
@@ -1640,7 +1587,7 @@ class Unit : public WorldObject
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false);
|
||||
bool SetFall(bool enable);
|
||||
bool SetSwim(bool enable);
|
||||
bool SetCanFly(bool enable);
|
||||
bool SetCanFly(bool enable, bool packetOnly = false);
|
||||
bool SetWaterWalking(bool enable, bool packetOnly = false);
|
||||
bool SetFeatherFall(bool enable, bool packetOnly = false);
|
||||
bool SetHover(bool enable, bool packetOnly = false);
|
||||
@@ -1862,7 +1809,6 @@ class Unit : public WorldObject
|
||||
void SetChannelObjectGuid(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); }
|
||||
|
||||
void SetCurrentCastSpell(Spell* pSpell);
|
||||
virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { }
|
||||
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true);
|
||||
void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
|
||||
|
||||
@@ -1880,6 +1826,9 @@ class Unit : public WorldObject
|
||||
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
|
||||
int32 GetCurrentSpellCastTime(uint32 spell_id) const;
|
||||
|
||||
SpellHistory* GetSpellHistory() { return m_spellHistory; }
|
||||
SpellHistory const* GetSpellHistory() const { return m_spellHistory; }
|
||||
|
||||
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT];
|
||||
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
|
||||
|
||||
@@ -1950,7 +1899,7 @@ class Unit : public WorldObject
|
||||
void TauntApply(Unit* victim);
|
||||
void TauntFadeOut(Unit* taunter);
|
||||
ThreatManager& getThreatManager() { return m_ThreatManager; }
|
||||
void addHatedBy(HostileReference* pHostileReference) { m_HostileRefManager.insertFirst(pHostileReference); };
|
||||
void addHatedBy(HostileReference* pHostileReference) { m_HostileRefManager.insertFirst(pHostileReference); }
|
||||
void removeHatedBy(HostileReference* /*pHostileReference*/) { /* nothing to do yet */ }
|
||||
HostileRefManager& getHostileRefManager() { return m_HostileRefManager; }
|
||||
|
||||
@@ -2023,6 +1972,8 @@ class Unit : public WorldObject
|
||||
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
|
||||
void ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type, bool apply);
|
||||
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // redefined in Creature
|
||||
uint32 GetSchoolImmunityMask() const;
|
||||
uint32 GetMechanicImmunityMask() const;
|
||||
|
||||
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const;
|
||||
bool IsImmunedToDamage(SpellInfo const* spellInfo) const;
|
||||
@@ -2312,6 +2263,7 @@ class Unit : public WorldObject
|
||||
|
||||
time_t _lastDamagedTime; // Part of Evade mechanics
|
||||
|
||||
SpellHistory* m_spellHistory;
|
||||
uint16 _aiAnimKitId;
|
||||
uint16 _movementAnimKitId;
|
||||
uint16 _meleeAnimKitId;
|
||||
|
||||
@@ -22,12 +22,8 @@
|
||||
#include "Vehicle.h"
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "ZoneScript.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "EventProcessor.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "GossipDef.h"
|
||||
#include "Player.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "UnitAI.h"
|
||||
|
||||
@@ -97,7 +97,7 @@ class GameEventMgr
|
||||
{
|
||||
private:
|
||||
GameEventMgr();
|
||||
~GameEventMgr() { };
|
||||
~GameEventMgr() { }
|
||||
|
||||
public:
|
||||
static GameEventMgr* instance()
|
||||
|
||||
Loaded 100 of 859 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user