Jump to content

Recommended Posts

Posted

Hello.

I created this patch yesterday. It is really simple but very effective.

It allows you to delete, move, rotate, or go on a gameobject without typing its GUID.

You first enter ".gobject target" and then you just type ".gobject del" or ".gobject turn" or ".gobject move" or ".go object" to use these commands.

Of course you can still use the old method of typing the GUID.

diff --git a/src/game/Language.h b/src/game/Language.h
index 986f288..4f45929 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -829,6 +829,7 @@ enum MangosStrings
    //                                    10000-10999

    // Use for custom patches             11000-11999
+    LANG_NOGOSELECTED                   = 11500,

    // NOT RESERVED IDS                   12000-1999999999
    // `db_script_string` table index     2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 3e28e8c..c657411 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -342,19 +342,21 @@ bool ChatHandler::HandleGoCreatureCommand(const char* args)
//teleport to gameobject
bool ChatHandler::HandleGoObjectCommand(const char* args)
{
-    if(!*args)
-        return false;
-
    Player* _player = m_session->GetPlayer();

    // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
    char* cId = extractKeyFromLink((char*)args,"Hgameobject");
-    if(!cId)
-        return false;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() == 0)
+    {
+        PSendSysMessage(LANG_NOGOSELECTED);
+        return true;
+    }

-    int32 guid = atoi(cId);
-    if(!guid)
-        return false;
+    int32 guid = 0;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
+        guid = m_session->GetPlayer()->GetSelectedObject();
+    if(cId)
+        guid = atoi(cId);

    float x, y, z, ort;
    int mapid;
@@ -393,6 +395,7 @@ bool ChatHandler::HandleGoObjectCommand(const char* args)
        _player->SaveRecallPosition();

    _player->TeleportTo(mapid, x, y, z, ort);
+    m_session->GetPlayer()->SetSelectedObject(0);
    return true;
}

@@ -496,6 +499,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
    GameObject* target = m_session->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT));

    PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o);
+    m_session->GetPlayer()->SetSelectedObject(lowguid);

    if(target)
    {
@@ -516,12 +520,17 @@ bool ChatHandler::HandleGameObjectDeleteCommand(const char* args)
{
    // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
    char* cId = extractKeyFromLink((char*)args,"Hgameobject");
-    if(!cId)
-        return false;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() == 0)
+    {
+        PSendSysMessage(LANG_NOGOSELECTED);
+        return true;
+    }

-    uint32 lowguid = atoi(cId);
-    if(!lowguid)
-        return false;
+    uint32 lowguid = 0;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
+        lowguid = m_session->GetPlayer()->GetSelectedObject();
+    if(cId)
+        lowguid = atoi(cId);

    GameObject* obj = NULL;

@@ -555,6 +564,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(const char* args)
    obj->DeleteFromDB();

    PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow());
+    m_session->GetPlayer()->SetSelectedObject(0);

    return true;
}
@@ -564,12 +574,17 @@ bool ChatHandler::HandleGameObjectTurnCommand(const char* args)
{
    // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
    char* cId = extractKeyFromLink((char*)args,"Hgameobject");
-    if(!cId)
-        return false;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() == 0)
+    {
+        PSendSysMessage(LANG_NOGOSELECTED);
+        return true;
+    }

-    uint32 lowguid = atoi(cId);
-    if(!lowguid)
-        return false;
+    uint32 lowguid = 0;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
+        lowguid = m_session->GetPlayer()->GetSelectedObject();
+    if(cId)
+        lowguid = atoi(cId);

    GameObject* obj = NULL;

@@ -618,12 +633,17 @@ bool ChatHandler::HandleGameObjectMoveCommand(const char* args)
{
    // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
    char* cId = extractKeyFromLink((char*)args,"Hgameobject");
-    if(!cId)
-        return false;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() == 0)
+    {
+        PSendSysMessage(LANG_NOGOSELECTED);
+        return true;
+    }

-    uint32 lowguid = atoi(cId);
-    if(!lowguid)
-        return false;
+    uint32 lowguid = 0;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
+        lowguid = m_session->GetPlayer()->GetSelectedObject();
+    if(cId)
+        lowguid = atoi(cId);

    GameObject* obj = NULL;

@@ -681,6 +701,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(const char* args)
    obj->Refresh();

    PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow());
+    m_session->GetPlayer()->SetSelectedObject(0);

    return true;
}
@@ -769,12 +790,17 @@ bool ChatHandler::HandleGameObjectPhaseCommand(const char* args)
{
    // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
    char* cId = extractKeyFromLink((char*)args,"Hgameobject");
-    if(!cId)
-        return false;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() == 0)
+    {
+        PSendSysMessage(LANG_NOGOSELECTED);
+        return true;
+    }

-    uint32 lowguid = atoi(cId);
-    if(!lowguid)
-        return false;
+    uint32 lowguid = 0;
+    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
+        lowguid = m_session->GetPlayer()->GetSelectedObject();
+    if(cId)
+        lowguid = atoi(cId);

    GameObject* obj = NULL;

@@ -4504,4 +4530,4 @@ bool ChatHandler::HandleTitlesCurrentCommand(const char* args)
    PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[GetSessionDbcLocale()], tNameLink.c_str());

    return true;
-}
+}
\\ No newline at end of file
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8f5b70a..c1e2029 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -328,6 +328,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
    // players always accept
    if(GetSession()->GetSecurity() == SEC_PLAYER)
        SetAcceptWhispers(true);
+    
+    m_Selected_object = 0;

    m_curSelection = 0;
    m_lootGuid = 0;
diff --git a/src/game/Player.h b/src/game/Player.h
index 9b3669a..e300fca 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1111,6 +1111,8 @@ class MANGOS_DLL_SPEC Player : public Unit
        void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
        bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
        void SetGMVisible(bool on);
+        void SetSelectedObject(uint32 value){ m_Selected_object = value; };
+        uint32 GetSelectedObject() { return m_Selected_object; }; uint32 m_Selected_object;
        void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }

        void GiveXP(uint32 xp, Unit* victim);

Here,

Best regards,

et65.

_____________________________________

In French/En français :

Bonjour.

J'ai créé ce patch hier. Il est vraiment simple mais très efficace.

Il vous permet de pouvoir supprimer, bouger, tourner, ou aller sur un gameobject sans taper son GUID.

Vous tapez d'abord ".gobject target" et après vous n'avez qu'à taper ".gobject del" ou ".gobject turn" ou ".gobject move" ou ".go object" pour utiliser ces commandes.

Bien-sûr vous pouvez toujours utiliser l'ancienne méthode qui consiste à taper le GUID.

Voilà,

Cordialement,

et65.

Posted

I have not had enough time to test fully, but I can say that we need to add an entry in the table mangos_string and also when I use ".gobject move" I lose the "remembering" and with the object, nothing happens (it just respawns in the same place).

INSERT INTO `mangos_string` (`entry`,`content_default`) VALUES
('11500','error text')

I'm sorry for my bad english.

Posted
I have not had enough time to test fully, but I can say that we need to add an entry in the table mangos_string and also when I use ".gobject move" I lose the "remembering" and with the object, nothing happens (it just respawns in the same place).

INSERT INTO `mangos_string` (`entry`,`content_default`) VALUES
('11500','error text')

I'm sorry for my bad english.

Yes, I forgot it.

You can modify the table "commands" to change the command's description, too.

And the patch doesn't work ?

Did you really put ".gobject target" and after ".gobject del" ?

Posted
Yes, I forgot it.

You can modify the table "commands" to change the command's description, too.

And the patch doesn't work ?

Did you really put ".gobject target" and after ".gobject del" ?

No, you misunderstood me. When I store an object (.goject target), and then try to move me (.gobject move), then first he just disappears for a split second and then a second, I lose "remembering" of the object. Other commands (.gobject delete and gobject turn work).

Posted
No, you misunderstood me. When I store an object (.goject target), and then try to move me (.gobject move), then first he just disappears for a split second and then a second, I lose "remembering" of the object. Other commands (.gobject delete and gobject turn work).

It's weird...

I'll look on it tonight.

Posted
It's weird...

I'll look on it tonight.

I found the error.

It's because of this lines :

    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
       guid = m_session->GetPlayer()->GetSelectedObject();
   if(cId)
       guid = atoi(cId);

or

    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
       lowguid = m_session->GetPlayer()->GetSelectedObject();
   if(cId)
       lowguid = atoi(cId);

Replace it by :

    if(cId)
       guid = atoi(cId);
   else
       guid = m_session->GetPlayer()->GetSelectedObject();

and

    if(cId)
       lowguid = atoi(cId);
   else
       lowguid = m_session->GetPlayer()->GetSelectedObject();

Posted
I found the error.

It's because of this lines :

    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
       guid = m_session->GetPlayer()->GetSelectedObject();
   if(cId)
       guid = atoi(cId);

or

    if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
       lowguid = m_session->GetPlayer()->GetSelectedObject();
   if(cId)
       lowguid = atoi(cId);

Replace it by :

    if(cId)
       guid = atoi(cId);
   else
       guid = m_session->GetPlayer()->GetSelectedObject();

and

    if(cId)
       lowguid = atoi(cId);
   else
       lowguid = m_session->GetPlayer()->GetSelectedObject();

Give me a patch file, because there are several similar places in the code for this:

if(!cId && m_session->GetPlayer()->GetSelectedObject() != 0)
       lowguid = m_session->GetPlayer()->GetSelectedObject();
   if(cId)
       lowguid = atoi(cId);

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use