azerothcore / mod-eluna

Eluna Lua Engine © for WoW Emulators
https://elunaluaengine.github.io/
GNU General Public License v3.0
96 stars 126 forks source link

feat: add GetRank method for creatures #173

Closed kabigon143 closed 4 months ago

kabigon143 commented 4 months ago

Introduces the GetRank method. Rank is used in creature_template to set the rank of the creature, e.g. rare (4) or rare elite (2).

You can test this in game with this lua script:

local command = "#rank"
local function FetchCreatureRank(event, player, message, type, language)
    if message == command then
        local creature = player:GetSelection() -- Get the player's target

        if creature then
            local rank = creature:GetRank() -- Fetch the rank of the selected creature

            if rank then
                print("Creature Rank: " .. rank) -- Print the creature's rank
            else
                print("Creature rank not available.")
            end
        else
            print("No creature selected.")
        end

        return false -- Prevent the default chat behavior
    end
end
RegisterPlayerEvent(18, FetchCreatureRank)

If the player types "#rank" while having targeted a creature, the script will print the creature's rank to the console.

55Honey commented 4 months ago

Thanks for the PR!