stoneharry

Untitled

May 25th, 2011
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.51 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include <cstring>
  3.  
  4. // on_events.cpp
  5.  
  6. //This function is called when the player logs in (every login)
  7. void OnLogin(Player *pPlayer)
  8. {
  9.  
  10. }
  11.  
  12. //This function is called when the player logs out
  13. void OnLogout(Player *pPlayer)
  14. {
  15.  
  16. }
  17.  
  18. float Version = 1.00f; //Don't touch this.
  19. bool LooseTokenOnPvPDeath = false; //Set to true if you want the victim to loose tokens when the victim dies.
  20. int32 AmountOfItemsYouWantTheVictimToLoose = 1; //Amount of items you want the victim to loose when victim dies.
  21. bool AddTokenOnPvPKill = false; //Set to false if you don't want the killer to be rewarded.
  22. int32 ItemReward = 40753; //The ItemID of the reward.
  23. int32 AmountOfRewardsOnKillStreak[5] = { 1, 3, 5, 7, 10 }; //With how many items you want to reward the killer when he slays the victim.
  24. int32 HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim = 1; //Name speaks for It self.
  25. const int32 KillerStreak1 = 3;
  26. const int32 KillerStreak2 = 5;
  27. const int32 KillerStreak3 = 10;
  28. const int32 KillerStreak4 = 15;
  29. const int32 KillerStreak5 = 20;
  30. int32 KillStreaks[5] = { KillerStreak1, KillerStreak2, KillerStreak3, KillerStreak4, KillerStreak5 };//On how many kills the killstreaks should announce & Reward.
  31.  
  32. struct SystemInfo
  33. {
  34.     uint32              KillStreak;
  35.     uint64              LastGUIDKill;
  36.     uint8               KillCount;
  37. };
  38.  
  39. //This function is called when the player kills another player
  40. void OnPVPKill(Player *pKiller, Player *pVictim)
  41. {
  42.     uint64 kGUID;
  43.     uint64 vGUID;
  44.     char msg[500];
  45.     kGUID = pKiller->GetGUID();
  46.     vGUID = pVictim->GetGUID();                
  47.     if(kGUID == vGUID)
  48.     {
  49.         return;
  50.     }
  51.  
  52.     if(KillingStreak[kGUID].LastGUIDKill == vGUID)
  53.     {
  54.       KillingStreak[kGUID].KillCount++;
  55.       KillingStreak[vGUID].KillCount = 1;
  56.       //pKiller->AddItem(ItemReward, 1);
  57.       if(LooseTokenOnPvPDeath == true)
  58.           pVictim->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true, false);
  59.     }
  60.  
  61.     if(KillingStreak[kGUID].LastGUIDKill != vGUID)
  62.     {
  63.       KillingStreak[kGUID].KillCount = 1;
  64.       KillingStreak[vGUID].KillCount = 1;
  65.     }
  66.  
  67.     if(KillingStreak[kGUID].KillCount == HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim)
  68.     {
  69.       return;
  70.     }
  71.  
  72.     ItemPosCountVec dest;
  73.     Item* item = pKiller->StoreNewItem(dest, ItemReward, true, Item::GenerateItemRandomPropertyId(ItemReward));
  74.     KillingStreak[kGUID].KillStreak++;
  75.     KillingStreak[vGUID].KillStreak = 0;
  76.     KillingStreak[kGUID].LastGUIDKill = vGUID;
  77.     KillingStreak[vGUID].LastGUIDKill = 0;
  78.     if(AddTokenOnPvPKill == true)
  79.       pKiller->SendNewItem(item, 1, true, false);
  80.     if(LooseTokenOnPvPDeath == true)
  81.       pVictim->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true, false);
  82.    
  83.     switch(KillingStreak[kGUID].KillStreak)
  84.     {
  85.     case KillerStreak1:
  86.     sprintf(msg, "[PvP System]: %s killed %s and is on a %u kill streak. ", pKiller->GetName(), pVictim->GetName(), KillStreaks[1]);
  87.     //sWorld->SendWorldText(LANG_SYSTEMMESSAGE, msg);
  88.     pKiller->SendNewItem(item, AmountOfRewardsOnKillStreak[1], true, false);
  89.     break;
  90.  
  91.     case KillerStreak2:
  92.     sprintf(msg, "[PvP System]: %s killed %s and is on a %u kill streak. ", pKiller->GetName(), pVictim->GetName(), KillStreaks[2]);
  93.     //sWorld->SendWorldText(LANG_SYSTEMMESSAGE, msg);
  94.     pKiller->SendNewItem(item, AmountOfRewardsOnKillStreak[2], true, false);
  95.     break;
  96.  
  97.     case KillerStreak3:
  98.     sprintf(msg, "[PvP System]: %s killed %s and is on a %u kill streak. ", pKiller->GetName(), pVictim->GetName(), KillStreaks[3]);
  99.     //sWorld->SendWorldText(LANG_SYSTEMMESSAGE, msg);
  100.     pKiller->SendNewItem(item, AmountOfRewardsOnKillStreak[3], true, false);
  101.     break;
  102.  
  103.     case KillerStreak4:
  104.     sprintf(msg, "[PvP System]: %s killed %s and is on a %u kill streak. ", pKiller->GetName(), pVictim->GetName(), KillStreaks[4]);
  105.     //sWorld->SendWorldText(LANG_SYSTEMMESSAGE, msg);
  106.     pKiller->SendNewItem(item, AmountOfRewardsOnKillStreak[4], true, false);
  107.     break;
  108.  
  109.     case KillerStreak5:
  110.     sprintf(msg, "[PvP System]: %s killed %s and is on a %u kill streak. ", pKiller->GetName(), pVictim->GetName(), KillStreaks[5]);
  111.     //sWorld->SendWorldText(LANG_SYSTEMMESSAGE, msg);
  112.     pKiller->SendNewItem(item, AmountOfRewardsOnKillStreak[5], true, false);
  113.     KillingStreak[kGUID].KillStreak = 0;
  114.     break;
  115.     }
  116. }
  117.  
  118.  void AddSC_onevents()
  119. {
  120.     Script *newscript;
  121.     newscript = new Script;
  122.     newscript->Name = "scripted_on_events";
  123.     newscript->pOnLogin = &OnLogin;
  124.     newscript->pOnLogout = &OnLogout;
  125.     newscript->pOnPVPKill = &OnPVPKill;
  126.  
  127.     newscript->RegisterSelf();
  128. }
Advertisement
Add Comment
Please, Sign In to add comment