1、先来看看该魔兽单机代码有些什么功能
pPlayer->ADD_GOSSIP_ITEM(4, " 种族修改 5个物品消耗", GOSSIP_SENDER_MAIN, 0);
pPlayer->ADD_GOSSIP_ITEM(4, " 阵营修改 10个物品消耗", GOSSIP_SENDER_MAIN, 1);
pPlayer->ADD_GOSSIP_ITEM(4, " 修改外貌 1个物品消耗", GOSSIP_SENDER_MAIN, 2);
pPlayer->ADD_GOSSIP_ITEM(4, " 修改名字 1个物品消耗", GOSSIP_SENDER_MAIN, 3);
2、该功能脚本需要消耗你定义的物品(就是说,你需要有某些物品,才能使用该功能),呵呵,这样就给某些魔兽私服单机定义了更多的功能
if(Player->HasItemCount(12345, 5)) // 修改一下12345,修改成你需要设置消耗的物品ID
{
Player->DestroyItemCount(12345, 5, true, true); // 销毁该物品
Player->DestroyItemCount(12345, 5, true, false); // race change token (12345) you can change it
Player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
CharacterDatabase.PExecute("UPDATe characters Set at_login = at_login | '128' Where guid = %u", Player->GetGUID());
Player->GetSession()->SendNotification("你需要重新登录,然后才能修改种族!");
Player->PlayerTalkClass->CloseGossip();
3、支持TrinityCore的最新版本! 该脚本是宝石脚本,用在item_tempalte库中
4、例子:你可以选一些好看的模型来使用该脚本。
打开item_template表,选择一些好看的模型: 例如 勇猛的古莲,毒化雕纹,荣誉奖章,天然黑暗符印,巫术指环,蓝铜锭,附魔武器卷轴之类的
下面看看代码:
#include "ScriptPCH.h"
class npc_tool : public CreatureScript
{
public:
npc_tool() : CreatureScript("npc_tool"){}
bool OnGossipHello(Player * pPlayer, Creature * pCreature)
{
pPlayer->ADD_GOSSIP_ITEM(4, " 种族修改 5个物品消耗", GOSSIP_SENDER_MAIN, 0);
pPlayer->ADD_GOSSIP_ITEM(4, " 阵营修改 10个物品消耗", GOSSIP_SENDER_MAIN, 1);
pPlayer->ADD_GOSSIP_ITEM(4, " 修改外貌 1个物品消耗", GOSSIP_SENDER_MAIN, 2);
pPlayer->ADD_GOSSIP_ITEM(4, " 修改名字 1个物品消耗", GOSSIP_SENDER_MAIN, 3);
pPlayer->PlayerTalkClass->SendGossipMenu(9425, pCreature->GetGUID());
return true;
}
bool OnGossipSelect(Player * Player, Creature * Creature, uint32 /*uiSender*/, uint32 uiAction)
{
if(!Player)
return true;
switch(uiAction)
{
case 0:
if(Player->HasItemCount(12345, 5)) // 修改一下12345,修改成你需要设置消耗的物品ID
{
Player->DestroyItemCount(12345, 5, true, true); // 销毁该物品
Player->DestroyItemCount(12345, 5, true, false); // race change token (12345) you can change it
Player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
CharacterDatabase.PExecute("UPDATe characters Set at_login = at_login | '128' Where guid = %u", Player->GetGUID());
Player->GetSession()->SendNotification("你需要重新登录,然后才能修改种族!");
Player->PlayerTalkClass->CloseGossip();
}
else
{
Player->GetSession()->SendNotification("You need atleast 5 race change token!");
Player->PlayerTalkClass->CloseGossip();
}
break;
case 1:
if(Player->HasItemCount(123, 10)) // 修改一下123,修改成你需要设置消耗的物品ID
{
Player->DestroyItemCount(123, 10, true, true); // race change token (123) you can change it
Player->DestroyItemCount(123, 10, true, false); // race change token (123) you can change it
Player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '64' WHERE guid = %u", Player->GetGUID());
Player->GetSession()->SendNotification("你需要重新登录,然后才能修改阵营!");
Player->PlayerTalkClass->CloseGossip();
}
else
{
Player->GetSession()->SendNotification("you need atleast 10 faction change token!");
Player->PlayerTalkClass->CloseGossip();
回复查看完整代码
|