[Python] Oyun Seçeneklerine Gece/Gündüz Ekle (M2-Hero)

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
M2-Hero'da Oyun Seçenekleri bölümünde Gece/Gündüz seçimi yapabileceğiniz alan bulunuyor.
Sizde aşağıdaki adımları uygulayarak bu seçeneği oyununuza ekleyebilirsiniz.

1) root/uigameoption.py aç VE ara:

Kod:
import interfaceModule

Altına ekle:

Kod:
import background

Ara :

Kod:
self.RefreshShowSalesText()

Altına ekle :

Kod:
self.RefreshShowNightText()

Ara :

Kod:
self.showsalesTextButtonList = [*]

Altına ekle :

Kod:
self.showNightButtonList = [*]

Ara :

Kod:
self.showsalesTextButtonList.append(GetObject("salestext_on_button"))             self.showsalesTextButtonList.append(GetObject("salestext_off_button"))

Altına ekle :

Kod:
self.showNightButtonList.append(GetObject("showNight_on_button"))             self.showNightButtonList.append(GetObject("showNight_off_button"))

Ara :

Kod:
self.showsalesTextButtonList[0].SAFE_SetEvent(self.__OnClickSalesTextOnButton)         self.showsalesTextButtonList[1].SAFE_SetEvent(self.__OnClickSalesTextOffButton)

Altına ekle :

Kod:
self.showNightButtonList[0].SAFE_SetEvent(self.__OnClickShowNightOnButton)         self.showNightButtonList[1].SAFE_SetEvent(self.__OnClickShowNightOffButton)

Ara :

Kod:
def __OnClickSalesTextOnButton(self):         systemSetting.SetShowSalesTextFlag(TRUE)         self.RefreshShowSalesText()         uiPrivateShopBuilder.UpdateADBoard()              def __OnClickSalesTextOffButton(self):         systemSetting.SetShowSalesTextFlag(FALSE)         self.RefreshShowSalesText()

Altına ekle :

Kod:
def __OnClickShowNightOnButton(self):         background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)         background.SetEnvironmentData(1)         constInfo.Night = 1         self.RefreshShowNightText()     def __OnClickShowNightOffButton(self):         background.SetEnvironmentData(0)         constInfo.Night = 0         self.RefreshShowNightText()

Ara :

Kod:
def RefreshShowSalesText(self):         if systemSetting.IsShowSalesText():             self.showsalesTextButtonList[0].Down()             self.showsalesTextButtonList[1].SetUp()         else:             self.showsalesTextButtonList[0].SetUp()             self.showsalesTextButtonList[1].Down()

Altına ekle :

Kod:
def RefreshShowNightText(self):         if constInfo.Night == 1:             self.showNightButtonList[0].Down()             self.showNightButtonList[1].SetUp()         else:             self.showNightButtonList[0].SetUp()             self.showNightButtonList[1].Down()

2) root/constInfo.py aç ve ara :

Kod:
ENVIRONMENT_NIGHT="d:/ymir work/environment/moonlight04.msenv"

altına ekle :

Kod:
Night = 0

03) uiscript/gameoptiondialog.py aç VE başlangıçta yazan kısmı bununla değiştir :

Kod:
TEMPORARY_X = +14 BUTTON_TEMPORARY_X = 5 PVP_X = -10 LINE_LABEL_X     = 30 LINE_DATA_X     = 90 LINE_STEP    = 0 SMALL_BUTTON_WIDTH     = 45 MIDDLE_BUTTON_WIDTH     = 65

Ara :

Kod:
26*11+8, or 25*11+8,

Değiştir :

Kod:
28*11+8,

Ve bunu dosyada herhangi bir kod bloğunun altına ekleyin :

Kod:
{                     "name" : "showNight_on_off",                     "type" : "text",                     "x" : LINE_LABEL_X,                     "y" : 265+2,                     "text" : "Hava Ayarı",                 },                 {                     "name" : "showNight_on_button",                     "type" : "radio_button",                     "x" : LINE_DATA_X,                     "y"    : 265,                     "text" : "Gece",                     "default_image" : ROOT_PATH + "middle_button_01.sub",                     "over_image" : ROOT_PATH + "middle_button_02.sub",                     "down_image" : ROOT_PATH + "middle_button_03.sub",                 },                 {                     "name" : "showNight_off_button",                     "type" : "radio_button",                     "x" : LINE_DATA_X+MIDDLE_BUTTON_WIDTH,                     "y" : 265,                     "text" : "Gündüz",                     "default_image" : ROOT_PATH + "middle_button_01.sub",                     "over_image" : ROOT_PATH + "middle_button_02.sub",                     "down_image" : ROOT_PATH + "middle_button_03.sub",                 },

4) Oyuna girip deneyebilirsiniz. Eğer sorun çıkarsa, konu altından yazın.

Resimler:

- Gece seçeneği
- Gündüz seçeneği.

Çalıştığına dair kanıt ve önemli not:



Dediği gibi tab ayarını, ekrandaki koordinatını siz kendi oyununuza göre ayarlamalısınız. Oyun Seçeneklerinde yer alan son seçeneğin koordinatlarını esas alarak yapabilirsiniz.
Metin2 Oyunlarında Gece/Gündüz Sistemi Ekleme Rehberi (Python)
Metin2 özel sunucularında oyun deneyimini artırmak için birçok geliştirici, oyun içi dinamik sistemler eklemeyi tercih eder. Bu sistemlerden birisi de gece/gündüz döngüsüdür. Bu yazıda, M2-Hero veya benzeri bir Metin2 özel sunucu yapısında, oyun içi zamanı gün ışığına ve geceye göre ayarlayan bir Python tabanlı sistem nasıl uygulanır, onu inceleyeceğiz. Bu sistem, oyuncuların oyun içi atmosferi daha keyifli hale getirir ve sunucunuzun diğerlerinden ayrışmasını sağlar.

Gece/Gündüz Sisteminin Avantajları
Gece/gündüz sistemi, Metin2 gibi MMORPG oyunlarında görsel atmosferin değişmesini sağlar. Özellikle PvP sunucularında bu sistem, belirli zaman dilimlerinde farklı olayların tetiklenmesini sağlayabilir. Örneğin gece saatlerinde daha fazla canavar doğabilir veya belirli item düşüş oranları değişebilir. Bu sayede hem oyun içi dengeler hem de oyuncu etkileşimi artırılır. Bu sistemin arkasında genellikle bir zamanlayıcı ve oyun içi zamanı takip eden bir Python scripti yatar.

Python Script ile Zaman Ayarı
Metin2 özel sunucularında, oyun içi zamanı kontrol etmek için genellikle game core üzerinde değişiklik yapılır. Bu değişiklikler, genellikle Py Root dizinindeki dosyalarda yer alır. Bir Python scripti, sunucu saatinin oyun içinde gün ışığına göre değişmesini sağlar. Bu script, oyun içindeki zamanı gerçek zamana göre senkronize edebilir veya tamamen bağımsız bir döngüyle çalışabilir. Örneğin:

örnek_gece_gunduz.py
Kod:
[B]import time[BR][/BR]def gun_ayari():[BR][/BR]    saat = int(time.strftime('%H'))[BR][/BR]    if 6 <= saat < 18:[BR][/BR]        return 'gunduz'[BR][/BR]    else:[BR][/BR]        return 'gece'[/B]


Bu script, oyun içi zamanı sistem saatiyle karşılaştırarak gün veya gece modunu belirler. Daha sonra bu bilgi sunucu tarafında render edilerek oyun istemcisi tarafından işlenebilir.

UYARI: Bu sistem, doğru yapılandırılmazsa sunucu performansını etkileyebilir. Özellikle yoğun saatlerde zamanlayıcıların çok sık çalıştırılması, gecikmelere neden olabilir. Bu yüzden zamanlayıcılar uygun aralıklarla ayarlanmalıdır.

Oyun Seçeneklerine Entegrasyon
Metin2 istemcisi, oyuncuların grafik ayarlarını değiştirebildiği bir menüye sahiptir. Bu menüye bir gece/gündüz seçeneği eklemek için UIscript dosyalarında değişiklik yapılması gerekir. Bu işlem genellikle client src klasöründe yapılır. Oyuncu, bu menüden gece/gündüz efektlerini açıp kapatabilir. Bu, özellikle bazı oyuncuların göz sağlığı için önemlidir. Bu tür ayarlamalar, kullanıcı dostu bir arayüz sunar ve sunucu sadakatini artırır.

Python GUI Kullanımı
Eğer daha gelişmiş bir arayüz oluşturmak istiyorsanız, py GUI kütüphaneleri kullanarak bir ayar paneli tasarlayabilirsiniz. Bu panel üzerinden oyuncular, gece/gündüz oranlarını, efektlerin yoğunluğunu ve hatta sistemin aktif olup olmadığını değiştirebilirler. Bu tür gelişmiş sistemler, martysama gibi deneyimli geliştiriciler tarafından sıkça kullanılır.

Sonuç
Gece/gündüz sistemi, Metin2 özel sunucularında oyun atmosferini ciddi anlamda geliştiren bir özelliktir. Doğru uygulandığında, oyuncuların uzun süre oyunda kalmasını sağlar. Bu sistemi Python tabanlı olarak entegre etmek, hem esneklik hem de performans açısından avantaj sağlar. Sunucunuzda bu sistemi etkinleştirmek için game server programming bilginizi kullanmanız yeterlidir. Dilerseniz source edit veya C++ system bilgilerinizi de entegre edebilirsiniz.


Adding Day/Night Cycle to Game Options in Metin2 (Python)
In order to enhance the gaming experience on Metin2 private servers, many developers choose to implement dynamic in-game systems. One such system is the day/night cycle. In this article, we will explore how to implement a day/night cycle system using Python within a Metin2 private server structure like M2-Hero. This system makes the in-game atmosphere more enjoyable for players and helps your server stand out from others.

Benefits of the Day/Night System
The day/night system allows the visual environment in games like Metin2 to change dynamically. Especially in PvP servers, this system can trigger special events during certain times of the day. For example, monsters may spawn more frequently at night, or specific item drop rates may increase. This increases both in-game balance and player engagement. Behind this system usually lies a timer and a Python script that tracks in-game time.

Time Control with Python Script
In Metin2 private servers, controlling in-game time typically requires modifications to the game core. These changes are often located in files under the Py Root directory. A Python script can control how daylight changes in the game based on the system time. The script can either sync the in-game time with real-world time or run independently on its own loop. For example:

sample_day_night.py
Kod:
[B]import time[BR][/BR]def set_time():[BR][/BR]    hour = int(time.strftime('%H'))[BR][/BR]    if 6 <= hour < 18:[BR][/BR]        return 'day'[BR][/BR]    else:[BR][/BR]        return 'night'[/B]


This script determines whether it is day or night by comparing in-game time to the system clock. Then, this information can be rendered server-side and processed by the client.

WARNING: If not configured properly, this system can affect server performance. Especially during peak hours, frequent execution of timers could cause delays. Therefore, timers should be set to appropriate intervals.

Integration into Game Options
The Metin2 client includes a menu where players can adjust graphic settings. To add a day/night option, you need to modify the UIscript files, which are typically located in the client src folder. Players can then toggle day/night effects on or off through this menu. This is especially important for some players’ eye comfort. Such adjustments provide a user-friendly interface and increase server loyalty.

Using Python GUI
If you want to build a more advanced UI, you can use py GUI libraries to design a settings panel. From this panel, players can adjust day/night ratios, the intensity of effects, or even toggle the system on/off. Such advanced systems are commonly used by experienced developers like martysama.

Conclusion
The day/night cycle is a feature that significantly enhances the in-game atmosphere of Metin2 private servers. When implemented correctly, it encourages players to stay longer in the game. Integrating this system using Python offers both flexibility and performance advantages. You can use your game server programming knowledge to activate this system on your server. If desired, you can also integrate your source edit or C++ system skills.
 

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

Benzer konular

Geri
Üst Alt