Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: profession items #111

Merged
merged 5 commits into from
Nov 30, 2024
Merged

feat: profession items #111

merged 5 commits into from
Nov 30, 2024

Conversation

BieJay93
Copy link

@BieJay93 BieJay93 commented Oct 2, 2024

Changes Proposed:

  • Created a new Table with item ids that are used for professions or created by professions
  • Added this table to the sql query in AuctionHouseBotConfig.cpp

To get these item ids, i selected all spell ids from "SkillLineAbility.dbc" which are connected to a profession.
More information about these spells are stored in "Spell.dbc", so i selected all spells with the ids that i got from the first step and exported the item ids of the fields "Reagent_1" - "Reagent_8" and "EffectItemType_1" - "EffectItemType_3".
Removed the duplicates and stored them in a new table called "auctionhousebot_professionItems"

If someone is interested, i can also upload my php script to get the ids.

Issues Addressed:

Tests Performed:

Applied the changes, recompiled and looked for profession related items in the auctionhouse.
For example "silver rod" was missing before theses changes. Now I can find it in the ah

How to Test the Changes:

just compile, run and check the ah

Holds all items which are used for professions or created by them.
Exported from Spell.dbc
@kewinrausch
Copy link

Hi there.

Some of those items have buy or sell prices set to zero, especially enchanting reagents. How have you addressed this issue?
I'm asking this because I run in this issue myself. Basically I use the AH as a way to level up my professions without loosing too much time farming mobs and quests. If you have money to spend, you can advance with your professions (I achieved this by using the whitelist configuration variable).

Some of such items does not have any price related the sell or buy variable, meaning that they will be ignored by the current bot. Right now I have requested a pull to resolve this issue here.

For what I see you have put the items ID in a table and side loading them into the bot items bins, but this does not solve the problem of selling items set at zero. Do you see the dust reagents obtained by disenchanting the items, for example?

If I'm not wrong lot of these items are already put into the bin if you use the VendorTradeGoods, LootTradeGoods and OtherTradeGoods configurations.

@BieJay93
Copy link
Author

Hi,
yes, I think you're right, some Items still not showing up on the ah.

Before I made these changes, I just took some items, that i was missing on the ah and searched for them in all linked tables... and found nothing. (Maybe a bad coincidence, when you say, that many of them are also in VendorTradeGoods, LootTradeGoods and OtherTradeGoods). So I decided to create a new table with all relevant ids. And for many things it's working perfectly. Except for the ones without a sell/ buy price.

I'm only hosting a little server for some friends, and for now they're happy with these changes. But it's not perfect.

Can you maybe test my table with your changes? In theory that should bring all relevant items to the ah.

@kewinrausch
Copy link

You did a good job isolating the items necessary for professions.

Probably what you will need here is a way to make the current setup backward compatible; there can be setup that does not want the bots to trade in profession items because they want players to engage in their exchange. If I may provide a comment about the current implementation, is that probably it need a configuration set to zero by default to provide profession items.

You can setup an additional option, false by default:
Profession_Items = sConfigMgr->GetOption<bool> ("AuctionHouseBot.ProfessionItems " , false);

And organize the configuration loading in order to act when the flag is set to true. You have to repeat the lines above for the normal query and add the element only if not already present into the results (putting it more than once will result in unbalance the random pick of the algorithm)

    // 
    // Reload the list from the lootable items
    // 

    LootItems.clear();

    QueryResult itemsResults = WorldDatabase.Query(
        "SELECT item FROM creature_loot_template      UNION "
        "SELECT item FROM reference_loot_template     UNION "
        "SELECT item FROM disenchant_loot_template    UNION "
        "SELECT item FROM fishing_loot_template       UNION "
        "SELECT item FROM gameobject_loot_template    UNION "
        "SELECT item FROM item_loot_template          UNION "
        "SELECT item FROM milling_loot_template       UNION "
        "SELECT item FROM pickpocketing_loot_template UNION "
        "SELECT item FROM prospecting_loot_template   UNION "
        "SELECT item FROM skinning_loot_template");

    if (itemsResults)
    {
        do
        {
            Field* fields = itemsResults->Fetch();
            LootItems.insert(fields[0].Get<uint32>());

        } while (itemsResults->NextRow());
    }
    else
    {
        if (DebugOutConfig)
        {
            LOG_ERROR("module", "AuctionHouseBot: failed to retrieve loot items");
        }
    }

/* <-- HERE THE ADDITION TO THE LOOT ITEMS */

    if (DebugOutConfig)
    {
        LOG_INFO("module", "Loaded {} items from lootable items", uint32(LootItems.size()));
    }

Something like:

if (Profession_Items)
{
    itemsResults = WorldDatabase.Query(
        "SELECT item FROM auctionhousebot_professionItems");

    if (itemsResults)
    {
        do
        {
            Field* fields = itemsResults->Fetch();
            uint32 item   = fields[0].Get<uint32>();
            
            if(LootItems.find(item) == LootItems.end())
            {
                LootItems.insert(fields[0].Get<uint32>());
            }
        } while (itemsResults->NextRow());
    }
}

This will make the PR cohexists with any existing installation of the AH bots, so other server installation will not be disrupted by your contribution.

What do you think about this?

@BieJay93
Copy link
Author

That's a good point. Will do it.
I'll probably have some more time at the weekend to implement and test it. So give me some days.

@BieJay93
Copy link
Author

Already had some time to implement it. Works as expected 👍

@harbby
Copy link

harbby commented Nov 24, 2024

@BieJay93
Can you help fix it? Thanks
linux gcc build failed:
modules/mod-ah-bot/src/AuctionHouseBotConfig.cpp:2141:115: fatal error: member access into incomplete type 'element_type' (aka 'ResultSet') 2141 | SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", GetAHID())->Fetch()->Get<uint32>());

@BieJay93
Copy link
Author

Hi @harbby, that's strange..
But I saw this PR #120
Can you try to add #include "QueryResult.h" in your AuctionHouseBotConfig.cpp as in the PR?

@harbby
Copy link

harbby commented Nov 27, 2024

Hi @harbby, that's strange.. But I saw this PR #120 Can you try to add #include "QueryResult.h" in your AuctionHouseBotConfig.cpp as in the PR?

Great, it compiles now, thank you very much

@Helias
Copy link
Member

Helias commented Nov 29, 2024

There is an issue in the pipeline, please solve it so we can merge this PR

/home/runner/work/mod-ah-bot/mod-ah-bot/modules/mod-ah-bot/src/AuctionHouseBotConfig.cpp:2141:115: fatal error: member access into incomplete type 'element_type' (aka 'ResultSet')
 2141 |     SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", GetAHID())->Fetch()->Get<uint32>());
      |                                                                                                                   ^
/home/runner/work/mod-ah-bot/mod-ah-bot/src/server/database/Database/DatabaseEnvFwd.h:26:7: note: forward declaration of 'ResultSet'
   26 | class ResultSet;
      |       ^
1 error generated.
gmake[2]: *** [modules/CMakeFiles/modules.dir/build.make:135: modules/CMakeFiles/modules.dir/mod-ah-bot/src/AuctionHouseBotConfig.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/AI/CreatureAISelector.cpp.o
gmake[1]: *** [CMakeFiles/Makefile2:1455: modules/CMakeFiles/modules.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....

@BieJay93
Copy link
Author

Just synced my fork, now it should work.

@Helias Helias changed the title Profession items feat: profession items Nov 30, 2024
@Helias Helias merged commit eea2e77 into azerothcore:master Nov 30, 2024
1 check passed
@Helias
Copy link
Member

Helias commented Nov 30, 2024

merged, thanks!

@LannyE
Copy link

LannyE commented Dec 6, 2024

Just curious, but is there a reason the new database table this commit creates doesn't follow the module's standard for its tables? This one creates an auctionhousebot_professionItems table instead of mod_auctionhousebot_professionItems which would follow the format of the other tables within this mod.

@BieJay93
Copy link
Author

BieJay93 commented Dec 7, 2024

No, there isn't a reason, just hadn't thought about it.
Renaming it now might cause some problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants