Jump to content

cmaranec

Members
  • Posts

    37
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Everything posted by cmaranec

  1. I'll take a look at it. Maybe it should be better with loot record somewhere. I haven't found any item, that changes with amount greater than 1, but i did't say that it doesn't exist.
  2. So? Would new column in item_template be better? These two items were only examples - i think there's more than two items, which changes when duration expires. It would be also useful for custom items (in case of funserver, custom workarounds and so on..) What do you suggest? EDIT: For NoFantasy: i think duration update of any item is called when player loggs in, so it is ok.
  3. UPDATE: New Patch: http://paste2.org/p/711632 Works with 9558 Improvements: * changed return value if item with duration haven't got a duration change from NULL to 0 * implemented reload command Example items: INSERT INTO `item_duration_changes` VALUES ('39878', '39883'); INSERT INTO `item_duration_changes` VALUES ('44717', '44718'); EDIT:PS: You need set duration to items 39878 and 44717! For testing i've set 15 seconds
  4. UPDATE: New patch: http://paste2.org/p/710769 Works with 9558. Improvements: * added checks in loading function (if items exist and has duration) * storing in UNORDERED_MAP
  5. I'll try to modify this patch to make Lynx3d's eyes happy ..i just need some time
  6. What features does this patch add? It implements feature, when item duration expires, new item will be added to inventory if it has record in item_duration_change table For which revision? 9467 (but should work with newest) Who has been writing this patch? me Patch: diff --git a/sql/item_duration_changes.sql b/sql/item_duration_changes.sql new file mode 100644 index 0000000..3c8c952 --- /dev/null +++ b/sql/item_duration_changes.sql @@ -0,0 +1,6 @@ +DROP TABLE IF EXISTS `item_duration_changes`; +CREATE TABLE `item_duration_changes` ( + `item` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Item id with set duration', + `changed_item` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Item id to which should source item change', + PRIMARY KEY (`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item duration changes system'; diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 10eef36..5fc872b 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -273,6 +273,11 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner) return true; } +uint32 Item::GetDurationChange() +{ + return sObjectMgr.GetItemDurationChange(this->GetEntry()); +} + void Item::UpdateDuration(Player* owner, uint32 diff) { if (!GetUInt32Value(ITEM_FIELD_DURATION)) @@ -283,6 +288,8 @@ void Item::UpdateDuration(Player* owner, uint32 diff) if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff) { owner->DestroyItem(GetBagSlot(), GetSlot(), true); + if(uint32 ChangedItem = GetDurationChange()) + owner->StoreNewItemInBestSlots(ChangedItem,1); return; } diff --git a/src/game/Item.h b/src/game/Item.h index 409f8ce..8981925 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -272,6 +272,7 @@ class MANGOS_DLL_SPEC Item : public Object void SetSlot(uint8 slot) {m_slot = slot;} uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); } void SetContainer(Bag *container) { m_container = container; } + uint32 GetDurationChange(); bool IsInBag() const { return m_container != NULL; } bool IsEquipped() const; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index b887961..f9a900e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4523,6 +4523,49 @@ void ObjectMgr::LoadItemTexts() sLog.outString( ">> Loaded %u item texts", count ); } +void ObjectMgr::LoadItemDurationChanges() +{ + QueryResult *result = WorldDatabase.Query("SELECT item, changed_item FROM item_duration_changes"); + + mItemDurationChanges.clear(); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u item duration changes", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + Field* fields; + do + { + bar.step(); + + fields = result->Fetch(); + + ItemDurationChanges temp; + temp.source_item = fields[0].GetUInt32(); + temp.changed_item = fields[1].GetUInt32(); + + mItemDurationChanges.push_back(temp); + + ++count; + + } while ( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u item duration changes", count ); +} + void ObjectMgr::LoadPageTexts() { sPageTextStore.Free(); // for reload case diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 4442f56..376ab38 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -366,6 +366,12 @@ struct MANGOS_DLL_SPEC LanguageDesc uint32 skill_id; }; +struct ItemDurationChanges +{ + uint32 source_item; + uint32 changed_item; +}; + extern LanguageDesc lang_description[LANGUAGES_COUNT]; MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang); @@ -591,6 +597,7 @@ class ObjectMgr void LoadGameobjects(); void LoadGameobjectRespawnTimes(); void LoadItemPrototypes(); + void LoadItemDurationChanges(); void LoadItemRequiredTarget(); void LoadItemLocales(); void LoadQuestLocales(); @@ -846,6 +853,17 @@ class ObjectMgr return &iter->second; } + uint32 GetItemDurationChange(uint32 item) + { + for(std::list<ItemDurationChanges>::const_iterator itr = mItemDurationChanges.begin(); + itr != mItemDurationChanges.end(); ++itr) + { + if(itr->source_item == item) + return itr->changed_item; + } + return NULL; + } + VendorItemData const* GetNpcVendorItemList(uint32 entry) const { CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); @@ -917,6 +935,7 @@ class ObjectMgr ArenaTeamMap mArenaTeamMap; ItemTextMap mItemTexts; + std::list<ItemDurationChanges> mItemDurationChanges; QuestAreaTriggerMap mQuestAreaTriggerMap; TavernAreaTriggerSet mTavernAreaTriggerSet; diff --git a/src/game/World.cpp b/src/game/World.cpp index b1605d5..5e317a6 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -975,6 +975,9 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Item Texts..." ); sObjectMgr.LoadItemTexts(); + sLog.outString( "Loading Item Duration Changes..." ); + sObjectMgr.LoadItemDurationChanges(); + sLog.outString( "Loading Creature Model Based Info Data..." ); sObjectMgr.LoadCreatureModelInfo();
  7. Is anything missing, or do you think, that it's ready for "..under review" section?
  8. So there's my first attempt: From 7efabcff3117c03a8f417c3b01cd4f24489fea12 Mon Sep 17 00:00:00 2001 From: Cmaranec <[email protected]> Date: Sat, 27 Feb 2010 21:04:24 +0100 Subject: [PATCH] Added support for item change after duration expires --- sql/item_duration_changes.sql | 6 +++++ src/game/Item.cpp | 7 ++++++ src/game/Item.h | 1 + src/game/ObjectMgr.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ src/game/ObjectMgr.h | 19 ++++++++++++++++++ src/game/World.cpp | 3 ++ 6 files changed, 79 insertions(+), 0 deletions(-) create mode 100644 sql/item_duration_changes.sql diff --git a/sql/item_duration_changes.sql b/sql/item_duration_changes.sql new file mode 100644 index 0000000..3c8c952 --- /dev/null +++ b/sql/item_duration_changes.sql @@ -0,0 +1,6 @@ +DROP TABLE IF EXISTS `item_duration_changes`; +CREATE TABLE `item_duration_changes` ( + `item` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Item id with set duration', + `changed_item` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Item id to which should source item change', + PRIMARY KEY (`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item duration changes system'; diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 10eef36..5fc872b 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -273,6 +273,11 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner) return true; } +uint32 Item::GetDurationChange() +{ + return sObjectMgr.GetItemDurationChange(this->GetEntry()); +} + void Item::UpdateDuration(Player* owner, uint32 diff) { if (!GetUInt32Value(ITEM_FIELD_DURATION)) @@ -283,6 +288,8 @@ void Item::UpdateDuration(Player* owner, uint32 diff) if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff) { owner->DestroyItem(GetBagSlot(), GetSlot(), true); + if(uint32 ChangedItem = GetDurationChange()) + owner->StoreNewItemInBestSlots(ChangedItem,1); return; } diff --git a/src/game/Item.h b/src/game/Item.h index 409f8ce..8981925 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -272,6 +272,7 @@ class MANGOS_DLL_SPEC Item : public Object void SetSlot(uint8 slot) {m_slot = slot;} uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); } void SetContainer(Bag *container) { m_container = container; } + uint32 GetDurationChange(); bool IsInBag() const { return m_container != NULL; } bool IsEquipped() const; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index b887961..f9a900e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4523,6 +4523,49 @@ void ObjectMgr::LoadItemTexts() sLog.outString( ">> Loaded %u item texts", count ); } +void ObjectMgr::LoadItemDurationChanges() +{ + QueryResult *result = WorldDatabase.Query("SELECT item, changed_item FROM item_duration_changes"); + + mItemDurationChanges.clear(); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u item duration changes", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + Field* fields; + do + { + bar.step(); + + fields = result->Fetch(); + + ItemDurationChanges temp; + temp.source_item = fields[0].GetUInt32(); + temp.changed_item = fields[1].GetUInt32(); + + mItemDurationChanges.push_back(temp); + + ++count; + + } while ( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u item duration changes", count ); +} + void ObjectMgr::LoadPageTexts() { sPageTextStore.Free(); // for reload case diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 4442f56..376ab38 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -366,6 +366,12 @@ struct MANGOS_DLL_SPEC LanguageDesc uint32 skill_id; }; +struct ItemDurationChanges +{ + uint32 source_item; + uint32 changed_item; +}; + extern LanguageDesc lang_description[LANGUAGES_COUNT]; MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang); @@ -591,6 +597,7 @@ class ObjectMgr void LoadGameobjects(); void LoadGameobjectRespawnTimes(); void LoadItemPrototypes(); + void LoadItemDurationChanges(); void LoadItemRequiredTarget(); void LoadItemLocales(); void LoadQuestLocales(); @@ -846,6 +853,17 @@ class ObjectMgr return &iter->second; } + uint32 GetItemDurationChange(uint32 item) + { + for(std::list<ItemDurationChanges>::const_iterator itr = mItemDurationChanges.begin(); + itr != mItemDurationChanges.end(); ++itr) + { + if(itr->source_item == item) + return itr->changed_item; + } + return NULL; + } + VendorItemData const* GetNpcVendorItemList(uint32 entry) const { CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); @@ -917,6 +935,7 @@ class ObjectMgr ArenaTeamMap mArenaTeamMap; ItemTextMap mItemTexts; + std::list<ItemDurationChanges> mItemDurationChanges; QuestAreaTriggerMap mQuestAreaTriggerMap; TavernAreaTriggerSet mTavernAreaTriggerSet; diff --git a/src/game/World.cpp b/src/game/World.cpp index b1605d5..5e317a6 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -975,6 +975,9 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Item Texts..." ); sObjectMgr.LoadItemTexts(); + sLog.outString( "Loading Item Duration Changes..." ); + sObjectMgr.LoadItemDurationChanges(); + sLog.outString( "Loading Creature Model Based Info Data..." ); sObjectMgr.LoadCreatureModelInfo(); -- 1.6.4 Works with newest revision (9467) SQL file for import will be created by this patch to sql directory of mangos
  9. I'm working on full patch for this (with database support based on loot system with % chance and so on..). I'll post my patch when it'll be done, maybe today evening.
  10. Is there any patch for items, that has some duration and after this duration item disappears and automaticaly creates a new item? For example http://www.wowhead.com/?item=39878 changes into http://www.wowhead.com/?item=39883 If there's no patch, how should i make it? Should i do it the same way like classical "duration-destructed" items? (in Item.cpp in UpdteItemDuration) Sorry for my English, i'm Czech
  11. Updated first post, thanks Dagguh. Btw. Revy i've updated it now.
  12. What bug does the patch fix? What features does the patch add? It adds core support for spell Spinning triggered by item Unusual Compass For which repository revision was the patch created? Created at 8079 Who has been writing this patch? Please include either forum user names or email addresses. cmaranec How does it work: After using item Unusual Compass (cast Spinning), player's orientation will be changed to random between 0 and 6 (0.0000 and 6.2832). diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 957c205..e49d6f0 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -622,6 +622,15 @@ void Spell::EffectDummy(uint32 i) { switch(m_spellInfo->Id ) { + case 64385: // Unusual Compas + { + float part = urand(0,62832); + m_caster->SetOrientation(part / 10000); + WorldPacket data; + m_caster->BuildHeartBeatMsg(&data); + m_caster->SendMessageToSet(&data,true); + return; + } case 8063: // Deviate Fish { if(m_caster->GetTypeId() != TYPEID_PLAYER) Sorry for my bad english
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use