Item Sets (part 1)
Posted: Wed Nov 08, 2017 4:43 am
this is Part one of a 2 part update. Part one is the examining of item sets ie.. bags, boxes, crates, of items that can be opened and the contents be added to you invntory. example veteran rewards and armour packs.
Part 2 will update and add code to actually open these items sets and receive your items.
Part 3 will be an update to allow for the selection of one item from the item set ie burynai plant, eggs
throughout the aritcle, if you update your code yourself and dont rely on svn updated code then you want the following changes, this is becuase of Jab's unability to alter the db due to a technical difficulty. its just a name change so Jab will have to keep references to the old names instead of new names i will be posting in the itemsdb.cpp
original name `item_unknown1` new name `item_stack_size`
original name `item_unknown2` new name `item_list_color`
this is the DB change
Items.h
add (yes its a duplicate number but armorsets use the same code #
add
to the section that starts with
add the struct ItemSet below
add this to the
section
struct ItemSet_Info{
int32 item_id;
int32 item_crc;
int16 item_icon;
int32 item_stack_size;
int32 item_list_color;
};
add these 2 lines
into the section below
Items.cpp
in
add
in
add
in
add
add
right after
add
right after
add
just before
add
just before
add
after
WorldDatabase.h
in
ItemsDB.cpp
add NOTE: if DB your is not updated then change item_stack_size to Item_unknown1, and item_list_color to item_unknown2(emu server this means you
after
add
after
Part 2 will update and add code to actually open these items sets and receive your items.
Part 3 will be an update to allow for the selection of one item from the item set ie burynai plant, eggs
throughout the aritcle, if you update your code yourself and dont rely on svn updated code then you want the following changes, this is becuase of Jab's unability to alter the db due to a technical difficulty. its just a name change so Jab will have to keep references to the old names instead of new names i will be posting in the itemsdb.cpp
original name `item_unknown1` new name `item_stack_size`
original name `item_unknown2` new name `item_list_color`
this is the DB change
Code: Select all
ALTER TABLE `eq2world7`.`item_details_itemset`
CHANGE `item_unknown1` `item_stack_size` SMALLINT(5) UNSIGNED DEFAULT 0 NOT NULL,
CHANGE `item_unknown2` `item_list_color` INT(10) DEFAULT 0 NOT NULL;add (yes its a duplicate number but armorsets use the same code #
Code: Select all
#define ITEM_TYPE_ITEMCRATE 18Code: Select all
vector<ItemSet*> item_sets;
ItemSet_Info* itemset_info;Code: Select all
#pragma pack()
Item();
Item(Item* in_item);
~Item();
string lowername;
string name;
string description;
int8 stack_count;
int32 sell_price;add the struct ItemSet below
Code: Select all
#pragma pack()
struct ItemStat{
string stat_name;
int8 stat_type;
sint16 stat_subtype;
int16 stat_type_combined;
float value;
};
struct ItemSet{
int32 item_id;
int32 item_crc;
int16 item_icon;
int16 item_stack_size;
int32 item_list_color;
};
struct Classifications{
int32 class_id; //classifications MJ
string class_name;
};Code: Select all
public:
#pragma pack(1)struct ItemSet_Info{
int32 item_id;
int32 item_crc;
int16 item_icon;
int32 item_stack_size;
int32 item_list_color;
};
add these 2 lines
Code: Select all
void AddSet(ItemSet* in_set);
void AddSet(int32 item_id, int32 item_crc, int16 item_icon, int32 item_stack_size, int32 item_unknown2);Code: Select all
void SetAppearance(int16 type, int8 red, int8 green, int8 blue, int8 highlight_red, int8 highlight_green, int8 highlight_blue);
void SetAppearance(ItemAppearance* appearance);
void AddStat(ItemStat* in_stat);
void AddSet(ItemSet* in_set);
void AddStatString(ItemStatString* in_stat);
void AddStat(int8 type, int16 subtype, float value, char* name = 0);
void AddSet(int32 item_id, int32 item_crc, int16 item_icon, int32 item_stack_size, int32 item_unknown2);
void SetWeaponType(int8 type);
int8 GetWeaponType();
bool HasSlot(int8 slot, int8 slot2 = 255);
bool HasAdorn0();
bool HasAdorn1();
bool HasAdorn2();in
Code: Select all
Item::Item(){Code: Select all
itemset_info = 0;Code: Select all
Item::~Item(){Code: Select all
safe_delete(itemset_info);Code: Select all
void Item::SetItem(Item* old_item){Code: Select all
itemset_info = 0;Code: Select all
item_sets.clear();
for (int32 i = 0; i<old_item->item_sets.size(); i++){
ItemSet* set = old_item->item_sets[i];
if (set){
ItemSet* set2 = new ItemSet;
set2->item_id = set->item_id;
set2->item_crc = set->item_crc;
set2->item_icon = set->item_icon;
set2->item_stack_size = set->item_stack_size;
set2->item_list_color = set->item_list_color;
item_sets.push_back(set2);
}
}Code: Select all
creator = old_item->creator;
adornment = old_item->adornment;Code: Select all
void Item::AddSet(ItemSet* in_set){
item_sets.push_back(in_set);
}Code: Select all
void Item::AddStat(ItemStat* in_stat){
item_stats.push_back(in_stat);
}Code: Select all
void Item::AddSet(int32 item_id, int32 item_crc, int16 item_icon, int32 item_stack_size, int32 item_list_color){
ItemSet* set = new ItemSet;
set->item_id = item_id;
set->item_icon = item_icon;
set->item_crc = item_crc;
set->item_stack_size = item_stack_size;
set->item_list_color = item_list_color;
AddSet(set);
}Code: Select all
int16 Item::GetOverrideLevel(int8 adventure_class, int8 tradeskill_class){Code: Select all
if (item_sets.size() > 0){
packet->setArrayLengthByName("num_pieces", item_sets.size());
for (int32 i = 0; i < item_sets.size(); i++){
ItemSet* set = item_sets[i];
packet->setArrayDataByName("item_id", set->item_id, i);
packet->setArrayDataByName("item_crc", set->item_crc, i);
packet->setArrayDataByName("item_icon", set->item_icon, i);
packet->setArrayDataByName("item_unknown1", set->item_stack_size, i);
Item* item2 = master_item_list.GetItem(set->item_id);
//item2 = master_item_list.GetItem(set->item_id);
string itemname = item2->name;
packet->setArrayDataByName("item_name", item2->name.c_str(), i);
packet->setArrayDataByName("item_unknown2", set->item_list_color, i);
}
}Code: Select all
if(!loot_item && item_effects.size() > 0){
packet->setSubstructArrayLengthByName("footer", "num_effects", item_effects.size());
for(int32 i=0;i<item_effects.size();i++){
ItemEffect* effect = item_effects[i];
packet->setArrayDataByName("subbulletflag", effect->subbulletflag, i);
packet->setArrayDataByName("effect", &(effect->effect), i);
packet->setArrayDataByName("percentage", effect->percentage, i);
}
}Code: Select all
case ITEM_TYPE_ITEMCRATE:{
if (merchant_item)
packet = configReader.getStruct("WS_MerchantItemSet", version);
else
packet = configReader.getStruct("WS_ItemSet", version);
break;
}Code: Select all
case ITEM_TYPE_BAUBLE:{
if(merchant_item)
packet = configReader.getStruct("WS_MerchantItemBauble", version);
else
packet = configReader.getStruct("WS_ItemBauble", version);
break;
}Code: Select all
int32 LoadItemsets();Code: Select all
class WorldDatabase : public Database {
public:add NOTE: if DB your is not updated then change item_stack_size to Item_unknown1, and item_list_color to item_unknown2(emu server this means you
Code: Select all
int32 WorldDatabase::LoadItemsets()
{
DatabaseResult result;
int32 total = 0;
int32 id = 0;
if (database_new.Select(&result, "SELECT id, itemset_item_id, item_id, item_icon,item_stack_size,item_list_color,language_type FROM item_details_itemset"))
{
while (result.Next())
{
id = result.GetInt32Str("itemset_item_id");
Item* item = master_item_list.GetItem(id);
if (item)
{
item->SetItemType(ITEM_TYPE_ITEMCRATE);
//int32 item_id = result.GetInt32Str("item_id");
item->AddSet(result.GetInt32Str("item_id"),0, result.GetInt16Str("item_icon"), result.GetInt16Str("item_stack_size"), result.GetInt32Str("item_list_color"));
total++;
}
else
LogWrite(ITEM__ERROR, 0, "Item Set Crate Items", "Error loading `item_details_Items`, ID: %i", id);
}
}
return total;
}Code: Select all
int32 WorldDatabase::LoadBooks()
{
DatabaseResult result;
int32 total = 0;
int32 id = 0;
if( database_new.Select(&result, "SELECT item_id, language, author, title FROM item_details_book") )
{
while( result.Next() )
{
id = result.GetInt32Str("item_id");
Item* item = master_item_list.GetItem(id);
if(item)
{
LogWrite(ITEM__DEBUG, 5, "Items", "\tItem Book for item_id %u", id);
LogWrite(ITEM__DEBUG, 5, "Items", "\ttype: %i, %i, %s, %s",
ITEM_TYPE_BOOK,
result.GetInt8Str("language"),
result.GetStringStr("author"),
result.GetStringStr("title"));
item->SetItemType(ITEM_TYPE_BOOK);
item->book_info->language = result.GetInt8Str("language");
item->book_info->author.data = result.GetStringStr("author");
item->book_info->author.size = item->book_info->author.data.length();
item->book_info->title.data = result.GetStringStr("title");
item->book_info->title.size = item->book_info->title.data.length();
total++;
}
else
LogWrite(ITEM__ERROR, 0, "Items", "Error loading `item_details_book`, ID: %i", id);
}
}
return total;
}Code: Select all
LogWrite(ITEM__DEBUG, 0, "Items", "\tLoaded %u Item Sets", LoadItemsets());Code: Select all
LogWrite(ITEM__DEBUG, 0, "Items", "\tLoaded %u Normal Items", normal_items);
LogWrite(ITEM__DEBUG, 0, "Items", "\tLoaded %u Baubles", LoadBaubles());
LogWrite(ITEM__DEBUG, 0, "Items", "\tLoaded %u Bags", LoadBags());
LogWrite(ITEM__DEBUG, 0, "Items", "\tLoaded %u Books", LoadBooks());