[C++,Python]Karşıdaki Kişinin HP Görme - Bar & Decimal Target HP

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
[/FONT]


0lAQEW.png

zaqbpY.png


Karşıdaki oyuncunun hpsini bar ve değer olarak göremeye yarar.
Slotlarında hp değerlerini gösterir.
Sistem bana ait değil.






Metin2'de Karşı Tarafın Can Değerini Gösteren Sistem: Bar & Decimal Target HP

Metin2 özel sunucularında PvP deneyimini daha verimli hale getirmek, oyuncuların karşı tarafın can değerini (HP) hem grafiksel hem de sayısal olarak takip edebilmesini sağlar. Bu özellik, özellikle savaş sırasında stratejik planlama yapabilmek ve rakibin durumuna göre taktiksel hamleler geliştirebilmek açısından son derece önemlidir. Bu yazıda, C++ ve Python tabanlı sistemler üzerinden Bar & Decimal Target HP özelliğini nasıl uygulayacağımızı detaylıca ele alacağız.

Bar & Decimal Target HP Nedir?

Bu sistem, oyuncunun hedef aldığı karakterin can değerini ekranda bir çubuk (bar) ve sayısal değer (decimal) şeklinde gösterir. Oyuncu, rakibinin ne kadar canının kaldığını hem görsel hem de sayısal olarak takip edebilir. Bu, özellikle turnuva tarzı etkinliklerde veya yüksek seviye PvP mücadelelerinde büyük avantaj sağlar.

C++ Tarafında Uygulama[/CTYPE=][/BR]
Metin2'nin game server tarafında C++ kullanılarak geliştirilen bu sistem, packet yapıları üzerinden çalışır. Oyuncunun hedef aldığı karakterin can değeri, sunucudan istemciye belirli aralıklarla gönderilir. Bunun için öncelikle game/src/char/char.cpp dosyasında gerekli fonksiyonlar tanımlanmalıdır. Örnek olarak:

Kod:
void CHARACTER::SendTargetHP() const {[BR][/BR]    TPacketGCCharacterUpdate pkt;[BR][/BR]    pkt.header = HEADER_GC_CHARACTER_UPDATE;[BR][/BR]    pkt.dwVID = GetVID();[BR][/BR]    pkt.sHP = GetHP();[BR][/BR]    pkt.sMaxHP = GetMaxHP();[BR][/BR]    PacketBlockEncode((LPBYTE)&pkt, sizeof(pkt));[BR][/BR]}


Bu fonksiyon sayesinde, sunucu hedeflenen karakterin HP bilgisini düzenli olarak istemciye gönderir. Ayrıca, bu verileri almak için istemci tarafında da uygun python handler tanımlanmalıdır.

Python Tarafında Uygulama

İstemci tarafında, uiscript.py dosyasında bir GUI penceresi oluşturulabilir. Bu pencere, rakibin can çubuğunu ve sayısını ekranda gösterir. PyGUI kütüphanesi kullanılarak bir arayüz tasarımı yapılabilir. Örneğin:

Kod:
import ui[BR][/BR]import net[BR][/BR][BR][/BR]class TargetHPWindow(ui.Window):[BR][/BR]    def __init__(self):[BR][/BR]        ui.Window.__init__(self)[BR][/BR]        self.hpBar = None[BR][/BR]        self.hpText = None[BR][/BR]        self.LoadWindow()[BR][/BR][BR][/BR]    def LoadWindow(self):[BR][/BR]        # UI Elemanlarını yükle[BR][/BR]        pass[BR][/BR][BR][/BR]    def UpdateHP(self, hp, maxHp):[BR][/BR]        if self.hpBar:[BR][/BR]            self.hpBar.SetPercentage(hp, maxHp)[BR][/BR]        if self.hpText:[BR][/BR]            self.hpText.SetText(str(hp))[BR][/BR]


Bu yapı sayesinde, sunucudan gelen HP verisi Python tarafında işlenerek ekrana çizdirilir. Decimal değer ise doğrudan rakam olarak gösterilirken, Bar kısmı ise bir progress bar şeklinde can durumu görsel olarak yansıtılmış olur.

Dikkat Edilmesi Gerekenler

• Sunucu tarafında paket boyutları optimize edilmelidir. Her frame'de HP verisi göndermek performansı düşürebilir.
• İstemci tarafında UI yenilemeleri FPS üzerinde etki yaratabilir. Bu nedenle Threading veya timer kontrolleri yapılmalıdır.
• Sunucu ve istemci arasında zaman senkronizasyonu sağlanmalıdır.

Sonuç

Bar & Decimal Target HP sistemi, Metin2 özel sunucularında PvP kalitesini artırmak için oldukça faydalı bir özelliktir. C++ ve Python dilleri ile geliştirilen bu sistem, doğru şekilde entegre edildiğinde kullanıcı deneyimini ciddi anlamda artırır. Geliştiriciler, bu sistemi temel alarak daha gelişmiş görsel efektler ve kullanıcı arayüzü bileşenleri ekleyebilir.


Displaying Opponent's HP in Metin2: Bar & Decimal Target HP

Enhancing the PvP experience on Metin2 private servers involves enabling players to track the health points (HP) of their opponents both visually and numerically. This feature is crucial for strategic planning during combat and adapting tactics based on the opponent's status. In this article, we will explain in detail how to implement the Bar & Decimal Target HP system using C++ and Python-based systems.

What is Bar & Decimal Target HP?

This system displays the health value of the targeted character as both a visual bar and a numerical value on the screen. Players can monitor how much health their opponent has left both visually and numerically. This provides significant advantages especially during tournament-style events or high-level PvP battles.

Implementation in C++

On the game server side of Metin2, this system is developed using C++ and operates through packet structures. The health value of the targeted character is sent from the server to the client at regular intervals. For this, relevant functions must be defined in the file game/src/char/char.cpp. As an example:

Kod:
void CHARACTER::SendTargetHP() const {[BR][/BR]    TPacketGCCharacterUpdate pkt;[BR][/BR]    pkt.header = HEADER_GC_CHARACTER_UPDATE;[BR][/BR]    pkt.dwVID = GetVID();[BR][/BR]    pkt.sHP = GetHP();[BR][/BR]    pkt.sMaxHP = GetMaxHP();[BR][/BR]    PacketBlockEncode((LPBYTE)&pkt, sizeof(pkt));[BR][/BR]}


Thanks to this function, the server regularly sends the HP information of the targeted character to the client. Additionally, appropriate python handlers must be defined on the client side to receive this data.

Implementation in Python

On the client side, a GUI window can be created in the uiscript.py file. This window shows the enemy's health bar and its numerical value on the screen. A UI design can be made using the PyGUI library. For example:

Kod:
import ui[BR][/BR]import net[BR][/BR][BR][/BR]class TargetHPWindow(ui.Window):[BR][/BR]    def __init__(self):[BR][/BR]        ui.Window.__init__(self)[BR][/BR]        self.hpBar = None[BR][/BR]        self.hpText = None[BR][/BR]        self.LoadWindow()[BR][/BR][BR][/BR]    def LoadWindow(self):[BR][/BR]        # Load UI elements[BR][/BR]        pass[BR][/BR][BR][/BR]    def UpdateHP(self, hp, maxHp):[BR][/BR]        if self.hpBar:[BR][/BR]            self.hpBar.SetPercentage(hp, maxHp)[BR][/BR]        if self.hpText:[BR][/BR]            self.hpText.SetText(str(hp))[BR][/BR]


With this structure, the HP data received from the server is processed in Python and drawn onto the screen. The Decimal value is displayed directly as a number, while the Bar part visually represents the health status as a progress bar.

Important Considerations

• Packet sizes on the server side must be optimized. Sending HP data every frame can decrease performance.
• UI updates on the client side may affect FPS. Therefore, Threading or timer controls should be implemented.
• Time synchronization between server and client must be ensured.

Conclusion

The Bar & Decimal Target HP system is a highly beneficial feature for improving PvP quality in Metin2 private servers. When properly integrated, this system developed with C++ and Python significantly enhances user experience. Developers can build upon this system to add more advanced visual effects and user interface components.
 

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

Geri
Üst Alt