当前位置:首页>>魔兽单机>>正文
一套T端1.12.1版本的PVP头衔购买脚本
2013-05-22 21:00:22 作者:网络 来源: 浏览次数:0
摘要:一套1.12.1版本T端的PVP头衔购买脚本
这个是一套NPC脚本的功能代码。主要实现购买头衔
 \\


下面是脚本代码,

/****************************************
*      Created by: Rochet2        *
*      Updated by: Asbert75        *
*      With help from:            *
*      LilleCarl, Rochet2, Jamey    *
*     *----- Title Vendor -----*    *
****************************************/
 
#include "ScriptPCH.h"
 
struct Rochet2
{
  uint8 icon;
  std::string name;
    uint32 HK, titleID;
};
 
/********************************************************
Possible icons:
0, //white chat bubble
1, //brown bag
2, //flight
3, //book
4, //interaction wheel
5, //interaction wheel
6, //brown bag with yellow dot
7, //white chat bubble with black dots
8, //tabard
9, //two swords
10, //yellow dot
 
Example Gossip Option: {iconID (see above), "title name", honorable_kills_required (set to whatever you require the player to have to get this rank), titleID (from database)}
***********************************************************/
 
Rochet2 Titles [] =
{
 
    {9,        "Private",                      50,            1     }, 
    {9,        "Corporal",                      100,        2     },
    {9,        "Sergeant",                    250,        3     },
    {9,        "Master Sergeant",            500,        4     },
    {9,        "Sergeant Major",              750,        5     },
    {9,        "Knight",                    1000,        6     },
    {9,        "Knight-Lieutenant",        1500,        7     },
    {9,        "Knight-Captain",              2000,        8     },
    {9,        "Knight-Champion",            2500,        9     },
    {9,        "Lieutenant Commander",        3000,        10  },
    {9,        "Commander",                3500,        11    },
    {9,        "Marshal",                    4000,        12    },
    {9,        "Field Marshal",              4500,        13    },
    {9,        "Grand Marshal",              5000,        14    },
 
    {9,        "Scout",                    50,          15    },
    {9,        "Grunt",                    100,        16    },
    {9,        "Sergeant",                    250,        17    },
    {9,        "Senior Sergeant",            500,        18    },
    {9,        "First Sergeant",              750,        19    },
    {9,        "Stone Guard",                1000,        20    },
    {9,        "Blood Guard",                1500,        21    },
    {9,        "Legionnaire",                2000,        22    },
    {9,        "Centurion",                2500,        23    },
    {9,        "Champion",                    3000,        24    },
    {9,        "Lieutenant General",        3500,        25    },
    {9,        "General",                    4000,        26    },
    {9,        "Warlord",                    4500,        27    },
    {9,        "High Warlord",                  5000,        28    },
};
 
enum eEnums
{
    Amount    =    sizeof Titles/sizeof(*Titles),
 
    // npc_text ID
    Greetings_A    =    1,
    Greetings_H    =    2,
};
 
#define ERROR_HASTITLE    "|cffff0000You already have this title|r" // Error message that shows up when a player already has the title
#define ERROR_CASH "|cffff0000You don't have enough honorable kills|r" // Error message if player does not have enough honorable kills
 
 
class Title_gossip_codebox : public CreatureScript
{
    public:
    Title_gossip_codebox()
    : CreatureScript("Title_gossip_codebox")
    {
    }
 
    bool OnGossipHello(Player* pPlayer, Creature* pCreature)
    {
        uint32 txt    = Greetings_A;
        uint32 i    = 0;
        uint32 m    = Amount/2;
        if(pPlayer->GetTeam() == HORDE)
        {
            txt = Greetings_H;
            i = Amount/2;
            m = Amount;
        }
        for (i; i<m; i++)
        {
            std::ostringstream ss;
            ss << Titles[i].name << " - " << Titles[i].HK << " HKs";
            std::string showcoolshit = ss.str();
            ss.str(" ");
            ss.clear();
            ss << "Are you sure? You will be granted the title: " << Titles[i].name;
            std::string showcoolshit2 = ss.str();
            // ADD_GOSSIP_ITEM_EXTENDED Parameters: (icon, label, GOSSIP_SENDER_MAIN (Sender), Title ID ? (action - Sends info to OnGossipSelect), popup, coppercost, code (codebox))
            pPlayer->ADD_GOSSIP_ITEM_EXTENDED(Titles[i].icon, showcoolshit.c_str(), GOSSIP_SENDER_MAIN, i, showcoolshit2, 0, false);
        }
        pPlayer->PlayerTalkClass->SendGossipMenu(txt, pCreature->GetGUID());
        return true;
    }
 
    bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 i)
    {
        pPlayer->PlayerTalkClass->ClearMenus(); // clear the menu
 
        if (CharTitlesEntry const* Title = sCharTitlesStore.LookupEntry(Titles[i].titleID)) // Get title
        {
            if(pPlayer->HasTitle(Title)) // If has title
                pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_HASTITLE);
            else if(Titles[i].HK > pPlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)) // If doesnt have enough honored kills
                pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_CASH);
            else
            {
                pPlayer->SetTitle(Title);
                pPlayer->SaveToDB();
            }
            OnGossipHello(pPlayer, pCreature);
        }
        return true;
    }
};
 
void AddSC_Title_gossip_codebox()
{
    new Title_gossip_codebox();
}

下载完整代码:查看完整代码




相关报道:

[关闭] [返回顶部]


  返回首页 | 最新资讯 | 资源下载 | 魔兽图片 | 单机文档 | 技术攻略 | 玩家视频
备案号:蜀ICP备2024062380号-1
免责声明:本网站为热爱怀旧WOW的玩家们建立的魔兽世界资料网站,仅供交流和学习使用,非盈利和商用.如有侵权之处,请联系我们,我们会在24小时内确认删除侵权内容,谢谢合作。
Copyright © 2024 - 2024 WOWAII.COM Corporation, All Rights Reserved

机器人国度