Advertisement
Rochet2

Untitled

Jul 25th, 2015
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2. #include "ScriptedCreature.h"
  3. #include "ScriptedGossip.h"
  4. #include "Player.h"
  5. #include <cstring>
  6.  
  7.  
  8. struct VendorData
  9. {
  10.     uint32 rank;
  11.     uint32 required_kills;
  12.     uint32 entry;
  13. };
  14.  
  15. //  {vendor rank (1-14), required kills to use vendor, vendor entry}
  16. static VendorData const Vendors[] = {
  17.     {1, 10, 800001},
  18.     {2, 50, 800002},
  19.     {3, 100, 800003},
  20.     {4, 250, 800004},
  21.     {5, 500, 800005},
  22.     {6, 750, 800006},
  23.     {7, 1000, 800007},
  24.     {8, 1500, 800008},
  25.     {9, 2000, 800009},
  26.     {10, 2500, 800010},
  27.     {11, 3000, 800011},
  28.     {12, 3500, 800012},
  29.     {13, 4000, 800013},
  30.     {14, 5000, 800014},
  31. };
  32.  
  33. class ArrayVendor : public CreatureScript
  34. {
  35. public:
  36.     ArrayVendor() : CreatureScript("ArrayVendor")
  37.     {
  38.     }
  39.  
  40.     bool OnGossipHello(Player* player, Creature* creature) override
  41.     {
  42.         uint32 const playerHKs = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS);
  43.         for (auto& data : Vendors)
  44.         {
  45.             uint32 vendorRank = (800000 - data.rank);
  46.  
  47.             if (playerHKs < data.required_kills)
  48.             {
  49.                 std::ostringstream ss;
  50.                 ss << "The required rank to use this vendor is rank " << data.rank << "\nYou need " << (data.required_kills - playerHKs) << " more honorable kills to reach rank " << data.rank;
  51.  
  52.                 player->GetSession()->SendAreaTriggerMessage(ss.str().c_str());
  53.                 player->CLOSE_GOSSIP_MENU();
  54.                 return true;
  55.             }
  56.             else
  57.             {
  58.                 player->GetSession()->SendListInventory(creature->GetGUID());
  59.                 return true;
  60.             }
  61.         }
  62.     }
  63. };
  64.  
  65. void AddSC_ArrayVendor()
  66. {
  67.     new ArrayVendor();
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement