stoneharry

Untitled

Jun 1st, 2014
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. // Inserts the item into the loot (called by LootTemplate processors)
  2. void Loot::AddItem(LootStoreItem const& item)
  3. {
  4.     // The Hunger Games
  5.     // This code is for random item generation
  6.     if (item.itemid == 1000000) // some arbitrary number that we can flag with, this can be common (white)
  7.     {
  8.         // Generate a item ID to retrieve
  9.         std::bitset<32> x(0);
  10.  
  11.         // 5 = chest, 6 = waist, 7 = legs, 8 = feet, 9 = wrists
  12.         // 10 = hands, 13 = weapon, 14 = shield, 16 = back
  13.         //    9 values
  14.         const int32 types[] = { 5, 6, 7, 8, 9, 10, 13, 14, 16 };
  15.  
  16.         /*
  17.         4 bits: item inventory type
  18.         4 bits: stren
  19.         4 bits: agil
  20.         4 bits: stam
  21.         4 bits: spir
  22.         */
  23.  
  24.         // type
  25.         int32 type = types[irand(0, 8)];
  26.         std::bitset<4> typ(type);
  27.         for (int i = 0; i < 4; ++i)
  28.             x[i] = typ[i];
  29.  
  30.         // which stat to use
  31.         int32 stat = irand(0, 3);
  32.  
  33.         // Set that stat = 1
  34.         // 4 = stren
  35.         // + 4 * stat = stat index
  36.         // + 3 = 4th bit
  37.         x[4 + (4 * stat) + 3] = 1;
  38.  
  39.         // Get entry based of bits set
  40.         uint32 entry = (uint32)x.to_ulong();
  41.  
  42.         // Increment entry to get a higher value
  43.         uint64 data_size_test = entry += 1000000;
  44.         if (data_size_test < 0xffffffff)
  45.             entry += 100000;
  46.  
  47.         std::stringstream test;
  48.         test << "Entry generated: " << entry;
  49.  
  50.         TC_LOG_INFO("server.info", "Generated item entry: %s", test.str().c_str());
  51.  
  52.         return;
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment