Modcraft - The community dedicated to quality WoW modding!
Wrath of the Lich King Modding => Serverside Modding => Topic started by: Смердокрыл on July 02, 2015, 02:04:44 pm
-
Hey everyone!
Any good tutorial on making an item that morphs when worn? No spell-morphs, please, I need to use displayids.
-
ITEM >> SPELL ( with morph )
Done .. look at noggers elixir
-
I hope you are just trolling
-
I hope you are just trolling
Why? Thats a good idea. Can't be so difficult to copy the code and just edit the display id..
edit:
ah...see just now what you mean....
edit2:
maybe you could try to look into the databse if item XYZ has durability >0 and if not, the owner get any effect..?
-
I was gonna use trinkets, so cant use durability, can I?
-
No that's not possible. But i thought u try to morph the player when the item is worn...maybe it is an translation mistake by me...worn means damaged so in wow the item is shown "red". trinkets, rings, back, neck etc. can never lose durability.
-
You either need to use a spell or a script.
Spell would nicely take use of the aura system incase the player has multiple morphs. Lets say he has your trinket and noggenfogger, the spell system would probably be able to restore the other when the other wears out and maybe take into account other things.
If you apply the morph on equip (or on spell cast) and then the player morphs to something else (noggenfogger) it might be a hassle to try to restore the morph from the trinket after that without checking all the time for the correct displayid.
What core do you use for the server?
Mangos based cores (mangos, cmangos, trinitycore.. ) do not have an "on equip" hook in their C++ scripting API. Unsure about arcemu ?_?
This means that you would need to modify the core to add such a hook.
A workaround for this could be .. yet again .. using a spell.
By using a spell on use for the item you can script the spell to do what you want in C++.
You can use the same spell for all items you create since you can script it to do different things according to the item entry or other data.
Did I mention a spell yet? :3
No that's not possible. But i thought u try to morph the player when the item is worn...maybe it is an translation mistake by me...worn means damaged so in wow the item is shown "red". trinkets, rings, back, neck etc. can never lose durability.
by worn he probably meant that he wanted the morph to be visible when the item is equipped/weared.
-
Hey everyone!
Any good tutorial on making an item that morphs when worn? No spell-morphs, please, I need to use displayids.
You can make hook in core to catch this event. For example in TrinityCore in file Player.cpp, It is tested.
void Player::DurabilityPointsLoss(Item* item, int32 points)
.
.
.
if (pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped())
{
_ApplyItemMods(item, item->GetSlot(), false);
// Morph on durability loss
SetDisplayId(999);
ChatHandler(GetSession()).PSendSysMessage("It's broken and You are morphed!");
}
.
.
.
item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability);
I hope I helped You...
-
Rochet2 and Daweo's replies look promising, other than I have no experience in C++ at all, so I dont really get what demonic rituals do I have to perform with this ancient scripts...
-
Rochet2 and Daweo's replies look promising, other than I have no experience in C++ at all, so I dont really get what demonic rituals do I have to perform with this ancient scripts...
So, what you really wanted? Morph on item equip or on durability loss? :)
-
Morph on item equip, but with the ability to morph using ANY displayid, and not only those that are attached to a certain spell/aura
-
Off top of my head there are a few options.
A) Hook in Core... C++
- You would have to find in core, where the item equip is handled and there add your own code
- But, this option will definitely work...
B) Make SpellScript to any spell and that spell will be set on item equip.. C++
- So if you equip an item, the spell will be executed and then our spellscript too. And in code of spellscript wil be implementation of your Morphs.
C) DBC Edits of spells
- It may not seem, but if you dont know C++, it is the most easy method for you, but the custom patch is then needed...
-
C) DBC Edits of spells
This seems to be the best option for a noob like myself. But can I create a custom spell, not to destroy any existing ones?
P.S. I have 4.3.4 trinity
-
Ou... I dont have any experience with DBC above 3.3.5a...
But maybe i can write a simple code...
The solution would be:
SQL table item_morph with two columns: item_id and model_id
C++ Script to handle whoch model_id should be used
-
Ok, you can congratulae me, because I managed to create a table!
[attachment=0:1v80o1pg]table.jpg[/attachment:1v80o1pg]
-
For TrinityCore 3.3.5a the solution could be:
SQL table in world database:
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:
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...
-
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 :(
-
For TrinityCore 3.3.5a the solution could be:
SQL table in world database:
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:
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.
-
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)