Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[FEATURE] Lock Movement on Tab
#1
Alright, so this is a pretty simple feature. It's basically like a Caps Lock, except instead of Caps, you run Tongue

Difficulty : 1 / 5

ModGlobals

In modGlobals, look for

Code:
' Game direction vars

And in that little section, add :
Code:
Public IsUserTabbed As Boolean
.

In modConstants, look for :
Code:
Public Const VK_CONTROL As Long = &H11

And under it add :
Code:
Public Const VK_TAB as long = &H9

Now, in modGameLogic, look for sub GameLoop. Add the following variable at the top, inside that sub :

Code:
Dim TabTimer as long

and then look for the following snippet :

Code:
If GetAsyncKeyState(VK_CONTROL) >= 0 Then
            If ControlDown = True Then
            ControlDown = False
            End If
        End If

and add this under :

Code:
If GetAsyncKeyState(VK_TAB)  0 Then
            If TabTimer + 1000 < GetTickCount Then
                IsUserTabbed = Not IsUserTabbed
                TabTimer = GetTickCount
            End If
        End If

Now, what this code does is, each time you press tab, it will turn the IsUserTabbed boolean on and off, so you just have to press it once and it'll turn on Smile. The reason for the TabTimer is because, with that function, it is processed very quickly, and if you hold tab it will mess up. You cannot do this with the CheckInput sub because the Tab key code is basically 'removed' by VB6 since you use tab to go through controls.

Now, in modGameLogic, look for sub CheckMovement. Now, look at the part that says :

Code:
' Check if player has the shift key down for running
            If ShiftDown Then
                Player(MyIndex).Moving = MOVING_RUNNING
            Else
                Player(MyIndex).Moving = MOVING_WALKING
            End If

And replace it with :

Code:
' Check if player has the shift key down for running
            If ShiftDown Or IsUserTabbed Then
                Player(MyIndex).Moving = MOVING_RUNNING
            Else
                Player(MyIndex).Moving = MOVING_WALKING
            End If

This will check whether you are pressing shift or you pressed tab to turn on the Auto-Run Smile And there you go, wasn't that simple? Big Grin
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)