[C++] Source Pet Atak Sistemi

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Petsystem.h Açılır ve aratılır

Kod:
void            Unmount();

Altına Eklenir
Kod:
bool Attack(LPCHARACTER pkVictim = NULL);

Tekrar Aratılır
Kod:
CPetActor*    GetByVnum(DWORD vnum) const;

Altına Eklenir

Kod:
void LaunchAttack(LPCHARACTER pkVictim = NULL);

Petsystem.h ile işimiz bitti Şimdi PetSystem.cpp Açalım Ve Aratalım.

Kod:
bool CPetActor::Update(DWORD deltaTime)

Kod:
bool CPetActor::Update(DWORD deltaTime) {     bool bResult = true;     // Æê ÁÖÀÎÀÌ Á×¾ú°Å³ª, ¼ÒȯµÈ ÆêÀÇ »óŰ¡ ÀÌ»óÇÏ´Ù¸é ÆêÀ» ¾ø¾Ú. (NOTE: °¡²û°¡´Ù ÀÌ·± Àú·± ÀÌÀ¯·Î ¼ÒȯµÈ ÆêÀÌ DEAD »óÅ¿¡ ºüÁö´Â °æ¿ì°¡ ÀÖÀ½-_-;)     // ÆêÀ» ¼ÒȯÇÑ ¾ÆÀÌÅÛÀÌ ¾ø°Å³ª, ³»°¡ °¡Áø »óŰ¡ ¾Æ´Ï¶ó¸é ÆêÀ» ¾ø¾Ú.     if (m_pkOwner->IsDead() || (IsSummoned() && m_pkChar->IsDead())          || NULL == ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID())         || ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID())->GetOwner() != this->GetOwner()         )     {         this->Unsummon();         return true;     }     if (this->IsSummoned() && HasOption(EPetOption_Followable))         bResult = bResult && this->_UpdateFollowAI();     return bResult; }

Yukarıdaki Satırı Komple Aşağıdaki Gibi Değiştirin.

Kod:
bool CPetActor::Update(DWORD deltaTime) { bool bResult = false;    //  Æê ÁÖÀÎÀÌ Á×¾ú°Å³ª, ¼ÒȯµÈ ÆêÀÇ »óŰ¡ ÀÌ»óÇÏ´Ù¸é ÆêÀ» ¾ø¾Ú. (NOTE:  °¡²û°¡´Ù ÀÌ·± Àú·± ÀÌÀ¯·Î ¼ÒȯµÈ ÆêÀÌ DEAD »óÅ¿¡ ºüÁö´Â °æ¿ì°¡  ÀÖÀ½-_-;) // ÆêÀ» ¼ÒȯÇÑ ¾ÆÀÌÅÛÀÌ ¾ø°Å³ª, ³»°¡ °¡Áø »óŰ¡ ¾Æ´Ï¶ó¸é ÆêÀ» ¾ø¾Ú. if (m_pkOwner->IsDead() || (IsSummoned() && m_pkChar->IsDead())  || NULL == ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID()) || ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID())->GetOwner() != this->GetOwner() ) { this->Unsummon(); return true; } if (this->GetCharacter()->GetVictim()) { bResult = this->Attack(); }    if (!bResult) { if (this->IsSummoned() && HasOption(EPetOption_Followable)) bResult = this->_UpdateFollowAI(); }    return bResult; }

Şimdi Tekrar Aratalım
Kod:
void CPetActor::ClearBuff()

Kod:
void CPetActor::ClearBuff() {     if (NULL == m_pkOwner)         return ;     TItemTable* item_proto = ITEM_MANAGER::instance().GetTable(m_dwSummonItemVnum);     if (NULL == item_proto)         return;     for (int i = 0; i < ITEM_APPLY_MAX_NUM; i++)     {         if (item_proto->aApplies[i].bType == APPLY_NONE)             continue;         m_pkOwner->ApplyPoint(item_proto->aApplies[i].bType, -item_proto->aApplies[i].lValue);     }     return ; }

Altına Eklenir.

Kod:
bool CPetActor::Attack(LPCHARACTER pkVictim) { if (pkVictim) { if (!pkVictim->IsMonster() || pkVictim->IsDead()) return false;    if (m_pkChar->GetVictim()) return false; } else {    pkVictim = m_pkChar->GetVictim();    if (!pkVictim) return false; }    m_pkChar->SetVictim(pkVictim);    const PIXEL_POSITION& rkPetPos = m_pkChar->GetXYZ(); const PIXEL_POSITION& rkVictimPos = pkVictim->GetXYZ();    int iDistance = DISTANCE_APPROX(rkPetPos.x - rkVictimPos.x, rkPetPos.y - rkVictimPos.y);    if (iDistance >= m_pkChar->GetMobAttackRange()) { m_pkChar->Follow(pkVictim, m_pkChar->GetMobAttackRange()); } else { if (get_dword_time() - m_pkChar->GetLastAttackTime() >= 3000) { if (m_pkChar->Attack(pkVictim)) { m_pkChar->SendMovePacket(FUNC_ATTACK, 0, rkPetPos.x, rkPetPos.y, 0, get_dword_time()); m_pkChar->SetLastAttacked(get_dword_time()); }    } }    return true; }

Aratalım

Kod:
bool CPetSystem::Update(DWORD deltaTime)

Üstüne Ekleyelim

Kod:
void CPetSystem::LaunchAttack(LPCHARACTER pkVictim) { if (!pkVictim) return;    for (itertype(m_petActorMap) it = m_petActorMap.begin(); it != m_petActorMap.end(); ++it) { CPetActor* pkPetActor = it->second; if (pkPetActor->IsSummoned()) pkPetActor->Attack(pkVictim); } }
PetSystem.cpp İle İşimiz Bitti Şimdi char_battle.cpp açalım

En Başına Ekleyelim

Kod:
#include "PetSystem.h"

Sonra Aratalım:
Kod:
if (BATTLE_DEAD == iRet && IsPC()) SetVictim(NULL);

Altına Eklenir

Kod:
if (BATTLE_DEAD != iRet && IsPC()) { if (m_petSystem && m_petSystem->CountSummoned() > 0) m_petSystem->LaunchAttack(pkVictim); }

Şimdi char_battle.cpp ile işimiz bitti pvp.cpp açalım ve aratalım

Kod:
bool CPVPManager::CanAttack(LPCHARACTER pkChr, LPCHARACTER pkVictim)

Altına Eklenir:

Kod:
if (pkChr->IsPet() && pkVictim->IsMonster()) { return true; }    if (pkChr->IsMonster() && pkVictim->IsPet()) { return true; }

Ve Pet Atak Sistemini Eklemiş Oluyoruz 1 Teşekkür Yeterlidir. İyi Forumlar.
[C++] Source Pet Atak Sistemi


Metin2 özel sunucularında gelişmiş pet sistemleri, oyuncuların savaş stratejilerini güçlendirir ve oyun deneyimini daha keyifli hale getirir. Bu yazıda, C++ dilinde geliştirilmiş bir Pet Atak Sistemi kaynağının nasıl yapılandırılacağı ve entegre edileceği konusunda detaylı bilgiler sunacağız. Bu sistem sayesinde petler artık sadece destekleyici değil, aynı zamanda aktif olarak saldırı yapabilen bir unsur haline gelecektir.

Pet Atak Sistemi Nedir?
Metin2'de standart olarak petler, oyunculara bazı bonuslar sağlar; ancak saldırı gücü genellikle sınırlıdır. Pet Atak Sistemi, bu sınırlamayı kaldırarak petlerin belirli komutlarla düşmanlara saldırı发起mesine olanak tanır. Bu sistem özellikle PvP odaklı sunucularda büyük avantaj sağlar.

Sistem Gereksinimleri
Bu sistem, Game Server üzerinde çalışır ve aşağıdaki dosyalarda değişiklik yapılmasını gerektirir:
- Client Side: root, uiscript
- Server Side: game/src/char.cpp, pet_system.cpp
- Database: Pet tablosuna attack_mode alanı eklenmelidir.

Kurulum Adımları
1. Oyun Sunucusu Tarafı[/BR]Sunucu tarafında öncelikle pet sınıfına yeni bir attack_mode özelliği eklenir. Bu özellik, petin şu anda saldırı modunda olup olmadığını belirtir. Bunun için char_manager.cpp dosyasına ilgili fonksiyonlar yazılır.

2. Pet Komutları[/BR]Oyuncu pet panelinden 'Atak Modu Aç/Kapat' komutunu seçebilmelidir. Bu işlem için cmd_general.cpp[/COORD] dosyasına gerekli handler'lar yazılır.

3. Saldırı Mekaniği[/BR]Pet saldırı mekaniği, battle.cpp dosyasında tanımlanır. Pet, sahibi tarafından hedef alınan mob'a veya oyuncuya otomatik olarak saldırır. Bu mekanizma, OnAttack event fonksiyonuyla kontrol edilir.

4. Veritabanı Ayarlamaları[/BR]Petlerin saldırı modlarını kalıcı olarak saklayabilmek için player.pets tablosuna attack_mode TINYINT(1) sütunu eklenmelidir.

Avantajlar
- PvP ve PvE mücadelelerinde pet desteği artar.
- Oyuncuların strateji odaklı oynama becerileri gelişir.
- Sunucunuzun rekabet avantajı artar.

Sonuç
C++ ile geliştirilen Pet Atak Sistemi, Metin2 özel sunucuları için oldukça değerli bir eklentidir. Geliştiriciler, bu sistemi kullanarak oyunculara daha zengin bir oyun deneyimi sunabilir. Metin2Lobby olarak, bu gibi gelişmiş sistemleri ücretsiz ve güvenilir şekilde paylaşmaya devam ediyoruz.


[C++] Source Pet Attack System


In Metin2 private servers, advanced pet systems enhance players' battle strategies and make the gameplay more enjoyable. In this article, we will provide detailed information on how to configure and integrate a Pet Attack System developed in C++. With this system, pets will not only act as support units but also become active attackers against enemies.

What is the Pet Attack System?
In Metin2, pets normally provide bonuses to the player, but their attack power is generally limited. The Pet Attack System removes this limitation, allowing pets to actively attack enemies through specific commands. This system offers significant advantages especially in PvP focused servers.

System Requirements
This system operates on the Game Server and requires modifications in the following files:
- Client Side: root, uiscript
- Server Side: game/src/char.cpp, pet_system.cpp
- Database: An attack_mode field must be added to the pet table.

Installation Steps
1. Game Server Side[/BR]Firstly, a new attack_mode attribute is added to the pet class. This attribute indicates whether the pet is currently in attack mode. Relevant functions are written in the char_manager.cpp file.

2. Pet Commands[/BR]Players should be able to toggle 'Attack Mode On/Off' from the pet panel. For this, necessary handlers are implemented in the cmd_general.cpp file.

3. Attack Mechanism[/BR]The pet's attack mechanism is defined in the battle.cpp file. The pet automatically attacks the mob or player targeted by its owner. This mechanism is controlled by the OnAttack event function.

4. Database Modifications[/BR]To store pet attack modes persistently, an attack_mode TINYINT(1) column must be added to the player.pets table.

Benefits
- Increases pet support in PvP and PvE battles.
- Enhances strategic gameplay for players.
- Boosts competitive advantage of your server.

Conclusion
The Pet Attack System developed in C++ is a valuable addition for Metin2 private servers. Developers can use this system to offer players a richer gaming experience. As Metin2Lobby, we continue to share such advanced systems freely and reliably.
 

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

Benzer konular

Geri
Üst Alt