Jump to content

[10647][FIX] show anim when totem destroyed


eggxp

Recommended Posts

Rev 10640

ticket:

https://mangos.lighthouseapp.com/projects/18208-mangos/tickets/641-totem-should-show-anim-when-destroyed

show anim when totem destroyed. it's only slowly disappear in current version.

From f2ea3f23a0ecb8127951485f6a2f486fe4079a19 Mon Sep 17 00:00:00 2001
From: eggxp <[email protected]>
Date: Mon, 25 Oct 2010 09:16:18 +0800
Subject: [PATCH 1/2][Fix] show anim when totem destroy

---
src/game/Object.cpp |    5 +++--
src/game/Object.h   |    4 ++++
src/game/Player.cpp |    2 +-
src/game/Totem.cpp  |    1 +
4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 61677cc..d6f69d1 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -220,7 +220,7 @@ void Object::DestroyForPlayer( Player *target, bool anim ) const
{
    MANGOS_ASSERT(target);

-    WorldPacket data(SMSG_DESTROY_OBJECT, 8);
+    WorldPacket data(SMSG_DESTROY_OBJECT, 9);
    data << GetObjectGuid();
    data << uint8(anim ? 1 : 0);                            // WotLK (bool), may be despawn animation
    target->GetSession()->SendPacket(&data);
@@ -1134,6 +1134,7 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask )
{
    Object::_Create(guidlow, 0, guidhigh);
    m_phaseMask = phaseMask;
+    m_destroyAnim = false;
}

void WorldObject::Relocate(float x, float y, float z, float orientation)
@@ -2084,4 +2085,4 @@ bool WorldObject::IsControlledByPlayer() const
        default:
            return false;
    }
-}
+}
\\ No newline at end of file
diff --git a/src/game/Object.h b/src/game/Object.h
index 653b169..2919f72 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -492,6 +492,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }

        ViewPoint& GetViewPoint() { return m_viewPoint; }
+
+        void SetDestroyAnim(bool anim) {m_destroyAnim = anim;}
+        bool GetDestroyAnim() { return m_destroyAnim; }
    protected:
        explicit WorldObject();

@@ -515,6 +518,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        float m_positionY;
        float m_positionZ;
        float m_orientation;
+        bool m_destroyAnim;

        ViewPoint m_viewPoint;
};
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 85cea3d..09a5952 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -19364,7 +19364,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe

            ObjectGuid t_guid = target->GetGUID();

-            target->DestroyForPlayer(this);
+            target->DestroyForPlayer(this, target->GetDestroyAnim());
            m_clientGUIDs.erase(t_guid);

            DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index 2b1c968..8300430 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -29,6 +29,7 @@ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
{
    m_duration = 0;
    m_type = TOTEM_PASSIVE;
+    SetDestroyAnim(true);
}

void Totem::Update( uint32 time )
-- 
1.7.3.1.msysgit.0

========================================

add patch 2: add destroy anim for all object when destroyed

there may be more VisibleForInStateResult enums in furture use

From 45fdb768b00d66fa84ca074d25c2c843fd9547b6 Mon Sep 17 00:00:00 2001
From: eggxp <[email protected]>
Date: Mon, 25 Oct 2010 22:29:28 +0800
Subject: [PATCH 2/2] [fix]add destroy anim for all object when destroyed

---
src/game/Corpse.cpp        |    2 +-
src/game/Corpse.h          |    2 +-
src/game/DynamicObject.cpp |    5 ++++-
src/game/DynamicObject.h   |    2 +-
src/game/GameObject.cpp    |    5 ++++-
src/game/GameObject.h      |    2 +-
src/game/Object.cpp        |    1 -
src/game/Object.h          |   12 ++++++++----
src/game/Player.cpp        |   10 ++++++++--
src/game/Totem.cpp         |    1 -
src/game/Unit.cpp          |   15 ++++++++++++---
src/game/Unit.h            |    4 ++--
12 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp
index 062a005..1fabba9 100644
--- a/src/game/Corpse.cpp
+++ b/src/game/Corpse.cpp
@@ -250,7 +250,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
    return true;
}

-bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
+bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result) const
{
    return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
diff --git a/src/game/Corpse.h b/src/game/Corpse.h
index f72afea..6904052 100644
--- a/src/game/Corpse.h
+++ b/src/game/Corpse.h
@@ -77,7 +77,7 @@ class Corpse : public WorldObject
        GridPair const& GetGrid() const { return m_grid; }
        void SetGrid(GridPair const& grid) { m_grid = grid; }

-        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
+        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result = NULL) const;

        Loot loot;                                          // remove insignia ONLY at BG
        Player* lootRecipient;
diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp
index b2d88f9..a242bc3 100644
--- a/src/game/DynamicObject.cpp
+++ b/src/game/DynamicObject.cpp
@@ -183,10 +183,13 @@ void DynamicObject::Delay(int32 delaytime)
    }
}

-bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
+bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result) const
{
    if(!IsInWorld() || !u->IsInWorld())
+    {
+        if(result) {*result = VISIBLE_FOR_INSTATE_NOT_IN_MAP;}
        return false;
+    }

    // always seen by owner
    if(GetCasterGUID()==u->GetGUID())
diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h
index 0907664..d5db699 100644
--- a/src/game/DynamicObject.h
+++ b/src/game/DynamicObject.h
@@ -56,7 +56,7 @@ class DynamicObject : public WorldObject
            return 0.0f;                                    // dynamic object not have real interact size
        }

-        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
+        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result = NULL) const;

        void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
        void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 32bedb3..e7bd9e0 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -676,11 +676,14 @@ void GameObject::SaveRespawnTime()
        sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime);
}

-bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
+bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *visibleResult) const
{
    // Not in world
    if(!IsInWorld() || !u->IsInWorld())
+    {
+        if (visibleResult) {*visibleResult = VISIBLE_FOR_INSTATE_NOT_IN_MAP;}
        return false;
+    }

    // invisible at client always
    if(!GetGOInfo()->displayId)
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index f09e749..6cc6622 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -703,7 +703,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
        void SummonLinkedTrapIfAny();
        void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);

-        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
+        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *visibleResult = NULL) const;

        GameObject* LookupFishingHoleAround(float range);

diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index d6f69d1..19d5723 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1134,7 +1134,6 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask )
{
    Object::_Create(guidlow, 0, guidhigh);
    m_phaseMask = phaseMask;
-    m_destroyAnim = false;
}

void WorldObject::Relocate(float x, float y, float z, float orientation)
diff --git a/src/game/Object.h b/src/game/Object.h
index 2919f72..1a539bf 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -60,6 +60,13 @@ enum PhaseMasks
    PHASEMASK_ANYWHERE = 0xFFFFFFFF
};

+enum VisibleForInStateResult
+{
+    VISIBLE_FOR_INSTATE_NONE = 0,                //visible
+    VISIBLE_FOR_INSTATE_NOT_IN_MAP = 1,
+    VISIBLE_FOR_INSTATE_NOT_IN_WORLD = 2,
+};
+
class WorldPacket;
class UpdateData;
class WorldSession;
@@ -473,7 +480,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        bool isVisibleFor(Player const* u, WorldObject const* viewPoint) const { return isVisibleForInState(u,viewPoint,false); }

        // low level function for visibility change code, must be define in all main world object subclasses
-        virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0;
+        virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result = NULL) const = 0;

        void SetMap(Map * map);
        Map * GetMap() const { MANGOS_ASSERT(m_currMap); return m_currMap; }
@@ -493,8 +500,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object

        ViewPoint& GetViewPoint() { return m_viewPoint; }

-        void SetDestroyAnim(bool anim) {m_destroyAnim = anim;}
-        bool GetDestroyAnim() { return m_destroyAnim; }
    protected:
        explicit WorldObject();

@@ -518,7 +523,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        float m_positionY;
        float m_positionZ;
        float m_orientation;
-        bool m_destroyAnim;

        ViewPoint m_viewPoint;
};
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 09a5952..2f12cc1 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -19357,14 +19357,20 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
{
    if(HaveAtClient(target))
    {
-        if(!target->isVisibleForInState(this, viewPoint, true))
+        VisibleForInStateResult visibleResult = VISIBLE_FOR_INSTATE_NONE;
+        if(!target->isVisibleForInState(this, viewPoint, true, &visibleResult))
        {
            if (target->GetTypeId()==TYPEID_UNIT)
                BeforeVisibilityDestroy<Creature>((Creature*)target,this);

            ObjectGuid t_guid = target->GetGUID();

-            target->DestroyForPlayer(this, target->GetDestroyAnim());
+            bool anim = false;
+            if (visibleResult == VISIBLE_FOR_INSTATE_NOT_IN_MAP)
+            {
+                anim = true;
+            }
+            target->DestroyForPlayer(this, anim);
            m_clientGUIDs.erase(t_guid);

            DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index 8300430..2b1c968 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -29,7 +29,6 @@ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
{
    m_duration = 0;
    m_type = TOTEM_PASSIVE;
-    SetDestroyAnim(true);
}

void Totem::Update( uint32 time )
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 2614123..84fed60 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -7714,10 +7714,14 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
    return gain;
}

-bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList, bool is3dDistance) const
+bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList, bool is3dDistance, VisibleForInStateResult *visibleResult) const
{
+    if(visibleResult) {*visibleResult = VISIBLE_FOR_INSTATE_NONE;}
    if(!u || !IsInMap(u))
+    {
+        if(visibleResult) {*visibleResult = VISIBLE_FOR_INSTATE_NOT_IN_MAP;}
        return false;
+    }

    // Always can see self
    if (u==this)
@@ -7733,11 +7737,16 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo

    // not in world
    if(!at_same_transport && (!IsInWorld() || !u->IsInWorld()))
+    {
+        if(visibleResult) {*visibleResult = VISIBLE_FOR_INSTATE_NOT_IN_WORLD;}
        return false;
+    }

    // forbidden to seen (at GM respawn command)
    if(m_Visibility==VISIBILITY_RESPAWN)
+    {
        return false;
+    }

    Map& _map = *u->GetMap();
    // Grid dead/alive checks
@@ -8804,9 +8813,9 @@ void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply )
    }
}

-bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, bool inVisibleList ) const
+bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result) const
{
-    return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false);
+    return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false, result);
}

/// returns true if creature can't be seen by alive units
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 9b7aeba..a3fc558 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1676,12 +1676,12 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        void SetVisibility(UnitVisibility x);

        // common function for visibility checks for player/creatures with detection code
-        bool isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
+        bool isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList = false, bool is3dDistance = true, VisibleForInStateResult *visibleResult = NULL) const;
        bool canDetectInvisibilityOf(Unit const* u) const;
        void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask

        // virtual functions for all world objects types
-        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
+        bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList, VisibleForInStateResult *result = NULL) const;
        // function for low level grid visibility checks in player/creature cases
        virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0;
        bool isInvisibleForAlive() const;
-- 
1.7.3.1.msysgit.0

Link to comment
Share on other sites

yes, I thought about that. but if we use

target->DestroyForPlayer(this, target->GetDestroyAnim());

the "bool anim" argument is no use,

what if someone wanna specify anim but don't wanna change m_destroyAnim?

for example:

a object with m_destroyAnim = true disappear (invisibility) is different from

a object with m_destroyAnim = true *must* start destroy anim

Link to comment
Share on other sites

I guess that

SetDestroyAnim(true);

should be moved to

void Totem::UnSummon()

then.

I agree.

we must send "destroy" anime for any objects that not out-of-range remove?

no. if we do this, if a mage cast spell "stealth" near a shaman with totems, the mage will see all totems destroyed

Link to comment
Share on other sites

no. if we do this, if a mage cast spell "stealth" near a shaman with totems, the mage will see all totems destroyed

This is not related to visibility totally. Player object know what objects related client see and what not see..

And stealth visibility cast from server point same as out of range, but some reason object exist bit not visible now...

I meaning we can send to destroyfor player function hint is this removed at real object destroy or at visibility update.

My main point: send for _all_ objects, not only for totems and without any additional fields...

Link to comment
Share on other sites

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