mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[11646] Implement support item converting at expire
Example: items 44623->44625->44627 convertion chain * New table `item_enchantment_template` store original->final item pairs Original item must have duration setup. * Small change in GetItemConvert for consistence (now 0 returned if no convert pair instead original entry id) Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
a97370a7f0
commit
2d7768a5ab
10 changed files with 117 additions and 13 deletions
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
|||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`cache_id` int(10) default '0',
|
||||
`required_11613_01_mangos_spell_bonus_data` bit(1) default NULL
|
||||
`required_11646_01_mangos_item_expire_convert` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
@ -2193,7 +2193,7 @@ CREATE TABLE `item_convert` (
|
|||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`item` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Npc System';
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `item_convert`
|
||||
|
|
@ -2225,6 +2225,26 @@ LOCK TABLES `item_enchantment_template` WRITE;
|
|||
/*!40000 ALTER TABLE `item_enchantment_template` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `item_expire_convert`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `item_expire_convert`;
|
||||
CREATE TABLE `item_expire_convert` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`item` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';
|
||||
|
||||
--
|
||||
-- Dumping data for table `item_convert`
|
||||
--
|
||||
|
||||
LOCK TABLES `item_convert` WRITE;
|
||||
/*!40000 ALTER TABLE `item_convert` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `item_convert` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `item_loot_template`
|
||||
--
|
||||
|
|
|
|||
10
sql/updates/11646_01_mangos_item_expire_convert.sql
Normal file
10
sql/updates/11646_01_mangos_item_expire_convert.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_11613_01_mangos_spell_bonus_data required_11646_01_mangos_item_expire_convert bit;
|
||||
|
||||
DROP TABLE IF EXISTS `item_expire_convert`;
|
||||
CREATE TABLE `item_expire_convert` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`item` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';
|
||||
|
||||
INSERT INTO `item_expire_convert` VALUES (44623, 44625), (44625, 44627);
|
||||
|
|
@ -280,7 +280,10 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
|
|||
|
||||
if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
|
||||
{
|
||||
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
|
||||
if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
|
||||
owner->ConvertItem(this, newItemId);
|
||||
else
|
||||
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -801,9 +801,9 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid)
|
|||
// convert if can use and then buy
|
||||
if (pProto->RequiredReputationFaction && uint32(_player->GetReputationRank(pProto->RequiredReputationFaction)) >= pProto->RequiredReputationRank)
|
||||
{
|
||||
itemId = sObjectMgr.GetItemConvert(itemId, _player->getRaceMask());
|
||||
// checked at convert data loading as existed
|
||||
pProto = ObjectMgr::GetItemPrototype(itemId);
|
||||
if (uint32 newItemId = sObjectMgr.GetItemConvert(itemId, _player->getRaceMask()))
|
||||
pProto = ObjectMgr::GetItemPrototype(newItemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2408,6 +2408,66 @@ void ObjectMgr::LoadItemConverts()
|
|||
sLog.outString(">> Loaded %u Item converts", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadItemExpireConverts()
|
||||
{
|
||||
m_ItemExpireConvert.clear(); // needed for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_expire_convert");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
BarGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outErrorDb(">> Loaded 0 Item expire converts . DB table `item_expire_convert` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
BarGoLink bar(result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
bar.step();
|
||||
|
||||
uint32 itemEntry = fields[0].GetUInt32();
|
||||
uint32 itemTargetId = fields[1].GetUInt32();
|
||||
|
||||
ItemPrototype const* pItemEntryProto = sItemStorage.LookupEntry<ItemPrototype>(itemEntry);
|
||||
if (!pItemEntryProto)
|
||||
{
|
||||
sLog.outErrorDb("Table `item_expire_convert`: Item %u not exist in `item_template`.", itemEntry);
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemPrototype const* pItemTargetProto = sItemStorage.LookupEntry<ItemPrototype>(itemTargetId);
|
||||
if (!pItemTargetProto)
|
||||
{
|
||||
sLog.outErrorDb("Table `item_expire_convert`: Item target %u for original item %u not exist in `item_template`.", itemTargetId, itemEntry);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Expire convert possible only for items with duration
|
||||
if (pItemEntryProto->Duration == 0)
|
||||
{
|
||||
sLog.outErrorDb("Table `item_expire_convert` not appropriate item %u conversion to %u. Table can be used for items with duration.", itemEntry, itemTargetId);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_ItemExpireConvert[itemEntry] = itemTargetId;
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u Item expire converts", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadItemRequiredTarget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -642,8 +642,9 @@ class ObjectMgr
|
|||
void LoadEquipmentTemplates();
|
||||
void LoadGameObjectLocales();
|
||||
void LoadGameobjects();
|
||||
void LoadItemConverts();
|
||||
void LoadItemPrototypes();
|
||||
void LoadItemConverts();
|
||||
void LoadItemExpireConverts();
|
||||
void LoadItemRequiredTarget();
|
||||
void LoadItemLocales();
|
||||
void LoadQuestLocales();
|
||||
|
|
@ -979,10 +980,16 @@ class ObjectMgr
|
|||
{
|
||||
ItemConvertMap::const_iterator iter = m_ItemConvert.find(itemEntry);
|
||||
if (iter == m_ItemConvert.end())
|
||||
return itemEntry;
|
||||
return 0;
|
||||
|
||||
ItemPrototype const* proto = GetItemPrototype(iter->second);
|
||||
return (proto && proto->AllowableRace & raceMask) ? iter->second : itemEntry;
|
||||
return (proto && proto->AllowableRace & raceMask) ? iter->second : 0;
|
||||
}
|
||||
|
||||
uint32 GetItemExpireConvert(uint32 itemEntry) const
|
||||
{
|
||||
ItemConvertMap::const_iterator iter = m_ItemExpireConvert.find(itemEntry);
|
||||
return iter != m_ItemExpireConvert.end() ? iter->second : 0;
|
||||
}
|
||||
|
||||
ItemRequiredTargetMapBounds GetItemRequiredTargetMapBounds(uint32 uiItemEntry) const
|
||||
|
|
@ -1095,6 +1102,7 @@ class ObjectMgr
|
|||
SpellClickInfoMap mSpellClickInfoMap;
|
||||
|
||||
ItemConvertMap m_ItemConvert;
|
||||
ItemConvertMap m_ItemExpireConvert;
|
||||
ItemRequiredTargetMap m_ItemRequiredTarget;
|
||||
|
||||
typedef std::vector<LocaleConstant> LocalForIndex;
|
||||
|
|
|
|||
|
|
@ -19194,7 +19194,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
|||
ItemPrototype const* crProto = ObjectMgr::GetItemPrototype(crItem->item);
|
||||
if (crProto->Flags & ITEM_FLAG_BOA && crProto->RequiredReputationFaction &&
|
||||
uint32(GetReputationRank(crProto->RequiredReputationFaction)) >= crProto->RequiredReputationRank)
|
||||
converted = item == sObjectMgr.GetItemConvert(crItem->item, getRaceMask());
|
||||
converted = (sObjectMgr.GetItemConvert(crItem->item, getRaceMask()) != 0);
|
||||
|
||||
if (!converted)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1010,12 +1010,15 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Loading Item Random Enchantments Table..." );
|
||||
LoadRandomEnchantmentsTable();
|
||||
|
||||
sLog.outString( "Loading Items..." ); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
|
||||
sLog.outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
|
||||
sObjectMgr.LoadItemPrototypes();
|
||||
|
||||
sLog.outString( "Loading Item converts..." ); // must be after LoadItemPrototypes
|
||||
sLog.outString("Loading Item converts..."); // must be after LoadItemPrototypes
|
||||
sObjectMgr.LoadItemConverts();
|
||||
|
||||
sLog.outString("Loading Item expire converts..."); // must be after LoadItemPrototypes
|
||||
sObjectMgr.LoadItemExpireConverts();
|
||||
|
||||
sLog.outString( "Loading Creature Model Based Info Data..." );
|
||||
sObjectMgr.LoadCreatureModelInfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11645"
|
||||
#define REVISION_NR "11646"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_11620_01_characters_character_equipmentsets"
|
||||
#define REVISION_DB_MANGOS "required_11613_01_mangos_spell_bonus_data"
|
||||
#define REVISION_DB_MANGOS "required_11646_01_mangos_item_expire_convert"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue