这个是一套T端的魔兽私服单机的脚本文件。首先你得学会如何在Trinity中加入脚本,这里就不细说了!脚本的大致功能是:在每PVP杀死 5, 10, 15, 20, 25, 30 个角色后,进行世界公告(你可以配置是否获得PVP的掉落!).
1、数据库部分,你要把下面的SQL代码导入到你的数据库中去

INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES (12001, \'[|cffFF0000Battleground :: PvP System|cffFFFF05] %s\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
2、脚本的大致功能是:在每PVP杀死 5, 10, 15, 20, 25, 30 个角色后,进行世界公告(你可以配置是否获得PVP的掉落!).
下面是一些配置代码!都在C++的脚本中


#include "ScriptPCH.h"
#include <cstring>

///////////////////////      CONFIG      /////////////////////////////
/////////////////////////////////////////////////////////////////////

float Version = 2.50f; //不要修改这里
bool PvPSystemEnabled = true; //如果你要关闭PVP系统,这里设置为false
bool OnlyInBattlegrounds = true; //如果你只在战场中开启,那么这里设置为true.
bool LooseTokenOnPvPDeath = true; //如果你想再杀死敌方的时候获取对方的掉落物品,设置为true.
int32 AmountOfItemsYouWantTheVictimToLoose = 1; //杀死敌方掉落的物品的数量.
bool AddTokenOnPvPKill = true; //如果你不希望掉落,那么设置为false!
int32 ItemReward = 23247; //PVP掉落,你将获得的物品ID
int32 AmountOfRewardsOnKillStreak[5] = { 5, 10, 15, 20, 25 }; //获得的物品的数量的一个数组设置.
int32 HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim = 2; //Name speaks for It self.
const int32 KillerStreak1 = 05; 
const int32 KillerStreak2 = 10; 
const int32 KillerStreak3 = 15; 
const int32 KillerStreak4 = 20; 
const int32 KillerStreak5 = 30; 
int32 KillStreaks[5] = { KillerStreak1, KillerStreak2, KillerStreak3, KillerStreak4, KillerStreak5 };
///////////////////////////////////////////////////////////////////
///////////////////////      END      ////////////////////////////
/////////////////////////////////////////////////////////////////

struct SystemInfo
{
    uint32 KillStreak;
    uint32 LastGUIDKill;
    uint8 KillCount;
};

static std::map<uint32, SystemInfo> KillingStreak;

class System_OnPvPKill : public PlayerScript
{
    public:
        System_OnPvPKill() : PlayerScript("System_OnPvPKill") {}

        
void OnPVPKill(Player *pKiller, Player *pVictim)
{
    if(PvPSystemEnabled == false)
    {
             return;
    }
    else if(PvPSystemEnabled == true)
    {
        uint32 kGUID; 
        uint32 vGUID;
        char msg[500];
        kGUID = pKiller->GetGUID();
        vGUID = pVictim->GetGUID();                 
        if(kGUID == vGUID)
        {
          return;
        }
                
      if(KillingStreak[kGUID].LastGUIDKill == vGUID)
        {
        KillingStreak[kGUID].KillCount++;
        KillingStreak[vGUID].KillCount = 1;
          pKiller->AddItem(ItemReward, 1);
        if(LooseTokenOnPvPDeath == true)
          pVictim->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true, false);
           ChatHandler(pVictim->GetSession()).PSendSysMessage("You died, because of that you have lost an Event Token!");
        }
      if(KillingStreak[kGUID].LastGUIDKill != vGUID)
      {
        KillingStreak[kGUID].KillCount = 1;
        KillingStreak[vGUID].KillCount = 1;
      }

      if(KillingStreak[kGUID].KillCount == HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim)
      {
        return;
      }

      if(OnlyInBattlegrounds == true)
      {
        if(!pKiller->GetMap()->IsBattleground() || pKiller->GetMapId() == 30)
           return;
      }

        KillingStreak[kGUID].KillStreak++;
        KillingStreak[vGUID].KillStreak = 0;
        KillingStreak[kGUID].LastGUIDKill = vGUID;
        KillingStreak[vGUID].LastGUIDKill = 0;
      if(AddTokenOnPvPKill == true)
          pKiller->AddItem(29435, 1);
           ChatHandler(pKiller->GetSession()).PSendSysMessage("You killed a player therefor you have been rewarded with his soul!");
      if(LooseTokenOnPvPDeath == true)
          pVictim->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true, false);
                
        switch(KillingStreak[kGUID].KillStreak)
        {
        case KillerStreak1:
        sprintf(msg, "|cffFF0000%s|cffFFFF05 killed |cffFF0000%s|cffFFFF05 and is on a |cffFF00005|cffFFFF05 kill streak. ", pKiller->GetName(), pVictim->GetName());
        sWorld->SendWorldText(LANG_PVPKILL_SYSTEM, msg); //发送PVP的世界公告
        pKiller->AddItem(ItemReward, AmountOfRewardsOnKillStreak[1]);
         pKiller->ModifyHonorPoints(250);
         pKiller->CastSpell(pKiller, 24378, true);
        break;

        case KillerStreak2:
        sprintf(msg, "|cffFF0000%s|cffFFFF05 killed |cffFF0000%s|cffFFFF05 and is on a |cffFF000010|cffFFFF05 kill streak. ", pKiller->GetName(), pVictim->GetName());
        sWorld->SendWorldText(LANG_PVPKILL_SYSTEM, msg); //发送PVP的世界公告
        pKiller->AddItem(ItemReward, AmountOfRewardsOnKillStreak[2]);
         pKiller->ModifyHonorPoints(250);
         pKiller->CastSpell(pKiller, 24378, true);
        break;

        case KillerStreak3:
        sprintf(msg, "|cffFF0000%s|cffFFFF05 killed |cffFF0000%s|cffFFFF05 and is on a |cffFF000015|cffFFFF05 kill streak. ", pKiller->GetName(), pVictim->GetName());
        sWorld->SendWorldText(LANG_PVPKILL_SYSTEM, msg);
        pKiller->AddItem(ItemReward, AmountOfRewardsOnKillStreak[3]);
         pKiller->ModifyHonorPoints(250);
         pKiller->CastSpell(pKiller, 24378, true);
        break;

        case KillerStreak4:
        sprintf(msg, "|cffFF0000%s|cffFFFF05 killed |cffFF0000%s|cffFFFF05 and is on a |cffFF000020|cffFFFF05 kill streak. ", pKiller->GetName(), pVictim->GetName());
        sWorld->SendWorldText(LANG_PVPKILL_SYSTEM, msg);
        pKiller->AddItem(ItemReward, AmountOfRewardsOnKillStreak[4]);
         pKiller->ModifyHonorPoints(250);
         pKiller->CastSpell(pKiller, 24378, true);
        break;

        case KillerStreak5:
        sprintf(msg, "|cffFF0000%s|cffFFFF05 killed |cffFF0000%s|cffFFFF05 and is on a |cffFF000030|cffFFFF05 kill streak. ", pKiller->GetName(), pVictim->GetName());
        sWorld->SendWorldText(LANG_PVPKILL_SYSTEM, msg);
        pKiller->AddItem(23247, 25);
        KillingStreak[kGUID].KillStreak = 0;
         pKiller->ModifyHonorPoints(250);
         pKiller->CastSpell(pKiller, 24378, true);
        break;
     }
    }
}
};

void AddSC_System()
{
    new System_OnPvPKill;
}

 

版权声明:本文为needly原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/needly/p/3753362.html