Jump to content

[Dev] Destructible Building (type 33)


Recommended Posts

  • Replies 92
  • Created
  • Last Reply

Top Posters In This Topic

Some additions: Destructible buildings' health is shown by its animprogress on the client, uint8 max (255) is 100%.

For correct damage logs we should send SMSG_DESTRUCTIBLE_BUILDING_DAMAGE

structure looks like:

(size 29)

packguid (GameObject)

packguid(vehicle used/attacker if no vehicle)

packguid(attacker)

uint32 damage

uint32 spellId

Thanks to TOM_RUS for the structure.

I tested this data and it's correct.

packguid(vehicle used/attacker if no vehicle)

Correspond to: packguid(caster)

packguid(attacker)

Correspond to: packguid(originalCaster)

Link to comment
Share on other sites

Ты бы лучше вместо того чтобы понтоваться, подготовил бы все в виде патча и выложил бы на обсуждение и доводку до идеала. Или ты пришел сюда только понты гонять и кричать всем какой ты умный и все реализовал?

А смысл, что-то сюда выкладывать? Я самую первую версию выложил патча и в течении 2-х дней ни кто ни чего не написал, тока тупо качали (180 закачек за 2 дня)! Помощи о которой я просил, я не получил! Пришлось все самому делать! И на счет понтов, я не такой человек, что бы понты гонять в отличии от некоторых! Смотрю тут кучу репозитарий наделали и чем же они отличаются? все друг у друга взяли и один копия другого! Ну выложу я его сюда и что? Сразу же воткнешь в свой репозитарий?

И чем тебя не устраиват та версия, которая выложена!

Link to comment
Share on other sites

А смысл, что-то сюда выкладывать? Я самую первую версию выложил патча и в течении 2-х дней ни кто ни чего не написал, тока тупо качали (180 закачек за 2 дня)! Помощи о которой я просил, я не получил! Пришлось все самому делать! И на счет понтов, я не такой человек, что бы понты гонять в отличии от некоторых! Смотрю тут кучу репозитарий наделали и чем же они отличаются? все друг у друга взяли и один копия другого! Ну выложу я его сюда и что? Сразу же воткнешь в свой репозитарий?

И чем тебя не устраиват та версия, которая выложена!

Интересно, что бы было бы, если бы Владимир не делился своими коммитами с сообществом? Может быть тогда все вместе уйдём в закрытую разработку и будем сидеть по углам, каждый со своими помидорами? Мангос - проект с открытым исходным кодом, и вы должны быть благодарны всем, кто участвует в разработке данного проекта. Лучшая ваша благодарность - ваша помощь и активность.

I wonder what would happen would be if Vladimir does not share his commit to the community, maybe then all leave together in a closed development and will sit in the corners, each with their own tomatoes? Mangos - an open-source project, and you should be grateful to everyone who participates in the development of this project. Best your thanks - your help and activity.

Link to comment
Share on other sites

Интересно, что бы было бы, если бы Владимир не делился своими коммитами с сообществом? Может быть тогда все вместе уйдём в закрытую разработку и будем сидеть по углам, каждый со своими помидорами? Мангос - проект с открытым исходным кодом, и вы должны быть благодарны всем, кто участвует в разработке данного проекта. Лучшая ваша благодарность - ваша помощь и активность.

The patch is in This Theme, use, who to you disturbs!

It quite not badly works, only demands updating!

-------------------------------------------------------------------------

Патч есть в Этой Теме, пользуйтесь, кто вам мешает!

Он вполне не плохо работает, только требует обновления!

Link to comment
Share on other sites

I try to update you patch, but it goes to an error.

That's changes i will make:

in Cell.h

template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float radius, float x_off, float y_off) const;
To
template<class T, class CONTAINER> void Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float radius, float x_off, float y_off) const;

CellImpl.h:

template<class LOCK_TYPE,class T, class CONTAINER>
to
template<class T, class CONTAINER>
and
Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
to
Cell::Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
and
m.Visit(l, visitor); 
to
m.Visit(*this, visitor);
and
CellLock<LOCK_TYPE> lock(r_zone, cell_pair);
to
CellPair lock(r_zone, cell_pair);

But this part of code compiled with errors:

for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
   {
       for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
       {
           CellPair cell_pair(x,y);
           Cell r_zone(cell_pair);
           r_zone.data.Part.nocreate = l->data.Part.nocreate;
           CellPair lock(r_zone, cell_pair);
           m.Visit(lock, visitor);
       }
   }

And olso errors in map.h and GameObject.cpp

-------------------------------------------------------------------------------

Вобщем нифига не понял че еще не поменял, я новичек в С++ с трудом разбираюсь в коде. Не мог бы ты помочь, либо выложить уже обновленный патч?

Кстати насчет скрипта для нового бг - я был бы рад помочь в тестировании и может даже в разработке.

Link to comment
Share on other sites

for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
   {
       for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
       {
           CellPair cell_pair(x,y);
           Cell r_zone(cell_pair);
           r_zone.data.Part.nocreate = data.Part.nocreate;
           m.Visit(r_zone, visitor);
       }
   }
}

diff --git a/src/game/Map.h b/src/game/Map.h
index 6e68529..0ff3799 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -406,6 +406,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
        void RemoveFromActive(T* obj) { RemoveFromActiveHelper(obj); }

        void RemoveFromActive(Creature* obj);
+        
+        template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier);

        Creature* GetCreature(uint64 guid);
        Vehicle* GetVehicle(uint64 guid);
@@ -629,4 +631,17 @@ Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
        getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
    }
}
-#endif
+
+template<class NOTIFIER>
+inline void
+Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
+{
+    CellPair p(MaNGOS::ComputeCellPair(x, y));
+    Cell cell(p);
+    cell.data.Part.reserved = ALL_DISTRICT;
+    cell.SetNoCreate();
+
+    TypeContainerVisitor<NOTIFIER, GridTypeMapContainer >  grid_object_notifier(notifier);
+    cell.Visit(p, grid_object_notifier, *this, radius, x, y);
+}
+#endif
\\ No newline at end of file

http://pastebin.com/m79340633

In line

MaNGOS:: GameObjectInRangeCheck check (x, y, z, radius + 15);

Instead of value 15 I recommend to use 15-20, the most optimum variant!

-------------------------------------------------------------------------------------------------------

В строке

MaNGOS::GameObjectInRangeCheck check(x, y, z, radius + 15);

вместо значения 15 рекомендую использовать 15-20, самый оптимальный вариант!

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

+1

также я отказался от поддержки своего мода отправки почты в игру через таблицу mysql.

---

like tc i don't support my external mail patch. I must find you ways to solve a problems.

P.S.: а про git-репозитории в точку, теперь каждая букашка создает свой репо, причем копирует его обычно у карателя. Народ перестал трудиться над участками кода в рамках проекта, зато каждый занимает место у гугля :) Я в таком плане просто свалил на тринити, у них тоже самое, но без выпендрежа с "образовательным проектом", как это и было с wowd.

Здесь проект без Владимира просто бы умер. Остальные тупо правят очепятки и т.п. фигню. :/

Link to comment
Share on other sites

I heard that on official servers it displays damage dealt to building like when damaging unit. I thing SMSG_DESTRUCTIBLE_BUILDING_DAMAGE is used for this, but i don't know the packet structure

EDIT: found a packet structure:

uint64 gameObjTarget (packGUID)

uint64 original caster packGUID

uint64 vehicle/caster owner packGUID

uint32 damage

uint32 spell ID

Link to comment
Share on other sites

  • 1 month later...

Hi,

I've tried to update patch for lastest revision (9940), compile is fine but seems still don't work, i don't know if is needed DB support or something other, anyway i think we can restart this work from this patch and finally complete

http://paste2.org/p/839905

If there are any suggestions or someone know how to complete this patch (with DB support and other ways) please help us :)

Enjoy

Link to comment
Share on other sites

The code in TakenDamage is wrong

   if(m_health > damage)
   {
       m_health -= damage;
       return;
   }
   m_health = 0;

should be

if (m_health > damage)
   m_health -= damage;
else
   m_health = 0;

Or it will never update the display and flags of the GO.

U should also add check for factions as i did for trinity, otherwise people can attack their own buildings. In WG some cheaters helped the other team to win destroying their own buildings. Also after TakenDamage send SMSG_DESTRUCTIBLE_BUILDING_DAMAGE

// Trinity code, Adapt to Mangos (if needed)
void Spell::EffectWMODamage(uint32 /*i*/)
{
   if (gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
   {
       Unit *caster = m_originalCaster;
       if (!caster)
           return;

       FactionTemplateEntry const *casterft, *goft;
       casterft = caster->getFactionTemplateEntry();
       goft = sFactionTemplateStore.LookupEntry(gameObjTarget->GetUInt32Value(GAMEOBJECT_FACTION));
       // Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls)
       if (casterft && goft && !casterft->IsFriendlyTo(*goft))
       {
           gameObjTarget->TakenDamage(uint32(damage), caster);
           WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8+8+8+4+4);
           data.append(gameObjTarget->GetPackGUID());
           data.append(caster->GetPackGUID());
           if (Unit *who = caster->GetCharmerOrOwner())
               data.append(who->GetPackGUID());
           else
               data.append(caster->GetPackGUID());
           data << uint32(damage);
           data << uint32(m_spellInfo->Id);
           gameObjTarget->SendMessageToSet(&data, false);
       }
   }
}

About HealthBar:

Need to set animprogress with the correct value. On creation force AnimProgress to 255 (or update DB value), each time it gets damaged update with the formula (Health*255/MaxHealth)

Link to comment
Share on other sites

@j4r0d

In your patch, in InstanceData.h and Vehicle.cpp:

#include "ZoneScript.h"

Where is "ZoneScript.h"? Does it exists? The core doesn't compile with this patch because of that #include :/

Also, it give me this error:

4>..\\..\\src\\game\\GameObject.cpp(1507) : error C2027: use of type 'ZoneScript' undefined
4>        c:\\users\\ankso\\mangos\\mangos\\src\\game\\Object.h(74) : see declaration of 'ZoneScript'
4>..\\..\\src\\game\\GameObject.cpp(1507) : error C2227: the left operand of '-> processEvent' must point to the type class / struct / union / generic

Link to comment
Share on other sites

Where is "ZoneScript.h"? Does it exists? The core doesn't compile with this patch because of that #include :/

Also, it give me this error:

yep sorry for missing ZoneScript.h... :P it's the same of trinity

#ifndef ZONE_SCRIPT_H_
#define ZONE_SCRIPT_H_

#include "Common.h"
#include "Creature.h"

//struct CreatureData;
class Creature;
class GameObject;

class ZoneScript
{
   public:
       explicit ZoneScript() {}

       virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, const CreatureData *data) { return data->id; }
       virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; }

       virtual void OnCreatureCreate(Creature *, bool /*add*/) {}
       virtual void OnGameObjectCreate(GameObject * /*go*/, bool /*add*/) {}

       //All-purpose data storage 64 bit
       virtual uint64 GetData64(uint32 /*DataId*/) { return 0; }
       virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) {}

       //All-purpose data storage 32 bit
       virtual uint32 GetData(uint32 /*DataId*/) { return 0; }
       virtual void SetData(uint32 /*DataId*/, uint32 /*Value*/) {}

       virtual void ProcessEvent(GameObject * /*obj*/, uint32 /*eventId*/) {}
};

#endif

if there are changes for DB, can someone make a patch?if someone can update the patch with newest modifies i think will be better :)

Thanks

Link to comment
Share on other sites

IMO all code related to ZoneScript should be removed:

- That is not Destructible Object dependant (ie: adding 2 functionalities in one patch).

- Adding stuff from trinity AS IS is without removing the unused data (ZoneScript only using 1 function)

- Why Rebuild event depends on the killer? those events are supposed to be notified always, not depending on the player.

Note: Remember to give credits to the original authors.

Link to comment
Share on other sites

IMO all code related to ZoneScript should be removed:

- That is not Destructible Object dependant (ie: adding 2 functionalities in one patch).

- Adding stuff from trinity AS IS is without removing the unused data (ZoneScript only using 1 function)

- Why Rebuild event depends on the killer? those events are supposed to be notified always, not depending on the player.

Note: Remember to give credits to the original authors.

Ok i've cleaned up last patch, and updated with Spp_ suggested modifies...

ZoneScript.h and it's references was been removed (useless)

http://paste2.org/p/840330

I noticed that now vehicles deal damage to buildings correctly, tested on "Wintergrasp Fortress Wall" in wintergrasp, but building is still whole... what missing?

Ofc credits to everyone who have worked on this function, and credits to trinity too for some parts :D

Link to comment
Share on other sites

To see GO healthbar need to change

void WorldObject::SendGameObjectCustomAnim(uint64 guid)
{
   WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
   data << uint64(guid);
   data << uint32(0);                                      // not known what this is
   SendMessageToSet(&data, true);
}

To

void WorldObject::SendGameObjectCustomAnim(uint64 guid, uint8 animprogress)
{
   WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
   data << uint64(guid);
   data << uint32(animprogress);
   SendMessageToSet(&data, true);
}

In Object.cpp

Remember u need to set animprogress = 255 on DB or force the value on GameObject::create and update the value in TakenDamage

Depending on the GO health u going to need a lot of hits.

Link to comment
Share on other sites

I'm trying with this

diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index a03e866..4905f3f 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -208,7 +208,7 @@ void GameObject::Update(uint32 /*p_time*/)
                            udata.BuildPacket(&packet);
                            ((Player*)caster)->GetSession()->SendPacket(&packet);

-                            SendGameObjectCustomAnim(GetGUID());
+                            SendGameObjectCustomAnim(GetGUID(), GetGoAnimProgress());
                        }

                        m_lootState = GO_READY;                 // can be successfully open with some chance
@@ -1075,7 +1075,7 @@ void GameObject::Use(Unit* user)

            // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
            if (time_to_restore && info->goober.customAnim)
-                SendGameObjectCustomAnim(GetGUID());
+                SendGameObjectCustomAnim(GetGUID(), GetGoAnimProgress());
            else
                SetGoState(GO_STATE_ACTIVE);

diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 55cc856..b995cab 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1618,11 +1618,11 @@ void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
    SendMessageToSet(&data, true);
}

-void WorldObject::SendGameObjectCustomAnim(uint64 guid)
+void WorldObject::SendGameObjectCustomAnim(uint64 guid, uint8 animprogress)
{
    WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
    data << uint64(guid);
-    data << uint32(0);                                      // not known what this is
+    data << uint8(animprogress);
    SendMessageToSet(&data, true);
}

diff --git a/src/game/Object.h b/src/game/Object.h
index 074fc94..527bec5 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -447,7 +447,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        void PlayDirectSound(uint32 sound_id, Player* target = NULL);

        void SendObjectDeSpawnAnim(uint64 guid);
-        void SendGameObjectCustomAnim(uint64 guid);
+        void SendGameObjectCustomAnim(uint64 guid, uint8 animprogress);

        virtual bool IsHostileTo(Unit const* unit) const =0;
        virtual bool IsFriendlyTo(Unit const* unit) const =0;

but still can't see healthbar, what's wrong?

EDIT : Sorry, my bad... i see correctly the health bar in upper right under the gobject name, but gobject when take dmg is still at 100% of hp...

Link to comment
Share on other sites

I'm trying with this

// Some code... 
-void WorldObject::SendGameObjectCustomAnim(uint64 guid)
+void WorldObject::SendGameObjectCustomAnim(uint64 guid, uint8 animprogress)
{
    WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
    data << uint64(guid);
-    data << uint32(0);                                      // not known what this is
+    data << uint8(animprogress);
    SendMessageToSet(&data, true);
}

but still can't see healthbar, what's wrong?

Dont' change types when sending opcodes, it needs to be uint32. idk about healthbar, that was just enough in trinity.

u can just test the hp bar thing with ".debug send opcode" u will need the opcode.txt file in the bin folder file with the correct data

179
uint64
TheGOGuid (Not the db value, u need the uint64 used in code)
uint32
animprogress

Link to comment
Share on other sites

Ok all done and works great :D

diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index a03e866..ef7543c 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -147,7 +147,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
    SetGoAnimProgress(animprogress);

    if(goinfo->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
-        m_health = goinfo->destructibleBuilding.damagedHealth;
+    {
+        m_health = goinfo->destructibleBuilding.damagedHealth + goinfo->destructibleBuilding.damagedDisplayId;
+        SetGoAnimProgress(255);
+    }

    //Notify the map's instance data.
    //Only works if you create the object in it, not if it is moves to that map.
@@ -208,7 +211,7 @@ void GameObject::Update(uint32 /*p_time*/)
                            udata.BuildPacket(&packet);
                            ((Player*)caster)->GetSession()->SendPacket(&packet);

-                            SendGameObjectCustomAnim(GetGUID());
+                            SendGameObjectCustomAnim(GetGUID(), GetGoAnimProgress());
                        }

                        m_lootState = GO_READY;                 // can be successfully open with some chance
@@ -1075,7 +1078,7 @@ void GameObject::Use(Unit* user)

            // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
            if (time_to_restore && info->goober.customAnim)
-                SendGameObjectCustomAnim(GetGUID());
+                SendGameObjectCustomAnim(GetGUID(), GetGoAnimProgress());
            else
                SetGoState(GO_STATE_ACTIVE);

@@ -1462,6 +1465,8 @@ void GameObject::TakenDamage(uint32 damage, Unit* pKiller)
        else
            m_health = 0;
    }
+
+    SetGoAnimProgress(m_health*255/(m_goInfo->destructibleBuilding.damagedHealth + m_goInfo->destructibleBuilding.destroyedHealth));
}

void GameObject::Rebuild(Unit* pKiller)
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 55cc856..07ba552 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1618,11 +1618,11 @@ void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
    SendMessageToSet(&data, true);
}

-void WorldObject::SendGameObjectCustomAnim(uint64 guid)
+void WorldObject::SendGameObjectCustomAnim(uint64 guid, uint8 animprogress)
{
    WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
    data << uint64(guid);
-    data << uint32(0);                                      // not known what this is
+    data << uint32(animprogress);
    SendMessageToSet(&data, true);
}

diff --git a/src/game/Object.h b/src/game/Object.h
index 074fc94..527bec5 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -447,7 +447,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        void PlayDirectSound(uint32 sound_id, Player* target = NULL);

        void SendObjectDeSpawnAnim(uint64 guid);
-        void SendGameObjectCustomAnim(uint64 guid);
+        void SendGameObjectCustomAnim(uint64 guid, uint8 animprogress);

        virtual bool IsHostileTo(Unit const* unit) const =0;
        virtual bool IsFriendlyTo(Unit const* unit) const =0;

That's the last update enjoy it and thanks to all :)

EDIT : typo fix, thanks to Spp_

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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