Eluna implementation (#847)
* azerothcore + eluna done. * Remove the Eluna single thread limit. * Read Eluna Settings file. * submodule change. * fix(test) Ubuntu - Cant Link Library after Compile * The ELUNA is disabled by default. * remove submodule luaEngine. * some change * fix a error * change cmake * fix: some onplayerchat does not have hooks. * Eluna: Add BG event Hooks. * fix:cmake hook AFTER_LOAD_CONF not work. * Remove the eluna switch. * Remove some define in the core. * fix conf file not read in the linux. * eluna : change bg hook parameter type * Remove TC log function call * change bg hook OnBGEnd parameter type. Note: to enable Eluna, the module is required
This commit is contained in:
@@ -42,6 +42,10 @@
|
||||
|
||||
#include "Transport.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
|
||||
{
|
||||
TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
|
||||
@@ -211,6 +215,9 @@ void Creature::AddToWorld()
|
||||
AIM_Initialize();
|
||||
if (IsVehicle())
|
||||
GetVehicleKit()->Install();
|
||||
#ifdef ELUNA
|
||||
sEluna->OnAddToWorld(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +225,9 @@ void Creature::RemoveFromWorld()
|
||||
{
|
||||
if (IsInWorld())
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnRemoveFromWorld(this);
|
||||
#endif
|
||||
if (GetZoneScript())
|
||||
GetZoneScript()->OnCreatureRemove(this);
|
||||
if (m_formation)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
licenzastrasd1
|
||||
licenzastrasd2
|
||||
licenzastrasd3
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
#include "Transport.h"
|
||||
#include "AccountMgr.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
GameObject::GameObject() : WorldObject(false), MovableMapObject(),
|
||||
m_model(NULL), m_goValue(), m_AI(NULL)
|
||||
{
|
||||
@@ -147,6 +151,9 @@ void GameObject::AddToWorld()
|
||||
EnableCollision(GetGoState() == GO_STATE_READY || IsTransport()); // pussywizard: this startOpen is unneeded here, collision depends entirely on GOState
|
||||
|
||||
WorldObject::AddToWorld();
|
||||
#ifdef ELUNA
|
||||
sEluna->OnAddToWorld(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +162,9 @@ void GameObject::RemoveFromWorld()
|
||||
///- Remove the gameobject from the accessor
|
||||
if (IsInWorld())
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnRemoveFromWorld(this);
|
||||
#endif
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnGameObjectRemove(this);
|
||||
|
||||
@@ -328,7 +338,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
}
|
||||
|
||||
void GameObject::Update(uint32 diff)
|
||||
{
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->UpdateAI(this, diff);
|
||||
#endif
|
||||
if (AI())
|
||||
AI()->UpdateAI(diff);
|
||||
else if (!AIM_Initialize())
|
||||
@@ -1225,6 +1238,10 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
if (Player* playerUser = user->ToPlayer())
|
||||
{
|
||||
#ifdef ELUNA
|
||||
if (sEluna->OnGossipHello(playerUser, this))
|
||||
return;
|
||||
#endif
|
||||
if (sScriptMgr->OnGossipHello(playerUser, this))
|
||||
return;
|
||||
|
||||
@@ -2036,6 +2053,9 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
|
||||
break;
|
||||
case GO_DESTRUCTIBLE_DAMAGED:
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnDamaged(this, eventInvoker);
|
||||
#endif
|
||||
EventInform(m_goInfo->building.damagedEvent);
|
||||
sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
|
||||
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
|
||||
@@ -2064,6 +2084,9 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
|
||||
}
|
||||
case GO_DESTRUCTIBLE_DESTROYED:
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnDestroyed(this, eventInvoker);
|
||||
#endif
|
||||
sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
|
||||
EventInform(m_goInfo->building.destroyedEvent);
|
||||
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
|
||||
@@ -2118,6 +2141,9 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
|
||||
void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
{
|
||||
m_lootState = state;
|
||||
#ifdef ELUNA
|
||||
sEluna->OnLootStateChanged(this, state);
|
||||
#endif
|
||||
AI()->OnStateChanged(state, unit);
|
||||
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
|
||||
// pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState
|
||||
@@ -2140,6 +2166,9 @@ void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
void GameObject::SetGoState(GOState state)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
|
||||
#ifdef ELUNA
|
||||
sEluna->OnGameObjectStateChanged(this, state);
|
||||
#endif
|
||||
sScriptMgr->OnGameObjectStateChanged(this, state);
|
||||
if (m_model)
|
||||
{
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
#include "Chat.h"
|
||||
#include "DynamicVisibility.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#include "ElunaEventMgr.h"
|
||||
#endif
|
||||
|
||||
uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
{
|
||||
switch (guid_hi)
|
||||
@@ -78,6 +83,11 @@ Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
||||
|
||||
WorldObject::~WorldObject()
|
||||
{
|
||||
#ifdef ELUNA
|
||||
delete elunaEvents;
|
||||
elunaEvents = NULL;
|
||||
#endif
|
||||
|
||||
// this may happen because there are many !create/delete
|
||||
if (IsWorldObject() && m_currMap)
|
||||
{
|
||||
@@ -957,6 +967,9 @@ void MovementInfo::OutDebug()
|
||||
}
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(), LastUsedScriptID(0),
|
||||
#ifdef ELUNA
|
||||
elunaEvents(NULL),
|
||||
#endif
|
||||
m_name(""), m_isActive(false), m_isWorldObject(isWorldObject), m_zoneScript(NULL),
|
||||
m_transport(NULL), m_currMap(NULL), m_InstanceId(0),
|
||||
m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0), m_executed_notifies(0)
|
||||
@@ -965,6 +978,13 @@ m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0), m_executed_notifies(0)
|
||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
void WorldObject::Update(uint32 time_diff)
|
||||
{
|
||||
elunaEvents->Update(time_diff);
|
||||
}
|
||||
#endif
|
||||
|
||||
void WorldObject::SetWorldObject(bool on)
|
||||
{
|
||||
if (!IsInWorld())
|
||||
@@ -1990,6 +2010,13 @@ void WorldObject::SetMap(Map* map)
|
||||
m_currMap = map;
|
||||
m_mapId = map->GetId();
|
||||
m_InstanceId = map->GetInstanceId();
|
||||
|
||||
#ifdef ELUNA
|
||||
delete elunaEvents;
|
||||
// On multithread replace this with a pointer to map's Eluna pointer stored in a map
|
||||
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
|
||||
#endif
|
||||
|
||||
if (IsWorldObject())
|
||||
m_currMap->AddWorldObject(this);
|
||||
}
|
||||
@@ -2000,6 +2027,12 @@ void WorldObject::ResetMap()
|
||||
ASSERT(!IsInWorld());
|
||||
if (IsWorldObject())
|
||||
m_currMap->RemoveWorldObject(this);
|
||||
|
||||
#ifdef ELUNA
|
||||
delete elunaEvents;
|
||||
elunaEvents = NULL;
|
||||
#endif
|
||||
|
||||
m_currMap = NULL;
|
||||
//maybe not for corpse
|
||||
//m_mapId = 0;
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include "GridDefines.h"
|
||||
#include "Map.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
class ElunaEventProcessor;
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -721,8 +725,11 @@ class WorldObject : public Object, public WorldLocation
|
||||
public:
|
||||
virtual ~WorldObject();
|
||||
|
||||
virtual void Update (uint32 /*time_diff*/) { }
|
||||
|
||||
#ifdef ELUNA
|
||||
virtual void Update(uint32 /*time_diff*/);
|
||||
#else
|
||||
virtual void Update(uint32 /*time_diff*/) { };
|
||||
#endif
|
||||
void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
|
||||
|
||||
virtual void RemoveFromWorld()
|
||||
@@ -735,6 +742,10 @@ class WorldObject : public Object, public WorldLocation
|
||||
Object::RemoveFromWorld();
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
ElunaEventProcessor* elunaEvents;
|
||||
#endif
|
||||
|
||||
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const;
|
||||
void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const;
|
||||
bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = NULL, bool force = false) const;
|
||||
|
||||
@@ -75,6 +75,10 @@
|
||||
#include "TicketMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
#define ZONE_UPDATE_INTERVAL (2*IN_MILLISECONDS)
|
||||
|
||||
#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3))
|
||||
@@ -5223,6 +5227,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
|
||||
// update visibility
|
||||
UpdateObjectVisibility();
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnResurrect(this);
|
||||
#endif
|
||||
|
||||
if(!applySickness)
|
||||
return;
|
||||
|
||||
@@ -12337,7 +12345,11 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
#ifdef ELUNA
|
||||
InventoryResult eres = sEluna->OnCanUseItem(this, proto->ItemId);
|
||||
if (eres != EQUIP_ERR_OK)
|
||||
return eres;
|
||||
#endif
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -12783,7 +12795,9 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
|
||||
pItem2->SetState(ITEM_CHANGED, this);
|
||||
|
||||
ApplyEquipCooldown(pItem2);
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnEquip(this, pItem2, bag, slot);
|
||||
#endif
|
||||
return pItem2;
|
||||
}
|
||||
|
||||
@@ -12791,6 +12805,10 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnEquip(this, pItem, bag, slot);
|
||||
#endif
|
||||
|
||||
sScriptMgr->OnEquip(this, pItem, bag, slot, update);
|
||||
return pItem;
|
||||
}
|
||||
@@ -12813,6 +12831,10 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem)
|
||||
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnEquip(this, pItem, (pos >> 8), slot);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13027,6 +13049,8 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
|
||||
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
|
||||
|
||||
sScriptMgr->OnItemRemove(this, pItem);
|
||||
|
||||
if (bag == INVENTORY_SLOT_BAG_0)
|
||||
{
|
||||
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
|
||||
@@ -15529,6 +15553,9 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
|
||||
switch (questGiver->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
#ifdef ELUNA
|
||||
sEluna->OnQuestAccept(this, questGiver->ToCreature(), quest);
|
||||
#endif
|
||||
sScriptMgr->OnQuestAccept(this, (questGiver->ToCreature()), quest);
|
||||
questGiver->ToCreature()->AI()->sQuestAccept(this, quest);
|
||||
break;
|
||||
@@ -15555,6 +15582,9 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
#ifdef ELUNA
|
||||
sEluna->OnQuestAccept(this, questGiver->ToGameObject(), quest);
|
||||
#endif
|
||||
sScriptMgr->OnQuestAccept(this, questGiver->ToGameObject(), quest);
|
||||
questGiver->ToGameObject()->AI()->QuestAccept(this, quest);
|
||||
break;
|
||||
@@ -16615,6 +16645,9 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
|
||||
{
|
||||
case TYPEID_GAMEOBJECT:
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->GetDialogStatus(this, questgiver->ToGameObject());
|
||||
#endif
|
||||
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToGameObject()));
|
||||
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
|
||||
return questStatus;
|
||||
@@ -16624,6 +16657,9 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
|
||||
}
|
||||
case TYPEID_UNIT:
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->GetDialogStatus(this, questgiver->ToCreature());
|
||||
#endif
|
||||
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToCreature()));
|
||||
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
|
||||
return questStatus;
|
||||
@@ -19548,6 +19584,9 @@ void Player::SaveToDB(bool create, bool logout)
|
||||
#endif
|
||||
outDebugValues();
|
||||
|
||||
if (!create)
|
||||
sScriptMgr->OnPlayerSave(this);
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
_SaveCharacter(create, trans);
|
||||
@@ -20751,6 +20790,10 @@ void Player::Say(const std::string& text, const uint32 language)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
|
||||
#ifdef ELUNA
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_SAY, language, _text))
|
||||
return;
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, Language(language), this, this, _text);
|
||||
@@ -20761,6 +20804,10 @@ void Player::Yell(const std::string& text, const uint32 language)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
|
||||
#ifdef ELUNA
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_YELL, language, _text))
|
||||
return;
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, Language(language), this, this, _text);
|
||||
@@ -20771,7 +20818,10 @@ void Player::TextEmote(const std::string& text)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
|
||||
|
||||
#ifdef ELUNA
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
|
||||
return;
|
||||
#endif
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
|
||||
@@ -20788,6 +20838,10 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
|
||||
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
|
||||
#ifdef ELUNA
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer))
|
||||
return;
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, Language(language), this, this, _text);
|
||||
@@ -25099,6 +25153,9 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
|
||||
if (loot->containerId > 0)
|
||||
sLootItemStorage->RemoveStoredLootItem(loot->containerId, item->itemid, item->count, loot);
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID());
|
||||
#endif
|
||||
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
|
||||
}
|
||||
else
|
||||
@@ -25538,6 +25595,10 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
// xinef: update free talent points count
|
||||
m_usedTalentCount += talentPointsChange;
|
||||
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
|
||||
|
||||
#ifdef ELUNA
|
||||
sEluna->OnLearnTalents(this, talentId, talentRank, spellId);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
#include "DynamicVisibility.h"
|
||||
#include "AccountMgr.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#include "ElunaEventMgr.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float baseMoveSpeed[MAX_MOVE_TYPE] =
|
||||
@@ -335,6 +340,9 @@ Unit::~Unit()
|
||||
|
||||
void Unit::Update(uint32 p_time)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
elunaEvents->Update(p_time);
|
||||
#endif
|
||||
// WARNING! Order of execution here is important, do not change.
|
||||
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
|
||||
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
|
||||
@@ -12552,6 +12560,10 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
|
||||
|
||||
controlled->SetInCombatState(PvP, enemy);
|
||||
}
|
||||
#ifdef ELUNA
|
||||
if (Player* player = this->ToPlayer())
|
||||
sEluna->OnPlayerEnterCombat(player, enemy);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Unit::ClearInCombat()
|
||||
@@ -12580,6 +12592,10 @@ void Unit::ClearInCombat()
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
player->SetGracePeriod(i, 0);
|
||||
}
|
||||
#ifdef ELUNA
|
||||
if (Player* player = this->ToPlayer())
|
||||
sEluna->OnPlayerLeaveCombat(player);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Unit::ClearInPetCombat()
|
||||
|
||||
Reference in New Issue
Block a user