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

Cant move ? What is the problem with my code?


ulquial
 Share

Recommended Posts

I really need someone experimented to help me with that. Its a serious major part of my project, i really need a resource type that we can pass thru like herbs or plants.

Ty ! And It will help a lot of pplz too.

Thanks in advance, and sorry i made a similar topic about something else, but i was in wrong place, so i make it here.

Ty.
Link to comment
Share on other sites

Go into frmEditor_Resources in the client, right click on the list of resource types hit properties. In the properties window go down and look for the list property and add your resource types to the list.

Then in the client (Sub CheckDirection) find

```
' Check to see if the map tile is tree or not
If Map.Tile(X, Y).type = TILE_TYPE_RESOURCE Then
CheckDirection = True
Exit Function
End If

```
and replace it with

```
' Check to see if the map tile is tree or not
If Map.Tile(X, Y).type = TILE_TYPE_RESOURCE Then
'Checks to see if it is a certain resource type. I am using 4 because it is Herb is the fifth item
' on my list. (5 - 1).
If Resource(Map.Tile(X, Y).Data1).ResourceType = 4 Then
'Do nothing
Else
'It is not walkable, block it.
CheckDirection = True
Exit Function
End If
End If

```
Then in the server in Sub PlayerMove you have it check the 4 directions that the player can move. The part that stops the player from moving looks like this.

```
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_RESOURCE Then

' Check to see if the tile is a key and if it is check if its opened
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type = TILE_TYPE_KEY And temptile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
Call SetPlayerY(Index, GetPlayerY(Index) - 1)
SendPlayerMove Index, movement, sendToSelf
Moved = YES
End If
End If
```
You need to rewrite the line regarding resources to look like this (long but works)

```
If (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_RESOURCE) Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type = TILE_TYPE_RESOURCE And Resource(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1).ResourceType = 4) Then

```
^^ All one line. Notice how I am still using the 4?

And you will need to do that for the up, down, left and right cases changing the coordinates in that line correctly. Notice the GetPlayerY(index) -1? That means I just did the line for the up direction leaving you with only 3 more ;)

Everything above will work if you install it correctly. It is a quick edit but messy and not very proper. Someone else may come around and give a better code sample but this is all I can give in my limited time, best of luck :P
Link to comment
Share on other sites

n sub DrawMapResource add a parameter (belowPlayer as boolean) then in sub Render_Graphics find the loop where it does map graphics, copy and paste it above where it draws the Y based rendering and then add a ,true or false to match the parameter. Finally go back into Sub DrawMapResource you will have to do the type check again and draw or not draw it based on the type and the belowPlayer boolean
Link to comment
Share on other sites

```
' Check to make sure that the tile is walkable
If Not isDirBlocked(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).DirBlock, DIR_UP + 1) Then
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_BLOCKED Then
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type = TILE_TYPE_RESOURCE Then
If Resource(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1).ResourceType = 4 Then
' Check to see if the tile is a key and if it is check if its opened
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type = TILE_TYPE_KEY And temptile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
Call SetPlayerY(Index, GetPlayerY(Index) - 1)
SendPlayerMove Index, movement, sendToSelf
Moved = YES
End If
End If
Else
' Check to see if the tile is a key and if it is check if its opened
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).type = TILE_TYPE_KEY And temptile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
Call SetPlayerY(Index, GetPlayerY(Index) - 1)
SendPlayerMove Index, movement, sendToSelf
Moved = YES
End If
End If
End If
End If

Again messy and such but replace the chunks in up/down/left/right server side with that and it will not error.

```
Link to comment
Share on other sites

error 9 –-> If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_RESOURCE Then

Is it normal you have twice the same bloc of codes ? One in purple ? Or i dont copy the right one ???
Link to comment
Share on other sites

```

Case DIR_RIGHT

' Check to make sure not outside of boundries
If GetPlayerX(Index) < Map(mapnum).MaxX Then

' Check to make sure that the tile is walkable
If Not isDirBlocked(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).DirBlock, DIR_RIGHT + 1) Then
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type <> TILE_TYPE_BLOCKED Then
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_RESOURCE Then
If Resource(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Data1).ResourceType = 4 Then
' Check to see if the tile is a key and if it is check if its opened
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
Call SetPlayerY(Index, GetPlayerY(Index) - 1)
SendPlayerMove Index, movement, sendToSelf
Moved = YES
End If
End If
Else
' Check to see if the tile is a key and if it is check if its opened
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
Call SetPlayerY(Index, GetPlayerY(Index) - 1)
SendPlayerMove Index, movement, sendToSelf
Moved = YES
End If
End If
End If
End If
Else

```
Link to comment
Share on other sites

i have been helped. just look from the beginning : [http://www.eclipseorigins.com/community/index.php?/topic/134010-resource-type-that-is-walkable-serious-help/#entry906215](http://www.eclipseorigins.com/community/index.php?/topic/134010-resource-type-that-is-walkable-serious-help/#entry906215)

and now with the last part it doesnt work. I cant move. it blockes when i move.
Link to comment
Share on other sites

A resource type that is walkable. If you look the link, you will see that with help, i success passing thru a resource type, but i got error 9\. And that person gived me a code to change and supposed to fix the error 9\. But instead, it would not let me move my character in all directions. I wanted to make a resource type like plants to gather or herbs. There is 2 problems now:

->Cant move.

-> The resource appears on top of me. Not under player. (not important for now, i just want to fix the cant move first).

Thanks if you can help ! :)
Link to comment
Share on other sites

1\. im working on it right now.

2\. in Sub Render_Graphics, there's a small section at the top that draws all the graphics to the screen. look for the Resources. above is the Player and NPCs, being as how they are first, the players get rendered first, which means anything will be above it after that render. to fix this, just copy/paste the resource drawing to somewhere above the player drawing.
Link to comment
Share on other sites

As for your current code block that you posted you are not listening to me. I gave you a chunk of code for DIR_UP but you have to modifiy it for DIR_DOWN, left and right.

In DIR_RIGHT the players position is X + 1 not Y - 1\. You need to change your code to reflect that.
Link to comment
Share on other sites

```
Select Case Dir
        Case DIR_UP

            ' Check to make sure not outside of boundries
            If GetPlayerY(index) > 0 Then

                ' Check to make sure that the tile is walkable
                ' Check to make sure that the tile is walkable
                If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) Then
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_RESOURCE Then
                            If Resource(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).ResourceType = 4 Then
                                ' Check to see if the tile is a key and if it is check if its opened
                                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                    Call SetPlayerY(index, GetPlayerY(index) - 1)
                                    SendPlayerMove index, movement, sendToSelf
                                    Moved = YES
                                End If
                            End If
                        Else
                            ' Check to see if the tile is a key and if it is check if its opened
                            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                Call SetPlayerY(index, GetPlayerY(index) - 1)
                                SendPlayerMove index, movement, sendToSelf
                                Moved = YES
                            End If
                        End If
                    End If
                End If
            End If

        Case DIR_DOWN

            ' Check to make sure not outside of boundries
            If GetPlayerY(index) < Map(mapnum).MaxY Then

                ' Check to make sure that the tile is walkable
                ' Check to make sure that the tile is walkable
                If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_DOWN + 1) Then
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_RESOURCE Then
                            If Resource(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).ResourceType = 4 Then
                                ' Check to see if the tile is a key and if it is check if its opened
                                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                    Call SetPlayerY(index, GetPlayerY(index) + 1)
                                    SendPlayerMove index, movement, sendToSelf
                                    Moved = YES
                                End If
                            End If
                        Else
                            ' Check to see if the tile is a key and if it is check if its opened
                            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                Call SetPlayerY(index, GetPlayerY(index) + 1)
                                SendPlayerMove index, movement, sendToSelf
                                Moved = YES
                            End If
                        End If
                    End If
                End If
            End If

        Case DIR_LEFT

            ' Check to make sure not outside of boundries
            If GetPlayerX(index) > 0 Then

                ' Check to make sure that the tile is walkable
                ' Check to make sure that the tile is walkable
                If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_LEFT + 1) Then
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_RESOURCE Then
                            If Resource(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).ResourceType = 4 Then
                                ' Check to see if the tile is a key and if it is check if its opened
                                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                    Call SetPlayerX(index, GetPlayerX(index) - 1)
                                    SendPlayerMove index, movement, sendToSelf
                                    Moved = YES
                                End If
                            End If
                        Else
                            ' Check to see if the tile is a key and if it is check if its opened
                            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                Call SetPlayerX(index, GetPlayerX(index) - 1)
                                SendPlayerMove index, movement, sendToSelf
                                Moved = YES
                            End If
                        End If
                    End If
                End If
            End If

        Case DIR_RIGHT

            ' Check to make sure not outside of boundries
            If GetPlayerX(index) < Map(mapnum).MaxX Then

                ' Check to make sure that the tile is walkable
            ' Check to make sure not outside of boundries

                 ' Check to make sure that the tile is walkable
                If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).DirBlock, DIR_RIGHT + 1) Then
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_RESOURCE Then
                            If Resource(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).ResourceType = 4 Then
                                ' Check to see if the tile is a key and if it is check if its opened
                                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                    Call SetPlayerX(index, GetPlayerX(index) + 1)
                                    SendPlayerMove index, movement, sendToSelf
                                    Moved = YES
                                End If
                            End If
                        Else
                            ' Check to see if the tile is a key and if it is check if its opened
                            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And temptile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                                Call SetPlayerX(index, GetPlayerX(index) + 1)
                                SendPlayerMove index, movement, sendToSelf
                                Moved = YES
                            End If
                        End If
                    End If
                End If
            End If
    End Select

```
Link to comment
Share on other sites

The code you are editing is the code that finds the tile the player is trying to walk to, it makes sure the tile is clear and then it finally moves the player. The problem is, is that it checks the direction the player is going so it has the code for all four directions.

Notice how in my code I had "GetPlayerX(Index), GetPlayerY(Index) - 1"  several times? It is because it is checking the tile **above** the player in this grid. So the code will only work for the DIR_UP case.

When you get down to the DIR_RIGHT that you posted the code should have "GetPlayerX(Index) + 1, GetPlayerY(Index)" instead and you need to change that yourself to make it work.

Edit: Or growlith can just do it all for ya lol.
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...