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

Autotile in EO 2.0 (beta)


canido
 Share

Recommended Posts

Hello, today I come to explain how to install a layer "autotile"
just above the "Ground" and below the "Mask 1"
But it is difficult for me because English is not my usual language
**Credits**: Robin for create of system

**server side**

Open **modEnumerations**
And search **Public Enum MapLayer**
And replaced by the following
```
Public Enum MapLayer
    Ground = 1
    Autotile
    Mask
    Mask2
    Fringe
    Fringe2
    ' Make sure Layer_Count is below everything else
    Layer_Count
End Enum

```

**Client side**

Open **modGameLogic**
And search **If tmr25 < Tick Then**
And before of "If tmr25 < Tick Then" write…
```
        If tmr250 < Tick Then
          If autoAnim < 3 Then
                autoAnim = autoAnim + 1
            Else
                autoAnim = 0
            End If
            tmr250 = GetTickCount + 250
        End If

```
Open **modGameEditors**

And search **If EditorTileWidth = 1 And EditorTileHeight = 1 Then**

And Remplace for
```
If (EditorTileWidth = 1 And EditorTileHeight = 1) Or CurLayer = MapLayer.Autotile Then 'single tile

```

And search **frmEditor_Map.shpSelected.height = PIC_Y**
and below
```
If frmEditor_Map.optLayer(MapLayer.Autotile) Then
            EditorTileX = (X \ 32)
            EditorTileY = (Y \ 32)
            EditorTileWidth = 3
            EditorTileHeight = 4
            frmEditor_Map.shpSelected.top = EditorTileY * PIC_Y
            frmEditor_Map.shpSelected.Left = EditorTileX * PIC_X
            frmEditor_Map.shpSelected.width = 96
            frmEditor_Map.shpSelected.height = 128
        End If

```
Open **modDirectDraw7**

And search **BltMapTile**
and replace with the following

```
Public Sub BltMapTile(ByVal X As Long, ByVal Y As Long)
    Dim rec As DxVBLib.RECT
    Dim i As Long

    With Map.Tile(X, Y)
        For i = MapLayer.Ground To MapLayer.Mask2
            ' skip tile if tileset isn't set
            If i = MapLayer.Autotile Then
                BltAutotile X, Y
            Else
                If .Layer(i).Tileset > 0 And .Layer(i).Tileset <= NumTileSets Then
                    ' sort out rec
                    rec.top = .Layer(i).Y * PIC_Y
                    rec.Bottom = rec.top + PIC_Y
                    rec.Left = .Layer(i).X * PIC_X
                    rec.Right = rec.Left + PIC_X
                    ' render
                    Call Engine_BltFast(ConvertMapX(X * PIC_X), ConvertMapY(Y * PIC_Y), DDS_Tileset(.Layer(i).Tileset), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                End If
            End If
        Next
    End With

    ' Error handler
    Exit Sub

errorhandler:
    HandleError "BltMapTile", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
Now go to the bottom of the mod(modDirectDraw7) and put the following code
```
Public Function isAutotileMatch(ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Boolean
    isAutotileMatch = False
    ' end of the map, pretend there's a tile there :3
    If x1 < 0 Or x1 > Map.MaxX Or x2 < 0 Or x2 > Map.MaxX Or y1 < 0 Or y1 > Map.MaxY Or y2 < 0 Or y2 > Map.MaxY Then
        isAutotileMatch = True
    Else
        If Map.Tile(x1, y1).Layer(MapLayer.Autotile).X = Map.Tile(x2, y2).Layer(MapLayer.Autotile).X Then
            If Map.Tile(x1, y1).Layer(MapLayer.Autotile).Y = Map.Tile(x2, y2).Layer(MapLayer.Autotile).Y Then
                If Map.Tile(x1, y1).Layer(MapLayer.Autotile).Tileset = Map.Tile(x2, y2).Layer(MapLayer.Autotile).Tileset Then
                    isAutotileMatch = True
                End If
            End If
        End If
    End If
End Function

Public Sub BltAutotile(ByVal X As Long, ByVal Y As Long)
    Dim rec As DxVBLib.RECT
    Dim AutoSet As Long
    Dim bTop As Long
    Dim bLeft As Long

    AutoSet = Map.Tile(X, Y).Layer(MapLayer.Autotile).Tileset

    If AutoSet <= 0 Or AutoSet > NumTileSets Then Exit Sub

    bTop = Map.Tile(X, Y).Layer(MapLayer.Autotile).Y * 32
    bLeft = Map.Tile(X, Y).Layer(MapLayer.Autotile).X * 32

    ' animate
    If DDSD_Tileset(AutoSet).lWidth = 384 Then bLeft = autoAnim * 96

    ' ########################
    ' ########################
    ' ###    top left    ###
    ' ########################
    ' ########################
    With rec
        .top = bTop + 32
        .Bottom = .top + 16
        .Left = bLeft + 0
        .Right = .Left + 16
    End With
    ' 1-dir horizontal join
    If isAutotileMatch(X, Y, X - 1, Y) Then
        With rec
            .top = bTop + 32
            .Bottom = .top + 16
            .Left = bLeft + 64
            .Right = .Left + 16
        End With
        ' 2-dir horizontal join
        If isAutotileMatch(X, Y, X + 1, Y) Then
            With rec
                .top = bTop + 32
                .Bottom = .top + 16
                .Left = bLeft + 32
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir vertical join
    If isAutotileMatch(X, Y, X, Y - 1) Then
        With rec
            .top = bTop + 96
            .Bottom = .top + 16
            .Left = bLeft + 0
            .Right = .Left + 16
        End With
        ' 2-dir vertical join
        If isAutotileMatch(X, Y, X, Y + 1) Then
            With rec
                .top = bTop + 64
                .Bottom = .top + 16
                .Left = bLeft + 0
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir corner join
    If isAutotileMatch(X, Y, X - 1, Y) And isAutotileMatch(X, Y, X, Y - 1) Then
        With rec
            .top = bTop + 0
            .Bottom = .top + 16
            .Left = bLeft + 64
            .Right = .Left + 16
        End With
        ' 2-dir corner join
        If isAutotileMatch(X, Y, X - 1, Y - 1) Then
            With rec
                .top = bTop + 96
                .Bottom = .top + 16
                .Left = bLeft + 64
                .Right = .Left + 16
            End With
        End If
    End If
    ' surrounded to the left or top
    If (isAutotileMatch(X, Y, X - 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X, Y + 1) And isAutotileMatch(X, Y, X - 1, Y - 1) And _
    isAutotileMatch(X, Y, X - 1, Y + 1)) Or (isAutotileMatch(X, Y, X - 1, Y) And _
    isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X + 1, Y - 1) And isAutotileMatch(X, Y, X - 1, Y - 1)) Then
        With rec
            .top = bTop + 64
            .Bottom = .top + 16
            .Left = bLeft + 32
            .Right = .Left + 16
        End With
    End If
    Call Engine_BltFast(ConvertMapX((X * PIC_X)), ConvertMapY((Y * PIC_Y)), DDS_Tileset(AutoSet), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

    ' ########################
    ' ########################
    ' ###    top right    ###
    ' ########################
    ' ########################
    With rec
        .top = bTop + 32
        .Bottom = .top + 16
        .Left = bLeft + 80
        .Right = .Left + 16
    End With
    ' 1-dir horizontal join
    If isAutotileMatch(X, Y, X + 1, Y) Then
        With rec
            .top = bTop + 32
            .Bottom = .top + 16
            .Left = bLeft + 16
            .Right = .Left + 16
        End With
        ' 2-dir horizontal join
        If isAutotileMatch(X, Y, X - 1, Y) Then
            With rec
                .top = bTop + 32
                .Bottom = .top + 16
                .Left = bLeft + 48
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir vertical join
    If isAutotileMatch(X, Y, X, Y - 1) Then
        With rec
            .top = bTop + 96
            .Bottom = .top + 16
            .Left = bLeft + 80
            .Right = .Left + 16
        End With
        ' 2-dir vertical join
        If isAutotileMatch(X, Y, X, Y + 1) Then
            With rec
                .top = bTop + 64
                .Bottom = .top + 16
                .Left = bLeft + 80
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir corner join
    If isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y - 1) Then
        With rec
            .top = bTop + 0
            .Bottom = .top + 16
            .Left = bLeft + 80
            .Right = .Left + 16
        End With
        ' 2-dir corner join
        If isAutotileMatch(X, Y, X + 1, Y - 1) Then
            With rec
                .top = bTop + 96
                .Bottom = .top + 16
                .Left = bLeft + 16
                .Right = .Left + 16
            End With
        End If
    End If
    ' surrounded to the right or top
    If (isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X, Y + 1) And isAutotileMatch(X, Y, X + 1, Y - 1) And _
    isAutotileMatch(X, Y, X + 1, Y + 1)) Or (isAutotileMatch(X, Y, X - 1, Y) And _
    isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X + 1, Y - 1) And isAutotileMatch(X, Y, X - 1, Y - 1)) Then
        With rec
            .top = bTop + 64
            .Bottom = .top + 16
            .Left = bLeft + 48
            .Right = .Left + 16
        End With
    End If
    Call Engine_BltFast(ConvertMapX((X * PIC_X) + 16), ConvertMapY((Y * PIC_Y)), DDS_Tileset(AutoSet), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

    ' ########################
    ' ########################
    ' ###  bottom left    ###
    ' ########################
    ' ########################
    With rec
        .top = bTop + 112
        .Bottom = .top + 16
        .Left = bLeft + 0
        .Right = .Left + 16
    End With
    ' 1-dir horizontal join
    If isAutotileMatch(X, Y, X - 1, Y) Then
        With rec
            .top = bTop + 112
            .Bottom = .top + 16
            .Left = bLeft + 64
            .Right = .Left + 16
        End With
        ' 2-dir horizontal join
        If isAutotileMatch(X, Y, X + 1, Y) Then
            With rec
                .top = bTop + 112
                .Bottom = .top + 16
                .Left = bLeft + 32
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir vertical join
    If isAutotileMatch(X, Y, X, Y + 1) Then
        With rec
            .top = bTop + 48
            .Bottom = .top + 16
            .Left = bLeft + 0
            .Right = .Left + 16
        End With
        ' 2-dir vertical join
        If isAutotileMatch(X, Y, X, Y - 1) Then
            With rec
                .top = bTop + 80
                .Bottom = .top + 16
                .Left = bLeft + 0
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir corner join
    If isAutotileMatch(X, Y, X - 1, Y) And isAutotileMatch(X, Y, X, Y + 1) Then
        With rec
            .top = bTop + 16
            .Bottom = .top + 16
            .Left = bLeft + 64
            .Right = .Left + 16
        End With
        ' 2-dir corner join
        If isAutotileMatch(X, Y, X - 1, Y + 1) Then
            With rec
                .top = bTop + 48
                .Bottom = .top + 16
                .Left = bLeft + 64
                .Right = .Left + 16
            End With
        End If
    End If
    ' surrounded to the left or top
    If (isAutotileMatch(X, Y, X - 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X, Y + 1) And isAutotileMatch(X, Y, X - 1, Y - 1) And _
    isAutotileMatch(X, Y, X - 1, Y + 1)) Or (isAutotileMatch(X, Y, X - 1, Y) And _
    isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y + 1) And _
    isAutotileMatch(X, Y, X + 1, Y + 1) And isAutotileMatch(X, Y, X - 1, Y + 1)) Then
        With rec
            .top = bTop + 80
            .Bottom = .top + 16
            .Left = bLeft + 64
            .Right = .Left + 16
        End With
    End If
    Call Engine_BltFast(ConvertMapX((X * PIC_X)), ConvertMapY((Y * PIC_Y) + 16), DDS_Tileset(AutoSet), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

    ' ########################
    ' ########################
    ' ###  bottom right  ###
    ' ########################
    ' ########################
    With rec
        .top = bTop + 112
        .Bottom = .top + 16
        .Left = bLeft + 80
        .Right = .Left + 16
    End With
    ' 1-dir horizontal join
    If isAutotileMatch(X, Y, X + 1, Y) Then
        With rec
            .top = bTop + 112
            .Bottom = .top + 16
            .Left = bLeft + 16
            .Right = .Left + 16
        End With
        ' 2-dir horizontal join
        If isAutotileMatch(X, Y, X - 1, Y) Then
            With rec
                .top = bTop + 112
                .Bottom = .top + 16
                .Left = bLeft + 48
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir vertical join
    If isAutotileMatch(X, Y, X, Y + 1) Then
        With rec
            .top = bTop + 48
            .Bottom = .top + 16
            .Left = bLeft + 80
            .Right = .Left + 16
        End With
        ' 2-dir vertical join
        If isAutotileMatch(X, Y, X, Y - 1) Then
            With rec
                .top = bTop + 80
                .Bottom = .top + 16
                .Left = bLeft + 80
                .Right = .Left + 16
            End With
        End If
    End If
    ' 1-dir corner join
    If isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y + 1) Then
        With rec
            .top = bTop + 16
            .Bottom = .top + 16
            .Left = bLeft + 80
            .Right = .Left + 16
        End With
        ' 2-dir corner join
        If isAutotileMatch(X, Y, X + 1, Y + 1) Then
            With rec
                .top = bTop + 48
                .Bottom = .top + 16
                .Left = bLeft + 16
                .Right = .Left + 16
            End With
        End If
    End If
    ' surrounded to the left or top
    If (isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y - 1) And _
    isAutotileMatch(X, Y, X, Y + 1) And isAutotileMatch(X, Y, X + 1, Y - 1) And _
    isAutotileMatch(X, Y, X + 1, Y + 1)) Or (isAutotileMatch(X, Y, X - 1, Y) And _
    isAutotileMatch(X, Y, X + 1, Y) And isAutotileMatch(X, Y, X, Y + 1) And _
    isAutotileMatch(X, Y, X + 1, Y + 1) And isAutotileMatch(X, Y, X - 1, Y + 1)) Then
        With rec
            .top = bTop + 80
            .Bottom = .top + 16
            .Left = bLeft + 48
            .Right = .Left + 16
        End With
    End If
    Call Engine_BltFast(ConvertMapX((X * PIC_X) + 16), ConvertMapY((Y * PIC_Y) + 16), DDS_Tileset(AutoSet), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

```
Open **modEnumerations**
And search **Public Enum MapLayer**
And replaced by the following
```
Public Enum MapLayer
    Ground = 1
    Autotile
    Mask
    Mask2
    Fringe
    Fringe2
    ' Make sure Layer_Count is below everything else
    Layer_Count
End Enum

```
Open **modDatabase**
And search **Put #f, , Map.Tile(x, y).DirBlock**
put the following code After Put #f, , Map.Tile(x, y).Animation.Animation
```
Put #f, , Map.Tile(x, y).Animation.Animation
```

**Notes:**
To play animations "Water" the tile should measure the "384" wide 
Here are some picture along with the frmEditor_Map
Change frmEditor_Map by my you to download below
Link to comment
Share on other sites

  • 3 weeks later...
@Meteor:

> This doesnt work at all.

Please be more specific when saying something doesnt work. Like, for example, saying what kind of errors youre getting etc. Are you sure YOU just dont know how to add it properly? Its an insult to canido who gracefully posted this tutorial to be so ignorant.
Link to comment
Share on other sites

so i didnt follow this tut, but i did rip robins autotile feature, and i havnt noticed any fps drop even on my old 2ghz laptop.  it may still have a fps leak, but i cant see one after 2 hours of playtesting.
Link to comment
Share on other sites

Canido, for the people like Meteor Rain and I, wouldn't it be nice to post a compiled client/server including this code? It's like what Alatar did with his quest system, it'd surely shake off doubts. So far I'm too have some doubts if it really works nicely enough.
Link to comment
Share on other sites

This tutorial is not complete.

You say Quote

"Open modDatabase
And search Put #f, , Map.Tile(x, y).DirBlock
put the following code After Put #f, , Map.Tile(x, y).Animation.Animation"

Um if you use default EO 2.0 there is no line of code that says:
Put #f, , Map.Tile(x, y).DirBlock

Or one that says

#f, , Map.Tile(x, y).Animation.Animation

I ran a search on the whole project and still not there, so you must have added something else to the system and not telling everyone.

Please finish or Fix the tutorial.
Link to comment
Share on other sites

If you're going to rip my systems at least do it properly. This is a bloody awful system. You've taken all the shit which was done in the caching and put it in the damn renderer! That shit should be done once on map change and cached for use, not re-calculated every loop.

This is basic programming logic. Unless you have constantly changing data then you should have all your calculations done once and the results cached.

How you managed to screw up ripping a fully working system I'll never know.
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...