Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Working Auto-Attack


tslusny
 Share

Recommended Posts

Thx to Zopto for his [base AutoAttack system](http://www.touchofdeathforums.com/smf2/index.php/topic,80725.msg864206.html#new)

So this tutorial will make this: If you have target then if you are facing NPC you will autoattack that NPC.

CLIENT SIDE

In **frmMain** in **picOptions** create

> **Checkbox**
> **Name**: chkAutoAttack
> **Caption**: Auto attack

Then in **mod GameLogic** find this:
```
If CanMoveNow Then
                Call CheckMovement ' Check if player is trying to move
                Call CheckAttack  ' Check to see if player is trying to attack
            End If
```Replace it with this:
```
If frmMain.chkAutoAttack.Value = YES Then
        If CanMoveNow Then
                Select Case Player(MyIndex).Dir
                    Case DIR_UP
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) - 1
                    Case DIR_DOWN
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) + 1
                    Case DIR_LEFT
                        x = GetPlayerX(MyIndex) - 1
                        Y = GetPlayerY(MyIndex)
                    Case DIR_RIGHT
                        x = GetPlayerX(MyIndex) + 1
                        Y = GetPlayerY(MyIndex)
                End Select
                If myTarget > 0 Then
                    If x = MapNpc(myTarget).x And Y = MapNpc(myTarget).Y Then ControlDown = True
                End If
                Call checkmovement ' Check if player is trying to move
                Call CheckAttack  ' Check to see if player is trying to attack
            End If
      else
            If CanMoveNow Then
                Select Case Player(MyIndex).Dir
                    Case DIR_UP
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) - 1
                    Case DIR_DOWN
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) + 1
                    Case DIR_LEFT
                        x = GetPlayerX(MyIndex) - 1
                        Y = GetPlayerY(MyIndex)
                    Case DIR_RIGHT
                        x = GetPlayerX(MyIndex) + 1
                        Y = GetPlayerY(MyIndex)
                End Select
                Call checkmovement
        End If

```
Link to comment
Share on other sites

```
    If frmMain.chkAutoAttack.Value = YES Then
            If CanMoveNow Then
                Select Case Player(MyIndex).dir
                    Case DIR_UP
                        X = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) - 1
                    Case DIR_DOWN
                        X = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) + 1
                    Case DIR_LEFT
                        X = GetPlayerX(MyIndex) - 1
                        Y = GetPlayerY(MyIndex)
                    Case DIR_RIGHT
                        X = GetPlayerX(MyIndex) + 1
                        Y = GetPlayerY(MyIndex)
                End Select
                If myTarget > 0 Then
                    If X = MapNpc(myTarget).X And Y = MapNpc(myTarget).Y Then ControlDown = True
                End If
                Call CheckMovement ' Check if player is trying to move
                Call CheckAttack  ' Check to see if player is trying to attack
            End If
    End If
```
Changing it to

```
  If frmMain.chkAutoAttack.Value = YES Then

        If CanMoveNow Then
                Select Case Player(MyIndex).Dir
                    Case DIR_UP
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) - 1
                    Case DIR_DOWN
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) + 1
                    Case DIR_LEFT
                        x = GetPlayerX(MyIndex) - 1
                        Y = GetPlayerY(MyIndex)
                    Case DIR_RIGHT
                        x = GetPlayerX(MyIndex) + 1
                        Y = GetPlayerY(MyIndex)
                End Select
                If myTarget > 0 Then
                    If x = MapNpc(myTarget).x And Y = MapNpc(myTarget).Y Then ControlDown = True
                End If
                Call checkmovement ' Check if player is trying to move
                Call CheckAttack  ' Check to see if player is trying to attack
            End If

      else
            If CanMoveNow Then
                Select Case Player(MyIndex).Dir
                    Case DIR_UP
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) - 1
                    Case DIR_DOWN
                        x = GetPlayerX(MyIndex)
                        Y = GetPlayerY(MyIndex) + 1
                    Case DIR_LEFT
                        x = GetPlayerX(MyIndex) - 1
                        Y = GetPlayerY(MyIndex)
                    Case DIR_RIGHT
                        x = GetPlayerX(MyIndex) + 1
                        Y = GetPlayerY(MyIndex)
                End Select
                Call checkmovement
        End If

```
Should work, although i couldn't test as i don't have VB6 where i am at the moment.
Link to comment
Share on other sites

  • 4 weeks later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...