[FIX] Cancel LogOut with Special Ability Actived

    Share
    avatar
    Magn0S[GM]
    Admin

    Number of posts : 177
    Registration date : 2008-01-29

    [FIX] Cancel LogOut with Special Ability Actived

    Post by Magn0S[GM] on Tue Jul 30, 2013 6:35 am

    Hi, well, how the title says, its a "fix" to people dont logout while is using any Special Ability, like when your enemy is using Merien Shield, and u lize him, then he just Log Out, and bye bye, u lost ur ek... Smile (Happens alot with me on Olympia... Very Happy )

    CLIENT SRC.

    Game.h - Add:
    Code:
    bool bSpecialAbilityActived;

    Game.cpp on:
    Code:
    CGame::CGame()

    add:
    Code:
    bSpecialAbilityActived = false;

    Game.cpp - Search:
    Code:
    #ifdef _DEBUG
                m_cLogOutCount = 1;
    #else
                m_cLogOutCount = 11;
    #endif

    And replace for:
    Code:
    #ifdef _DEBUG
                m_cLogOutCount = 1;
    #else
                if (bSpecialAbilityActived == true) {
                    AddEventList("You can't log out while Special Ability is actived", 10);
                    return;
                }
                else
                m_cLogOutCount = 11;
    #endif

    Search and replace the "case DEF_NOTIFY_SPECIALABILITYSTATUS:" for that one:
    Code:
    case DEF_NOTIFY_SPECIALABILITYSTATUS:
            cp = (char *)(pData    + DEF_INDEX2_MSGTYPE + 2);
            sp = (short *)cp;
            sV1 = *sp;
            cp += 2;
            sp = (short *)cp;
            sV2 = *sp;
            cp += 2;
            sp = (short *)cp;
            sV3 = *sp;
            cp += 2;
            if (sV1 == 1) // Use SA
            {    PlaySound('E', 35, 0);
                AddEventList(NOTIFY_MSG_HANDLER4, 10); // "Use special ability!"
                switch (sV2) {
                case 1: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER5,sV3); break;//"You are untouchable for %d seconds!"
                case 2: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER6, sV3); break;//"
                case 3: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER7, sV3); break;//"
                case 4: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER8, sV3); break;//"
                case 5: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER9, sV3); break;//"
                case 50:wsprintf(G_cTxt, NOTIFY_MSG_HANDLER10, sV3); break;//"
                case 51:wsprintf(G_cTxt, NOTIFY_MSG_HANDLER11, sV3); break;//"
                case 52:wsprintf(G_cTxt, NOTIFY_MSG_HANDLER12, sV3); break;//"
                case 55: // Spell effect
                    if (sV3 >90)
                        wsprintf(G_cTxt, "You cast a powerfull incantation, you can't use it again before %d minutes.", sV3/60);
                    else
                        wsprintf(G_cTxt, "You cast a powerfull incantation, you can't use it again before %d seconds.", sV3);
                    break;
                }
                AddEventList(G_cTxt, 10);
                bSpecialAbilityActived = true; // Magn0S:: Spec. Abili. actived
            }else if (sV1 == 2) // Finished using
            {    if (m_iSpecialAbilityType != (int)sV2)
                {    PlaySound('E', 34, 0);
                    AddEventList(NOTIFY_MSG_HANDLER13, 10);//"Special ability has been set!"
                    if (sV3 >= 60)
                    {    switch (sV2) {
                        case 1: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER14, sV3/60); AddEventList(G_cTxt, 10); break;//"Ability that decreases enemy's HP by 50%: Can use after %dMin"
                        case 2: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER15, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 3: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER16, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 4: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER17, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 5: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER18, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 50:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER19, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 51:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER20, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        case 52:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER21, sV3/60); AddEventList(G_cTxt, 10); break;//"
                        }
                    }else
                    {    switch (sV2) {
                        case 1: wsprintf(G_cTxt, NOTIFY_MSG_HANDLER22, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 2: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER23, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 3: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER24, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 4: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER25, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 5: wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER26, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 50:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER27, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 51:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER28, sV3); AddEventList(G_cTxt, 10); break;//"
                        case 52:wsprintf(G_cTxt,  NOTIFY_MSG_HANDLER29, sV3); AddEventList(G_cTxt, 10); break;//""Ability that makes character untouchable: Can use after %dSec"
                }    }    }
                m_iSpecialAbilityType = (int)sV2;
                m_dwSpecialAbilitySettingTime = dwTime;
                m_iSpecialAbilityTimeLeftSec  = (int)sV3;
            }else if (sV1 == 3)  // End of using time
            {    m_bIsSpecialAbilityEnabled = FALSE;
                m_dwSpecialAbilitySettingTime = dwTime;
                if (sV3 == 0)
                {    m_iSpecialAbilityTimeLeftSec  = 1200;
                    AddEventList(NOTIFY_MSG_HANDLER30, 10);//"Special ability has run out! Will be available in 20 minutes."
                    bSpecialAbilityActived = false; // Magn0S: Spec. Abi. not actived
                }else
                {    m_iSpecialAbilityTimeLeftSec  = (int)sV3;
                    if (sV3 >90)
                        wsprintf(G_cTxt, "Special ability has run out! Will be available in %d minutes." , sV3/60);
                    else wsprintf(G_cTxt, "Special ability has run out! Will be available in %d seconds." , sV3);
                    AddEventList(G_cTxt, 10);
                }
            }else if (sV1 == 4) // Unequiped the SA item
            {    AddEventList(NOTIFY_MSG_HANDLER31, 10);//"Special ability has been released."
                m_iSpecialAbilityType = 0;
            }else if (sV1 == 5) // Angel
            {    PlaySound('E', 52, 0); // Angel
            }
            break;

    In Wmain.cpp search for:
    Code:

    #ifdef _DEBUG
                if (G_pGame->m_cLogOutCount == -1 || G_pGame->m_cLogOutCount > 2) G_pGame->m_cLogOutCount = 1;
    #else
                if (G_pGame->m_cLogOutCount == -1 || G_pGame->m_cLogOutCount > 11) G_pGame->m_cLogOutCount = 11;
    #endif

    And replace for:
    Code:
    #ifdef _DEBUG
                if (G_pGame->m_cLogOutCount == -1 || G_pGame->m_cLogOutCount > 2) G_pGame->m_cLogOutCount = 1;
    #else
                if (G_pGame->bSpecialAbilityActived == true) {
                    G_pGame->AddEventList("You can't log out while Special Ability is actived", 10);
                    //Magn0S:: Provide people logout with alt+f4 with special abi. actived...
                }
                else {
                if (G_pGame->m_cLogOutCount == -1 || G_pGame->m_cLogOutCount > 11) G_pGame->m_cLogOutCount = 11;
                }
    #endif








    ~Magn0S
    avatar
    Magn0S[GM]
    Admin

    Number of posts : 177
    Registration date : 2008-01-29

    Re: [FIX] Cancel LogOut with Special Ability Actived

    Post by Magn0S[GM] on Wed Jul 31, 2013 8:38 am

    Srry, forget about Scrolls..

    Still in Client src, Game.cpp in function:
    Code:
    void CGame::DlbBoxDoubleClick_Inventory(short msX, short msY)

    Search for:
    Code:
    if (  (m_pItemList[cItemID]->m_cItemType == DEF_ITEMTYPE_USE_DEPLETE)
                    || (m_pItemList[cItemID]->m_cItemType == DEF_ITEMTYPE_USE_PERM)
                    || (m_pItemList[cItemID]->m_cItemType == DEF_ITEMTYPE_ARROW)
                    || (m_pItemList[cItemID]->m_cItemType == DEF_ITEMTYPE_EAT) )
                {    if (bCheckItemOperationEnabled(cItemID) == FALSE) return;
    ....

    Before it, ADD:
    Code:
    if ((m_pItemList[cItemID]->m_cItemType == DEF_ITEMTYPE_USE_DEPLETE) && (bSpecialAbilityActived == true)) {
                    AddEventList("You can't use any Scroll while Special Ability is actived.", 10); // Magn0S:: Prevent people to use scrolls/inv pots while spec. abi. active
                    return;
                }



    Obs: Ofc, if your server have summon guild player, it need to be added in ur code, nothing hard to do.

      Current date/time is Fri Nov 17, 2017 4:07 pm