吾爱尚玩资源基地
标题:
比较老的魔兽世界私服传送宝石内核部分代码
[打印本页]
作者:
admin
时间:
2016-4-18 22:23
标题:
比较老的魔兽世界私服传送宝石内核部分代码
下面是一个比较老的模拟器技术的传送宝石的代码,不过现在可以参考使用
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cppindex 1f079ab..da57d75 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -24,6 +24,8 @@
#include "ObjectMgr.h"
#include "Player.h"
#include "Item.h"
+#include "ScriptCalls.h" //宝石增加
+#include "Spell.h" //宝石增加
#include "UpdateData.h"
#include "ObjectAccessor.h"
@@ -456,6 +458,7 @@ void WorldSession::HandleReadItem( WorldPacket & recv_data )
CHECK_PACKET_SIZE(recv_data,1+1);
//sLog.outDebug( "WORLD: CMSG_READ_ITEM");
+ SpellCastTargets targets; //宝石部分
uint8 bag, slot;
recv_data >> bag >> slot;
@@ -468,6 +471,8 @@ void WorldSession::HandleReadItem( WorldPacket & recv_data )
WorldPacket data;
uint8 msg = _player->CanUseItem( pItem );
+ if(!Script->ItemUse(GetPlayer(),pItem,targets)) //宝石部分开始 加入此行,不加这里的话会造成使用传送宝石不会出现选单,会要你去接任务
+ {
if( msg == EQUIP_ERR_OK )
{
data.Initialize (SMSG_READ_ITEM_OK, 8);
@@ -481,6 +486,7 @@ void WorldSession::HandleReadItem( WorldPacket & recv_data )
}
data << pItem->GetGUID();
SendPacket(&data);
+ } //宝石部分结束
}
else
_player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp
index e5fb150..60eaac7 100644
--- a/src/game/NPCHandler.cpp
+++ b/src/game/NPCHandler.cpp
@@ -32,6 +32,7 @@
#include "ObjectAccessor.h"
#include "Creature.h"
#include "Pet.h"
+#include "Spell.h" //宝石新增
#include "BattleGroundMgr.h"
#include "BattleGround.h"
#include "Guild.h"
@@ -317,6 +318,10 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
recv_data >> guid >> unk >> option;
+ SpellCastTargets targets; //宝石新增
+ Item *pItem = _player->GetItemByGuid(guid); //宝石新增//
+ if (pItem)
+ Script->GossipSelect_Item( _player, pItem, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ),targets);
if(_player->PlayerTalkClass->GossipOptionCoded( option ))
{
// recheck
diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp
index adbdcb1..d3a093c 100644
--- a/src/game/ScriptCalls.cpp
+++ b/src/game/ScriptCalls.cpp
@@ -77,6 +77,7 @@ bool LoadScriptingModule(char const* libName)
||!(testScript->EffectDummyCreature =(scriptCallEffectDummyCreature )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyCreature" ))
||!(testScript->EffectDummyItem =(scriptCallEffectDummyItem )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyItem" ))
||!(testScript->GetAI =(scriptCallGetAI )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"GetAI" ))
+ ||!(testScript->GossipSelect_Item =(scriptCallGossipSelect_Item )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"GossipSelect_Item" )) //传送宝石
||!(testScript->CreateInstanceData =(scriptCallCreateInstanceData )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"CreateInstanceData" ))
)
{
diff --git a/src/game/ScriptCalls.h b/src/game/ScriptCalls.h
index 4c8f46b..a161ea1 100644
--- a/src/game/ScriptCalls.h
+++ b/src/game/ScriptCalls.h
@@ -39,6 +39,7 @@ typedef void(MANGOS_IMPORT * scriptCallScriptsInit) (const ObjectMgr::ScriptName
typedef void(MANGOS_IMPORT * scriptCallScriptsFree) ();
typedef char const* (MANGOS_IMPORT * scriptCallScriptsVersion) ();
+typedef bool(MANGOS_IMPORT * scriptCallGossipSelect_Item)(Player *player, Item *_Item, uint32 sender, uint32 action,SpellCastTargets const& targets); //传送宝石
typedef bool(MANGOS_IMPORT * scriptCallGossipHello) (Player *player, Creature *_Creature );
typedef bool(MANGOS_IMPORT * scriptCallQuestAccept) (Player *player, Creature *_Creature, Quest const *);
typedef bool(MANGOS_IMPORT * scriptCallGossipSelect)(Player *player, Creature *_Creature, uint32 sender, uint32 action);
@@ -67,6 +68,7 @@ typedef struct
scriptCallScriptsFree ScriptsFree;
scriptCallScriptsVersion ScriptsVersion;
+ scriptCallGossipSelect_Item GossipSelect_Item; //传送宝石
scriptCallGossipHello GossipHello;
scriptCallGOChooseReward GOChooseReward;
scriptCallQuestAccept QuestAccept;
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4