Jump to content

[patch][5774] Respawntime Info On Commands


Guest NeFasT
 Share

Recommended Posts

bonjour,

A small information is missing that can help gms in game to get respawntime information.

On .target and .npcinfo you can see the current respawntime and the respawntime in the sql table named `creature` or `gameobject`.

Index: src/game/Creature.h
===================================================================
--- src/game/Creature.h        (revision 4609)
+++ src/game/Creature.h        (working copy)
@@ -483,6 +483,7 @@
                   void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
                   void Respawn();
                   void SaveRespawnTime();
+                uint32 GetRespawnDelay() { return m_respawnDelay; }
   
                   uint32 m_groupLootTimer;                                                        // (msecs)timer used for group loot
                   uint64 lootingGroupLeaderGUID;                                            // used to find group which is looting corpse
Index: src/game/GameObject.h
===================================================================
--- src/game/GameObject.h        (revision 4609)
+++ src/game/GameObject.h        (working copy)
@@ -160,6 +160,7 @@
                                   m_respawnTime > 0 && !m_spawnedByDefault || 
                                   m_respawnTime == 0 && m_spawnedByDefault;
                   }
+                uint32 GetRespawnDelay() { return m_respawnDelayTime; }
                   bool isSpawnedByDefault() const { return m_spawnedByDefault; }
                   void Refresh();
                   void Delete();
Index: src/game/Language.h
===================================================================
--- src/game/Language.h        (revision 4609)
+++ src/game/Language.h        (working copy)
@@ -456,7 +456,7 @@
   #define LANG_GAMEOBJECT_NOT_EXIST                "Game Object (GUID: %u) not found"
                                                                                                                           //log
   #define LANG_GAMEOBJECT_CURRENT                    ">> Game Object %s (GUID: %u) at %f %f %f. Orientation %f."
-#define LANG_GAMEOBJECT_DETAIL                     "Selected object:\\n%s\\nGUID: %u ID: %u\\nX: %f Y: %f Z: %f MapId: %u\\nOrientation: %f"
+#define LANG_GAMEOBJECT_DETAIL                     "Selected object:\\n%s\\nGUID: %u ID: %u\\nX: %f Y: %f Z: %f MapId: %u\\nOrientation: %f\\nSpawnTime: -Current:%u Saved:%u"
   #define LANG_GAMEOBJECT_ADD                            ">> Add Game Object '%i' (%s) (GUID: %i) added at '%f %f %f'."
   
   #define LANG_MOVEGENS_LIST                             "%s (lowguid: %u) movement generators stack:"
@@ -482,6 +482,7 @@
   #define LANG_NPCINFO_VENDOR                            "*** Is a vendor!"
   #define LANG_NPCINFO_TRAINER                         "*** Is a trainer!"
   #define LANG_NPCINFO_DUNGEON_ID                    "InstanceID: %u"
+#define LANG_NPCINFO_RESPAWN                         "SpawnTime: -Current:%u -Saved:%u"
   
   #define LANG_PINFO_ACCOUNT                             "Player%s %s (guid: %u) Account: %s (id: %u) GMLevel: %u Last IP: %s"
   #define LANG_PINFO_LEVEL                                 "Played time: %s Level: %u Money: %ug%us%uc"
Index: src/game/Level2.cpp
===================================================================
--- src/game/Level2.cpp        (revision 4609)
+++ src/game/Level2.cpp        (working copy)
@@ -200,20 +200,20 @@
           {
                   int32 id = atoi((char*)args);
                   if(id)
-                        result = sDatabase.PQuery("SELECT `guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, (POW(`position_x` - '%f', 2) + POW(`position_y` - '%f', 2) + POW(`position_z` - '%f', 2)) as `order` FROM `gameobject` WHERE `map` = '%i' AND `id` = '%u' ORDER BY `order` ASC LIMIT 1",
+                        result = sDatabase.PQuery("SELECT `guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `spawntimesecs`, (POW(`position_x` - '%f', 2) + POW(`position_y` - '%f', 2) + POW(`position_z` - '%f', 2)) as `order` FROM `gameobject` WHERE `map` = '%i' AND `id` = '%u' ORDER BY `order` ASC LIMIT 1",
                                   pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
                   else
                   {
                           std::string name = args;
                           sDatabase.escape_string(name);
                           result = sDatabase.PQuery(
-                                "SELECT `guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, (POW(`position_x` - %f, 2) + POW(`position_y` - %f, 2) + POW(`position_z` - %f, 2)) as `order` "
+                                "SELECT `guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `spawntimesecs`, (POW(`position_x` - %f, 2) + POW(`position_y` - %f, 2) + POW(`position_z` - %f, 2)) as `order` "
                                   "FROM `gameobject`,`gameobject_template` WHERE `gameobject_template`.`entry` = `gameobject`.`id` AND `map` = %i AND `name` LIKE '%%%s%%' ORDER BY `order` ASC LIMIT 1",
                                   pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str());
                   }
           }
           else
-                result = sDatabase.PQuery("SELECT `gameobject`.`guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, (POW(`position_x` - %f, 2) + POW(`position_y` - %f, 2) + POW(`position_z` - %f, 2)) as `order` FROM `gameobject` LEFT OUTER JOIN `game_event_gameobject` on `gameobject`.`guid`=`game_event_gameobject`.`guid` WHERE `map` = %i%s%s ORDER BY `order` ASC LIMIT 1", m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter,eventFilter2);
+                result = sDatabase.PQuery("SELECT `gameobject`.`guid`, `id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `spawntimesecs`, (POW(`position_x` - %f, 2) + POW(`position_y` - %f, 2) + POW(`position_z` - %f, 2)) as `order` FROM `gameobject` LEFT OUTER JOIN `game_event_gameobject` on `gameobject`.`guid`=`game_event_gameobject`.`guid` WHERE `map` = %i%s%s ORDER BY `order` ASC LIMIT 1", m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter,eventFilter2);
   
           if (!result)
           {
@@ -229,8 +229,9 @@
           float z = fields[4].GetFloat();
           float o = fields[5].GetFloat();
           int mapid = fields[6].GetUInt16();
+        uint32 spawnTimeSaved = fields[7].GetUInt16();
           delete result;
-
+        
           const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id);
   
           if (!goI)
@@ -238,9 +239,14 @@
                   PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
                   return false;
           }
+        GameObject* obj = ObjectAccessor::Instance().GetGameObject(*m_session->GetPlayer(), MAKE_GUID(guid, HIGHGUID_GAMEOBJECT));
+        if (!obj)
+        {
+                PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
+                return false;
+        }
+        PSendSysMessage(LANG_GAMEOBJECT_DETAIL, goI->name, guid, id, x, y, z, mapid, o, obj->GetRespawnDelay(), spawnTimeSaved );
   
-        PSendSysMessage(LANG_GAMEOBJECT_DETAIL, goI->name, guid, id, x, y, z, mapid, o);
-
           return true;
   }
   
Index: src/game/Level3.cpp
===================================================================
--- src/game/Level3.cpp        (revision 4609)
+++ src/game/Level3.cpp        (working copy)
@@ -2685,7 +2685,7 @@
   bool ChatHandler::HandleNpcInfoCommand(const char* args)
   {
           Creature* target = getSelectedCreature();
-
+        QueryResult *result;
           if(!target)
           {
                   SendSysMessage(LANG_SELECT_CREATURE);
@@ -2697,6 +2697,18 @@
           uint32 displayid = target->GetUInt32Value(UNIT_FIELD_DISPLAYID);
           uint32 nativeid = target->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID);
           uint32 Entry = target->GetUInt32Value(OBJECT_FIELD_ENTRY);
+        uint32 spawnTimeCurrent = target->GetRespawnDelay();
+        
+        result = sDatabase.PQuery( "SELECT `spawntimesecs` FROM `creature` WHERE `guid` = %u",target->GetDBTableGUIDLow());
+        if(!result)
+             {
+                        PSendSysMessage(LANG_SELECT_CREATURE);
+                        return true;
+                }
+        Field *fields = result->Fetch();
+        uint32 spawnTimeSaved = fields[0].GetUInt32();
+        delete result;
+        
           CreatureInfo const* cInfo = target->GetCreatureInfo();
   
           PSendSysMessage(LANG_NPCINFO_CHAR,    target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid);
@@ -2705,6 +2717,7 @@
           PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction());
           PSendSysMessage(LANG_NPCINFO_LOOT,    cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId);
           PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId());
+        PSendSysMessage(LANG_NPCINFO_RESPAWN, spawnTimeCurrent, spawnTimeSaved);
   
           PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));

Link to comment
Share on other sites

  • 1 month later...

Idea good, but

+        GameObject* obj = ObjectAccessor::Instance().GetGameObject(*m_session->GetPlayer(), MAKE_GUID(guid, HIGHGUID_GAMEOBJECT));
+        if (!obj)
+        {
+                PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
+                return false;
+        }

Will not work. DB guid for GO can be defferent from in game guid of GO in case GO in instance.

This make command not working for any instance's GO

Link to comment
Share on other sites

  • 3 months later...
 Share

×
×
  • 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