diff options
-rw-r--r-- | src/bindings/scripts/ScriptMgr.cpp | 24 | ||||
-rw-r--r-- | src/bindings/scripts/ScriptMgr.h | 2 | ||||
-rw-r--r-- | src/game/MiscHandler.cpp | 74 | ||||
-rw-r--r-- | src/game/NPCHandler.cpp | 4 | ||||
-rw-r--r-- | src/game/ScriptCalls.cpp | 2 | ||||
-rw-r--r-- | src/game/ScriptCalls.h | 4 |
6 files changed, 108 insertions, 2 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 728bc435d81..0d7f47a4c84 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -2064,6 +2064,30 @@ bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, u } TRINITY_DLL_EXPORT +bool GOSelect( Player *player, GameObject *_GO, uint32 sender, uint32 action ) +{ + debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action); + + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; + if(!tmpscript || !tmpscript->pGOSelect) return false; + + player->PlayerTalkClass->ClearMenus(); + return tmpscript->pGOSelect(player,_GO,sender,action); +} + +TRINITY_DLL_EXPORT +bool GOSelectWithCode( Player *player, GameObject *_GO, uint32 sender, uint32 action, const char* sCode ) +{ + debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action); + + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; + if(!tmpscript || !tmpscript->pGOSelectWithCode) return false; + + player->PlayerTalkClass->ClearMenus(); + return tmpscript->pGOSelectWithCode(player,_GO,sender,action,sCode); +} + +TRINITY_DLL_EXPORT bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest ) { Script *tmpscript = m_scripts[_Creature->GetScriptId()]; diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h index b3c25bfaffd..87a557779a2 100644 --- a/src/bindings/scripts/ScriptMgr.h +++ b/src/bindings/scripts/ScriptMgr.h @@ -44,6 +44,8 @@ struct Script bool (*pQuestAccept )(Player*, Creature*, Quest const* ); bool (*pGossipSelect )(Player*, Creature*, uint32 , uint32 ); bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* ); + bool (*pGOSelect )(Player*, GameObject*, uint32 , uint32 ); + bool (*pGOSelectWithCode )(Player*, GameObject*, uint32 , uint32 , const char* ); bool (*pQuestSelect )(Player*, Creature*, Quest const* ); bool (*pQuestComplete )(Player*, Creature*, Quest const* ); uint32 (*pNPCDialogStatus )(Player*, Creature* ); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 6d0c94fa0ef..14da3a94360 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -26,6 +26,7 @@ #include "Opcodes.h" #include "Log.h" #include "Player.h" +#include "GossipDef.h" #include "World.h" #include "ObjectMgr.h" #include "WorldSession.h" @@ -70,6 +71,79 @@ void WorldSession::HandleRepopRequestOpcode( WorldPacket & /*recv_data*/ ) GetPlayer()->RepopAtGraveyard(); } +void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4+4); + + sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION"); + + uint32 option; + uint32 unk; + uint64 guid; + std::string code = ""; + + recv_data >> guid >> unk >> option; + + if(_player->PlayerTalkClass->GossipOptionCoded( option )) + { + // recheck + CHECK_PACKET_SIZE(recv_data,8+4+1); + sLog.outBasic("reading string"); + recv_data >> code; + sLog.outBasic("string read: %s", code.c_str()); + } + + Creature *unit = NULL; + GameObject *go = NULL; + if(IS_CREATURE_GUID(guid)) + { + unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); + if (!unit) + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + } + else if(IS_GAMEOBJECT_GUID(guid)) + { + go = ObjectAccessor::GetGameObject(*_player, guid); + if (!go) + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid)) ); + return; + } + } + else + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)) ); + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if(!code.empty()) + { + if(unit) + { + if(!Script->GossipSelectWithCode( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()) ) + unit->OnGossipSelect( _player, option ); + } + else + Script->GOSelectWithCode( _player, go, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()); + } + else + { + if(unit) + { + if(!Script->GossipSelect( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )) ) + unit->OnGossipSelect( _player, option ); + } + else + Script->GOSelect( _player, go, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )); + } +} + void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,4+4+1+1+4+4+4+4); diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 23077ec36be..df027a48acd 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -305,7 +305,7 @@ void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) +/*void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4+4); @@ -348,7 +348,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) unit->OnGossipSelect (_player, option); } -} +}*/ void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) { diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp index 37880cc3dfd..bce96344931 100644 --- a/src/game/ScriptCalls.cpp +++ b/src/game/ScriptCalls.cpp @@ -64,6 +64,8 @@ bool LoadScriptingModule(char const* libName) ||!(testScript->QuestAccept =(scriptCallQuestAccept )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"QuestAccept" )) ||!(testScript->GossipSelect =(scriptCallGossipSelect )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GossipSelect" )) ||!(testScript->GossipSelectWithCode=(scriptCallGossipSelectWithCode)TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GossipSelectWithCode")) + ||!(testScript->GOSelect =(scriptCallGOSelect )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GOSelect" )) + ||!(testScript->GOSelectWithCode =(scriptCallGOSelectWithCode )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"GOSelectWithCode" )) ||!(testScript->QuestSelect =(scriptCallQuestSelect )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"QuestSelect" )) ||!(testScript->QuestComplete =(scriptCallQuestComplete )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"QuestComplete" )) ||!(testScript->NPCDialogStatus =(scriptCallNPCDialogStatus )TRINITY_GET_PROC_ADDR(testScript->hScriptsLib,"NPCDialogStatus" )) diff --git a/src/game/ScriptCalls.h b/src/game/ScriptCalls.h index b66f23563de..83a6572e0e1 100644 --- a/src/game/ScriptCalls.h +++ b/src/game/ScriptCalls.h @@ -45,6 +45,8 @@ typedef bool(TRINITY_IMPORT * scriptCallGossipHello) (Player *player, Creature * typedef bool(TRINITY_IMPORT * scriptCallQuestAccept) (Player *player, Creature *_Creature, Quest const *); typedef bool(TRINITY_IMPORT * scriptCallGossipSelect)(Player *player, Creature *_Creature, uint32 sender, uint32 action); typedef bool(TRINITY_IMPORT * scriptCallGossipSelectWithCode)( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode ); +typedef bool(TRINITY_IMPORT * scriptCallGOSelect)(Player *player, GameObject *_GO, uint32 sender, uint32 action); +typedef bool(TRINITY_IMPORT * scriptCallGOSelectWithCode)( Player *player, GameObject *_GO, uint32 sender, uint32 action, const char* sCode ); typedef bool(TRINITY_IMPORT * scriptCallQuestSelect)( Player *player, Creature *_Creature, Quest const* ); typedef bool(TRINITY_IMPORT * scriptCallQuestComplete)(Player *player, Creature *_Creature, Quest const*); typedef uint32(TRINITY_IMPORT * scriptCallNPCDialogStatus)( Player *player, Creature *_Creature); @@ -72,6 +74,8 @@ typedef struct scriptCallQuestAccept QuestAccept; scriptCallGossipSelect GossipSelect; scriptCallGossipSelectWithCode GossipSelectWithCode; + scriptCallGOSelect GOSelect; + scriptCallGOSelectWithCode GOSelectWithCode; scriptCallQuestSelect QuestSelect; scriptCallQuestComplete QuestComplete; scriptCallNPCDialogStatus NPCDialogStatus; |