Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Inserts the item into the loot (called by LootTemplate processors)
- void Loot::AddItem(LootStoreItem const& item)
- {
- // The Hunger Games
- // This code is for random item generation
- if (item.itemid == 1000000) // some arbitrary number that we can flag with, this can be common (white)
- {
- // Generate a item ID to retrieve
- std::bitset<32> x(0);
- // 5 = chest, 6 = waist, 7 = legs, 8 = feet, 9 = wrists
- // 10 = hands, 13 = weapon, 14 = shield, 16 = back
- // 9 values
- const int32 types[] = { 5, 6, 7, 8, 9, 10, 13, 14, 16 };
- /*
- 4 bits: item inventory type
- 4 bits: stren
- 4 bits: agil
- 4 bits: stam
- 4 bits: spir
- */
- // type
- int32 type = types[irand(0, 8)];
- std::bitset<4> typ(type);
- for (int i = 0; i < 4; ++i)
- x[i] = typ[i];
- // which stat to use
- int32 stat = irand(0, 3);
- // Set that stat = 1
- // 4 = stren
- // + 4 * stat = stat index
- // + 3 = 4th bit
- x[4 + (4 * stat) + 3] = 1;
- // Get entry based of bits set
- uint32 entry = (uint32)x.to_ulong();
- // Increment entry to get a higher value
- uint64 data_size_test = entry += 1000000;
- if (data_size_test < 0xffffffff)
- entry += 100000;
- std::stringstream test;
- test << "Entry generated: " << entry;
- TC_LOG_INFO("server.info", "Generated item entry: %s", test.str().c_str());
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment