This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Morphing item  (Read 2858 times)

Daweo

  • Registred Member
  • Race Changer
  • *****
  • Posts: 39
    • View Profile
Re: [QUESTION] Morphing item
« Reply #15 on: July 03, 2015, 01:49:53 am »
For TrinityCore 3.3.5a the solution could be:

SQL table in world database:
Code: [Select]
CREATE TABLE IF NOT EXISTS `item_morph` (
`item_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`morph_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`item_id`)
)
COMMENT='Item Morph system'
COLLATE='utf8_general_ci'
ENGINE=MyISAM;


C++ code in Player.cpp:
Code: [Select]
Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
{
.
.
.
ApplyEquipCooldown(pItem2);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem2->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END

return pItem2;
    }
.
.
.
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END

return pItem;
}
.
.
.
void Player::QuickEquipItem(uint16 pos, Item* pItem)
{
.
.
.
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END


Did not test, but should work... However this only morph player on equip and doesnt demorph on unequip...
« Last Edit: July 03, 2015, 08:01:24 am by Admin »

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
Re: [QUESTION] Morphing item
« Reply #16 on: July 03, 2015, 03:35:41 am »
Is  there maybe a solution with smartscripts?
I remember one item, which do exact the thing you are looking for.
The ID should be 17142 [Shard of the Defiler]. This sword morph you into a demon, and demorph you after remove the item.
But the Item has no script in the database...so I'm confused..:)


edit:

oh..my bad. This sword just use a spell on the player...nevermind :(
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Morphing item
« Reply #17 on: July 03, 2015, 01:26:04 pm »
Quote from: "Daweo"
For TrinityCore 3.3.5a the solution could be:

SQL table in world database:
Code: [Select]
CREATE TABLE IF NOT EXISTS `item_morph` (
`item_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`morph_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`item_id`)
)
COMMENT='Item Morph system'
COLLATE='utf8_general_ci'
ENGINE=MyISAM;


C++ code in Player.cpp:
Code: [Select]
Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
{
.
.
.
ApplyEquipCooldown(pItem2);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem2->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END

return pItem2;
    }
.
.
.
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END

return pItem;
}
.
.
.
void Player::QuickEquipItem(uint16 pos, Item* pItem)
{
.
.
.
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);

// Item Morph
QueryResult result = WorldDatabase.PQuery("SELECT model_id FROM item_morph WHERE item_id = %u", pItem->GetEntry());

if (result)
{
Field* fields = result->Fetch();
uint32 model_id = fields[0].GetUInt32();

if (sCreatureDisplayInfoStore.LookupEntry(sObjectMgr->GetCreatureDisplay(model_id)))
SetDisplayId(model_id);
}
// END


Did not test, but should work... However this only morph player on equip and doesnt demorph on unequip...
A cleaner execution would be creating a new spell and have it morph.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [QUESTION] Morphing item
« Reply #18 on: July 03, 2015, 06:23:14 pm »
Quote from: "Ascathos"
A cleaner execution would be creating a new spell and have it morph.
We've aready came up with this and now Im trying to get my noobish brain understand the spell.dbc structure.

p.s. Please dont make quotes be 99% of your comment, especially when theyre that large)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
or no.
At least I tried.