Forum > Serverside Modding

[QUESTION] Morphing item

<< < (4/4)

Daweo:
For TrinityCore 3.3.5a the solution could be:

SQL table in world database:

--- Code: ---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;

--- End code ---


C++ code in Player.cpp:

--- Code: ---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


--- End code ---

Did not test, but should work... However this only morph player on equip and doesnt demorph on unequip...

bizzlesnaff:
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 :(

Ascathos:

--- Quote from: "Daweo" ---For TrinityCore 3.3.5a the solution could be:

SQL table in world database:

--- Code: ---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;

--- End code ---


C++ code in Player.cpp:

--- Code: ---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


--- End code ---

Did not test, but should work... However this only morph player on equip and doesnt demorph on unequip...
--- End quote ---
A cleaner execution would be creating a new spell and have it morph.

Смердокрыл:

--- Quote from: "Ascathos" ---A cleaner execution would be creating a new spell and have it morph.
--- End quote ---
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)

Navigation

[0] Message Index

[*] Previous page

Go to full version