Skip to content

feat(Core/SetCurrentTrainer): Add multitrainer function #21354

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

manstfu
Copy link
Contributor

@manstfu manstfu commented Feb 7, 2025

Inregistrare.ecran.2025-02-07.200701.mp4

Changes Proposed:

This PR proposes changes to:

  • Core (units, players, creatures, game systems).
  • Scripts (bosses, spell scripts, creature scripts).
  • Database (SAI, creatures, etc).

Issues Addressed:

  • Closes

SOURCE:

The changes have been validated through:

  • Live research (checked on live servers, e.g Classic WotLK, Retail, etc.)
  • Sniffs (remember to share them with the open source community!)
  • Video evidence, knowledge databases or other public sources (e.g forums, Wowhead, etc.)
  • The changes promoted by this pull request come partially or entirely from another project (cherry-pick). Cherry-picks must be committed using the proper --author tag in order to be accepted, thus crediting the original authors, unless otherwise unable to be found

Co-Author: @Winfidonarleyan & yangyitzzg

Tests Performed:

This PR has been:

  • Tested in-game by the author.
  • Tested in-game by other community members/someone else other than the author/has been live on production servers.
  • This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  • This pull request can be tested by following the reproduction steps provided in the linked issue
  • This pull request requires further testing. Provide steps to test your changes. If it requires any specific setup e.g multiple players please specify it as well.

Known Issues and TODO List:

  • [ ]
  • [ ]

How to Test AzerothCore PRs

When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].

You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:

http://www.azerothcore.org/wiki/How-to-test-a-PR

REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).

For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.

@github-actions github-actions bot added CORE Related to the core file-cpp Used to trigger the matrix build labels Feb 7, 2025
@manstfu
Copy link
Contributor Author

manstfu commented Feb 7, 2025

Eluna need update azerothcore/mod-eluna#254 after merge.

@TheSCREWEDSoftware
Copy link
Contributor

I understand the outcome of this PR as you shown in the video.

How would as user would use this?

@sudlud
Copy link
Member

sudlud commented Feb 8, 2025

Reminds me of #17988, if you've taken that pr as a basis please reference the original author correctly here.

@manstfu
Copy link
Contributor Author

manstfu commented Feb 8, 2025

Reminds me of #17988, if you've taken that pr as a basis please reference the original author correctly here.

I have found that PR later and took only the title and @Winfidonarleyan suggestion with **[[nodiscard]]** uint32 GetCurrentTrainer() const { return m_currentTrainerEntry; }

You are free to co-author them!

@TheSCREWEDSoftware
Copy link
Contributor

My question still stands. How would a user use this feature? Same for testing this PR

@manstfu
Copy link
Contributor Author

manstfu commented Feb 13, 2025

Apply it as patch if required.

Eluna Patch

@manstfu manstfu closed this Feb 13, 2025
@YggdrasilWotLK
Copy link
Contributor

As this is now closed, I just want to mention for future interested parties that this is already possible with existing Eluna API and some creativity like in the below framework:

local CREATURE_ID = 191000 -- Replace with your multi trainer's NPC ID

local TRAINERS = {
    [1] = 28704,  -- Herbalism Trainer
    [2] = 28694,  -- Blacksmithing Trainer
    [3] = 16771,   -- Warrior Trainer
    -- Add more trainers here, ensure the [number] aligns with the intid (final number) of the appropriate GossipMenuAddItem
}

local function OnGossipHello(event, player, creature)
    player:GossipMenuAddItem(0, "Herbalism Trainer", 0, 1)
    player:GossipMenuAddItem(0, "Blacksmithing Trainer", 0, 2)
    player:GossipMenuAddItem(0, "Warrior Trainer", 0, 3)
    -- Add trainer gossip options here
    player:GossipSendMenu(12, creature)
    return true
end

local function OnGossipSelect(event, player, creature, sender, intid)
    if TRAINERS[intid] then
        local trainer = creature:SpawnCreature(TRAINERS[intid], creature:GetX(), creature:GetY(), creature:GetZ(), creature:GetO(), 1, 30000)
        if trainer then
                trainer:SetDisplayId(25316) -- Setting temp trainer to invisible 
                player:GossipMenuAddItem(0, "Placeholder", 0, 1) -- Placeholder menu item to activate gossip
                player:GossipSendMenu(12, trainer) -- We must be in active gossip to send trainer list. After this, we can send the trainer list
                player:SendTrainerList(trainer) -- Now we can train from our new temp trainer
            end
        end
    end
end

RegisterCreatureGossipEvent(CREATURE_ID, 1, OnGossipHello)
RegisterCreatureGossipEvent(CREATURE_ID, 2, OnGossipSelect)

@manstfu manstfu reopened this Feb 14, 2025
@TheSCREWEDSoftware
Copy link
Contributor

I will rephrase my previous message so if i can get an answer to understand (not the result of this PR but how to use this PR).

If I was to download and compile this PR. How can I make a multi-trainer?

@Kitzunu
Copy link
Member

Kitzunu commented Feb 15, 2025

okay I get the vision. But instead of tying it onto existing creature entries, I would like to see it tied to npc_trainer.ID

@manstfu
Copy link
Contributor Author

manstfu commented Feb 15, 2025

okay I get the vision. But instead of tying it onto existing creature entries, I would like to see it tied to npc_trainer.ID

Not sure how to implement that.

@55Honey 55Honey requested a review from Kitzunu February 18, 2025 23:02
@yuanf225
Copy link

Is PR ready for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CORE Related to the core file-cpp Used to trigger the matrix build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants