首页 > 代码库 > T端军衔系统c++源代码,转自飞狐魔兽

T端军衔系统c++源代码,转自飞狐魔兽

//自定义 -- 军衔
 
void Player::ModjunxianPrice()
 
{
 
        uint32 Honorpoints = GetCurrency(CURRENCY_TYPE_HONOR_POINTS);
 
        uint32 Conquestpoints = GetCurrency(CURRENCY_TYPE_CONQUEST_POINTS);
 
        uint8 currlevel = m_junxian_level;
 
        currlevel++;
 
        if (currlevel >= 1 && currlevel <= (uint8)sConfig->GetIntDefault("Max.JunXian.Level", 0))
 
        {
 
                Junxian& pPlayerPReqitem1Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqitem2Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqitem3Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqitem4Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqCount1Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqCount2Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqCount3Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqCount4Data =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqJFData =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqMBData =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPReqVIPData =http://www.mamicode.com/ eJunxian[currlevel];
 
                uint32 PReqitem1 = pPlayerPReqitem1Data.Reqitem1;
 
                uint32 PReqCount1 = pPlayerPReqCount1Data.ReqCount1;
 
                uint32 Junitem1count = GetItemCount(PReqitem1);
 
                uint32 PReqitem2 = pPlayerPReqitem2Data.Reqitem2;
 
                uint32 PReqCount2 = pPlayerPReqCount2Data.ReqCount2;
 
                uint32 Junitem2count = GetItemCount(PReqitem2);
 
                uint32 PReqitem3 = pPlayerPReqitem3Data.Reqitem3;
 

                uint32 PReqCount3 = pPlayerPReqCount3Data.ReqCount3;
 
                uint32 Junitem3count = GetItemCount(PReqitem3);
 
                uint32 PReqitem4 = pPlayerPReqitem4Data.Reqitem4;
 
                uint32 PReqCount4 = pPlayerPReqCount4Data.ReqCount4;
 
                uint32 Junitem4count = GetItemCount(PReqitem4);
 
                uint32 PJF = pPlayerPReqJFData.ReqJF;
 
                uint32 PMB = pPlayerPReqMBData.ReqMB;
 
                uint32 PVIP = pPlayerPReqVIPData.ReqVIP;
 
                uint32 JunJF = GetJf();
 
                uint32 JunMB = GetMB();
 
                uint32 JunVIP = GetVIP();
 
                Junxian& pPlayerPhonorData =http://www.mamicode.com/ eJunxian[currlevel];
 
                Junxian& pPlayerPconquestData =http://www.mamicode.com/ eJunxian[currlevel];
 
                if (Honorpoints >= pPlayerPhonorData.honor *100 && Conquestpoints >= pPlayerPconquestData.conquest * 100 && Junitem1count >= PReqCount1 && Junitem2count >= PReqCount2 && Junitem3count >= PReqCount3 && Junitem4count >= PReqCount4 && JunJF >= PJF && JunMB >= PMB && JunVIP >= PVIP)
 
                {
 
                        SetCurrency(CURRENCY_TYPE_HONOR_POINTS, Honorpoints - pPlayerPhonorData.honor * 100);
 
                        SetCurrency(CURRENCY_TYPE_CONQUEST_POINTS, Conquestpoints - pPlayerPconquestData.conquest * 100);
 
                        DestroyItemCount(PReqitem1,PReqCount1,true);
 
                        DestroyItemCount(PReqitem2,PReqCount2,true);
 
                        DestroyItemCount(PReqitem3,PReqCount3,true);
 
                        DestroyItemCount(PReqitem4,PReqCount4,true);
 
                        uint32 sjf = JunJF - PJF;
 
                        SetJf(sjf);
 
                        uint32 smb = JunMB - PMB;
 
                        SetMB(smb);
 
                        m_junxian_level = currlevel;
 
                        ModifyProperty(currlevel,false);
 
                }
 

                uint32 level = m_junxian_level;
 
                Junxian& data= http://www.mamicode.com/eJunxian[level+1];
 
                if (Honorpoints < pPlayerPhonorData.honor)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d点荣誉"),level,data.level,data.honor);
 
                if (Conquestpoints < pPlayerPhonorData.conquest)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d点征服点"),level,data.level,data.conquest);
 
                if (Junitem1count < pPlayerPhonorData.ReqCount1 && PReqitem1 != 0)
 
                {
 
                        if (ObjectMgr::GetItemPrototype(PReqitem1))
 
                        {
 
                                ItemPrototype const *pProto1 = ObjectMgr::GetItemPrototype(PReqitem1);
 
                                std::string itemname1;
 
                                itemname1 = pProto1->Name1;
 
                                ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d个%s"),level,data.level,data.ReqCount1,itemname1.c_str());
 
                        }else ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000提升军衔需要未知物品请联系管 理 员"));
 
                }
 
                if (Junitem2count < pPlayerPhonorData.ReqCount2 && PReqitem2 != 0)
 
                {
 
                        if (ObjectMgr::GetItemPrototype(PReqitem2))
 
                        {
 
                                ItemPrototype const *pProto2 = ObjectMgr::GetItemPrototype(PReqitem2);
 
                                std::string itemname2;
 
                                itemname2 = pProto2->Name1;
 
                                ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d个"),level,data.level,data.ReqCount2,itemname2.c_str());
 
                        }else ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000提升军衔需要未知物品请联系管 理 员"));
 
                }
 
                if (Junitem3count < pPlayerPhonorData.ReqCount3 && PReqitem3 != 0)
 
                {
 
                        if  (ObjectMgr::GetItemPrototype(PReqitem3))
 
                        {
 
                                ItemPrototype const *pProto3 = ObjectMgr::GetItemPrototype(PReqitem3);
 
                                std::string itemname3;
 
                                itemname3 = pProto3->Name1;
 
                                ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d个"),level,data.level,data.ReqCount3,itemname3.c_str());
 
                        }else ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000提升军衔需要未知物品请联系管 理 员"));
 
                }
 
                if (Junitem4count < pPlayerPhonorData.ReqCount4  && PReqitem4 != 0)
 
                {
 
                        if (ObjectMgr::GetItemPrototype(PReqitem4))
 
                        {
 
                                ItemPrototype const *pProto4 = ObjectMgr::GetItemPrototype(PReqitem4);
 
                                std::string itemname4;
 
                                itemname4 = pProto4->Name1;
 
                                ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d个"),level,data.level,data.ReqCount4,itemname4.c_str());
 
                        }else ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000提升军衔需要未知物品请联系管 理 员"));
 
                }
 
                if (JunJF < PJF)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d积分"),level,data.level,data.ReqJF);
 
                if (JunMB < PMB)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要有%d魔币"),level,data.level,data.ReqMB);
 
                if (JunVIP < PVIP)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("|CFFFF0000您当前军衔等级%d,要升级到%d级军衔你必需至少要是级%d会员"),level,data.level,data.ReqVIP);
 
        }
 
}//
 
//自定义 -- 荣誉军衔
 
void Player::ModifyProperty(uint32 currlevel, bool playerloading)
 
{
 
        Junxian& data=http://www.mamicode.com/ eJunxian[currlevel];
 

        //设置名称
 
        if (GetTeamId()==0)
 
        {
 
                if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(data.new_title_lm))
 
                {
 
                        SetUInt32Value(PLAYER_CHOSEN_TITLE, data.new_title_lm);
 
                }
 
        }else
 
        {
 
                if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(data.new_title_bl))
 
                {
 
                        SetUInt32Value(PLAYER_CHOSEN_TITLE, data.new_title_bl);
 
                }
 
        }
 


        if (!playerloading)
 
        {
 
                InitTalentForLevel();
 
                Junxian& data1 = eJunxian[currlevel-1];
 
                uint32 itementry1 = data1.Rewitem;
 
                if (ObjectMgr::GetItemPrototype(itementry1))
 
                {
 
                        Item *pItem = Item::CreateItem(itementry1, 1, this);
 
                        _ApplyItemMods(pItem, 15, false);
 
                }
 
                //CharacterDatabase.PExecute("UPDATE junxian_level SET honorlevel = %u WHERE guid = ‘%u‘",currlevel, GetGUIDLow());
 
                if (data.talent > 0)
 
                        ChatHandler(this).PSendSysMessage(_StringToUTF8("恭喜您升级了!您当前军衔等级%d,+天赋%d"),currlevel, data.talent);
 
                else ChatHandler(this).PSendSysMessage(_StringToUTF8("恭喜您升级了!您当前军衔等级%d"),currlevel);
 
        }
 

        //奖励物品属性
 

        uint32 itementry = data.Rewitem;
 
        if (ObjectMgr::GetItemPrototype(itementry))
 
        {
 
            Item *pItem = Item::CreateItem(itementry, 1, this);
 
        _ApplyItemMods(pItem, 15, true);
 
        }
 
}