HomeUseful information for Helbreath beginnersStatistics overviewSearchMemberlistGalleryRulesRegisterLog in

 

 [CODE] Client-based Potion Use Delay

Go down 
2 posters
AuthorMessage
sleeq


sleeq

Silver 4
Over 12 posts and comments.

Likes : 3

[CODE] Client-based Potion Use Delay Empty
#1PostSubject: [CODE] Client-based Potion Use Delay   [CODE] Client-based Potion Use Delay 9991011/21/2019, 1:17 pm

Repost from old helbreath.online forum

Fixed use delay of potion (2 seconds) rather than before which was absolutely ping based. These simple codes kills the advantage for those low ping players in your server thus provide fairer gameplay for other high pingers.

I only did a minor test only but based on codes, they should work without problems. Have fun

Also, if you find 2 seconds is too long and you want to make it 0.5sec, change the 2000 to 500 and that is it.

Client SRC

Game.h

Find
Code:
class CGame
{
public:


Add
Code:
// sleeq - potion use delay
DWORD PotionUseDelay;


Game.cpp

Find in CGame::UpdateScreen_OnGame
Code:
m_dwFPStime = m_dwCheckConnTime = m_dwCheckSprTime = m_dwCheckChatTime = dwTime;


Add below
Code:
// sleeq - potion use delay
PotionUseDelay = dwTime;


Find in CGame::OnKeyUp
Code:
case VK_INSERT:
        if (m_iHP <= 0) return;
        if (m_bItemUsingStatus == TRUE)
        {    AddEventList(USE_RED_POTION1, 10);
            return;
        }
        if (m_bIsDialogEnabled[27] == TRUE)
        {    AddEventList(USE_RED_POTION2, 10);
            return;
        }
        for (i = 0; i < DEF_MAXITEMS; i++)
        if ( (m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) &&
             (m_pItemList[i]->m_sSprite == 6) && (m_pItemList[i]->m_sSpriteFrame == 1))
        {    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
            m_bIsItemDisabled[i] = TRUE;
            m_bItemUsingStatus = TRUE;
            return;
        }

        for (i = 0; i < DEF_MAXITEMS; i++)
        if ( (m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) &&
             (m_pItemList[i]->m_sSprite == 6) && (m_pItemList[i]->m_sSpriteFrame == 2))
        {    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
            m_bIsItemDisabled[i] = TRUE;
            m_bItemUsingStatus = TRUE;
            return;
        }
        break;

    case VK_DELETE:
        if (m_iHP <= 0) return;
        if (m_bItemUsingStatus == TRUE)
        {    AddEventList(USE_BLUE_POTION1, 10);
            return;
        }
        if (m_bIsDialogEnabled[27] == TRUE)
        {    AddEventList(USE_BLUE_POTION2, 10);
            return;
        }

        for (i = 0; i < DEF_MAXITEMS; i++)
        if ( (m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) &&
             (m_pItemList[i]->m_sSprite == 6) && (m_pItemList[i]->m_sSpriteFrame == 3))
        {    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
            m_bIsItemDisabled[i] = TRUE;
            m_bItemUsingStatus = TRUE;
            return;
        }

        for (i = 0; i < DEF_MAXITEMS; i++)
        if ( (m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) &&
             (m_pItemList[i]->m_sSprite == 6) && (m_pItemList[i]->m_sSpriteFrame == 4))
        {    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
            m_bIsItemDisabled[i] = TRUE;
            m_bItemUsingStatus = TRUE;
            return;
        }
        break;


Replace with this new one
Code:
case VK_INSERT:
        if (m_iHP <= 0) return;
        if (m_bItemUsingStatus == TRUE)
        {    AddEventList(USE_RED_POTION1, 10);
            return;
        }
        if (m_bIsDialogEnabled[27] == TRUE)
        {    AddEventList(USE_RED_POTION2, 10);
            return;
        }

        // sleeq - potion use delay
        for (i = 0; i < DEF_MAXITEMS; i++)
        if ((m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) && (m_pItemList[i]->m_sSprite == 6)) {
            if (m_pItemList[i]->m_sSpriteFrame == 1 || m_pItemList[i]->m_sSpriteFrame == 2) {
                if (dwTime - PotionUseDelay >= 2000) {
                    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
                    m_bIsItemDisabled[i] = TRUE;
                    m_bItemUsingStatus = TRUE;
                    PotionUseDelay = dwTime;
                    return;
                } else { AddEventList("You can only drink another potion after 2 seconds.", 10); return; }
            }
        }
        break;

    case VK_DELETE:
        if (m_iHP <= 0) return;
        if (m_bItemUsingStatus == TRUE)
        {    AddEventList(USE_BLUE_POTION1, 10);
            return;
        }
        if (m_bIsDialogEnabled[27] == TRUE)
        {    AddEventList(USE_BLUE_POTION2, 10);
            return;
        }

        // sleeq - potion use delay
        for (i = 0; i < DEF_MAXITEMS; i++)
        if ((m_pItemList[i] != NULL) && (m_bIsItemDisabled[i] != TRUE) && (m_pItemList[i]->m_sSprite == 6)) {
            if (m_pItemList[i]->m_sSpriteFrame == 3 || m_pItemList[i]->m_sSpriteFrame == 4) {
                if (dwTime - PotionUseDelay >= 2000) {
                    bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, i, NULL, NULL, NULL);
                    m_bIsItemDisabled[i] = TRUE;
                    m_bItemUsingStatus = TRUE;
                    PotionUseDelay = dwTime;
                    return;
                } else { AddEventList("You can only drink another potion after 2 seconds.", 10); return; }
            }
        }
        break;


Find in CGame::DlbBoxDoubleClick_Inventory
Code:
bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, cItemID, NULL, NULL, NULL);


Replace with this new one
Code:
                // sleeq - potion use delay
                if (m_pItemList[cItemID]->m_sSprite == 6) {
                    if (m_pItemList[cItemID]->m_sSpriteFrame >= 1 && m_pItemList[cItemID]->m_sSpriteFrame <= 4) {
                        if ((timeGetTime() - PotionUseDelay) <= 2000) {
                            AddEventList("You can only drink another potion after 2 seconds.", 10);
                            return;
                        } else {
                            PotionUseDelay = timeGetTime();
                            bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, cItemID, NULL, NULL, NULL);
                        }
                    }
                }
                bSendCommand(MSGID_COMMAND_COMMON, DEF_COMMONTYPE_REQ_USEITEM, NULL, cItemID, NULL, NULL, NULL);
Back to top Go down
GM4


GM4

Silver
Earned after your first post and comment.

Likes : 0

[CODE] Client-based Potion Use Delay Empty
#2PostSubject: Re: [CODE] Client-based Potion Use Delay   [CODE] Client-based Potion Use Delay 999104/26/2021, 9:28 pm

Hello can i contact you?
Back to top Go down
 
[CODE] Client-based Potion Use Delay
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Join Helbreath :: Development :: Code Posting-
Jump to: