Sosyal açıldı! Bir göz at → Hemen gir →

ÇÖZÜLDÜ Pk bot spawn Max level kodu ekleme

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
Kullanılan Source
Istırap
Versiyon
2369
+pkbotspawn kodu ile bot atarken min level belirtebiliyoruz fakat max level belirtemiyoruz. src'de ilgili bölüme nasıl bir ekleme yapılmalı bunun için?

COMMAND_HANDLER(CUser::HandleBotSpawnPk)
{
if (!isGM())
return false;

if (vargs.size() < 5)
{
// send description
g_pMain->SendHelpDescription(this, "Using Sample : +pkbotspawn Count Minute MinLevel Nation Class");
return true;
}

int sTime = 0, sLevel = 0, sCount = 0, sNation = 0, sClass = 0;
sCount = atoi(vargs.front().c_str());
vargs.pop_front();
sTime = atoi(vargs.front().c_str());
vargs.pop_front();
sLevel = atoi(vargs.front().c_str());
vargs.pop_front();
sNation = atoi(vargs.front().c_str());
vargs.pop_front();
sClass = atoi(vargs.front().c_str());

if (sCount > 100)
sCount = 100;

for (int i = 0; i < sCount; i++)
{
float BonX = myrand(1, 15) * 1.0f;
float BonZ = myrand(1, 15) * 1.0f;
g_pMain->SpawnEventBotPk(sTime, GetZoneID(), GetX() + BonX, GetY(), GetZ() + BonZ, sLevel, sNation, sClass, this);
}
return true;
}
 

goksu516

Premium Üye
KAYIT
26 Eyl 2021
Mesajlar
790
Çözümler
12
Tepki puanı
167
C++:
COMMAND_HANDLER(CUser::HandleBotSpawnPk)
{
    if (!isGM())
        return false;

    if (vargs.size() < 6)
    {
        // send description
        g_pMain->SendHelpDescription(this, "Using Sample : +pkbotspawn Count Minute MinLevel MaxLevel Nation Class");
        return true;
    }

    int sTime = 0, sMinLevel = 0, sMaxLevel = 0, sCount = 0, sNation = 0, sClass = 0;

    sCount = atoi(vargs.front().c_str()); vargs.pop_front();
    sTime = atoi(vargs.front().c_str()); vargs.pop_front();
    sMinLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sMaxLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sNation = atoi(vargs.front().c_str()); vargs.pop_front();
    sClass = atoi(vargs.front().c_str()); vargs.pop_front();

    if (sCount > 100)
        sCount = 100;

    for (int i = 0; i < sCount; i++)
    {
        float BonX = myrand(1, 15) * 1.0f;
        float BonZ = myrand(1, 15) * 1.0f;

        g_pMain->SpawnEventBotPk(
            sTime,
            GetZoneID(),
            GetX() + BonX,
            GetY(),
            GetZ() + BonZ,
            sMinLevel,
            sMaxLevel,
            sNation,
            sClass,
            this
        );
    }
    return true;
}

Alttaki SpawnEventBotPk’nın içeriğinde de düzeltme yapman lazım

C++:
void CGameServerDlg::SpawnEventBotPk(int sTime, uint16 ZoneID, float fX, float fY, float fZ,
                                     int sMinLevel, int sMaxLevel, int sNation, int sClass, CUser* pUser)
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
C++:
COMMAND_HANDLER(CUser::HandleBotSpawnPk)
{
    if (!isGM())
        return false;

    if (vargs.size() < 6)
    {
        // send description
        g_pMain->SendHelpDescription(this, "Using Sample : +pkbotspawn Count Minute MinLevel MaxLevel Nation Class");
        return true;
    }

    int sTime = 0, sMinLevel = 0, sMaxLevel = 0, sCount = 0, sNation = 0, sClass = 0;

    sCount = atoi(vargs.front().c_str()); vargs.pop_front();
    sTime = atoi(vargs.front().c_str()); vargs.pop_front();
    sMinLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sMaxLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sNation = atoi(vargs.front().c_str()); vargs.pop_front();
    sClass = atoi(vargs.front().c_str()); vargs.pop_front();

    if (sCount > 100)
        sCount = 100;

    for (int i = 0; i < sCount; i++)
    {
        float BonX = myrand(1, 15) * 1.0f;
        float BonZ = myrand(1, 15) * 1.0f;

        g_pMain->SpawnEventBotPk(
            sTime,
            GetZoneID(),
            GetX() + BonX,
            GetY(),
            GetZ() + BonZ,
            sMinLevel,
            sMaxLevel,
            sNation,
            sClass,
            this
        );
    }
    return true;
}

Alttaki SpawnEventBotPk’nın içeriğinde de düzeltme yapman lazım

C++:
void CGameServerDlg::SpawnEventBotPk(int sTime, uint16 ZoneID, float fX, float fY, float fZ,
                                     int sMinLevel, int sMaxLevel, int sNation, int sClass, CUser* pUser)
Cevabın için çok teşekkür ederim hocam, BotChatSpawnHandler.cpp'nın yanı sıra GameServerDlg.h'ye de uygulamam lazım aynı şekilde değil mi
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
C++:
COMMAND_HANDLER(CUser::HandleBotSpawnPk)
{
    if (!isGM())
        return false;

    if (vargs.size() < 6)
    {
        // send description
        g_pMain->SendHelpDescription(this, "Using Sample : +pkbotspawn Count Minute MinLevel MaxLevel Nation Class");
        return true;
    }

    int sTime = 0, sMinLevel = 0, sMaxLevel = 0, sCount = 0, sNation = 0, sClass = 0;

    sCount = atoi(vargs.front().c_str()); vargs.pop_front();
    sTime = atoi(vargs.front().c_str()); vargs.pop_front();
    sMinLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sMaxLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sNation = atoi(vargs.front().c_str()); vargs.pop_front();
    sClass = atoi(vargs.front().c_str()); vargs.pop_front();

    if (sCount > 100)
        sCount = 100;

    for (int i = 0; i < sCount; i++)
    {
        float BonX = myrand(1, 15) * 1.0f;
        float BonZ = myrand(1, 15) * 1.0f;

        g_pMain->SpawnEventBotPk(
            sTime,
            GetZoneID(),
            GetX() + BonX,
            GetY(),
            GetZ() + BonZ,
            sMinLevel,
            sMaxLevel,
            sNation,
            sClass,
            this
        );
    }
    return true;
}

Alttaki SpawnEventBotPk’nın içeriğinde de düzeltme yapman lazım

C++:
void CGameServerDlg::SpawnEventBotPk(int sTime, uint16 ZoneID, float fX, float fY, float fZ,
                                     int sMinLevel, int sMaxLevel, int sNation, int sClass, CUser* pUser)
hocam 3 farklı yerde değişiklik yaptım ancak +pkbotspawn 20 9999 30 40 1 1 şeklinde yazsam da minimumu dikkate alıp maximumu dikkate almıyor 40 levelin üstü botlar atmaya devam ediyor

BotChatSpawnHandler.cpp içinde

Kod:
COMMAND_HANDLER(CUser::HandleBotSpawnPk)
{
    if (!isGM())
        return false;

    if (vargs.size() < 6)
    {
        // send description
        g_pMain->SendHelpDescription(this, "Using Sample : +pkbotspawn Count Minute MinLevel MaxLevel Nation Class");
        return true;
    }

    int sTime = 0, sMinLevel = 0, sMaxLevel = 0, sCount = 0, sNation = 0, sClass = 0;

    sCount = atoi(vargs.front().c_str()); vargs.pop_front();
    sTime = atoi(vargs.front().c_str()); vargs.pop_front();
    sMinLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sMaxLevel = atoi(vargs.front().c_str()); vargs.pop_front();
    sNation = atoi(vargs.front().c_str()); vargs.pop_front();
    sClass = atoi(vargs.front().c_str()); vargs.pop_front();

    if (sCount > 100)
        sCount = 100;

    for (int i = 0; i < sCount; i++)
    {
        float BonX = myrand(1, 15) * 1.0f;
        float BonZ = myrand(1, 15) * 1.0f;

        g_pMain->SpawnEventBotPk(
            sTime,
            GetZoneID(),
            GetX() + BonX,
            GetY(),
            GetZ() + BonZ,
            sMinLevel,
            sMaxLevel,
            sNation,
            sClass,
            this
        );
    }
    return true;
}

BotChatSpawnHandler.cpp içinde

Kod:
uint16 CGameServerDlg::SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ, uint8 minlevel, uint8 maxlevel, uint8 sNation, uint8 sClass, CUser* pUser)

GameServerDlg.h içinde

Kod:
uint16 SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ, uint8 minlevel, uint8 maxlevel, uint8 sNation, uint8 sClass, CUser* pUser = nullptr);
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
SpawnEventBotPk bu tanımlı olduğu kısmı da atar mısın
Yanlış yazdığım için olmadı sandım ama ondan değilmiş hocam atıyorum aşağıya
Kod:
uint16 CGameServerDlg::SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ, uint8 sMinLevel, uint8 sMaxLevel, uint8 sNation, uint8 sClass, CUser* pUser)
{
    if (pUser == nullptr)
        return true;

    m_ArtificialIntelligenceArray.m_lock.lock();
    auto m_sArtificialIntelligenceArray = m_ArtificialIntelligenceArray.m_UserTypeMap;
    m_ArtificialIntelligenceArray.m_lock.unlock();

    foreach(itr, m_sArtificialIntelligenceArray)
    {
        _BOT_DATA* pBotInfo = itr->second;
        if (pBotInfo == nullptr)
            continue;

        switch (byZone)
        {
        case ZONE_RONARK_LAND:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        case ZONE_ARDREAM:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        case ZONE_RONARK_LAND_BASE:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        default:
            continue;
            break;
        }

        if (pBotInfo->m_bLevel < sMinLevel
            || pBotInfo->m_bNation != sNation)
            continue;

        _ITEM_DATA* pItem = pBotInfo->GetItem(RIGHTHAND);
        if (pItem == nullptr)
            continue;

        _ITEM_TABLE pTable = GetItemPtr(pItem->nNum);
        if (pTable.isnull())
            continue;

        if (pTable.isShield()
            || pTable.isPickaxe()
            || pTable.isFishing())
            continue;

        if (sClass > 0 && sClass < 15)
        {
            if (sClass == 1 && !pBotInfo->isWarrior())
                continue;

            if (sClass == 2 && !pBotInfo->isRogue())
                continue;

            if (sClass == 3 && !pBotInfo->isMage())
                continue;

            if (sClass == 4 && !pBotInfo->isPriest())
                continue;

            if (sClass == 14 && !pBotInfo->isPortuKurian())
                continue;

            if (sClass > 4 && sClass < 14)
                continue;
        }
        else
            continue;

        // Check if bot already exist
        CBot* pBotCheck = GetBotPtr(pBotInfo->m_sSid);
        if (pBotCheck != nullptr)
            continue;

        CBot* pBot = new CBot();

        pBot->m_strUserID = pBotInfo->m_strUserID;
        pBot->m_bNation = pBotInfo->m_bNation;
        pBot->m_bRace = pBotInfo->m_bRace;
        pBot->m_sClass = pBotInfo->m_sClass;
        pBot->m_nHair = pBotInfo->m_nHair;
        pBot->m_bLevel = pBotInfo->m_bLevel;
        pBot->m_bFace = pBotInfo->m_bFace;
        pBot->m_bKnights = pBotInfo->m_bKnights;
        pBot->m_bFame = pBotInfo->m_bFame;

        memcpy(pBot->m_sItemArray, pBotInfo->m_sItemArray, sizeof(pBot->m_sItemArray));
        memcpy(pBot->m_bstrSkill, pBotInfo->m_bstrSkill, sizeof(pBot->m_bstrSkill));
        memcpy(pBot->m_bStats, pBotInfo->m_bStats, sizeof(pBot->m_bStats));

        pBot->m_sSid = pBotInfo->m_sSid;
        pBot->m_sAchieveCoverTitle = pBotInfo->m_sAchieveCoverTitle;
        pBot->m_reblvl = pBotInfo->m_reblvl;
        pBot->m_iGold = pBotInfo->m_iGold;
        pBot->m_sPoints = pBotInfo->m_sPoints;
        pBot->m_iLoyalty = pBotInfo->m_iLoyalty;
        pBot->m_iLoyaltyMonthly = pBotInfo->m_iLoyaltyMonthly;

        pBot->m_PlayerKillingLoyaltyDaily = 0;
        pBot->m_PlayerKillingLoyaltyPremiumBonus = 0;

        pBot->m_bMerchantState = MERCHANT_STATE_NONE;
        pBot->LastWarpTime = UNIXTIME + (Minute * MINUTE);
        pBot->m_pMap = GetZoneByID(byZone);
        pBot->m_bZone = byZone;
        pBot->m_sTargetID = int16(-1);
        pBot->m_TargetChanged = false;
        pBot->m_bBlockPrivateChat = false;
        pBot->m_BotState = BOT_MOVE;
        pBot->m_bPartyLeader = false;
        pBot->m_bGenieStatus = false;

        short sx, sz;
        pBot->GetStartPosition(sx, sz);
        fX = sx;
        fZ = sz;

        pBot->isReset(false);
        pBot->SetBotAbility();
        pBot->SetPosition(fX, fY, fZ);
        pBot->SetRegion(pBot->GetNewRegionX(), pBot->GetNewRegionZ());
        pBot->SetZoneAbilityChange(pBot->GetZoneID());
        pBot->StateChangeServerDirect(1, USER_STANDING);

        if (byZone == ZONE_RONARK_LAND
            || byZone == ZONE_RONARK_LAND_BASE
            || byZone == ZONE_ARDREAM)
        {
            C3DMap* pMap = g_pMain->GetZoneByID(byZone);
            if (pMap == nullptr)
                continue;

            TRACE("%s In the Game Insert Player Ranking ZoneID %d\n", pBot->GetName().c_str(), pBot->GetZoneID());
            pBot->AddBotRank(pMap);
        }

        AddMapBotList(pBot);
        pBot->UserInOut(INOUT_IN);
        return pBot->GetID();
    }
    return true;
}
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
Yanlış yazdığım için olmadı sandım ama ondan değilmiş hocam atıyorum aşağıya
Kod:
uint16 CGameServerDlg::SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ, uint8 sMinLevel, uint8 sMaxLevel, uint8 sNation, uint8 sClass, CUser* pUser)
{
    if (pUser == nullptr)
        return true;

    m_ArtificialIntelligenceArray.m_lock.lock();
    auto m_sArtificialIntelligenceArray = m_ArtificialIntelligenceArray.m_UserTypeMap;
    m_ArtificialIntelligenceArray.m_lock.unlock();

    foreach(itr, m_sArtificialIntelligenceArray)
    {
        _BOT_DATA* pBotInfo = itr->second;
        if (pBotInfo == nullptr)
            continue;

        switch (byZone)
        {
        case ZONE_RONARK_LAND:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        case ZONE_ARDREAM:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        case ZONE_RONARK_LAND_BASE:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        default:
            continue;
            break;
        }

        if (pBotInfo->m_bLevel < sMinLevel
            || pBotInfo->m_bNation != sNation)
            continue;

        _ITEM_DATA* pItem = pBotInfo->GetItem(RIGHTHAND);
        if (pItem == nullptr)
            continue;

        _ITEM_TABLE pTable = GetItemPtr(pItem->nNum);
        if (pTable.isnull())
            continue;

        if (pTable.isShield()
            || pTable.isPickaxe()
            || pTable.isFishing())
            continue;

        if (sClass > 0 && sClass < 15)
        {
            if (sClass == 1 && !pBotInfo->isWarrior())
                continue;

            if (sClass == 2 && !pBotInfo->isRogue())
                continue;

            if (sClass == 3 && !pBotInfo->isMage())
                continue;

            if (sClass == 4 && !pBotInfo->isPriest())
                continue;

            if (sClass == 14 && !pBotInfo->isPortuKurian())
                continue;

            if (sClass > 4 && sClass < 14)
                continue;
        }
        else
            continue;

        // Check if bot already exist
        CBot* pBotCheck = GetBotPtr(pBotInfo->m_sSid);
        if (pBotCheck != nullptr)
            continue;

        CBot* pBot = new CBot();

        pBot->m_strUserID = pBotInfo->m_strUserID;
        pBot->m_bNation = pBotInfo->m_bNation;
        pBot->m_bRace = pBotInfo->m_bRace;
        pBot->m_sClass = pBotInfo->m_sClass;
        pBot->m_nHair = pBotInfo->m_nHair;
        pBot->m_bLevel = pBotInfo->m_bLevel;
        pBot->m_bFace = pBotInfo->m_bFace;
        pBot->m_bKnights = pBotInfo->m_bKnights;
        pBot->m_bFame = pBotInfo->m_bFame;

        memcpy(pBot->m_sItemArray, pBotInfo->m_sItemArray, sizeof(pBot->m_sItemArray));
        memcpy(pBot->m_bstrSkill, pBotInfo->m_bstrSkill, sizeof(pBot->m_bstrSkill));
        memcpy(pBot->m_bStats, pBotInfo->m_bStats, sizeof(pBot->m_bStats));

        pBot->m_sSid = pBotInfo->m_sSid;
        pBot->m_sAchieveCoverTitle = pBotInfo->m_sAchieveCoverTitle;
        pBot->m_reblvl = pBotInfo->m_reblvl;
        pBot->m_iGold = pBotInfo->m_iGold;
        pBot->m_sPoints = pBotInfo->m_sPoints;
        pBot->m_iLoyalty = pBotInfo->m_iLoyalty;
        pBot->m_iLoyaltyMonthly = pBotInfo->m_iLoyaltyMonthly;

        pBot->m_PlayerKillingLoyaltyDaily = 0;
        pBot->m_PlayerKillingLoyaltyPremiumBonus = 0;

        pBot->m_bMerchantState = MERCHANT_STATE_NONE;
        pBot->LastWarpTime = UNIXTIME + (Minute * MINUTE);
        pBot->m_pMap = GetZoneByID(byZone);
        pBot->m_bZone = byZone;
        pBot->m_sTargetID = int16(-1);
        pBot->m_TargetChanged = false;
        pBot->m_bBlockPrivateChat = false;
        pBot->m_BotState = BOT_MOVE;
        pBot->m_bPartyLeader = false;
        pBot->m_bGenieStatus = false;

        short sx, sz;
        pBot->GetStartPosition(sx, sz);
        fX = sx;
        fZ = sz;

        pBot->isReset(false);
        pBot->SetBotAbility();
        pBot->SetPosition(fX, fY, fZ);
        pBot->SetRegion(pBot->GetNewRegionX(), pBot->GetNewRegionZ());
        pBot->SetZoneAbilityChange(pBot->GetZoneID());
        pBot->StateChangeServerDirect(1, USER_STANDING);

        if (byZone == ZONE_RONARK_LAND
            || byZone == ZONE_RONARK_LAND_BASE
            || byZone == ZONE_ARDREAM)
        {
            C3DMap* pMap = g_pMain->GetZoneByID(byZone);
            if (pMap == nullptr)
                continue;

            TRACE("%s In the Game Insert Player Ranking ZoneID %d\n", pBot->GetName().c_str(), pBot->GetZoneID());
            pBot->AddBotRank(pMap);
        }

        AddMapBotList(pBot);
        pBot->UserInOut(INOUT_IN);
        return pBot->GetID();
    }
    return true;
}
case ZONE_RONARK_LAND:
if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
|| pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
continue;
bu kısımdaki max level satırını ben ekledim oraya, en azından sql'den cz max level ayarı yapınca botspawn komutuna tanımlı maxlevel komutu olmasa da belirlediğim max levela göre atıyor, çözemezsek bu şekilde idare edeceğim artık
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
if (pBotInfo->m_bLevel < sMinLevel
|| pBotInfo->m_bNation != sNation)
continue;

bu kısmın altına şöyle birşey ekledim bir de böyle deneyeyim

if (pBotInfo->m_bLevel < sMinLevel
|| pBotInfo->m_bNation != sNation)
continue;

if (pBotInfo->m_bLevel > sMaxLevel
|| pBotInfo->m_bNation != sNation)
continue;
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
if (pBotInfo->m_bLevel < sMinLevel
|| pBotInfo->m_bNation != sNation)
continue;

bu kısmın altına şöyle birşey ekledim bir de böyle deneyeyim

if (pBotInfo->m_bLevel < sMinLevel
|| pBotInfo->m_bNation != sNation)
continue;

if (pBotInfo->m_bLevel > sMaxLevel
|| pBotInfo->m_bNation != sNation)
continue;
aynen hocam bu satırlar işimi gördü sorun çözüldü
 

goksu516

Premium Üye
KAYIT
26 Eyl 2021
Mesajlar
790
Çözümler
12
Tepki puanı
167
C++:
uint16 CGameServerDlg::SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ,
                                       uint8 sMinLevel, uint8 sMaxLevel, uint8 sNation, uint8 sClass, CUser* pUser)
{
    if (pUser == nullptr)
        return true;

    m_ArtificialIntelligenceArray.m_lock.lock();
    auto m_sArtificialIntelligenceArray = m_ArtificialIntelligenceArray.m_UserTypeMap;
    m_ArtificialIntelligenceArray.m_lock.unlock();

    foreach(itr, m_sArtificialIntelligenceArray)
    {
        _BOT_DATA* pBotInfo = itr->second;
        if (pBotInfo == nullptr)
            continue;

        switch (byZone)
        {
        case ZONE_RONARK_LAND:
        case ZONE_ARDREAM:
        case ZONE_RONARK_LAND_BASE:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        default:
            continue;
            break;
        }

        //  Min & Max Level kontrolü
        if (pBotInfo->m_bLevel < sMinLevel
            || pBotInfo->m_bLevel > sMaxLevel
            || pBotInfo->m_bNation != sNation)
            continue;

        _ITEM_DATA* pItem = pBotInfo->GetItem(RIGHTHAND);
        if (pItem == nullptr)
            continue;

        _ITEM_TABLE pTable = GetItemPtr(pItem->nNum);
        if (pTable.isnull())
            continue;

        if (pTable.isShield()
            || pTable.isPickaxe()
            || pTable.isFishing())
            continue;

        if (sClass > 0 && sClass < 15)
        {
            if (sClass == 1 && !pBotInfo->isWarrior())
                continue;

            if (sClass == 2 && !pBotInfo->isRogue())
                continue;

            if (sClass == 3 && !pBotInfo->isMage())
                continue;

            if (sClass == 4 && !pBotInfo->isPriest())
                continue;

            if (sClass == 14 && !pBotInfo->isPortuKurian())
                continue;

            if (sClass > 4 && sClass < 14)
                continue;
        }
        else
            continue;

        // Check if bot already exist
        CBot* pBotCheck = GetBotPtr(pBotInfo->m_sSid);
        if (pBotCheck != nullptr)
            continue;

        CBot* pBot = new CBot();

        pBot->m_strUserID = pBotInfo->m_strUserID;
        pBot->m_bNation = pBotInfo->m_bNation;
        pBot->m_bRace = pBotInfo->m_bRace;
        pBot->m_sClass = pBotInfo->m_sClass;
        pBot->m_nHair = pBotInfo->m_nHair;
        pBot->m_bLevel = pBotInfo->m_bLevel;
        pBot->m_bFace = pBotInfo->m_bFace;
        pBot->m_bKnights = pBotInfo->m_bKnights;
        pBot->m_bFame = pBotInfo->m_bFame;

        memcpy(pBot->m_sItemArray, pBotInfo->m_sItemArray, sizeof(pBot->m_sItemArray));
        memcpy(pBot->m_bstrSkill, pBotInfo->m_bstrSkill, sizeof(pBot->m_bstrSkill));
        memcpy(pBot->m_bStats, pBotInfo->m_bStats, sizeof(pBot->m_bStats));

        pBot->m_sSid = pBotInfo->m_sSid;
        pBot->m_sAchieveCoverTitle = pBotInfo->m_sAchieveCoverTitle;
        pBot->m_reblvl = pBotInfo->m_reblvl;
        pBot->m_iGold = pBotInfo->m_iGold;
        pBot->m_sPoints = pBotInfo->m_sPoints;
        pBot->m_iLoyalty = pBotInfo->m_iLoyalty;
        pBot->m_iLoyaltyMonthly = pBotInfo->m_iLoyaltyMonthly;

        pBot->m_PlayerKillingLoyaltyDaily = 0;
        pBot->m_PlayerKillingLoyaltyPremiumBonus = 0;

        pBot->m_bMerchantState = MERCHANT_STATE_NONE;
        pBot->LastWarpTime = UNIXTIME + (Minute * MINUTE);
        pBot->m_pMap = GetZoneByID(byZone);
        pBot->m_bZone = byZone;
        pBot->m_sTargetID = int16(-1);
        pBot->m_TargetChanged = false;
        pBot->m_bBlockPrivateChat = false;
        pBot->m_BotState = BOT_MOVE;
        pBot->m_bPartyLeader = false;
        pBot->m_bGenieStatus = false;

        short sx, sz;
        pBot->GetStartPosition(sx, sz);
        fX = sx;
        fZ = sz;

        pBot->isReset(false);
        pBot->SetBotAbility();
        pBot->SetPosition(fX, fY, fZ);
        pBot->SetRegion(pBot->GetNewRegionX(), pBot->GetNewRegionZ());
        pBot->SetZoneAbilityChange(pBot->GetZoneID());
        pBot->StateChangeServerDirect(1, USER_STANDING);

        if (byZone == ZONE_RONARK_LAND
            || byZone == ZONE_RONARK_LAND_BASE
            || byZone == ZONE_ARDREAM)
        {
            C3DMap* pMap = g_pMain->GetZoneByID(byZone);
            if (pMap == nullptr)
                continue;

            TRACE("%s In the Game Insert Player Ranking ZoneID %d\n", pBot->GetName().c_str(), pBot->GetZoneID());
            pBot->AddBotRank(pMap);
        }

        AddMapBotList(pBot);
        pBot->UserInOut(INOUT_IN);
        return pBot->GetID();
    }
    return true;
}

dene bakalım hocam
 

gorothred

KY Kıdemli Üye
KAYIT
8 Ağu 2022
Mesajlar
110
Çözümler
1
Tepki puanı
60
C++:
uint16 CGameServerDlg::SpawnEventBotPk(int Minute, uint8 byZone, float fX, float fY, float fZ,
                                       uint8 sMinLevel, uint8 sMaxLevel, uint8 sNation, uint8 sClass, CUser* pUser)
{
    if (pUser == nullptr)
        return true;

    m_ArtificialIntelligenceArray.m_lock.lock();
    auto m_sArtificialIntelligenceArray = m_ArtificialIntelligenceArray.m_UserTypeMap;
    m_ArtificialIntelligenceArray.m_lock.unlock();

    foreach(itr, m_sArtificialIntelligenceArray)
    {
        _BOT_DATA* pBotInfo = itr->second;
        if (pBotInfo == nullptr)
            continue;

        switch (byZone)
        {
        case ZONE_RONARK_LAND:
        case ZONE_ARDREAM:
        case ZONE_RONARK_LAND_BASE:
            if (pBotInfo->m_bLevel < pUser->GetMap()->GetMinLevelReq()
                || pBotInfo->m_bLevel > pUser->GetMap()->GetMaxLevelReq())
                continue;
            break;
        default:
            continue;
            break;
        }

        //  Min & Max Level kontrolü
        if (pBotInfo->m_bLevel < sMinLevel
            || pBotInfo->m_bLevel > sMaxLevel
            || pBotInfo->m_bNation != sNation)
            continue;

        _ITEM_DATA* pItem = pBotInfo->GetItem(RIGHTHAND);
        if (pItem == nullptr)
            continue;

        _ITEM_TABLE pTable = GetItemPtr(pItem->nNum);
        if (pTable.isnull())
            continue;

        if (pTable.isShield()
            || pTable.isPickaxe()
            || pTable.isFishing())
            continue;

        if (sClass > 0 && sClass < 15)
        {
            if (sClass == 1 && !pBotInfo->isWarrior())
                continue;

            if (sClass == 2 && !pBotInfo->isRogue())
                continue;

            if (sClass == 3 && !pBotInfo->isMage())
                continue;

            if (sClass == 4 && !pBotInfo->isPriest())
                continue;

            if (sClass == 14 && !pBotInfo->isPortuKurian())
                continue;

            if (sClass > 4 && sClass < 14)
                continue;
        }
        else
            continue;

        // Check if bot already exist
        CBot* pBotCheck = GetBotPtr(pBotInfo->m_sSid);
        if (pBotCheck != nullptr)
            continue;

        CBot* pBot = new CBot();

        pBot->m_strUserID = pBotInfo->m_strUserID;
        pBot->m_bNation = pBotInfo->m_bNation;
        pBot->m_bRace = pBotInfo->m_bRace;
        pBot->m_sClass = pBotInfo->m_sClass;
        pBot->m_nHair = pBotInfo->m_nHair;
        pBot->m_bLevel = pBotInfo->m_bLevel;
        pBot->m_bFace = pBotInfo->m_bFace;
        pBot->m_bKnights = pBotInfo->m_bKnights;
        pBot->m_bFame = pBotInfo->m_bFame;

        memcpy(pBot->m_sItemArray, pBotInfo->m_sItemArray, sizeof(pBot->m_sItemArray));
        memcpy(pBot->m_bstrSkill, pBotInfo->m_bstrSkill, sizeof(pBot->m_bstrSkill));
        memcpy(pBot->m_bStats, pBotInfo->m_bStats, sizeof(pBot->m_bStats));

        pBot->m_sSid = pBotInfo->m_sSid;
        pBot->m_sAchieveCoverTitle = pBotInfo->m_sAchieveCoverTitle;
        pBot->m_reblvl = pBotInfo->m_reblvl;
        pBot->m_iGold = pBotInfo->m_iGold;
        pBot->m_sPoints = pBotInfo->m_sPoints;
        pBot->m_iLoyalty = pBotInfo->m_iLoyalty;
        pBot->m_iLoyaltyMonthly = pBotInfo->m_iLoyaltyMonthly;

        pBot->m_PlayerKillingLoyaltyDaily = 0;
        pBot->m_PlayerKillingLoyaltyPremiumBonus = 0;

        pBot->m_bMerchantState = MERCHANT_STATE_NONE;
        pBot->LastWarpTime = UNIXTIME + (Minute * MINUTE);
        pBot->m_pMap = GetZoneByID(byZone);
        pBot->m_bZone = byZone;
        pBot->m_sTargetID = int16(-1);
        pBot->m_TargetChanged = false;
        pBot->m_bBlockPrivateChat = false;
        pBot->m_BotState = BOT_MOVE;
        pBot->m_bPartyLeader = false;
        pBot->m_bGenieStatus = false;

        short sx, sz;
        pBot->GetStartPosition(sx, sz);
        fX = sx;
        fZ = sz;

        pBot->isReset(false);
        pBot->SetBotAbility();
        pBot->SetPosition(fX, fY, fZ);
        pBot->SetRegion(pBot->GetNewRegionX(), pBot->GetNewRegionZ());
        pBot->SetZoneAbilityChange(pBot->GetZoneID());
        pBot->StateChangeServerDirect(1, USER_STANDING);

        if (byZone == ZONE_RONARK_LAND
            || byZone == ZONE_RONARK_LAND_BASE
            || byZone == ZONE_ARDREAM)
        {
            C3DMap* pMap = g_pMain->GetZoneByID(byZone);
            if (pMap == nullptr)
                continue;

            TRACE("%s In the Game Insert Player Ranking ZoneID %d\n", pBot->GetName().c_str(), pBot->GetZoneID());
            pBot->AddBotRank(pMap);
        }

        AddMapBotList(pBot);
        pBot->UserInOut(INOUT_IN);
        return pBot->GetID();
    }
    return true;
}

dene bakalım hocam
Sorun çözüldü hocam çok teşekkür ederim ilgin ve zamanın için
 
Anasayfa Kayıt ol Giriş yap
Üst Alt