diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/CharacterHandler.cpp | 45 | ||||
-rw-r--r-- | src/game/Chat.cpp | 4 | ||||
-rw-r--r-- | src/game/Chat.h | 3 | ||||
-rw-r--r-- | src/game/Player.cpp | 22 | ||||
-rw-r--r-- | src/game/Player.h | 7 | ||||
-rw-r--r-- | src/game/ScriptCalls.cpp | 14 | ||||
-rw-r--r-- | src/game/ScriptCalls.h | 23 | ||||
-rw-r--r-- | src/game/Spell.cpp | 5 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 3 | ||||
-rw-r--r-- | src/game/Unit.cpp | 8 | ||||
-rw-r--r-- | src/game/World.cpp | 4 | ||||
-rw-r--r-- | src/game/WorldSession.h | 9 |
12 files changed, 141 insertions, 6 deletions
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[]); |