Kod:
//service.h aç müsait bir yere ekle: #define ENABLE_DROP_GOLD // char_battle.cpp aç -> Arat: void CHARACTER::RewardGold(LPCHARACTER pkAttacker) // Komple kod bloğunu değiştir: void CHARACTER::RewardGold(LPCHARACTER pkAttacker) { // ADD_PREMIUM bool isAutoLoot = (pkAttacker->GetPremiumRemainSeconds(PREMIUM_AUTOLOOT) > 0 || pkAttacker->IsEquipUniqueGroup(UNIQUE_GROUP_AUTOLOOT)) ? true : false; // 제3의 손 // END_OF_ADD_PREMIUM PIXEL_POSITION pos; if (!isAutoLoot) if (!SECTREE_MANAGER::instance().GetMovablePosition(GetMapIndex(), GetX(), GetY(), pos)) return; int iTotalGold = 0; // // --------- 돈 드롭 확률 계산 ---------- // int iGoldPercent = MobRankStats[GetMobRank()].iGoldPercent; if (pkAttacker->IsPC()) iGoldPercent = iGoldPercent * (100 + CPrivManager::instance().GetPriv(pkAttacker, PRIV_GOLD_DROP)) / 100; if (pkAttacker->GetPoint(POINT_MALL_GOLDBONUS)) iGoldPercent += (iGoldPercent * pkAttacker->GetPoint(POINT_MALL_GOLDBONUS) / 100); iGoldPercent = iGoldPercent * CHARACTER_MANAGER::instance().GetMobGoldDropRate(pkAttacker) / 100; // ADD_PREMIUM if (pkAttacker->GetPremiumRemainSeconds(PREMIUM_GOLD) > 0 || pkAttacker->IsEquipUniqueGroup(UNIQUE_GROUP_LUCKY_GOLD)) iGoldPercent += iGoldPercent; // END_OF_ADD_PREMIUM if (iGoldPercent > 100) iGoldPercent = 100; int iPercent; if (GetMobRank() >= MOB_RANK_BOSS) iPercent = ((iGoldPercent * PERCENT_LVDELTA_BOSS(pkAttacker->GetLevel(), GetLevel())) / 100); else iPercent = ((iGoldPercent * PERCENT_LVDELTA(pkAttacker->GetLevel(), GetLevel())) / 100); //int iPercent = CALCULATE_VALUE_LVDELTA(pkAttacker->GetLevel(), GetLevel(), iGoldPercent); if (number(1, 100) > iPercent) return; int iGoldMultipler = GetGoldMultipler(); if (1 == number(1, 50000)) // 1/50000 확률로 돈이 10배 iGoldMultipler *= 10; else if (1 == number(1, 10000)) // 1/10000 확률로 돈이 5배 iGoldMultipler *= 5; // 개인 적용 if (pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS)) if (number(1, 100) <= pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS)) iGoldMultipler *= 2; // // --------- 돈 드롭 배수 결정 ---------- // if (test_server) pkAttacker->ChatPacket(CHAT_TYPE_PARTY, "gold_mul %d rate %d", iGoldMultipler, CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker)); // // --------- 실제 드롭 처리 ------------- // LPITEM item; int iGold10DropPct = 100; iGold10DropPct = (iGold10DropPct * 100) / (100 + CPrivManager::instance().GetPriv(pkAttacker, PRIV_GOLD10_DROP)); // MOB_RANK가 BOSS보다 높으면 무조건 돈폭탄 if (GetMobRank() >= MOB_RANK_BOSS && !IsStone() && GetMobTable().dwGoldMax != 0) { if (1 == number(1, iGold10DropPct)) iGoldMultipler *= 10; // 1% 확률로 돈 10배 int iSplitCount = number(25, 35); for (int i = 0; i < iSplitCount; ++i) { int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax) / iSplitCount; if (test_server) sys_log(0, "iGold %d", iGold); iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold *= iGoldMultipler; if (iGold == 0) { continue; } if (test_server) { sys_log(0, "Drop Moeny MobGoldAmountRate %d %d", CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker), iGoldMultipler); sys_log(0, "Drop Money gold %d GoldMin %d GoldMax %d", iGold, GetMobTable().dwGoldMax, GetMobTable().dwGoldMax); } // NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음 #ifdef ENABLE_DROP_GOLD pkAttacker->PointChange(POINT_GOLD, iGold, false); iTotalGold += iGold; // Total gold #else if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold))) { pos.x = GetX() + ((number(-14, 14) + number(-14, 14)) * 23); pos.y = GetY() + ((number(-14, 14) + number(-14, 14)) * 23); item->AddToGround(GetMapIndex(), pos); item->StartDestroyEvent(); iTotalGold += iGold; // Total gold } #endif } } // 1% 확률로 돈을 10개 떨어 뜨린다. (10배 드롭임) else if (1 == number(1, iGold10DropPct)) { // // 돈 폭탄식 드롭 // for (int i = 0; i < 10; ++i) { int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold *= iGoldMultipler; if (iGold == 0) { continue; } #ifdef ENABLE_DROP_GOLD pkAttacker->PointChange(POINT_GOLD, iGold, false); iTotalGold += iGold; // Total gold #else // NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음 if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold))) { pos.x = GetX() + (number(-7, 7) * 20); pos.y = GetY() + (number(-7, 7) * 20); item->AddToGround(GetMapIndex(), pos); item->StartDestroyEvent(); iTotalGold += iGold; // Total gold } #endif } } else { // // 일반적인 방식의 돈 드롭 // int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold *= iGoldMultipler; int iSplitCount; if (iGold >= 3 && !LC_IsYMIR()) iSplitCount = number(1, 3); else if (GetMobRank() >= MOB_RANK_BOSS) { iSplitCount = number(3, 10); if ((iGold / iSplitCount) == 0) iSplitCount = 1; } else iSplitCount = 1; if (iGold != 0) { iTotalGold += iGold; // Total gold for (int i = 0; i < iSplitCount; ++i) { if (isAutoLoot) { pkAttacker->GiveGold(iGold / iSplitCount); } #ifdef ENABLE_DROP_GOLD pkAttacker->PointChange(POINT_GOLD, iGold / iSplitCount, false); #else else if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold / iSplitCount))) { pos.x = GetX() + (number(-7, 7) * 20); pos.y = GetY() + (number(-7, 7) * 20); item->AddToGround(GetMapIndex(), pos); item->StartDestroyEvent(); } #endif } } } DBManager::instance().SendMoneyLog(MONEY_LOG_MONSTER, GetRaceNum(), iTotalGold); }
Artık kestiğiniz moblardan yanglar direk envanterinize eklenecektir.
Oto yang toplama sisteminiz varsa kaldırın. gerek kalmıyor.
Not: Alıntı değildir.
Metin2'de Görevden Arayüz Açma Rehberi
Metin2 özel sunucularında GUI açma işlemleri, oyuncu deneyimini zenginleştirmek için oldukça önemlidir. Özellikle görev (quest) tabanlı sistemlerde, belirli bir eylem tetiklenince arayüzün açılması gibi dinamik etkileşimler sağlanabilir. Bu rehberde, 'How To Open GUI from Quest' yani 'Görevden Arayüz Açma' konusunu detaylıca ele alacağız.
Öncelikle, Metin2 özel sunucu geliştirme sürecinde genellikle Python ve C++ dilleri kullanılır. Arayüz (GUI) tarafı genellikle Python ile PyUI veya UIScript ile oluşturulur. Görev sistemi ise hem Quest Editor[/CONDOR] üzerinden hem de Python kök dosyaları (py root) üzerinde değişiklik yapılarak geliştirilebilir.
1. Görev Tanımı Oluşturmak
Görevin çalıştırılacağı anı belirlemek gerekir. Örneğin, oyuncu belirli bir NPC ile konuşunca veya bir öğe kullandığında görev tetiklenebilir. Quest Editor veya doğrudan questlib.py dosyası üzerinden bir görev tanımlanabilir. Görevin sonunda, GUI'nin açılmasını sağlayacak komutu eklemek gerekecektir.
2. Python Tarafında GUI Sınıfı Oluşturmak
Metin2 özel sunucularda genellikle uiscript klasöründe özel arayüzler hazırlanır. Örneğin, bir ödül paneli veya özel menü açmak istiyorsanız, bunun için bir sınıf oluşturmanız gerekir. Bu sınıf genellikle wndMgr ve ui sınıflarını kullanır.
Aşağıdaki gibi basit bir GUI sınıfı örneği verebiliriz:
Kod:
[BR][/BR]import ui[BR][/BR]import wndMgr[BR][/BR][BR][/BR]class CustomWindow(ui.Window):[BR][/BR] def __init__(self):[BR][/BR] ui.Window.__init__(self)[BR][/BR] self.__CreateDialog()[BR][/BR][BR][/BR] def __CreateDialog(self):[BR][/BR] # Pencere bileşenleri burada tanımlanır[BR][/BR] pass[BR][/BR][BR][/BR] def Open(self):[BR][/BR] self.Show()[BR][/BR][BR][/BR] def Close(self):[BR][/BR] self.Hide()[BR][/BR]
3. Görev İçinden GUI Açmak
Quest dosyası içinde, belirli bir koşul sağlandığında yukarıdaki GUI sınıfını çağırmak için şu şekilde bir kod kullanılabilir:
Kod:
when 1000.click begin[BR][/BR] say('Arayüzü açmak ister misiniz?')[BR][/BR] if select('Evet', 'Hayır') == 0 then[BR][/BR] cmdchat('OpenCustomGUI')[BR][/BR] end[BR][/BR]end[BR][/BR]
Bu noktada, cmdchat komutu ile sunucuya özel bir mesaj gönderilir. Bu mesajı yakalamak için game/core tarafında bir fonksiyon yazmak gerekir.
4. Client Tarafında Komutu Yakalamak
Client tarafında, event.py veya net.py[/BR] gibi dosyalarda cmdchat mesajlarını dinleyen bir yapı kurulmalıdır. Mesaj geldiğinde, daha önce oluşturduğumuz GUI sınıfının Open() fonksiyonu çağrılır.
5. Paketleme ve Test Etme
Tüm bu değişiklikler yapıldıktan sonra, pack dosyaları güncellenmeli ve sunucu ile client yeniden derlenmelidir. Compile işlemi sırasında hata oluşmaması için tüm bağlantılar kontrol edilmelidir.
Sonuç
Metin2 özel sunucularında görev tabanlı GUI açma işlemleri, kullanıcı etkileşimini artıran önemli bir özelliktir. Martysama gibi geliştirici kaynakları da kullanarak, bu tür gelişmiş sistemleri kolayca entegre edebilirsiniz. Metin2Lobby olarak, Metin2 geliştirme dünyasında en kaliteli kaynakları sizler için derliyoruz.
How to Open GUI from Quest in Metin2
Opening GUIs in Metin2 private servers is essential for enhancing player interaction. In quest-based systems, dynamic interfaces can be triggered after specific events occur. This guide explains how to open a GUI from a quest in detail.
In Metin2 private server development, Python and C++ are commonly used. The GUI side is typically built using PyUI or UIScript. Quests can be created via Quest Editor or by modifying Python root files (py root).
1. Creating the Quest Definition
First, determine when the quest should trigger. For instance, it could activate when a player interacts with an NPC or uses an item. You can define the quest through Quest Editor or directly editing the questlib.py file. At the end of the quest, add a command to open the GUI.
2. Creating the GUI Class in Python
In Metin2 private servers, custom UIs are usually located in the uiscript folder. If you want to create a reward panel or a special menu, you need to define a class. It generally uses wndMgr and ui classes.
Here's a simple example of a GUI class:
Kod:
[BR][/BR]import ui[BR][/BR]import wndMgr[BR][/BR][BR][/BR]class CustomWindow(ui.Window):[BR][/BR] def __init__(self):[BR][/BR] ui.Window.__init__(self)[BR][/BR] self.__CreateDialog()[BR][/BR][BR][/BR] def __CreateDialog(self):[BR][/BR] # Window components are defined here[BR][/BR] pass[BR][/BR][BR][/BR] def Open(self):[BR][/BR] self.Show()[BR][/BR][BR][/BR] def Close(self):[BR][/BR] self.Hide()[BR][/BR]
3. Opening the GUI from the Quest
Inside the quest file, you can use code like this to call the GUI class when certain conditions are met:
Kod:
when 1000.click begin[BR][/BR] say('Do you wish to open the interface?')[BR][/BR] if select('Yes', 'No') == 0 then[BR][/BR] cmdchat('OpenCustomGUI')[BR][/BR] end[BR][/BR]end[BR][/BR]
At this point, a message is sent via cmdchat to the server. You'll need to implement a function on the game/core side to handle it.
4. Capturing the Command on the Client Side
On the client side, you must set up listeners in files such as event.py or net.py to catch the cmdchat message. When the message arrives, the Open() method of your GUI class will be called.
5. Packaging and Testing
After all changes, update the pack files and recompile both the server and client. Ensure that all connections are correct to avoid errors during the compile process.
Conclusion
Opening GUIs from quests in Metin2 private servers enhances user interaction significantly. With resources like Martysama, you can easily integrate advanced systems like these. As Metin2Lobby, we provide you with the highest quality resources in the Metin2 development scene.
