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

[EO] Npc movement speed in NPC editor


Kay-No
 Share

Recommended Posts

Hello, i've been checking around in the source and saw that there was  player movement constants that changed the movement speed of the character.
```
' Speed moving vars
Public Const WALK_SPEED As Byte = 4
Public Const RUN_SPEED As Byte = 6
```

While i think that the NPC as it is now, is to easy to kite around and not getting hit because of their slow movement speed.
Then i thought about making a variable in the NPC editor that determes the movement speed of characters.

```

  If MapNpc(MapNpcNum).Moving = MOVING_WALKING Then

      Select Case MapNpc(MapNpcNum).Dir
            Case DIR_UP
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))
                If MapNpc(MapNpcNum).YOffset < 0 Then MapNpc(MapNpcNum).YOffset = 0

            Case DIR_DOWN
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))
                If MapNpc(MapNpcNum).YOffset > 0 Then MapNpc(MapNpcNum).YOffset = 0

            Case DIR_LEFT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))
                If MapNpc(MapNpcNum).XOffset < 0 Then MapNpc(MapNpcNum).XOffset = 0

            Case DIR_RIGHT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))
                If MapNpc(MapNpcNum).XOffset > 0 Then MapNpc(MapNpcNum).XOffset = 0

        End Select
```
If  a switch out the WALK_SPEED with a constant that is determed from the NPC editor, would that work? If so, how do i make it to save this constant from the NPC editor to the NPC.dat files and then make it read from that? Im not that familiar with VB6 so dont laugh if it sound stupid.  :P
Link to comment
Share on other sites

@interloper:

> you cant use constants because you cant change them

Well, nvm constants.
Let's call it a value instead.
My question is. How do I save a value from npc editor to the npc file, and then make it read from it.

If i make a new scrollbar in npcEditor with the values 2,4,6,8,10,12 for example and save it as NPC_MOVEMENTSPEED. Then use it when npc is moving;

```
If MapNpc(MapNpcNum).Moving = MOVING_WALKING Then

      Select Case MapNpc(MapNpcNum).Dir
            Case DIR_UP
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - ((ElapsedTime / 1000) * (NPC_MOVEMENTSPEED * SIZE_X))
                If MapNpc(MapNpcNum).YOffset < 0 Then MapNpc(MapNpcNum).YOffset = 0

            Case DIR_DOWN
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + ((ElapsedTime / 1000) * (NPC_MOVEMENTSPEED * SIZE_X))
                If MapNpc(MapNpcNum).YOffset > 0 Then MapNpc(MapNpcNum).YOffset = 0

            Case DIR_LEFT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - ((ElapsedTime / 1000) * (NPC_MOVEMENTSPEED * SIZE_X))
                If MapNpc(MapNpcNum).XOffset < 0 Then MapNpc(MapNpcNum).XOffset = 0

            Case DIR_RIGHT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + ((ElapsedTime / 1000) * (NPC_MOVEMENTSPEED * SIZE_X))
                If MapNpc(MapNpcNum).XOffset > 0 Then MapNpc(MapNpcNum).XOffset = 0

        End Select
```
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...