lua part 1
This commit is contained in:
@@ -4,3 +4,6 @@
|
||||
[submodule "src/modules/Playerbot/deps/tbb"]
|
||||
path = src/modules/Playerbot/deps/tbb
|
||||
url = https://github.com/oneapi-src/oneTBB.git
|
||||
[submodule "src/server/game/LuaEngine"]
|
||||
path = src/server/game/LuaEngine
|
||||
url = https://github.com/ElunaLuaEngine/Eluna.git
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
|
||||
endforeach()
|
||||
|
||||
option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 1)
|
||||
option(ELUNA "Build Eluna Lua Engine" 1)
|
||||
option(BUILD_PLAYERBOT "Build optional Playerbot module for AI-controlled characters" 0)
|
||||
option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1)
|
||||
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
|
||||
@@ -48,7 +49,7 @@ if(WITH_DYNAMIC_LINKING OR WITH_DYNAMIC_LINKING_FORCED)
|
||||
else()
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
endif()
|
||||
if(WITH_FILESYSTEM_WATCHER OR BUILD_SHARED_LIBS)
|
||||
if(WITH_FILESYSTEM_WATCHER OR BUILD_SHARED_LIBS OR ELUNA)
|
||||
set(BUILD_EFSW ON)
|
||||
endif()
|
||||
option(WITH_WARNINGS "Show all warnings during compile" 0)
|
||||
|
||||
@@ -40,6 +40,15 @@ else()
|
||||
message("* Build map/vmap tools : No")
|
||||
endif()
|
||||
|
||||
if(ELUNA)
|
||||
message("* Build Eluna LuaEngine : Yes (default)")
|
||||
add_definitions(-DELUNA)
|
||||
add_definitions(-DELUNA_TRINITY)
|
||||
add_definitions(-DELUNA_EXPANSION=9)
|
||||
else()
|
||||
message("* Build Eluna LuaEngine : No")
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
message("* Build unit tests : Yes")
|
||||
else()
|
||||
|
||||
@@ -52,3 +52,7 @@ if(BUILD_TESTING)
|
||||
GIT_SHALLOW 1)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
endif()
|
||||
|
||||
if (ELUNA)
|
||||
add_subdirectory(lualib)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
set(LUA_VERSION "lua52" CACHE STRING "Lua version to use")
|
||||
set_property(CACHE LUA_VERSION PROPERTY STRINGS luajit lua51 lua52 lua53 lua54)
|
||||
MESSAGE(STATUS "Lua version: ${LUA_VERSION}")
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
|
||||
option(LUA_STATIC "link lua statically" OFF)
|
||||
if (LUA_STATIC)
|
||||
MESSAGE(STATUS "Lua linking: static")
|
||||
else()
|
||||
MESSAGE(STATUS "Lua linking: dynamic")
|
||||
endif()
|
||||
|
||||
if (LUA_VERSION MATCHES "luajit")
|
||||
add_subdirectory(luajit)
|
||||
else()
|
||||
add_subdirectory(lua)
|
||||
endif()
|
||||
@@ -0,0 +1,67 @@
|
||||
# BSD-3-Clause
|
||||
# Copyright (c) 2022, Rochet2 <[email protected]>
|
||||
# All rights reserved.
|
||||
|
||||
project (lua C)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
lua52
|
||||
URL https://www.lua.org/ftp/lua-5.2.4.tar.gz
|
||||
URL_HASH SHA256=b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b
|
||||
)
|
||||
FetchContent_MakeAvailable(lua52)
|
||||
|
||||
set(LUA_SOURCE_FOLDER "${lua52_SOURCE_DIR}/src")
|
||||
|
||||
file(GLOB LOCAL_SOURCES_H "${LUA_SOURCE_FOLDER}/*.h")
|
||||
file(GLOB LOCAL_SOURCES_C "${LUA_SOURCE_FOLDER}/*.c")
|
||||
list(REMOVE_ITEM LOCAL_SOURCES_C "${LUA_SOURCE_FOLDER}/lua.c")
|
||||
list(REMOVE_ITEM LOCAL_SOURCES_C "${LUA_SOURCE_FOLDER}/luac.c")
|
||||
|
||||
if (LUA_STATIC)
|
||||
add_library(lualib STATIC ${LOCAL_SOURCES_H} ${LOCAL_SOURCES_C})
|
||||
set_property(TARGET lualib PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
else()
|
||||
add_library(lualib SHARED ${LOCAL_SOURCES_H} ${LOCAL_SOURCES_C})
|
||||
set_property(TARGET lualib PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
add_library(lualib_static STATIC ${LOCAL_SOURCES_H} ${LOCAL_SOURCES_C})
|
||||
set_target_properties(lualib PROPERTIES LINKER_LANGUAGE C)
|
||||
set_target_properties(lualib_static PROPERTIES LINKER_LANGUAGE C)
|
||||
target_include_directories(lualib PUBLIC "${LUA_SOURCE_FOLDER}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_include_directories(lualib_static PUBLIC "${LUA_SOURCE_FOLDER}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
if (WIN32)
|
||||
set_target_properties(lualib PROPERTIES OUTPUT_NAME lua52)
|
||||
install(TARGETS lualib DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
if (NOT LUA_STATIC)
|
||||
install(FILES $<TARGET_PDB_FILE:lualib> DESTINATION "${CMAKE_INSTALL_PREFIX}" OPTIONAL)
|
||||
endif()
|
||||
else()
|
||||
set_target_properties(lualib PROPERTIES OUTPUT_NAME lua52)
|
||||
install(TARGETS lualib DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
install(TARGETS lualib_static DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(lualib PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(lualib_static PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
if (NOT LUA_STATIC)
|
||||
target_compile_definitions(lualib PRIVATE LUA_BUILD_AS_DLL)
|
||||
endif()
|
||||
elseif (APPLE)
|
||||
target_compile_definitions(lualib PUBLIC LUA_USE_MACOSX)
|
||||
target_compile_definitions(lualib_static PUBLIC LUA_USE_MACOSX)
|
||||
target_compile_options(lualib PRIVATE -Wno-deprecated-declarations -Wno-empty-body)
|
||||
target_compile_options(lualib_static PRIVATE -Wno-deprecated-declarations -Wno-empty-body)
|
||||
target_link_libraries(lualib readline)
|
||||
target_link_libraries(lualib_static readline)
|
||||
elseif (UNIX)
|
||||
target_compile_definitions(lualib PUBLIC LUA_USE_LINUX)
|
||||
target_link_libraries(lualib ${CMAKE_DL_LIBS} m readline)
|
||||
target_compile_definitions(lualib_static PUBLIC LUA_USE_LINUX)
|
||||
target_link_libraries(lualib_static ${CMAKE_DL_LIBS} m readline)
|
||||
set_target_properties(lualib PROPERTIES OUTPUT_NAME lua52)
|
||||
set_target_properties(lualib_static PROPERTIES OUTPUT_NAME lua52)
|
||||
endif()
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef LUA_HPP
|
||||
#define LUA_HPP
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
# Placeholder for luajit - using lua52 instead
|
||||
message(STATUS "Using lua52 instead of luajit")
|
||||
@@ -46,6 +46,12 @@ if(TARGET jemalloc)
|
||||
jemalloc)
|
||||
endif()
|
||||
|
||||
if(ELUNA)
|
||||
target_link_libraries(common
|
||||
PUBLIC
|
||||
lualib)
|
||||
endif()
|
||||
|
||||
target_link_libraries(common
|
||||
PRIVATE
|
||||
trinity-core-interface
|
||||
|
||||
@@ -659,6 +659,12 @@ QueryResultFieldMetadata const& ResultSet::GetFieldMetadata(Trinity::DB::FieldLo
|
||||
return _fieldMetadata[itr->second];
|
||||
}
|
||||
|
||||
char const* ResultSet::GetFieldName(std::size_t index) const
|
||||
{
|
||||
ASSERT(index < std::size_t(_fieldCount));
|
||||
return _fieldMetadata[index].Name;
|
||||
}
|
||||
|
||||
Field* PreparedResultSet::Fetch() const
|
||||
{
|
||||
ASSERT(m_rowPosition < m_rowCount);
|
||||
|
||||
@@ -64,6 +64,8 @@ class TC_DATABASE_API ResultSet
|
||||
QueryResultFieldMetadata const& GetFieldMetadata(std::size_t index) const;
|
||||
QueryResultFieldMetadata const& GetFieldMetadata(Trinity::DB::FieldLookupByAliasKey const& alias) const;
|
||||
|
||||
char const* GetFieldName(std::size_t index) const;
|
||||
|
||||
protected:
|
||||
std::vector<QueryResultFieldMetadata> _fieldMetadata;
|
||||
Trinity::DB::FieldAliasToIndexMap _fieldIndexByAlias;
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
#include "Transport.h"
|
||||
#include "Util.h"
|
||||
#include "WorldStateMgr.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <cstdarg>
|
||||
|
||||
template<class Do>
|
||||
|
||||
@@ -77,6 +77,26 @@ if(TARGET efsw)
|
||||
efsw)
|
||||
endif()
|
||||
|
||||
if(ELUNA)
|
||||
# Add Eluna source files to game library
|
||||
target_include_directories(game PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine")
|
||||
target_compile_definitions(game PRIVATE -DELUNA -DELUNA_TRINITY -DELUNA_EXPANSION=9)
|
||||
|
||||
# Link lualib
|
||||
if(TARGET lualib)
|
||||
target_link_libraries(game PRIVATE lualib)
|
||||
endif()
|
||||
|
||||
# Eluna source files
|
||||
file(GLOB ELUNA_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/hooks/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/methods/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/LuaEngine/*.cpp"
|
||||
)
|
||||
target_sources(game PRIVATE ${ELUNA_SOURCES})
|
||||
endif()
|
||||
|
||||
set_target_properties(game
|
||||
PROPERTIES
|
||||
COMPILE_WARNING_AS_ERROR ${WITH_WARNINGS_AS_ERRORS}
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#include "Vehicle.h"
|
||||
#include "World.h"
|
||||
#include "ZoneScript.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <G3D/g3dmath.h>
|
||||
#include <sstream>
|
||||
|
||||
@@ -361,6 +364,11 @@ void Creature::AddToWorld()
|
||||
|
||||
if (GetZoneScript())
|
||||
GetZoneScript()->OnCreatureCreate(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
GetMap()->GetEluna()->OnAddToWorld(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,6 +379,11 @@ void Creature::RemoveFromWorld()
|
||||
if (GetZoneScript())
|
||||
GetZoneScript()->OnCreatureRemove(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
GetMap()->GetEluna()->OnRemoveFromWorld(this);
|
||||
#endif
|
||||
|
||||
if (m_formation)
|
||||
FormationMgr::RemoveCreatureFromGroup(m_formation, this);
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
#include "Util.h"
|
||||
#include "Vignette.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <G3D/Box.h>
|
||||
#include <G3D/CoordinateFrame.h>
|
||||
#include <G3D/Quat.h>
|
||||
@@ -2589,6 +2592,12 @@ void GameObject::Use(Unit* user, bool ignoreCastInProgress /*= false*/)
|
||||
playerUser->PlayerTalkClass->ClearMenus();
|
||||
if (AI()->OnGossipHello(playerUser))
|
||||
return;
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
if (GetMap()->GetEluna()->OnGossipHello(playerUser, this))
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
// If cooldown data present in template
|
||||
@@ -3796,6 +3805,16 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, WorldOb
|
||||
GameEvents::Trigger(GetGOInfo()->destructibleBuilding.DamagedEvent, attackerOrHealer, this);
|
||||
AI()->Damaged(attackerOrHealer, m_goInfo->destructibleBuilding.DamagedEvent);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
{
|
||||
if (Player* player = attackerOrHealer->ToPlayer())
|
||||
GetMap()->GetEluna()->OnDamaged(this, player);
|
||||
else
|
||||
GetMap()->GetEluna()->OnDamaged(this, attackerOrHealer);
|
||||
}
|
||||
#endif
|
||||
|
||||
RemoveFlag(GO_FLAG_DESTROYED);
|
||||
SetFlag(GO_FLAG_DAMAGED);
|
||||
|
||||
@@ -3822,6 +3841,16 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, WorldOb
|
||||
GameEvents::Trigger(GetGOInfo()->destructibleBuilding.DestroyedEvent, attackerOrHealer, this);
|
||||
AI()->Destroyed(attackerOrHealer, m_goInfo->destructibleBuilding.DestroyedEvent);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
{
|
||||
if (Player* player = attackerOrHealer->ToPlayer())
|
||||
GetMap()->GetEluna()->OnDestroyed(this, player);
|
||||
else
|
||||
GetMap()->GetEluna()->OnDestroyed(this, attackerOrHealer);
|
||||
}
|
||||
#endif
|
||||
|
||||
RemoveFlag(GO_FLAG_DAMAGED);
|
||||
SetFlag(GO_FLAG_DESTROYED);
|
||||
|
||||
@@ -3871,6 +3900,11 @@ void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
|
||||
AI()->OnLootStateChanged(state, unit);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
GetMap()->GetEluna()->OnLootStateChanged(this, state);
|
||||
#endif
|
||||
|
||||
// Start restock timer if the chest is partially looted or not looted at all
|
||||
if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED && GetGOInfo()->chest.chestRestockTime > 0 && m_restockTime == 0 && m_loot && m_loot->IsChanged())
|
||||
m_restockTime = GameTime::GetGameTime() + GetGOInfo()->chest.chestRestockTime;
|
||||
@@ -3959,6 +3993,11 @@ void GameObject::SetGoState(GOState state)
|
||||
if (m_goTypeImpl)
|
||||
m_goTypeImpl->OnStateChanged(oldState, state);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (GetMap() && GetMap()->GetEluna())
|
||||
GetMap()->GetEluna()->OnGameObjectStateChanged(this, state);
|
||||
#endif
|
||||
|
||||
if (m_model && !IsTransport())
|
||||
{
|
||||
if (!IsInWorld())
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
#include "TradeData.h"
|
||||
#include "UpdateData.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "WorldSession.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
#include "VMapFactory.h"
|
||||
#include "VMapManager.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <G3D/Vector3.h>
|
||||
#include <sstream>
|
||||
|
||||
@@ -225,6 +228,10 @@ m_currMap(nullptr), m_InstanceId(0), _dbPhase(0), m_notifyflags(0), _heartbeatTi
|
||||
|
||||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
||||
|
||||
#ifdef ELUNA
|
||||
_eluna = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
WorldObject::~WorldObject()
|
||||
|
||||
@@ -62,6 +62,9 @@ class Unit;
|
||||
class UpdateData;
|
||||
class WorldObject;
|
||||
class ZoneScript;
|
||||
#ifdef ELUNA
|
||||
class Eluna;
|
||||
#endif
|
||||
struct FactionTemplateEntry;
|
||||
struct Loot;
|
||||
struct QuaternionData;
|
||||
@@ -573,6 +576,14 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
std::string GetDebugInfo() const override;
|
||||
|
||||
#ifdef ELUNA
|
||||
Eluna* GetEluna() const { return _eluna; }
|
||||
private:
|
||||
Eluna* _eluna;
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
|
||||
// Event handler
|
||||
EventProcessor m_Events;
|
||||
|
||||
|
||||
@@ -139,6 +139,9 @@
|
||||
#include "Vignette.h"
|
||||
#include "VignettePackets.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "WorldStateMgr.h"
|
||||
@@ -1572,6 +1575,11 @@ void Player::AddToWorld()
|
||||
GetSession()->GetBattlenetAccount().AddToWorld();
|
||||
GetSession()->GetHousingPlayerHouseEntity().AddToWorld();
|
||||
GetSession()->GetHousingNeighborhoodMirrorEntity().AddToWorld();
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnLogin(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::RemoveFromWorld()
|
||||
@@ -1608,6 +1616,11 @@ void Player::RemoveFromWorld()
|
||||
for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter)
|
||||
iter->second->RemoveFromWorld();
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnLogout(this);
|
||||
#endif
|
||||
|
||||
if (WorldObject* viewpoint = GetViewpoint())
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Player::RemoveFromWorld: Player '{}' ({}) has viewpoint (Entry:{}, Type: {}) when removed from world",
|
||||
@@ -2414,6 +2427,11 @@ void Player::GiveLevel(uint8 level)
|
||||
PushQuests();
|
||||
|
||||
sScriptMgr->OnPlayerLevelChanged(this, oldLevel);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnLevelChanged(this, oldLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Player::IsMaxLevel() const
|
||||
@@ -3281,6 +3299,11 @@ void Player::LearnSpell(uint32 spell_id, bool dependent, int32 fromSkill /*= 0*/
|
||||
}
|
||||
else
|
||||
UpdateQuestObjectiveProgress(QUEST_OBJECTIVE_LEARNSPELL, spell_id, 1);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (learning && sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnLearnSpell(this, spell_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::RemoveSpell(uint32 spell_id, bool disabled /*= false*/, bool learn_low_rank /*= true*/, bool suppressMessaging /*= false*/)
|
||||
@@ -3572,6 +3595,11 @@ bool Player::ResetTalents(bool noCost)
|
||||
{
|
||||
sScriptMgr->OnPlayerTalentsReset(this, noCost);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnTalentsReset(this, noCost);
|
||||
#endif
|
||||
|
||||
// not need after this call
|
||||
if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
|
||||
RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS, true);
|
||||
@@ -4033,6 +4061,11 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||
} while (resultFriends->NextRow());
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnDelete(guid);
|
||||
#endif
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER);
|
||||
stmt->setUInt64(0, guid);
|
||||
trans->Append(stmt);
|
||||
@@ -4515,6 +4548,11 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
|
||||
// PLAYERBOT HOOK: Notify bots of resurrection
|
||||
if (Playerbot::PlayerBotHooks::OnPlayerResurrected)
|
||||
Playerbot::PlayerBotHooks::OnPlayerResurrected(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnResurrect(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::KillPlayer()
|
||||
@@ -7744,6 +7782,12 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
|
||||
// call enter script hooks after everyting else has processed
|
||||
sScriptMgr->OnPlayerUpdateZone(this, newZone, newArea);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnUpdateZone(this, newZone, newArea);
|
||||
#endif
|
||||
|
||||
if (oldZone != newZone)
|
||||
{
|
||||
sOutdoorPvPMgr->HandlePlayerEnterZone(this, newZone);
|
||||
@@ -7906,6 +7950,16 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
|
||||
sScriptMgr->OnPlayerDuelEnd(opponent, this, type);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
{
|
||||
if (type == DUEL_WON)
|
||||
sWorld->GetEluna()->OnDuelEnd(this, opponent, type);
|
||||
else
|
||||
sWorld->GetEluna()->OnDuelEnd(opponent, this, type);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DUEL_FLED:
|
||||
@@ -11834,6 +11888,11 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
|
||||
|
||||
ApplyEquipCooldown(pItem);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnEquip(this, pItem, bag, slot);
|
||||
#endif
|
||||
|
||||
// update expertise and armor penetration - passive auras may need it
|
||||
|
||||
if (slot == EQUIPMENT_SLOT_MAINHAND)
|
||||
@@ -21353,6 +21412,11 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba
|
||||
// save pet (hunter pet level and experience and all type pets health/mana).
|
||||
if (Pet* pet = GetPet())
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnSave(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
// fast save function for item/money cheating preventing - save only inventory and money state
|
||||
@@ -22490,10 +22554,15 @@ void Player::ResetInstances(InstanceResetMethod method)
|
||||
break;
|
||||
case InstanceResetResult::CannotReset:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnQuestAccept(this, quest);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (forgetInstance)
|
||||
@@ -22630,6 +22699,11 @@ void Player::UpdateDuelFlag(time_t currTime)
|
||||
{
|
||||
sScriptMgr->OnPlayerDuelStart(this, duel->Opponent);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnDuelStart(this, duel->Opponent);
|
||||
#endif
|
||||
|
||||
SetDuelTeam(1);
|
||||
duel->Opponent->SetDuelTeam(2);
|
||||
|
||||
@@ -27643,6 +27717,27 @@ void Player::AtEnterCombat()
|
||||
Unit::AtEnterCombat();
|
||||
if (GetCombatManager().HasPvPCombat())
|
||||
EnablePvpRules(true);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
{
|
||||
Unit* enemy = nullptr;
|
||||
for (auto const& pair : GetCombatManager().GetPvECombatRefs())
|
||||
{
|
||||
enemy = pair.second->GetOther(this);
|
||||
break;
|
||||
}
|
||||
for (auto const& pair : GetCombatManager().GetPvPCombatRefs())
|
||||
{
|
||||
enemy = pair.second->GetOther(this);
|
||||
break;
|
||||
}
|
||||
if (enemy)
|
||||
sWorld->GetEluna()->OnPlayerEnterCombat(this, enemy);
|
||||
else
|
||||
sWorld->GetEluna()->OnPlayerEnterCombat(this, nullptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::AtExitCombat()
|
||||
@@ -27650,6 +27745,11 @@ void Player::AtExitCombat()
|
||||
Unit::AtExitCombat();
|
||||
UpdatePotionCooldown();
|
||||
m_regenInterruptTimestamp = GameTime::Now();
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnPlayerLeaveCombat(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
float Player::GetBlockPercent(uint8 attackerLevel) const
|
||||
@@ -28028,6 +28128,11 @@ void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot*
|
||||
else
|
||||
ApplyItemLootedSpell(sObjectMgr->GetItemTemplate(item->itemid));
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnLootItem(this, newitem, item->count, lootWorldObjectGuid);
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
case LootItemType::Currency:
|
||||
@@ -28384,6 +28489,11 @@ void Player::UpdateCriteria(CriteriaType type, uint64 miscValue1 /*= 0*/, uint64
|
||||
void Player::CompletedAchievement(AchievementEntry const* entry)
|
||||
{
|
||||
m_achievementMgr->CompletedAchievement(entry, this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnAchievementComplete(this, entry->ID);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Player::ModifierTreeSatisfied(uint32 modifierTreeId) const
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#include "Loot.h"
|
||||
#include "LootMgr.h"
|
||||
#include "LootPackets.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "MapUtils.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MotionMaster.h"
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Unit.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <sstream>
|
||||
|
||||
class VehicleJoinEvent : public BasicEvent
|
||||
@@ -92,6 +95,11 @@ void Vehicle::Install()
|
||||
_status = STATUS_INSTALLED;
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
sScriptMgr->OnInstall(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnInstall(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Vehicle::InstallAllAccessories(bool evading)
|
||||
@@ -134,6 +142,11 @@ void Vehicle::Uninstall()
|
||||
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
sScriptMgr->OnUninstall(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnUninstall(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#include "StringConvert.h"
|
||||
#include "World.h"
|
||||
#include "WorldStateMgr.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "WowTime.h"
|
||||
|
||||
GameEventMgr* GameEventMgr::instance()
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include "Player.h"
|
||||
#include "UpdateData.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
Seconds Group::CountdownInfo::GetTimeLeft() const
|
||||
{
|
||||
@@ -494,6 +497,11 @@ bool Group::AddMember(Player* player)
|
||||
SendUpdate();
|
||||
sScriptMgr->OnGroupAddMember(this, player->GetGUID());
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnAddMember(this, player->GetGUID());
|
||||
#endif
|
||||
|
||||
if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
|
||||
{
|
||||
if (player->GetDungeonDifficultyID() != GetDungeonDifficultyID())
|
||||
@@ -569,6 +577,11 @@ bool Group::RemoveMember(ObjectGuid guid, RemoveMethod method /*= GROUP_REMOVEME
|
||||
|
||||
sScriptMgr->OnGroupRemoveMember(this, guid, method, kicker, reason);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnRemoveMember(this, guid, method);
|
||||
#endif
|
||||
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
@@ -728,6 +741,11 @@ void Group::Disband(bool hideDestroy /* = false */)
|
||||
{
|
||||
sScriptMgr->OnGroupDisband(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnDisband(this);
|
||||
#endif
|
||||
|
||||
Player* player;
|
||||
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#include "SocialMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "api/client/v1/club_listener.pb.h"
|
||||
#include "api/client/v1/club_membership_listener.pb.h"
|
||||
|
||||
@@ -1201,6 +1204,11 @@ void Guild::Disband()
|
||||
// Call scripts before guild data removed from database
|
||||
sScriptMgr->OnGuildDisband(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnDisband(this);
|
||||
#endif
|
||||
|
||||
WorldPackets::Guild::GuildEventDisbanded guildEventDisbanded;
|
||||
guildEventDisbanded.Write();
|
||||
|
||||
@@ -2952,6 +2960,11 @@ bool Guild::AddMember(CharacterDatabaseTransaction trans, ObjectGuid guid, Optio
|
||||
// Call scripts if member was succesfully added (and stored to database)
|
||||
sScriptMgr->OnGuildAddMember(this, player, AsUnderlyingType(*rankId));
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnAddMember(this, player, AsUnderlyingType(*rankId));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2989,6 +3002,16 @@ bool Guild::DeleteMember(CharacterDatabaseTransaction trans, ObjectGuid guid, bo
|
||||
// Call script on remove before member is actually removed from guild (and database)
|
||||
sScriptMgr->OnGuildRemoveMember(this, guid, isDisbanding, isKicked);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
{
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
|
||||
sWorld->GetEluna()->OnRemoveMember(this, player, isDisbanding);
|
||||
else
|
||||
sWorld->GetEluna()->OnRemoveMember(this, guid, isDisbanding);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_members.erase(guid);
|
||||
|
||||
// If player not online data in data field will be loaded from guild tabs no need to update it !!
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#include "Random.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// --------- LootItem ---------
|
||||
|
||||
Submodule
+1
Submodule src/server/game/LuaEngine added at 1025849e22
@@ -68,6 +68,9 @@
|
||||
#include <sstream>
|
||||
//WowCommunity
|
||||
#include "MeshObject.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
//WowCommunity
|
||||
#define DEFAULT_GRID_EXPIRY 300
|
||||
#define MAX_GRID_LOAD_TIME 50
|
||||
@@ -162,6 +165,11 @@ i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _r
|
||||
m_mmapTileRebuilder = std::make_shared<MMAP::DynamicTileBuilder>(this, MMAP::MMapManager::instance()->GetNavMesh(GetId(), GetInstanceId()));
|
||||
|
||||
_worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
_eluna = new Eluna(this);
|
||||
_eluna->OnCreate(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Map::InitVisibilityDistance()
|
||||
@@ -417,6 +425,11 @@ bool Map::AddPlayerToMap(Player* player, bool initPlayer /*= true*/)
|
||||
ConvertCorpseToBones(player->GetGUID());
|
||||
|
||||
sScriptMgr->OnPlayerEnterMap(this, player);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (_eluna)
|
||||
_eluna->OnPlayerEnter(this, player);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -816,6 +829,11 @@ void Map::Update(uint32 t_diff)
|
||||
|
||||
sScriptMgr->OnMapUpdate(this, t_diff);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (_eluna)
|
||||
_eluna->OnMapUpdate(this, t_diff);
|
||||
#endif
|
||||
|
||||
TC_METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
|
||||
TC_METRIC_TAG("map_id", std::to_string(GetId())),
|
||||
TC_METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
|
||||
@@ -920,6 +938,11 @@ void Map::RemovePlayerFromMap(Player* player, bool remove)
|
||||
player->UpdateZone(MAP_INVALID_ZONE, 0);
|
||||
sScriptMgr->OnPlayerLeaveMap(this, player);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (_eluna)
|
||||
_eluna->OnPlayerLeave(this, player);
|
||||
#endif
|
||||
|
||||
GetMultiPersonalPhaseTracker().MarkAllPhasesForDeletion(player->GetGUID());
|
||||
|
||||
player->CombatStop();
|
||||
|
||||
@@ -78,6 +78,9 @@ struct SummonPropertiesEntry;
|
||||
struct UpdateAdditionalSaveDataEvent;
|
||||
struct UpdateBossStateSaveDataEvent;
|
||||
class Transport;
|
||||
#ifdef ELUNA
|
||||
class Eluna;
|
||||
#endif
|
||||
enum Difficulty : int16;
|
||||
enum WeatherState : uint32;
|
||||
enum class ItemContext : uint8;
|
||||
@@ -592,7 +595,13 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
|
||||
virtual std::string GetDebugInfo() const;
|
||||
|
||||
#ifdef ELUNA
|
||||
Eluna* GetEluna() const { return _eluna; }
|
||||
private:
|
||||
Eluna* _eluna;
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
|
||||
void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; }
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldStateMgr.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <numeric>
|
||||
@@ -498,6 +501,10 @@ bool MapManager::DestroyMap(Map* map)
|
||||
sOutdoorPvPMgr->DestroyOutdoorPvPForMap(map);
|
||||
sBattlefieldMgr->DestroyBattlefieldsForMap(map);
|
||||
sScriptMgr->OnDestroyMap(map);
|
||||
#ifdef ELUNA
|
||||
if (map->GetEluna())
|
||||
map->GetEluna()->OnDestroy(map);
|
||||
#endif
|
||||
|
||||
map->UnloadAll();
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
#include "Vehicle.h"
|
||||
#include "Weather.h"
|
||||
#include "WorldPacket.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <unordered_map>
|
||||
|
||||
// Trait which indicates whether this script type
|
||||
@@ -1965,11 +1968,19 @@ void ScriptMgr::OnRelocate(Transport* transport, uint32 mapId, float x, float y,
|
||||
void ScriptMgr::OnStartup()
|
||||
{
|
||||
FOREACH_SCRIPT(WorldScript)->OnStartup();
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnStartup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScriptMgr::OnShutdown()
|
||||
{
|
||||
FOREACH_SCRIPT(WorldScript)->OnShutdown();
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Achievement
|
||||
|
||||
@@ -97,6 +97,10 @@ enum SpellEffIndex : uint8;
|
||||
enum WeatherState : uint32;
|
||||
enum XPColorChar : uint8;
|
||||
|
||||
#ifdef ELUNA
|
||||
class Eluna;
|
||||
#endif
|
||||
|
||||
#define VISIBLE_RANGE 166.0f //MAX visible range (size of grid)
|
||||
|
||||
/*
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
#include "HousingNeighborhoodMirrorEntity.h"
|
||||
#include "HousingPlayerHouseEntity.h"
|
||||
#include "PerkProgramMgr.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
//WowCommunity
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@@ -84,6 +84,9 @@
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
//WowCommunity
|
||||
@@ -599,6 +602,18 @@ void Spell::EffectDummy()
|
||||
// normal DB scripted effect
|
||||
TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectDummy({})", m_spellInfo->Id, effectInfo->EffectIndex);
|
||||
m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (m_caster->GetMap() && m_caster->GetMap()->GetEluna())
|
||||
{
|
||||
if (unitTarget)
|
||||
m_caster->GetMap()->GetEluna()->OnDummyEffect(m_caster, m_spellInfo->Id, effectInfo->EffectIndex, unitTarget);
|
||||
else if (gameObjTarget)
|
||||
m_caster->GetMap()->GetEluna()->OnDummyEffect(m_caster, m_spellInfo->Id, effectInfo->EffectIndex, gameObjTarget);
|
||||
else if (itemTarget)
|
||||
m_caster->GetMap()->GetEluna()->OnDummyEffect(m_caster, m_spellInfo->Id, effectInfo->EffectIndex, itemTarget);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Spell::EffectTriggerSpell()
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
/// Create the Weather object
|
||||
Weather::Weather(uint32 zoneId, WeatherData const* weatherChances)
|
||||
@@ -267,6 +270,12 @@ bool Weather::UpdateWeather()
|
||||
|
||||
TC_LOG_INFO("misc", "Change the weather of zone {} to {}.", m_zone, wthstr);
|
||||
sScriptMgr->OnWeatherChange(this, state, m_intensity);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (sWorld->GetEluna())
|
||||
sWorld->GetEluna()->OnChange(this, m_zone, state, m_intensity);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,10 @@
|
||||
#include "Threading/BotActionManager.h"
|
||||
#endif
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
TC_GAME_API std::atomic<bool> World::m_stopEvent(false);
|
||||
TC_GAME_API uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
|
||||
|
||||
@@ -1967,6 +1971,10 @@ bool World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Initializing Scripts...");
|
||||
sScriptMgr->Initialize();
|
||||
sScriptMgr->OnConfigLoad(false); // must be done after the ScriptMgr has been properly initialized
|
||||
#ifdef ELUNA
|
||||
eluna = new Eluna(nullptr);
|
||||
eluna->OnLuaStateOpen();
|
||||
#endif
|
||||
|
||||
TC_LOG_INFO("server.loading", "Validating spell scripts...");
|
||||
sObjectMgr->ValidateSpellScripts();
|
||||
@@ -2362,6 +2370,11 @@ void World::Update(uint32 diff)
|
||||
sScriptMgr->OnWorldUpdate(diff);
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
if (eluna)
|
||||
eluna->OnWorldUpdate(diff);
|
||||
#endif
|
||||
|
||||
{
|
||||
TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Update modules"));
|
||||
ModuleManager::CallOnUpdate(diff);
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#ifdef ELUNA
|
||||
class Eluna;
|
||||
#endif
|
||||
class Player;
|
||||
class WorldPacket;
|
||||
class WorldSession;
|
||||
@@ -797,7 +800,10 @@ class TC_GAME_API World
|
||||
return _gameRules;
|
||||
}
|
||||
|
||||
protected:
|
||||
#ifdef ELUNA
|
||||
Eluna* GetEluna() const { return eluna; }
|
||||
Eluna* eluna;
|
||||
#endif
|
||||
void _UpdateGameTime();
|
||||
|
||||
// callback for UpdateRealmCharacters
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) WowCommunity Project
|
||||
*
|
||||
* This SourceCode is NOT free a software. Please hold everything Private
|
||||
* and read our Terms
|
||||
*/
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
class LearnRiding : public PlayerScript
|
||||
{
|
||||
public:
|
||||
LearnRiding() : PlayerScript("LearnRiding") {}
|
||||
|
||||
void CheckRidingSkill(Player* player)
|
||||
{
|
||||
enum
|
||||
{
|
||||
APPRENTICE_RIDING = 33388, // Classic riding, level 1
|
||||
JOURNEYMAN_RIDING = 33391, // Level 10
|
||||
EXPERT_RIDING = 34090, // Level 20
|
||||
MASTER_RIDING = 90265, // Level 30
|
||||
DRAGONRIDING_BASICS = 376777, // Level 10 (War Within)
|
||||
DRAGONRIDING_WHIRLING_SURGE = 361584, // Level 15
|
||||
DRAGONRIDING_LIFT_OFF = 374763, // Level 15
|
||||
QUEST_TIME_TO_FLY_HORDE = 75874, // Adjust if needed
|
||||
QUEST_TIME_TO_FLY_ALLIANCE = 75877
|
||||
};
|
||||
|
||||
// Define level-to-spell mappings
|
||||
std::vector<std::pair<int8, uint32>> levelToRiding =
|
||||
{
|
||||
{1, APPRENTICE_RIDING}, // Learn at level 1
|
||||
{10, JOURNEYMAN_RIDING}, // Learn at level 10
|
||||
{20, EXPERT_RIDING}, // Learn at level 20
|
||||
{30, MASTER_RIDING}, // Learn at level 30
|
||||
{10, DRAGONRIDING_BASICS}, // Learn at level 10
|
||||
{15, DRAGONRIDING_WHIRLING_SURGE}, // Learn at level 15
|
||||
{15, DRAGONRIDING_LIFT_OFF} // Learn at level 15
|
||||
};
|
||||
|
||||
// Teach spells based on player level
|
||||
for (const auto& riding : levelToRiding)
|
||||
{
|
||||
if (player->GetLevel() >= riding.first && !player->HasSpell(riding.second))
|
||||
{
|
||||
player->LearnSpell(riding.second, true);
|
||||
TC_LOG_DEBUG("scripts", "LearnRiding: Taught spell %u to player %s (level %u)", riding.second, player->GetName().c_str(), player->GetLevel());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle riding skill and quests at level 40
|
||||
if (player->GetLevel() >= 40)
|
||||
{
|
||||
// Set riding skill (verify ID 762 for 11.x)
|
||||
player->SetSkill(762, 0, 375, 375); // Step=0 for compatibility; adjust values if needed
|
||||
|
||||
// Horde quest
|
||||
if (player->IsInHorde())
|
||||
{
|
||||
if (player->GetQuestStatus(QUEST_TIME_TO_FLY_HORDE) != QUEST_STATUS_REWARDED && !player->HasQuest(QUEST_TIME_TO_FLY_HORDE))
|
||||
{
|
||||
if (const Quest* quest = sObjectMgr->GetQuestTemplate(QUEST_TIME_TO_FLY_HORDE))
|
||||
{
|
||||
player->AddQuest(quest, nullptr);
|
||||
TC_LOG_DEBUG("scripts", "LearnRiding: Added quest %u to Horde player %s", QUEST_TIME_TO_FLY_HORDE, player->GetName().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "LearnRiding: Quest %u not found for Horde player %s", QUEST_TIME_TO_FLY_HORDE, player->GetName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Alliance quest
|
||||
else if (player->IsInAlliance())
|
||||
{
|
||||
if (player->GetQuestStatus(QUEST_TIME_TO_FLY_ALLIANCE) != QUEST_STATUS_REWARDED && !player->HasQuest(QUEST_TIME_TO_FLY_ALLIANCE))
|
||||
{
|
||||
if (const Quest* quest = sObjectMgr->GetQuestTemplate(QUEST_TIME_TO_FLY_ALLIANCE))
|
||||
{
|
||||
if (player->GetLevel() >= 30)
|
||||
{
|
||||
player->AddQuest(quest, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnLogin(Player* player, bool firstLogin) override
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "LearnRiding: OnLogin called with null player");
|
||||
return;
|
||||
}
|
||||
|
||||
if (firstLogin)
|
||||
{
|
||||
CheckRidingSkill(player);
|
||||
}
|
||||
}
|
||||
|
||||
void OnLevelChanged(Player* player, uint8 /*oldLevel*/) override
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "LearnRiding: OnLevelChanged called with null player");
|
||||
return;
|
||||
}
|
||||
CheckRidingSkill(player);
|
||||
}
|
||||
};
|
||||
|
||||
void AddCustom_playerscript()
|
||||
{
|
||||
new LearnRiding();
|
||||
}
|
||||
@@ -19,6 +19,10 @@
|
||||
|
||||
// The name of this function should match:
|
||||
// void Add${NameOfDirectory}Scripts()
|
||||
|
||||
void AddCustom_playerscript();
|
||||
|
||||
void AddCustomScripts()
|
||||
{
|
||||
AddCustom_playerscript();
|
||||
}
|
||||
|
||||
@@ -87,3 +87,20 @@ endif()
|
||||
if(USE_COREPCH)
|
||||
add_cxx_pch(worldserver PrecompiledHeaders/worldPCH.h)
|
||||
endif()
|
||||
|
||||
# Copy Eluna lua scripts if ELUNA is enabled
|
||||
if(ELUNA)
|
||||
if(WIN32)
|
||||
add_custom_command(TARGET worldserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/lua_scripts
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/server/game/LuaEngine/lua ${CMAKE_BINARY_DIR}/bin/lua_scripts/
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET worldserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/lua_scripts
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/server/game/LuaEngine/lua ${CMAKE_BINARY_DIR}/bin/lua_scripts/
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user