🟢 [C++] 📢 Balık tutan oyuncuya damage işlemesin

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 39

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Selamun aleyküm serbest açıp balık tutan oyuncuları rahatsız etmeye son. Emek serverlerin işine yarayacağını düşünüyorum.

Kod:
🟢 İnstanceBase.h Dosyasını açın // ARAT BOOL                    IsGameMaster(); // ALTINA EKLE BOOL                    IsInWater(CInstanceBase& rkInstDst); 🟢 İnstanceBase.cpp Dosyayı Açın // ARAT BOOL CInstanceBase::IsGameMaster()   // ALTINA EKLE   BOOL CInstanceBase::IsInWater(CInstanceBase& rkInstDst) {     for (int bX = -1; bX <= 1; ++bX) {         for (int yX = -1; yX <= 1; ++yX) {             const TPixelPosition& c_rkPPosCur = rkInstDst.NEW_GetCurPixelPositionRef();             if (CPythonBackground::Instance().isAttrOn(c_rkPPosCur.x + bX*100, c_rkPPosCur.y + yX*100, (1 << 1)))                 return TRUE;         }     }     return FALSE; } // ARAT     else if (IsPC())     {         if (rkInstVictim.IsStone())             return true;         if (rkInstVictim.IsPC())         { // ALTINA EKLE             if (rkInstVictim.IsFishingMode() && (IsInWater(rkInstVictim)))                 return false;  🟢 BİTTİ , ALINTIDIR.

Metin2 Oyununda C++ ile Balık Tutma Sistemi Geliştirme ve PvP Koruması Uygulama

Metin2 özel sunucularında geliştirme yaparken bazı sistemlerin oyuncu deneyimini etkileyen küçük ama önemli detayları göz ardı edebiliriz. Bu detaylardan birisi de balık tutma sırasında diğer oyunculara zarar vermemek. Bu yazıda, C++ tabanlı Metin2 sunucularında balık tutan oyuncuya saldırı yapılmaması için gerekli koruma sistemini nasıl uygulayacağımızı adım adım ele alacağız. Bu sayede hem oyuncular daha güvenli balık tutabilir hem de istenmeyen PvP durumlarını engelleyebiliriz.

Balık Tutma Sistemi Nedir?

Metin2'de balık tutma sistemi, oyuncuların eğlenceli zaman geçirmesi ve belirli item'lar kazanabilmesi için geliştirilmiş bir sosyal özelliktir. Ancak bu esnada oyuncular genellikle savunmasızdır ve saldırıya açık olabilirler. Bu nedenle balık tutan bir oyuncunun başka bir oyuncu tarafından saldırıya uğramaması önemlidir. Bu koruma özellikle PvP sunucularda büyük bir avantaj sağlar.

C++ ile Balık Tutma Durumu Kontrolü

Öncelikle, balık tutma durumunu belirleyen fonksiyonu tanımlamamız gerekir. Genellikle bu bilgi karakterin statüsünde saklanır. Örneğin, player_state adlı bir değişkenle balık tutup tutmadığını takip edebiliriz. Balık tutma komutu çalıştığında bu durum aktif edilir ve saldırı yapılmasını engellemek için kontrol yapılır.

Saldırı Sistemine Müdahale

Oyuncular birbirine saldırırken kullanılan fonksiyonlar genellikle game/src/char/char_battle.cpp gibi dosyalarda bulunur. Buradaki Attack veya benzeri fonksiyonlara, hedef oyuncunun balık tutup tutmadığına dair bir kontrol eklenmelidir. Eğer hedef balık tutuyorsa, saldırı iptal edilmeli ve istemciye bir mesaj gönderilmelidir.

Örnek olarak:
Kod:
if (victim->IsFishing()) {[BR][/BR]    ChatPacket(ch, QCOLOR_RED 'Balık tutan bir oyuncuya saldıramazsınız!');[BR][/BR]    return false;[BR][/BR]}

Sistem Entegrasyonu ve Test

Yukarıdaki kod parçasını doğru yere yerleştirdikten sonra sistemi test etmek önemlidir. Sunucuda balık tutarken başka bir oyuncunun sizi vuramaması gerekir. Ayrıca hata ayıklama (debug) log'larını kontrol ederek sistemin sorunsuz çalıştığından emin olmalısınız.

Daha İleri Seviye Geliştirmeler

İsterseniz bu sistemi daha da geliştirebilirsiniz. Örneğin, balık tutan oyuncuya sadece saldırı değil, bazı beceriler de engellenebilir. Bunun için skill_tree.cpp dosyasında gerekli kontroller yapılabilir. Ayrıca, balık tutma süresince bir efekt veya görsel uyarı da eklenebilir.

Sonuç

Metin2 özel sunucularında kullanıcı dostu sistemler oluşturmak, oyuncuların uzun süre kalmasını sağlar. Balık tutan oyunculara saldırı yapılmaması gibi küçük ama etkili geliştirmeler, sunucunuzun kalitesini artırır. C++ bilgisiyle bu tür sistemleri kolayca entegre edebilir ve oyunculara daha iyi bir deneyim sunabilirsiniz. Bu makale sayesinde basitçe bir PvP koruma sistemi oluşturmayı öğrendiniz.


Implementing Fishing Protection System with C++ in Metin2 Private Servers

While developing Metin2 private servers, we might overlook small but important details that affect player experience. One of these details is preventing attacks on players who are fishing. In this article, we will cover step-by-step how to implement a protection system so that players who are fishing cannot be attacked by others, using C++ based Metin2 server code. This way, players can fish more safely and unwanted PvP situations can be avoided.

What Is The Fishing System?

The fishing system in Metin2 is a social feature designed for players to have fun and potentially earn items. However, during this activity, players are often defenseless and vulnerable to attacks. Therefore, ensuring that a player who is fishing cannot be attacked by another player is important. This protection is especially valuable on PvP servers.

Checking Fishing Status with C++

Firstly, we need to define a function that determines if a player is currently fishing. Usually, this information is stored within the character's state. For example, we can track whether the player is fishing with a variable such as player_state. When the fishing command is triggered, this status becomes active, and checks are made to prevent attacks.

Intercepting Attack Functions

Player-to-player attack functions are typically located in files like game/src/char/char_battle.cpp. We must add a check inside the Attack or similar functions to determine whether the target player is fishing. If the target is fishing, the attack should be canceled and a message sent to the client.

As an example:
Kod:
if (victim->IsFishing()) {[BR][/BR]    ChatPacket(ch, QCOLOR_RED 'You cannot attack a player who is fishing!');[BR][/BR]    return false;[BR][/BR]}

Integration and Testing

After inserting the above code snippet into the correct location, testing the system is crucial. While fishing on the server, other players should not be able to hit you. Additionally, you should check debugging logs to ensure the system runs without errors.

Advanced Improvements

You can further enhance this system. For instance, skills that could harm the fishing player can also be blocked. For this, appropriate checks can be added in the skill_tree.cpp file. Moreover, visual effects or notifications can be added while the player is fishing.

Conclusion

Creating user-friendly systems in Metin2 private servers increases the likelihood of player retention. Small but effective improvements like preventing attacks on fishing players can elevate your server's quality. With C++ knowledge, you can easily integrate such systems and provide a better gaming experience. With this article, you've learned how to create a basic PvP protection system.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Geri
Üst Alt