*add 11 new event hooks to the OnEvents system, by Hawthorne
--HG-- branch : trunk
This commit is contained in:
@@ -1368,3 +1368,48 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
|
||||
data << uint8(0); // 4 - equipment swap failed - inventory is full
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnPVPKill(Player *killed)
|
||||
{
|
||||
Script->OnPVPKill(GetPlayer(), killed);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnPlayerChat(const char *text)
|
||||
{
|
||||
return Script->OnPlayerChat(GetPlayer(), text);
|
||||
}
|
||||
|
||||
uint32 WorldSession::HandleOnGetXP(uint32 amount)
|
||||
{
|
||||
return Script->OnGetXP(GetPlayer(), amount);
|
||||
}
|
||||
|
||||
int32 WorldSession::HandleOnGetMoney(int32 amount)
|
||||
{
|
||||
return Script->OnGetMoney(GetPlayer(), amount);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnAreaChange(AreaTableEntry const *pArea)
|
||||
{
|
||||
Script->OnAreaChange(GetPlayer(), pArea);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnItemClick(Item *pItem)
|
||||
{
|
||||
return Script->OnItemClick(GetPlayer(), pItem);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnItemOpen(Item *pItem)
|
||||
{
|
||||
return Script->OnItemOpen(GetPlayer(), pItem);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnGoClick(GameObject *pGameObject)
|
||||
{
|
||||
return Script->OnGoClick(GetPlayer(), pGameObject);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnCreatureKill(Creature *pCreature)
|
||||
{
|
||||
Script->OnCreatureKill(GetPlayer(), pCreature);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "Player.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "ScriptCalls.h"
|
||||
|
||||
// Supported shift-links (client generated and server side)
|
||||
// |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r
|
||||
@@ -1049,6 +1050,9 @@ int ChatHandler::ParseCommands(const char* text)
|
||||
|
||||
std::string fullcmd = text;
|
||||
|
||||
if(!m_session->HandleOnPlayerChat(text))
|
||||
return 0;
|
||||
|
||||
/// chat case (.command or !command format)
|
||||
if (m_session)
|
||||
{
|
||||
|
||||
+2
-1
@@ -76,6 +76,7 @@ class TRINITY_DLL_SPEC ChatHandler
|
||||
static ChatCommand* getCommandTable();
|
||||
|
||||
bool isValidChatMessage(const char* msg);
|
||||
void SendGlobalSysMessage(const char *str);
|
||||
protected:
|
||||
explicit ChatHandler() : m_session(NULL) {} // for CLI subclass
|
||||
|
||||
@@ -91,7 +92,7 @@ class TRINITY_DLL_SPEC ChatHandler
|
||||
bool HasLowerSecurity(Player* target, uint64 guid, bool strong = false);
|
||||
bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false);
|
||||
|
||||
void SendGlobalSysMessage(const char *str);
|
||||
|
||||
void SendGlobalGMSysMessage(const char *str);
|
||||
|
||||
static bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand );
|
||||
|
||||
+21
-1
@@ -2498,7 +2498,7 @@ void Player::GiveXP(uint32 xp, Unit* victim)
|
||||
level = getLevel();
|
||||
nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
|
||||
}
|
||||
|
||||
newXP = GetSession()->HandleOnGetXP(newXP);
|
||||
SetUInt32Value(PLAYER_XP, newXP);
|
||||
}
|
||||
|
||||
@@ -6003,6 +6003,14 @@ void Player::CheckExploreSystem()
|
||||
if (isInFlight())
|
||||
return;
|
||||
|
||||
if(!m_AreaID)
|
||||
m_AreaID = GetAreaId();
|
||||
if(m_AreaID != GetAreaId())
|
||||
{
|
||||
m_AreaID = GetAreaId();
|
||||
GetSession()->HandleOnAreaChange(GetAreaEntryByAreaID(m_AreaID));
|
||||
}
|
||||
|
||||
uint16 areaFlag = GetBaseMap()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ());
|
||||
if(areaFlag==0xffff)
|
||||
return;
|
||||
@@ -22089,3 +22097,15 @@ void Player::ActivateSpec(uint8 spec)
|
||||
SetPower(pw, 0);
|
||||
}
|
||||
|
||||
void Player::SetReputation(uint32 factionentry, uint32 value)
|
||||
{
|
||||
GetReputationMgr().SetReputation(sFactionStore.LookupEntry(factionentry),value);
|
||||
}
|
||||
uint32 Player::GetReputation(uint32 factionentry)
|
||||
{
|
||||
return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry));
|
||||
}
|
||||
std::string Player::GetGuildName()
|
||||
{
|
||||
return objmgr.GetGuildById(GetGuildId())->GetName();
|
||||
}
|
||||
|
||||
+5
-2
@@ -1365,6 +1365,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||
uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
|
||||
void ModifyMoney( int32 d )
|
||||
{
|
||||
d = GetSession()->HandleOnGetMoney(d);
|
||||
if(d < 0)
|
||||
SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
|
||||
else
|
||||
@@ -1464,7 +1465,9 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||
void learnSpellHighRank(uint32 spellid);
|
||||
void AddTemporarySpell(uint32 spellId);
|
||||
void RemoveTemporarySpell(uint32 spellId);
|
||||
|
||||
void SetReputation(uint32 factionentry, uint32 value);
|
||||
uint32 GetReputation(uint32 factionentry);
|
||||
std::string GetGuildName();
|
||||
uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
|
||||
void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
|
||||
bool resetTalents(bool no_cost = false);
|
||||
@@ -2220,7 +2223,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||
void SetChampioningFaction(uint32 faction) { m_ChampioningFaction = faction; }
|
||||
Spell * m_spellModTakingSpell;
|
||||
protected:
|
||||
|
||||
uint32 m_AreaID;
|
||||
uint32 m_regenTimerCount;
|
||||
float m_powerFraction[MAX_POWERS];
|
||||
uint32 m_contestedPvPTimer;
|
||||
|
||||
@@ -62,6 +62,20 @@ bool LoadScriptingModule(char const* libName)
|
||||
||!(testScript->OnLogin =(scriptCallOnLogin )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnLogin" ))
|
||||
||!(testScript->OnLogout =(scriptCallOnLogout )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnLogout" ))
|
||||
||!(testScript->OnPVPKill =(scriptCallOnPVPKill )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnPVPKill" ))
|
||||
||!(testScript->OnLogin =(scriptCallOnLogin )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnLogin" ))
|
||||
||!(testScript->OnLogout =(scriptCallOnLogout )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnLogout" ))
|
||||
||!(testScript->OnPVPKill =(scriptCallOnPVPKill )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnPVPKill" ))
|
||||
||!(testScript->OnSpellCast =(scriptCallOnSpellCast )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnSpellCast" ))
|
||||
||!(testScript->OnGetXP =(scriptCallOnGetXP )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnGetXP" ))
|
||||
||!(testScript->OnGetMoney =(scriptCallOnGetMoney )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnGetMoney" ))
|
||||
||!(testScript->OnPlayerChat =(scriptCallOnPlayerChat )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnPlayerChat" ))
|
||||
||!(testScript->OnServerStartup =(scriptCallOnServerStartup )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnServerStartup" ))
|
||||
||!(testScript->OnServerShutdown =(scriptCallOnServerShutdown )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnServerShutdown" ))
|
||||
||!(testScript->OnAreaChange =(scriptCallOnAreaChange )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnAreaChange" ))
|
||||
||!(testScript->OnItemClick =(scriptCallOnItemClick )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnItemClick" ))
|
||||
||!(testScript->OnItemOpen =(scriptCallOnItemOpen )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnItemOpen" ))
|
||||
||!(testScript->OnGoClick =(scriptCallOnGoClick )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnGoClick" ))
|
||||
||!(testScript->OnCreatureKill =(scriptCallOnCreatureKill )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"OnCreatureKill" ))
|
||||
||!(testScript->ScriptsFree =(scriptCallScriptsFree )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"ScriptsFree" ))
|
||||
||!(testScript->ScriptsVersion =(scriptCallScriptsVersion )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"ScriptsVersion" ))
|
||||
||!(testScript->GossipHello =(scriptCallGossipHello )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GossipHello" ))
|
||||
|
||||
+22
-1
@@ -41,6 +41,17 @@ void UnloadScriptingModule();
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnLogin) (Player *pPlayer);
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnLogout) (Player *pPlayer);
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnPVPKill) (Player *killer, Player *killed);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallOnSpellCast)(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, uint32 i, SpellEntry const *spell);
|
||||
typedef uint32(TRINITY_IMPORT * scriptCallOnGetXP) (Player *pPlayer, uint32 amount);
|
||||
typedef int32(TRINITY_IMPORT * scriptCallOnGetMoney) (Player *pPlayer, int32 amount);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallOnPlayerChat) (Player *pPlayer, const char *text);
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnServerStartup) ();
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnServerShutdown) ();
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnAreaChange) (Player *pPlayer, AreaTableEntry const *pArea);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallOnItemClick) (Player *pPlayer, Item *pItem);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallOnItemOpen) (Player *pPlayer, Item *pItem);
|
||||
typedef bool(TRINITY_IMPORT * scriptCallOnGoClick) (Player *pPlayer, GameObject *pGameObject);
|
||||
typedef void(TRINITY_IMPORT * scriptCallOnCreatureKill) (Player *pPlayer, Creature *pCreature);
|
||||
|
||||
typedef void(TRINITY_IMPORT * scriptCallScriptsInit) (char const*);
|
||||
typedef void(TRINITY_IMPORT * scriptCallScriptsFree) ();
|
||||
@@ -80,7 +91,17 @@ typedef struct
|
||||
scriptCallOnLogin OnLogin;
|
||||
scriptCallOnLogout OnLogout;
|
||||
scriptCallOnPVPKill OnPVPKill;
|
||||
|
||||
scriptCallOnSpellCast OnSpellCast;
|
||||
scriptCallOnGetXP OnGetXP;
|
||||
scriptCallOnGetMoney OnGetMoney;
|
||||
scriptCallOnPlayerChat OnPlayerChat;
|
||||
scriptCallOnServerStartup OnServerStartup;
|
||||
scriptCallOnServerShutdown OnServerShutdown;
|
||||
scriptCallOnAreaChange OnAreaChange;
|
||||
scriptCallOnItemClick OnItemClick;
|
||||
scriptCallOnItemOpen OnItemOpen;
|
||||
scriptCallOnGoClick OnGoClick;
|
||||
scriptCallOnCreatureKill OnCreatureKill;
|
||||
scriptCallGossipHello GossipHello;
|
||||
scriptCallGOChooseReward GOChooseReward;
|
||||
scriptCallQuestAccept QuestAccept;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "Util.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Vehicle.h"
|
||||
#include "ScriptCalls.h"
|
||||
|
||||
#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILISECONDS)
|
||||
|
||||
@@ -4306,6 +4307,10 @@ void Spell::HandleThreatSpells(uint32 spellId)
|
||||
|
||||
void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i)
|
||||
{
|
||||
|
||||
if(!Script->OnSpellCast(pUnitTarget,pItemTarget,pGOTarget,i,m_spellInfo))
|
||||
return;
|
||||
|
||||
//effect has been handled, skip it
|
||||
if(m_effectMask & (1<<i))
|
||||
return;
|
||||
|
||||
@@ -189,6 +189,9 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
if(!pUser->GetSession()->HandleOnItemOpen(pItem))
|
||||
return;
|
||||
|
||||
// locked item
|
||||
uint32 lockId = proto->LockID;
|
||||
if(lockId)
|
||||
|
||||
+7
-1
@@ -785,7 +785,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||
{
|
||||
Player *killer = ((Player*)this);
|
||||
Player *killed = ((Player*)pVictim);
|
||||
Script->OnPVPKill(killer, killed);
|
||||
killer->GetSession()->HandleOnPVPKill(killed);
|
||||
}
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && this->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Player *killer = ((Player*)this);
|
||||
Creature *pCreature = ((Creature*)pVictim);
|
||||
killer->GetSession()->HandleOnCreatureKill(pCreature);
|
||||
}
|
||||
}
|
||||
else // if (health <= damage)
|
||||
|
||||
@@ -1678,6 +1678,8 @@ void World::SetInitialWorldSettings()
|
||||
sLog.SetLogDBLater(false);
|
||||
}
|
||||
|
||||
Script->OnServerStartup();
|
||||
|
||||
sLog.outString("WORLD: World initialized");
|
||||
}
|
||||
|
||||
@@ -2294,6 +2296,8 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
|
||||
m_ShutdownTimer = time;
|
||||
ShutdownMsg(true);
|
||||
}
|
||||
|
||||
Script->OnServerShutdown();
|
||||
}
|
||||
|
||||
/// Display a shutdown message to the user(s)
|
||||
|
||||
@@ -736,6 +736,15 @@ class TRINITY_DLL_SPEC WorldSession
|
||||
void HandleEquipmentSetSave(WorldPacket& recv_data);
|
||||
void HandleEquipmentSetDelete(WorldPacket& recv_data);
|
||||
void HandleEquipmentSetUse(WorldPacket& recv_data);
|
||||
void HandleOnPVPKill(Player *killed);
|
||||
bool HandleOnPlayerChat(const char *text);
|
||||
uint32 HandleOnGetXP(uint32 amount);
|
||||
int32 HandleOnGetMoney(int32 amount);
|
||||
void HandleOnAreaChange(AreaTableEntry const *pArea);
|
||||
bool HandleOnItemClick(Item *pItem);
|
||||
bool HandleOnItemOpen(Item *pItem);
|
||||
bool HandleOnGoClick(GameObject *pGameObject);
|
||||
void HandleOnCreatureKill(Creature *pCreature);
|
||||
private:
|
||||
// private trade methods
|
||||
void moveItems(Item* myItems[], Item* hisItems[]);
|
||||
|
||||
Reference in New Issue
Block a user