Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Feature] AutoMove Key
#1
Difficulty: 1/5 - Copy & Paste

This will make it so that if you press insert, you will automatically walk in that direction. To stop it you can either press any direction or insert again. This will also work in a map transition. Very basic. I also fixed a thing where if you are holding down a direction key and press insert and you let go of the direction it wont have an effect now. Try it out.

All client side.

Go into modGlobals and add this:
Code:
Public AutoMove As Boolean

Under:
Code:
Public ControlDown As Boolean

Replace the whole sub:
Code:
Sub CheckInput(ByVal KeyState As Byte, ByVal KeyCode As Integer, ByVal Shift As Integer)

With this:
Code:
Sub CheckInput(ByVal KeyState As Byte, ByVal KeyCode As Integer, ByVal Shift As Integer)
    If Not GettingMap Then
        If KeyState = 1 Then
            Select Case KeyCode
                
                Case vbKeyReturn
                    CheckMapGetItem
                    
                Case vbKeyControl
                    ControlDown = True
                    
                Case vbKeyShift
                    ShiftDown = True
                    
                Case vbKeyUp
                    DirDown = False
                    DirLeft = False
                    DirRight = False
                  
                    If AutoMove Then
                        DirUp = False
                        AutoMove = False
                    Else
                        DirUp = True
                    End If
                    
                Case vbKeyDown
                    DirUp = False
                    DirLeft = False
                    DirRight = False
                    
                    If AutoMove Then
                        DirDown = False
                        AutoMove = False
                    Else
                        DirDown = True
                    End If
                    
                Case vbKeyLeft
                    DirUp = False
                    DirDown = False
                    DirRight = False
                  
                    If AutoMove Then
                        DirLeft = False
                        AutoMove = False
                    Else
                        DirLeft = True
                    End If
                    
                Case vbKeyRight
                    DirUp = False
                    DirDown = False
                    DirLeft = False
                    
                    If AutoMove Then
                        DirRight = False
                        AutoMove = False
                    Else
                        DirRight = True
                    End If
                    
                Case vbKeyInsert
                    If Not AutoMove Then
                        AutoMove = True
                        
                        Select Case GetPlayerDir(MyIndex)
                        
                            Case DIR_UP
                                DirUp = True
                            
                            Case DIR_DOWN
                                DirDown = True
                            
                            Case DIR_LEFT
                                DirLeft = True
                            
                            Case DIR_RIGHT
                                DirRight = True
                        
                        End Select
                    Else
                        AutoMove = False
                        
                        Select Case GetPlayerDir(MyIndex)
                        
                            Case DIR_UP
                                DirUp = False
                                
                            Case DIR_DOWN
                                DirDown = False
                                
                            Case DIR_LEFT
                                DirLeft = False
                                
                            Case DIR_RIGHT
                                DirRight = False
                                
                        End Select
                        
            End Select
        Else
            Select Case KeyCode
                
                Case vbKeyUp
                    If Not AutoMove Then
                        DirUp = False
                    End If
                    
                Case vbKeyDown
                    If Not AutoMove Then
                        DirDown = False
                    End If
                    
                Case vbKeyLeft
                    If Not AutoMove Then
                        DirLeft = False
                    End If
                    
                Case vbKeyRight
                    If Not AutoMove Then
                        DirRight = False
                    End If
                    
                Case vbKeyShift
                    ShiftDown = False
                    
                Case vbKeyControl
                    ControlDown = False
                    
            End Select
        End If
    End If
End Sub

Go to:
Code:
Public Sub GameLoop()

and comment out:
Code:
If GetAsyncKeyState(VK_UP) >= 0 Then DirUp = False
            If GetAsyncKeyState(VK_DOWN) >= 0 Then DirDown = False
            If GetAsyncKeyState(VK_LEFT) >= 0 Then DirLeft = False
            If GetAsyncKeyState(VK_RIGHT) >= 0 Then DirRight = False

then go to:
Code:
Sub HandlePlayerData(ByRef Parse() As String)

and replace:
Code:
If i = MyIndex Then
         DirUp = False
         DirDown = False
         DirLeft = False
         DirRight = False
     End If

with:
Code:
If i = MyIndex Then
         If Not AutoMove Then
             DirUp = False
             DirDown = False
             DirLeft = False
             DirRight = False
         End If
     End If

and that's it. Tell me if I missed anything. Again, its very basic didn't want to go and make it real complicated.

Edit: Will optimize later on.
Reply
#2
Improved a little bit. Should work faster now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)