Skip to content

Commit

Permalink
Multiple Eluna changes and additions
Browse files Browse the repository at this point in the history
-New hooks for Player, Item, and Trade(Init and Accept) added to core
-Exclude VMangos header directory
-OnDummyEffect hooks added
-Update Eluna submodule

Co-Authored-By: Foereaper <[email protected]>
  • Loading branch information
Niam5 and Foereaper committed Oct 13, 2023
1 parent 861e64f commit 63cd464
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/game/AI/ScriptDevAI/ScriptDevAIMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ bool ScriptDevAIMgr::OnItemLoot(Player* pPlayer, Item* pItem, bool apply)
bool ScriptDevAIMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid)
{
Script* pTempScript = GetScript(pTarget->GetScriptId());

#ifdef BUILD_ELUNA
sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget);
#endif
if (!pTempScript || !pTempScript->pEffectDummyNPC)
return false;

Expand All @@ -483,7 +485,9 @@ bool ScriptDevAIMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectInd
bool ScriptDevAIMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget, ObjectGuid originalCasterGuid)
{
Script* pTempScript = GetScript(pTarget->GetGOInfo()->ScriptId);

#ifdef BUILD_ELUNA
sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget);
#endif
if (!pTempScript || !pTempScript->pEffectDummyGO)
return false;

Expand All @@ -493,7 +497,9 @@ bool ScriptDevAIMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectInd
bool ScriptDevAIMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget, ObjectGuid originalCasterGuid)
{
Script* pTempScript = GetScript(pTarget->GetProto()->ScriptId);

#ifdef BUILD_ELUNA
sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget);
#endif
if (!pTempScript || !pTempScript->pEffectDummyItem)
return false;

Expand Down
12 changes: 7 additions & 5 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ foreach (TMP_PATH ${LIBRARY_SRCS})
list(REMOVE_ITEM LIBRARY_SRCS ${TMP_PATH})
endif ()
endforeach()
set (EXCLUDE_DIR "LuaEngine/VMangos/")
foreach (TMP_PATH ${LIBRARY_SRCS})
string (FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM LIBRARY_SRCS ${TMP_PATH})
endif ()
endforeach()
set (EXCLUDE_DIR "LuaEngine/TrinityCore/")
foreach (TMP_PATH ${LIBRARY_SRCS})
string (FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
Expand Down Expand Up @@ -154,11 +161,6 @@ if (BUILD_SCRIPTDEV)
add_definitions(-DBUILD_SCRIPTDEV)
endif()

# Define BUILD_ELUNA if need
if (BUILD_ELUNA)
add_definitions(-DBUILD_ELUNA)
endif()

# Define BUILD_AHBOT if need
if (BUILD_AHBOT)
add_definitions(-DBUILD_AHBOT)
Expand Down
20 changes: 20 additions & 0 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3484,6 +3484,9 @@ void Player::learnSpell(uint32 spell_id, bool dependent, bool talent)
WorldPacket data(SMSG_LEARNED_SPELL, 4);
data << uint32(spell_id);
GetSession()->SendPacket(data);
#ifdef BUILD_ELUNA
sEluna->OnLearnSpell(this, spell_id);
#endif
}

// learn all disabled higher ranks (recursive) - skip for talent spells
Expand Down Expand Up @@ -6820,6 +6823,9 @@ uint32 Player::GetLevelFromDB(ObjectGuid guid)

void Player::UpdateArea(uint32 newArea)
{
#ifdef BUILD_ELUNA
uint32 oldArea = m_areaUpdateId;
#endif
m_areaUpdateId = newArea;

AreaTableEntry const* area = GetAreaEntryByAreaID(newArea);
Expand All @@ -6840,6 +6846,12 @@ void Player::UpdateArea(uint32 newArea)
}

UpdateAreaDependentAuras();

#ifdef BUILD_ELUNA
// We only want the hook to trigger when the old and new area is actually different
if (oldArea != newArea)
sEluna->OnUpdateArea(this, oldArea, newArea);
#endif
}

bool Player::CanUseCapturePoint() const
Expand Down Expand Up @@ -9917,6 +9929,10 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update
{
ItemAddedQuestCheck(item, count);
pItem = StoreItem(dest, pItem, update);

#ifdef BUILD_ELUNA
sEluna->OnAdd(this, pItem);
#endif
}
return pItem;
}
Expand Down Expand Up @@ -13349,6 +13365,10 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status)
}

UpdateForQuestWorldObjects();

#ifdef BUILD_ELUNA
sEluna->OnQuestStatusChanged(this, quest_id, status);
#endif
}

// not used in MaNGOS, but used in scripting code
Expand Down
23 changes: 23 additions & 0 deletions src/game/Trade/TradeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "Spells/Spell.h"
#include "Social/SocialMgr.h"
#include "Server/DBCStores.h"
#ifdef BUILD_ELUNA
#include "LuaEngine/LuaEngine.h"
#endif

void WorldSession::SendTradeStatus(TradeStatusInfo const& info) const
{
Expand Down Expand Up @@ -309,6 +312,17 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket)
}
}

#ifdef BUILD_ELUNA
if (!sEluna->OnTradeAccept(_player, trader))
{
info.Status = TRADE_STATUS_CLOSE_WINDOW;
info.Result = EQUIP_ERR_CANT_DO_RIGHT_NOW;
SendTradeStatus(info);
my_trade->SetAccepted(false, true);
return;
}
#endif

if (his_trade->IsAccepted())
{
setAcceptTradeMode(my_trade, his_trade, myItems, hisItems);
Expand Down Expand Up @@ -646,6 +660,15 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}

#ifdef BUILD_ELUNA
if (!sEluna->OnTradeInit(GetPlayer(), pOther))
{
info.Status = TRADE_STATUS_BUSY;
SendTradeStatus(info);
return;
}
#endif

// OK start trade
_player->m_trade = new TradeData(_player, pOther);
pOther->m_trade = new TradeData(pOther, _player);
Expand Down

0 comments on commit 63cd464

Please sign in to comment.