Merhabalar. Dungeonlarda canavar sayısında değişiklik yapılırken canavar öldüğünde değil ortadan kaybolunca azalma oluyor, dolayısıyla questlerde canavar sayısı kullanılırken(ki zaten bu yüzden pek kullanılmıyor) hata/bug yaşanıyor. Bunun fixi. Ordan burdan alma/çalma değil. Küçük bir kaç deneme yaptım, eski sorun ortadan kalktı ve herhangi bir sorun bulamadım. Yine de kendi filesinizde denemenizi öneririm.
d.purge ve ya gm kodu ile purge atıldığında canavarlarda eksilme olmuyor!
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
İyi kullanmalar.
[C++] Dungeon CountMonster() Fix
Metin2 özel sunucularında geliştirme yaparken, özellikle dungeon sistemleri üzerinde çalışırken karşılaşılan yaygın sorunlardan birisi CountMonster() fonksiyonunun doğru şekilde davranmamasıdır. Bu fonksiyon, dungeon içindeki canavar sayısını kontrol etmek için kullanılır ve bazı durumlarda eksik veya hatalı sonuçlar döndürebilir. Bu durum, oyuncu deneyimini olumsuz yönde etkileyebilir. Bu makalede, Metin2 özel sunucularında CountMonster() fonksiyonunun nasıl düzeltilmesi gerektiği, neden hatalı sonuçlar verdiği ve bu hatanın nasıl çözüleceği konusunda detaylı bilgiler sunacağız.
Sorun Nedir?
Bazı özel sunucularda, CountMonster() fonksiyonu, dungeon içindeki gerçek canavar sayısını doğru şekilde hesaplayamaz. Bu durum genellikle, canavar spawn sistemlerindeki hatalar, event handler'ların yanlış kullanımı ya da sunucu tarafında eksik veya yanlış kodlamadan kaynaklanabilir. Özellikle PvP odaklı sunucularda, dungeon içindeki düşman sayısının doğru belirlenmesi, oyuncuların stratejik planlamaları açısından kritik öneme sahiptir.
Çözüm Adımları
Öncelikle, CountMonster() fonksiyonunun doğru çalışması için dungeon içindeki tüm monsterların doğru şekilde sayaçta takip edilmesi gerekir. Bu işlem için aşağıdaki adımları izlemek önemlidir:
- Canavar spawn olduğunda sayaç artırılmalıdır.
- Canavar öldürüldüğünde sayaç azaltılmalıdır.
- Canavar dungeon dışına çıktığında sayaçtan düşürülmelidir.
Bu işlemleri doğru şekilde yapabilmek için game/src/char.cpp veya benzeri dosyalarda bulunan monster_count değişkeniyle etkileşime geçen fonksiyonlar incelenmelidir. Özellikle MonsterSpawnEvent(), OnDead(), LeaveDungeon() gibi fonksiyonlar gözden geçirilmelidir.
Örnek Kod Yapısı
Kod:
[B]int CountMonsterInDungeon(int dungeon_id)[/B]{[BR][/BR] int count = 0;[BR][/BR] for (const auto& ch : CHARACTER_MANAGER::instance().GetCharacterList()) {[BR][/BR] if (ch->IsMonster() && ch->GetDungeon() && ch->GetDungeon()->GetMapIndex() == dungeon_id) {[BR][/BR] count++;[BR][/BR] }[BR][/BR] }[BR][/BR] return count;[BR][/BR]}
Yukarıdaki örnek, dungeon içindeki tüm monsterları sayar. Ancak gerçek hayatta bu fonksiyonun daha fazla kontrol içermesi gerekir. Örneğin, AI 상태, spawn zamanı, death status gibi durumlar da kontrol edilmelidir.
Test Süreci
Bu fix uygulandıktan sonra, test aşaması çok önemlidir. Dungeon içinde farklı koşullarda spawn ve kill işlemleri yapılarak sayaç değerlerinin tutarlı olduğu kontrol edilmelidir. Ayrıca, aynı anda birden fazla oyuncunun dungeon içinde bulunduğu senaryolar da test edilmelidir.
Sonuç
Metin2 özel sunucularında dungeon sistemlerinin doğru çalışması, hem oyuncu deneyimini artırır hem de sunucunun genel performansını olumlu yönde etkiler. CountMonster() fonksiyonunun doğru çalışması için gereken düzenlemeler, C++ seviyesinde dikkatli kodlama ve test süreçleri ile sağlanabilir. Bu makalede anlatılan adımlar, sunucu geliştiricilerine rehberlik edecek niteliktedir.
[C++] Dungeon CountMonster() Fix
While developing on Metin2 private servers, one of the common issues encountered especially when working on dungeon systems is the malfunctioning of the CountMonster() function. This function is used to check the number of monsters inside a dungeon and may sometimes return incorrect or incomplete results. This situation can negatively affect the player experience. In this article, we will provide detailed information on how to fix the CountMonster() function in Metin2 private servers, why it returns wrong values, and how to resolve these errors.
What Is The Problem?
In some private servers, the CountMonster() function fails to accurately calculate the real number of monsters inside a dungeon. This issue usually stems from errors in monster spawn systems, incorrect usage of event handlers, or missing or faulty coding on the server side. Especially in PvP oriented servers, correctly determining the number of enemies in a dungeon is critical for players' strategic planning.
Solution Steps
Firstly, for the CountMonster() function to work properly, all monsters inside the dungeon must be tracked correctly in the counter. The following steps are important to achieve this:
- Increase the counter when a monster spawns.
- Decrease the counter when a monster dies.
- Remove the monster from the counter when it exits the dungeon.
To perform these operations correctly, functions interacting with the monster_count variable should be examined in files like game/src/char.cpp. Functions such as MonsterSpawnEvent(), OnDead(), and LeaveDungeon() should be reviewed carefully.
Sample Code Structure
Kod:
[B]int CountMonsterInDungeon(int dungeon_id)[/B]{[BR][/BR] int count = 0;[BR][/BR] for (const auto& ch : CHARACTER_MANAGER::instance().GetCharacterList()) {[BR][/BR] if (ch->IsMonster() && ch->GetDungeon() && ch->GetDungeon()->GetMapIndex() == dungeon_id) {[BR][/BR] count++;[BR][/BR] }[BR][/BR] }[BR][/BR] return count;[BR][/BR]}
The above example counts all monsters within the dungeon. However, in real life, this function should include more checks. For example, AI state, spawn time, death status, etc., should also be checked.
Testing Process
After applying this fix, the testing phase becomes very important. Counter consistency should be verified by performing spawn and kill operations under different conditions inside the dungeon. Additionally, scenarios where multiple players are simultaneously inside the dungeon should also be tested.
Conclusion
Proper functioning of dungeon systems in Metin2 private servers increases both the player experience and the overall performance of the server. The necessary adjustments to make the CountMonster() function work correctly can be achieved through careful C++ level coding and testing processes. The steps explained in this article will serve as a guide for server developers.
