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

CheckDirection Sub Question?


Justn
 Share

Recommended Posts

Hello guys I'm having an issue that I can't seem to solve on my own with this code..

```

' Check to see if a npc is already on that tile
For i = 1 To Npc_HighIndex
If MapNpc(i).num > 0 Then
If MapNpc(i).x = x Then
If MapNpc(i).y = y Then
CheckDirection = True
Exit Function
End If
End If
End If
Next

```
this is the code in a deafult eo to stop a player from walking on a tile with a npc on it.. The problem is that it only checks if they are on the same x or y so, left right up and down. I am trying to make it check all 8 sides surrounding a player but cant figure it out. I have tried lots of things but no matter what i change it just makes me walk through npcs from all directions.. Can someone help me out and teach me to check all 8 sides for an npc? =/
Link to comment
Share on other sites

The x and y position in a 2D world represent the point,you can go to that point from either direction left right up down or vertical directions but still what you have to check is your x and y with the npc's x and y so,I don't see why it is a problem.

Regards,Relative Null.
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...