trickerer / Trinity-Bots

NPCBots for TrinityCore and AzerothCore 3.3.5
https://github.com/trickerer/TrinityCore-3.3.5-with-NPCBots/
473 stars 157 forks source link

[TC] [AC] [Question/Feature] Changing the NPCBots Spawn Clothing #882

Closed RobertoHendo closed 1 month ago

RobertoHendo commented 2 months ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Description

Hello, I have been looking through the SQL and these forums and discussions and I was wondering if it was possible to change the Basic Clothing they are equipped with when they spawn to something more class oriented. I.e Plate for warrior / Robe for caster instead of the Matador jacket theyre equipped with. Im new to all this computer editing and programming stuff, I had seen in a post almost 2 years ago that it was hardcoded, is that still the case? Thanks

TrinityCore or AzerothCore

AzerothCore

Core rev. hash/commit

AzerothCore rev. 64c9e4a0a4d5+ 2024-09-15 21:16:14 +0000 (master branch) (Win64, RelWithDebInfo, Static) (authserver)

Operating system

Win10

trickerer commented 2 months ago
RobertoHendo commented 1 month ago

Hello again, I have been messing with my SpellHandler.cpp in an attempt to change the visual appearance, (i have a backup of course) I have made some progress, they no longer wear the haliscan jacket or pants, they just have some type of boots, pants, belt etc. I am very new to this, so ive been attempting to use chatgpt to help me fill in the gaps of what to do, but no matter what it seems to just not hold any new appearances, I know you said it was pretty easy to add and change the default visuals, and I was wondering if you could lend some tips on how, it would be very appreciated, thank you.

trickerer commented 1 month ago

It isn't clear to me what you tried exactly.

Here is an example code snippet (SpellHandler line 763) allowing to set default displayed equipment per bot class per slot (here it's only Druid). \'s must be replaced with desired item model id for a respective slot. Item models can be taken from item_template table or maybe googled. Note that only standard classes can be affected by this (1=Warrior to 11=Druid).

    ...
    uint32 display_id = bot->GetBotAI()->GetEquipDisplayId(slot);
    if (display_id)
        data << uint32(display_id);
    else
    {
        switch (bot->GetBotClass())
        {
            case BOT_CLASS_DRUID:
                switch (slot)
                {
                    case BOT_SLOT_SHOULDERS:
                        data << uint32(<PLACEHOLDER>);
                        break;
                    case BOT_SLOT_CHEST:
                        data << uint32(<PLACEHOLDER>);
                        break;
                    case BOT_SLOT_LEGS:
                        data << uint32(<PLACEHOLDER>);
                        break;
                    case BOT_SLOT_FEET:
                        data << uint32(<PLACEHOLDER>);
                        break;
                    case BOT_SLOT_HANDS:
                        data << uint32(<PLACEHOLDER>);
                        break;
                    default:
                        data << uint32(0);
                        break;
                }
                break;
            default:
                //don't allow to go naked
                if (slot == BOT_SLOT_CHEST)
                    data << uint32(CHEST_HALISCAN);
                else if (slot == BOT_SLOT_LEGS)
                    data << uint32(LEGS_HALISCAN);
                else
                    data << uint32(0);
                break;
        }
    }
    ...
RobertoHendo commented 1 month ago

Thanks for the fast response, I finally got a chance to try and input this in my SpellHandler.cpp it compiled with no errors, however upon adding and changing the spots to the desired model for the slot now they spawn with nothing but the haliscan shirt sleeves

trickerer commented 1 month ago

Are you sure you use item displayid and not item id?

RobertoHendo commented 1 month ago

Yes, I double checked just to be sure, maybe im inserting it wrong somehow? Because the druids spawn with just haliscan sleeves, and every other npcbot spawns naked, and remains naked even with clothes equipped. Ive got it inserted at line 763, and the only things ive changed has been the inside the parenthesis and removed the ... from the top and bottom, as well as the uint32 from the next line to prevent duplicates. Again, apologies if im making some kind of rudimentary mistakes, im still trying to get the hang of this kind of thing. Thank you

RobertoHendo commented 1 month ago

this is the snippet from 755 to 808, ive included a little bit of code from before and a little after, ive got the displayid (doublechecked with trinity creator)

//Items not displayed on bot: tabard, head, back if (slot == 0 || (slot == BOT_SLOT_HEAD && BotMgr::ShowEquippedHelm() == false) || (slot == BOT_SLOT_BACK && BotMgr::ShowEquippedCloak() == false)) { data << uint32(0); continue; } uint32 display_id = bot->GetBotAI()->GetEquipDisplayId(slot); if (display_id) data << uint32(display_id); else { switch (bot->GetBotClass()) { case BOT_CLASS_DRUID: switch (slot) { case BOT_SLOT_SHOULDERS: data << uint32(32016); break; case BOT_SLOT_CHEST: data << uint32(31934); break; case BOT_SLOT_LEGS: data << uint32(33148); break; case BOT_SLOT_FEET: data << uint32(4389); break; case BOT_SLOT_HANDS: data << uint32(33842); break; default: data << uint32(0); break; } break; default: //don't allow to go naked if (slot == BOT_SLOT_CHEST) data << uint32(CHEST_HALISCAN); else if (slot == BOT_SLOT_LEGS) data << uint32(LEGS_HALISCAN); else data << uint32(0); break; } } display_id = bot->GetBotAI()->GetEquipDisplayId(slot); if (display_id) data << uint32(display_id); else {

trickerer commented 1 month ago

Take a look at the original code

    uint32 display_id = bot->GetBotAI()->GetEquipDisplayId(slot);
    if (display_id)
        data << uint32(display_id);
    else
    {
        //don't allow to go naked
        if (slot == BOT_SLOT_CHEST)
            data << uint32(CHEST_HALISCAN);
        else if (slot == BOT_SLOT_LEGS)
            data << uint32(LEGS_HALISCAN);
        else
            data << uint32(0);
    }

Looks like you've added the code I posted above this code block instead of replacing it. As a result you put a value onto a stream twice per equipment slot

This code chunk is duplicated:

    display_id = bot->GetBotAI()->GetEquipDisplayId(slot);
    if (display_id)
        data << uint32(display_id);
...
RobertoHendo commented 1 month ago

Alright i got it to stick, i appreciate all your help! i assume to add other classes its simply just a copy / paste the following after the end bracket? switch (bot->GetBotClass()) { case BOT_CLASS_DRUID: switch (slot) { case BOT_SLOT_SHOULDERS: data << uint32(); break; case BOT_SLOT_CHEST: data << uint32(); break; case BOT_SLOT_LEGS: data << uint32(); break; case BOT_SLOT_FEET: data << uint32(); break; case BOT_SLOT_HANDS: data << uint32(); break; default: data << uint32(0); break; } break;

trickerer commented 1 month ago

No. First do some reading on how switch works and what scope is. Then notice that not all equipment slots were covered within druid case there (yes I did it on purpose). Once you add all remaining equipment slots you will be able to just copy whole druid block and and make it work for a new class, then another, ultimately adding all (standard) classes. Sorry but it isn't possible to guide you if you don't even know C++ basics.