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

Working with Auto-Attack (Complete)


Recommended Posts

**Sorry my english**

**Valentine**

I saw this tutorial originally posted here, he had a few bugs, was incomplete and only worked with npcs, so I completed.

**Deathbeam**

This tutorial will do the following: If you have target and faces the same, the player will automatically attack him to death.

**CLIENT SIDE**

**1 -** In **frmMain**, create in **picOptions**

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

**2 -** In **modGameLogic** find this:

```
Dim tmr10000 As Long
```

**3 -** Below add:

```
Dim x As Long, y As Long
```

**4 -** Now look for:

```
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
```

**5 -** Replace 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 myTargetType = TARGET_TYPE_NPC Then

If X = MapNpc(myTarget).X And y = MapNpc(myTarget).y Then ControlDown = True

ElseIf myTargetType = TARGET_TYPE_PLAYER Then

If X = Player(myTarget).X And y = Player(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

Call CheckMovement ' Check if player is trying to move

Call CheckAttack ' Check to see if player is trying to attack

End If

End If
```

**Credits:**

Deathbeam (As the original creator of the tutorial)

Valentine (By correcting some errors in the tutorial and post here)
Link to post
Share on other sites

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
×
×
  • Create New...