azerothcore / azerothcore-wotlk

Complete Open Source and Modular solution for MMO
http://www.azerothcore.org
GNU Affero General Public License v3.0
6.18k stars 2.46k forks source link

invalid .npc move [#guid]/ .npc delete [#guid] commands #18988

Open BillionGhosts opened 1 month ago

BillionGhosts commented 1 month ago

Current Behaviour

According to wiki: ".npc delete [#guid]" - Delete creature with guid #guid (or the selected if no guid is provided). ".npc move [#creature_guid]" - Move the targeted creature spawn point to your coordinates.

When i try to execute this command either through ingame chat or world console i just get syntaxis help: "Syntax: .npc move [#creature_guid]" - same with delete

My account have gmlevel 3 and i added npc beforehand with no problems (apart for his departure through textures in direction of his chill coordinates).

Expected Blizzlike Behaviour

As documentation stated expected behaviour is teleportation of npc by his guid to player position / or deletion of npc by his guid (which i found in "creature" DB table by his id1).

Source

https://www.azerothcore.org/wiki/gm-commands

Steps to reproduce the problem

All steps are ingame (except DB part): Spawn npc in stormwind: .npc add 32509 (it's a heirloom vendor, which roams betwen floors in Dalaran in his store) 'npc just goes away but that's not the point' Find his GUID in db with SQL: SELECT * FROM creature WHERE id1 = 32509; There suppose to be two entries - one for original NPC in Dalaran and one for our newly spawned NPC. Take the latter one. Try: .npc move xxxx - where xxxx is your guid.

Extra Notes

So as i can see in command cs_npc.cpp itself - there just no GUID argument in methods/functions:

static bool HandleNpcDeleteCommand(ChatHandler* handler)
    {
        Creature* unit = handler->getSelectedCreature();

        if (!unit || unit->IsPet() || unit->IsTotem())
        {
            handler->SendErrorMessage(LANG_SELECT_CREATURE);
            return false;
        }
 //move selected creature
    static bool HandleNpcMoveCommand(ChatHandler* handler)
    {
        Creature* creature = handler->getSelectedCreature();

        if (!creature)
            return false;

And it was like this since this commit (i think, i didn't see after it).

So is this just lost functionality or it was deliberate choice - to let move/delete npc only with targeting them?

Either Documentation is deprecated (which is less of a priority i think) or this functionality should be restored. So if there was deliberate decision to remove guid from commands then i could make a PR for documentation. And if there were not then i could try to reimplement it, because as i see it i just need to be something like this (i just took code from HandleNpcSetMoveTypeCommand):

//move selected creature
    static bool HandleNpcMoveCommand(ChatHandler* handler, Optional<CreatureSpawnId> lowGuid)
    {
        ObjectGuid::LowType lowguid = 0;
        Creature* creature = nullptr;

        if (!lowGuid)                                           
        {
            creature = handler->getSelectedCreature();
            if (!creature || creature->IsPet())
                return false;
            lowguid = creature->GetSpawnId();
        }
        else                                                  
        {
            lowguid = *lowGuid;

            if (lowguid)
                creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);

        if (!creature)
            return false;
        }
        CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);.....

And also there is redundant fetch of data because we already got one:

CreatureData const* data = sObjectMgr->GetCreatureData(lowguid); -- here we get data
        if (!data)
        {
            handler->SendErrorMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
            return false;
        }

        if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
        {
            handler->SendErrorMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
            return false;
        }

        float x = handler->GetSession()->GetPlayer()->GetPositionX();
        float y = handler->GetSession()->GetPlayer()->GetPositionY();
        float z = handler->GetSession()->GetPlayer()->GetPositionZ();
        float o = handler->GetSession()->GetPlayer()->GetOrientation();

        if (creature)
        {
            if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId())) -- and here we get it again

Or data fetched by lowGuid and creature.spawnId is different?

AC rev. hash/commit

AzerothCore rev. 82aedf747bfc+ 2024-05-04 08:33:28 +0700 (npcbots_3.3.5 branch) (Win64, Release, Static) (worldserver-daemon)

Operating system

Windows 11 x64

Custom changes or Modules

dungeonrespawn.conf.dist statbooster.conf.dist mod-time_is_time.conf.dist mod_achievements.conf.dist mod_accountbound.conf.dist mod_ahbot.conf.dist AutoBalance.conf.dist mod_LuaEngine.conf.dist GainHonorGuard.conf.dist mod_guildfunds.conf.dist Individual-XP.conf.dist mod_learnspells.conf.dist npc_allmounts.conf.dist skip_dk_module.conf.dist SoloLfg.conf.dist transmog.conf.dist

BillionGhosts commented 1 month ago

.npc set movetype [#creature_guid] stay/random/way [NODEL] - also didn't work as intended (but worked partially) with GUID. Tried

.npc set movetype xxxxx stay - and got error "An error occured formatting string "Creature movement type set tp '%s', waypoints removed (if any).". So i think command parsed wrong and my "stay" got lost. Because that wondering npc just respawns at his position and goes away instead of standing still.