|
到达一定等级领取奖品的代码 #include "StdAfx.h"
#include "Setup.h" class SCRIPT_DECL Wistic : public GossipScript { public: void GossipHello(Object * pObject, Player* Plr, bool AutoSend); void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code); void GossipEnd(Object * pObject, Player* Plr); void Destroy() { delete this; } }; void Wistic::GossipHello(Object * pObject, Player* Plr, bool AutoSend) { if(Plr->getLevel()>=40) { GossipMenu *Menu; objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "我能帮你吗, $N?", 1); if(AutoSend) Menu->SendTo(Plr); }else{ sChatHandler.SystemMessage(Plr->GetSession(),"You have already used this NPC and have no use for it!"); Plr->Gossip_Complete(); } } void Wistic::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL; GossipMenu * Menu; if(pCreature==NULL) return; switch(IntId) { case 0: GossipHello(pCreature, Plr, true); break; case 1: { objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr); Menu->AddItem(5, "你到达一定等级,将能领取奖金!", 2); Menu->SendTo(Plr); }break; case 2: { uint32 reward=50000000; uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); int32 newgold = currentgold + reward; if(newgold >= 2000000000){ string Goatz = " 得到奖金5金币."; sChatHandler.SystemMessage(Plr->GetSession(), Goatz.c_str()); }else{ Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); } uint32 Level = 40; LevelInfo * Info = objmgr.GetLevelInfo(Plr->getRace(), Plr->getClass(), Level); if(Info){ Plr->ApplyLevelInfo(Info, Level); } }break; } } void Wistic::GossipEnd(Object * pObject, Player* Plr) { GossipScript::GossipEnd(pObject, Plr); } void SetupWistic(ScriptMgr * mgr) { GossipScript * gs = (GossipScript*) new Wistic(); mgr->register_gossip_script(654321, gs); } |
| 上一篇魔兽私服文章:上一篇: | 自动公告 |
| 下一篇魔兽私服文章:下一篇: | 监狱系统源码 |