Question one and Request one(transmog for npcbot)
-
is it possible to use your npcbot's c++ function in lua? [example] bot : GossipMenuAddItem(X,X,X)
-
Tricker, Is there any plan to make transmogrification for npcbots in the future?
-
No idea. I never worked with Eluna, but I think you should be able to use any function as long as it is an override of a virtual func.
-
I didn't make any plans for bots since 2014, except for updates. Still, it seems like I have pending feature requests all the time. Transmog is not that difficult I guess, weapons could be a bit troublesome, but that's it.
Thank you for answering kinldy my question~~~. And I also hope there will be functions with saving bots like pdump
I think this is a good place to put my questions, since they seem like a follow up to this. Please let me know if I should move these questions somewhere else.
I am using the pre-patched TrinityCore-3.3.5-with-NPCBots code, along with the Rochet2 / TrinityCore transmogvendor_3.3.5 branch: TransmogDisplayVendor.
I am trying to figure out how to set the visible look of an item that an NPCBot has equipped. An item equipped by a player character shows the transmog, but an item equipped by an NPCBot doesn't show the transmog, rather it still shows the original item appearance. I saw the issue here #https://github.com/trickerer/Trinity-Bots/issues/101, but I think that is regarding Rochet2 Transmogrification, which is different from Rochet2 TransmogDisplayVendor (the latter doesn't add any columns to the item_instance table, it keeps track of transmogs in the custom_transmogrification table). If I'm reading it correctly, I wouldn't expect the steps at that link to accomplish do what I'm trying to do, and when I tried the steps it didn't.
I did fix the fact that the TransmogDisplayVendor code was deleting the records for a transmog from their custom_transmogrification table if the item that had the transmog was currently equipped on an NPCBot. I did that by excluding items from their delete query in TransmogVendor.cpp Player_Transmogrify->OnSave if they were still attributed to the owner in the item_instance table, but not in the character_inventory table, since it looks like when an item is given to an NPCBot the record for that item is removed from the character_inventory table:
trans->PAppend("DELETE FROM custom_transmogrification WHERE Owner = %u AND NOT EXISTS (SELECT 1 FROM item_instance LEFT JOIN character_inventory ON item_instance.guid = character_inventory.item WHERE item_instance.guid = custom_transmogrification.GUID AND character_inventory.guid IS NULL)", lowguid);
For players, the way the transmog shows seems to be via placing the item_template.entry value for the transmog appearance item into the various PLAYER_VISIBLE_ITEM_X_ENTRYID fields in the EUnitFields enum that is defined in UpdateFields.h. I tried doing something like that in bot_ai.cpp with me->SetUInt32Value, but the maximum field number for that is 148, which seems to correlate with the UNIT_END field in that EUnitFields enum. Is that right, and if so where is the code that limits bot_ai me->SetUInt32Value to max out at 148 when that enum has more fields?
Do you know where I should be focusing my effort to try to get the transmog to appear on the NPCBots? Is the enum approach I'm looking at on the right track? If I'm able to get it working I'll put a fork up on github.
Very interesting. Thanks for your research.
The NPCBots appearance is sent to client through SMSG_MIRRORIMAGE_DATA opcode. But instead of item_template.entry, item_template.displayid is used (item->GetTemplate()->DisplayInfoId).
You need to look in SpellHandler.cpp, at line 710 there is a loop which handles bot's equipment. Try replacing item_template there with your transmog item_template.
Thank you for your help. I was able to get armor transmogs to appear on the NPCBots. Have you seen a parse of the SMSG_MIRRORIMAGE_DATA packets before, and if so is there anywhere in there to include appearances for weapons?
Summary: This goal of this fork of TrinityCore-3.3.5-with-NPCBots is to get transmogrified gear appearances to display on the NPCBots, utilizing a merge with the TransmogDisplayVendor along with modifications to attempt to get it all to work together.
The NPCBots code uses the WorldSession::HandleMirrorImageDataRequest function in /src/server/game/Handlers/SpellHandler.cpp to manage the display of the NPCBots.
This fork has a function called GetNPCBotTransmogGuid defined in botdatamgr.cpp. If a transmog has been applied to an item that is passed in to that function, it will return the item_template.displayid for the transmog, otherwise the item_template.displayid for the passed-in item is returned. This will cause items for slots defined in the HandleMirrorImageDataRequest function's botItemSlots array to display as the transmog item (if applicable) on the NPCBot. That array doesn't contain weapons, so I haven't been able to get weapon transmogs to appear on the NPCBots yet.
To do items:
- Try to determine how to show weapon transmogs on the NPCBots. I'm going to try to get SMSG_MIRRORIMAGE_DATA packet parses to see if that helps.
- Try to modify the TransmogDisplayVendor to be able to transmog items in a player's bag (currently it transmogs items equipped on the player). This will allow, for example, a cloth-wearing player to transmog a plate item in their bags, which they can they have their plate-wearing NPCBot equip.
https://github.com/trickerer/Trinity-Bots/commit/8049150e7fbf0d9edcea71ccf5b05fb656c0e092