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

[EO2.0]NPC attack speed


Boynaar44
 Share

Recommended Posts

Hello guys,

This is requested by Zzbrandon, very nicely so I couldn't say no ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)

As the title says, you will be able to customize the attack speed of the NPC after this tutorial.

At least, there is still the random and protection system running, so don't expect to get an attack 10 times each second.

I have seen a tutorial for custom NPC movement speed by Growlith1223 where he used the variable name "Speed", so we will be using "AttackSpeed" in case you have both.

We start adding a Scrollbar and a Label in the frmEditor_NPC.

Name them as following.

_Label –>_ **lblAttackSpeed**

_Scrollbar_ –> **scrlAttackSpeed**

Change the following values of the property variables for **scrlAttackSpeed** to the values next to them.

_Max_ –> **30000**

_Min_ –> **100**

_LargeChange_ –> **100**

Now add the following variable to the **Type NpcRec** inside the **modTypes**, **Server and Client side.**

```

AttackSpeed As Integer

```

Go back to the Client.

Double click the **scrlAttackSpeed** and you should end up on the sub **scrlAttackSpeed_Change**.

There add the following code.

```

Dim intSpeed As Integer

Dim dblValue As Double

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

intSpeed = scrlAttackSpeed.Value

Npc(EditorIndex).AttackSpeed = intSpeed

If intSpeed >= 100 And intSpeed <= 1000 Then

dblValue = Round(1000 / intSpeed, 3)

lblAttackSpeed.Caption = "Attack speed: " & dblValue & " attack(s) per 1 second."

ElseIf intSpeed > 1000 Then

dblValue = intSpeed / 1000

lblAttackSpeed.Caption = "Attack speed: 1 attack per " & dblValue & " second(s)."

Else

' lblAttackSpeed.Caption = "Attack speed: " & intSpeed

End If

' Error handler

Exit Sub

errorhandler:

HandleError "scrlAttackSpeed_Change", "frmEditor_NPC", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Go to the sub **NpcEditorInit** inside **modGameEditors**.

**Add** there **inside** the **with-statement** the following line.

```

If Npc(EditorIndex).AttackSpeed >= .scrlAttackSpeed.Min And Npc(EditorIndex).AttackSpeed <= .scrlAttackSpeed.Max Then

.scrlAttackSpeed.Value = Npc(EditorIndex).AttackSpeed

End if

```

Now the easier part.

Find and **remove** the following line from the sub **BltNpc** inside your **modDirectDraw7**.

```

AttackSpeed = 1000

```

Place instead of it the following.

```

If Npc(MapNpc(MapNpcNum).num).AttackSpeed > 0 Then

AttackSpeed = Npc(MapNpc(MapNpcNum).num).AttackSpeed

Else

AttackSpeed = 1000

End If

```

Now we go **Server side**.

Find the following if-statement and **remove** it from your **CanNpcAttackPlayer** sub inside **modCombat**.

```

' Make sure npcs dont attack more then once a second

If GetTickCount < MapNpc(mapNum).Npc(mapNpcNum).AttackTimer + 1000 Then

Exit Function

End If

```

Now place instead of it the following.

```

If Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).AttackSpeed > 0 Then

If GetTickCount < MapNpc(mapNum).Npc(mapNpcNum).AttackTimer + Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).AttackSpeed Then

Exit Function

End If

Else

If GetTickCount < MapNpc(mapNum).Npc(mapNpcNum).AttackTimer + 1000 Then

Exit Function

End If

End If

```

That's all I believe…

[edit]I am sorry the code is not oriented, that's because of too many edits..[/edit]
Link to comment
Share on other sites

  • 4 weeks later...
What do i put in a Dx8 version where the tutorial says:

> Now the easier part.
>
> Find and **remove** the following line from the sub **BltNpc** inside your **modDirectDraw7**.
>
> AttackSpeed = 1000
>
> Place instead of it the following.
>
> If Npc(MapNpc(MapNpcNum).num).AttackSpeed > 0 Then
>
> AttackSpeed = Npc(MapNpc(MapNpcNum).num).AttackSpeed
>
> Else
>
> AttackSpeed = 1000
>
> End If
Link to comment
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
 Share

×
×
  • Create New...