aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-23 20:19:21 -0700
committermaximius <none@none>2009-09-23 20:19:21 -0700
commit906b00465ad7c41a018a6c6ea3f37b6c466d38cd (patch)
treedf4aa409d11e89d85fa8d8c3e9a0c424df29f612 /src
parent8102372a67098e1af65888b0b411eb3b47814bf0 (diff)
*add 11 new event hooks to the OnEvents system, by Hawthorne
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/ScriptMgr.cpp88
-rw-r--r--src/bindings/scripts/ScriptMgr.h11
-rw-r--r--src/bindings/scripts/include/precompiled.h2
-rw-r--r--src/bindings/scripts/scripts/custom/on_events.cpp77
-rw-r--r--src/game/CharacterHandler.cpp45
-rw-r--r--src/game/Chat.cpp4
-rw-r--r--src/game/Chat.h3
-rw-r--r--src/game/Player.cpp22
-rw-r--r--src/game/Player.h7
-rw-r--r--src/game/ScriptCalls.cpp14
-rw-r--r--src/game/ScriptCalls.h23
-rw-r--r--src/game/Spell.cpp5
-rw-r--r--src/game/SpellHandler.cpp3
-rw-r--r--src/game/Unit.cpp8
-rw-r--r--src/game/World.cpp4
-rw-r--r--src/game/WorldSession.h9
16 files changed, 319 insertions, 6 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp
index 7d1f27b2f96..0b48f5f7cef 100644
--- a/src/bindings/scripts/ScriptMgr.cpp
+++ b/src/bindings/scripts/ScriptMgr.cpp
@@ -245,6 +245,94 @@ void OnPVPKill(Player *killer, Player *killed)
}
TRINITY_DLL_EXPORT
+bool OnSpellCast (Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, uint32 i, SpellEntry const *spell)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnSpellCast) return true;
+ return tmpscript->pOnSpellCast(pUnitTarget,pItemTarget,pGoTarget,i,spell);
+}
+
+TRINITY_DLL_EXPORT
+uint32 OnGetXP(Player *pPlayer, uint32 amount)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnGetXP) return amount;
+ return tmpscript->pOnGetXP(pPlayer,amount);
+}
+
+TRINITY_DLL_EXPORT
+uint32 OnGetMoney(Player *pPlayer, int32 amount)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnGetMoney) return amount;
+ return tmpscript->pOnGetMoney(pPlayer,amount);
+}
+
+TRINITY_DLL_EXPORT
+bool OnPlayerChat(Player *pPlayer, const char *text)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnPlayerChat) return true;
+ return tmpscript->pOnPlayerChat(pPlayer,text);
+}
+
+TRINITY_DLL_EXPORT
+void OnServerStartup()
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnServerStartup) return;
+ tmpscript->pOnServerStartup();
+}
+
+TRINITY_DLL_EXPORT
+void OnServerShutdown()
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnServerShutdown) return;
+ tmpscript->pOnServerShutdown();
+}
+
+TRINITY_DLL_EXPORT
+void OnAreaChange(Player *pPlayer, AreaTableEntry const *pArea)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnAreaChange) return;
+ tmpscript->pOnAreaChange(pPlayer, pArea);
+}
+
+TRINITY_DLL_EXPORT
+bool OnItemClick (Player *pPlayer, Item *pItem)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnItemClick) return true;
+ return tmpscript->pOnItemClick(pPlayer,pItem);
+}
+
+TRINITY_DLL_EXPORT
+bool OnItemOpen (Player *pPlayer, Item *pItem)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnItemOpen) return true;
+ return tmpscript->pOnItemOpen(pPlayer,pItem);
+}
+
+TRINITY_DLL_EXPORT
+bool OnGoClick (Player *pPlayer, GameObject *pGameObject)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnGoClick) return true;
+ return tmpscript->pOnGoClick(pPlayer,pGameObject);
+}
+
+TRINITY_DLL_EXPORT
+void OnCreatureKill (Player *pPlayer, Creature *pCreature)
+{
+ Script *tmpscript = m_scripts[GetScriptId("scripted_on_events")];
+ if (!tmpscript || !tmpscript->pOnCreatureKill) return;
+ tmpscript->pOnCreatureKill(pPlayer,pCreature);
+}
+
+TRINITY_DLL_EXPORT
char const* ScriptsVersion()
{
return "Default Trinity scripting library";
diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h
index 5b5ce118236..9456a0da661 100644
--- a/src/bindings/scripts/ScriptMgr.h
+++ b/src/bindings/scripts/ScriptMgr.h
@@ -46,6 +46,17 @@ struct Script
void (*pOnLogin )(Player*);
void (*pOnLogout )(Player*);
void (*pOnPVPKill )(Player*, Player*);
+ bool (*pOnSpellCast )(Unit*, Item*, GameObject*, uint32, SpellEntry const*);
+ uint32 (*pOnGetXP )(Player*, uint32);
+ int32 (*pOnGetMoney )(Player*, int32);
+ bool (*pOnPlayerChat )(Player*, const char*);
+ void (*pOnServerStartup )();
+ void (*pOnServerShutdown )();
+ void (*pOnAreaChange )(Player*, AreaTableEntry const*);
+ bool (*pOnItemClick )(Player*, Item*);
+ bool (*pOnItemOpen )(Player*, Item*);
+ bool (*pOnGoClick )(Player*, GameObject*);
+ void (*pOnCreatureKill )(Player*, Creature*);
bool (*pGossipHello )(Player*, Creature*);
bool (*pQuestAccept )(Player*, Creature*, Quest const* );
bool (*pGossipSelect )(Player*, Creature*, uint32 , uint32 );
diff --git a/src/bindings/scripts/include/precompiled.h b/src/bindings/scripts/include/precompiled.h
index 46335c2d9eb..3f5bc7e7265 100644
--- a/src/bindings/scripts/include/precompiled.h
+++ b/src/bindings/scripts/include/precompiled.h
@@ -18,6 +18,8 @@
#include "CombatAI.h"
#include "PassiveAI.h"
#include "Chat.h"
+#include "DBCStructure.h"
+#include "DBCStores.h"
#ifdef WIN32
#include <windows.h>
diff --git a/src/bindings/scripts/scripts/custom/on_events.cpp b/src/bindings/scripts/scripts/custom/on_events.cpp
index 0f6a23698c5..842d07f35f0 100644
--- a/src/bindings/scripts/scripts/custom/on_events.cpp
+++ b/src/bindings/scripts/scripts/custom/on_events.cpp
@@ -19,6 +19,71 @@ void OnPVPKill(Player *killer, Player *killed)
}
+//This function is called when a players AreaID changes
+void OnAreaChange(Player *pPlayer, AreaTableEntry const *pArea)
+{
+
+}
+
+//This is called when a player kills a creature (non pvp)
+void OnCreatureKill(Player *pPlayer, Creature *pCreature)
+{
+
+}
+
+//This function is called when a player has a money exchange
+int32 OnGetMoney(Player *pPlayer, int32 amount)
+{
+ return amount;
+}
+
+//This function is called whenever a player gets XP
+uint32 OnGetXP(Player *pPlayer, uint32 amount)
+{
+ return amount;
+}
+
+//This function is called when a player clicks a GO Object
+bool OnGoClick(Player *pPlayer, GameObject *pGameObject)
+{
+ return true;
+}
+
+//This function is called when a player clicks and item
+bool OnItemClick(Player *pPlayer, Item *pItem)
+{
+ return true;
+}
+
+//This function is called when a player opens an item (like a clam)
+bool OnItemOpen(Player *pPlayer, Item *pItem)
+{
+ return true;
+}
+
+//This function is called when a player sends a chat message
+bool OnPlayerChat(Player *pPlayer, const char *text)
+{
+ return true;
+}
+
+//this function is called when the server starts
+void OnServerStartup()
+{
+
+}
+//this function is called when the server shuts down
+void OnServerShutdown()
+{
+
+}
+
+//this function is called when a player casts a spell
+bool OnSpellCast(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, uint32 i, SpellEntry const *spell)
+{
+ return true;
+}
+
void AddSC_onevents()
{
Script *newscript;
@@ -27,5 +92,17 @@ void OnPVPKill(Player *killer, Player *killed)
newscript->pOnLogin = &OnLogin;
newscript->pOnLogout = &OnLogout;
newscript->pOnPVPKill = &OnPVPKill;
+ newscript->pOnAreaChange = &OnAreaChange;
+ newscript->pOnCreatureKill = &OnCreatureKill;
+ newscript->pOnGetMoney = &OnGetMoney;
+ newscript->pOnGetXP = &OnGetXP;
+ newscript->pOnGoClick = &OnGoClick;
+ newscript->pOnItemClick = &OnItemClick;
+ newscript->pOnItemOpen = &OnItemOpen;
+ newscript->pOnPlayerChat = &OnPlayerChat;
+ newscript->pOnServerShutdown = &OnServerShutdown;
+ newscript->pOnServerStartup = &OnServerStartup;
+ newscript->pOnSpellCast = &OnSpellCast;
+
newscript->RegisterSelf();
}
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 58c7a70caea..e1e6eae86a3 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -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);
+}
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 34a1df42e0a..cbe8f118862 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -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)
{
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 796c0acaa70..252c198300b 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -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 );
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index e7c7a8aba23..9a6ebb558fe 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -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();
+}
diff --git a/src/game/Player.h b/src/game/Player.h
index 31750eaa1a5..44df2282f0b 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -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;
diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp
index 8a075448daf..805a5361063 100644
--- a/src/game/ScriptCalls.cpp
+++ b/src/game/ScriptCalls.cpp
@@ -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" ))
diff --git a/src/game/ScriptCalls.h b/src/game/ScriptCalls.h
index bb6ecee3b89..5a156c7e83f 100644
--- a/src/game/ScriptCalls.h
+++ b/src/game/ScriptCalls.h
@@ -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;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 8c751656795..1c0444cf782 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -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;
diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp
index 13d469c918b..b8aa4469472 100644
--- a/src/game/SpellHandler.cpp
+++ b/src/game/SpellHandler.cpp
@@ -189,6 +189,9 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
return;
}
+ if(!pUser->GetSession()->HandleOnItemOpen(pItem))
+ return;
+
// locked item
uint32 lockId = proto->LockID;
if(lockId)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index f9aa1a964c0..4ab2f05dc49 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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)
diff --git a/src/game/World.cpp b/src/game/World.cpp
index f3288d8c076..dd83aaef530 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -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)
diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
index 0da58f55445..35426d004d0 100644
--- a/src/game/WorldSession.h
+++ b/src/game/WorldSession.h
@@ -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[]);