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

7 minimap CS:DE upgrade


Wucker
 Share

Recommended Posts

welcome to my first tutorial :cheesy:
yami told me to mess with the d3d code of CS:DE, and i also needed the minimap system 7 made for EO, so i just rewrote the thing which came out in about 10 mins.
Tutorial:

Goto the modDirectX8 and after
```
Public Tex_Fader As Long
```add
```
Public Tex_Minimap As Long
```
now in EngineCacheTextures, after
```
    Tex_Shadow = SetTexturePath(App.path & Path_Graphics & "shadow.png")
```add
```
    Tex_Minimap = SetTexturePath(App.path & Path_Graphics & "minimap.png")
```
then at the bottom of the mod, paste this:
```
Public Sub DrawMinimap()
    Dim x As Long, y As Long, minimap_x As Long, minimap_y As Long, maxX As Long, maxY As Long
    Dim i As Long
    Dim mapnum As Long

    mapnum = Player(MyIndex).Map
    maxX = Map.maxX
    maxY = Map.maxY

    ' render
    For x = 0 To maxX
        For y = 0 To maxY
            Select Case Map.Tile(x, y).Type
                Case TILE_TYPE_BLANK
                    minimap_x = Camera.left + 600 + (x * 4)
                    minimap_y = Camera.top + 25 + (y * 4)
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 0, 4, 4, 4, 4
                Case TILE_TYPE_WALKABLE, TILE_TYPE_NPCAVOID
                    minimap_x = Camera.left + 600 + (x * 4)
                    minimap_y = Camera.top + 25 + (y * 4)
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 4, 4, 4, 4, 4
                Case TILE_TYPE_BLOCKED
                    minimap_x = Camera.left + 600 + (x * 4)
                    minimap_y = Camera.top + 25 + (y * 4)
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4
            End Select
        Next
    Next

    ' dir blocks
    For x = 0 To maxX
        For y = 0 To maxY
            If Map.Tile(x, y).DirBlock >= 1 Then
                minimap_x = Camera.left + 600 + (x * 4)
                minimap_y = Camera.top + 25 + (y * 4)
                RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4
            End If
        Next
    Next

    ' players
    For i = 1 To MAX_PLAYERS
        If Player(i).Vital(1) > 0 Then
            x = Player(i).x
            y = Player(i).y
            minimap_x = Camera.left + 600 + (x * 4)
            minimap_y = Camera.top + 25 + (y * 4)
            RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 0, 4, 4, 4, 4
        End If
    Next

    ' npcs
    For i = 1 To MAX_MAP_NPCS
        If MapNpc(i).num > 0 Then
            x = MapNpc(i).x
            y = MapNpc(i).y
            minimap_x = Camera.left + 600 + (x * 4)
            minimap_y = Camera.top + 25 + (y * 4)
            RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 4, 4, 4, 4, 4
        End If
    Next
End Sub
```
then in modText, in DrawMapAttributes, before the End Select, add
```
                            Case TILE_TYPE_BLANK
                                RenderText Font_Default, "BL", tX, tY, White
```
then in modConstants, below (AND IN SERVER TOO)
```
Public Const TILE_TYPE_CHAT As Byte = 15
```add
```
Public Const TILE_TYPE_BLANK As Byte = 16
```
then in modGlobals, at the bottom add
```
' minimap flag
Public bMinimap As Boolean
```
Then in modDirectX8, RenderGraphics, after
```
    ' draw the messages
    For i = 1 To MAX_BYTE
        If chatBubble(i).active Then
            DrawChatBubble i
        End If
    Next
```add
```
    If bMinimap Then DrawMinimap
```
Now in frmEditor_Map, in fraAttributes, add an opttion named optBlank.
then, in modGameEditors, MapEditorMouseDown, add, before the End With:
```
                If frmEditor_Map.optBlank.value Then .Type = TILE_TYPE_BLANK
```and finally in modInput, HandleKeyPresses, before
```
                    ' // Monitor Admin Commands //
```add
```
                Case "/minimap"
                    bMinimap = Not bMinimap
```
also, download this and put it in your data files/graphics/ folder:
http://i.imgur.com/njjuK.png

Hope you enjoy, and tell me if anything goes wrong

EDIT: screenshot:
![](http://i.imgur.com/uu49v.png)
Link to comment
Share on other sites

You mean something like this?
```
Public Sub DrawMinimap()
    Dim x As Long, y As Long, minimap_x As Long, minimap_y As Long, MaxX As Long, MaxY As Long
    Dim i As Long
    Dim MapNum As Long

    MapNum = Player(MyIndex).Map
    MaxX = Map.MaxX
    MaxY = Map.MaxY

    ' render
    For x = 0 To MaxX
        For y = 0 To MaxY
            minimap_x = Camera.left + 600 + (x * 4)
            minimap_y = Camera.top + 25 + (y * 4)
            Select Case Map.Tile(x, y).Type
                Case TILE_TYPE_BLANK
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 0, 4, 4, 4, 4
                Case TILE_TYPE_WALKABLE, TILE_TYPE_NPCAVOID
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 4, 4, 4, 4, 4
                Case TILE_TYPE_BLOCKED
                    RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4
            End Select
            ' dir blocks
            If Map.Tile(x, y).DirBlock >= 1 Then
                RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 8, 4, 4, 4, 4
            End If
        Next
    Next

    ' players
    For i = 1 To MAX_PLAYERS
        If Player(i).Vital(1) > 0 Then
            x = Player(i).x
            y = Player(i).y
            minimap_x = Camera.left + 600 + (x * 4)
            minimap_y = Camera.top + 25 + (y * 4)
            RenderTexture Tex_Minimap, minimap_x, minimap_y, 4, 0, 4, 4, 4, 4
        End If
    Next

    ' npcs
    For i = 1 To MAX_MAP_NPCS
        If MapNpc(i).num > 0 Then
            x = MapNpc(i).x
            y = MapNpc(i).y
            minimap_x = Camera.left + 600 + (x * 4)
            minimap_y = Camera.top + 25 + (y * 4)
            RenderTexture Tex_Minimap, minimap_x, minimap_y, 0, 4, 4, 4, 4, 4
        End If
    Next
End Sub

```
Link to comment
Share on other sites

The fact that it's in 'DrawMinimap' means I'm not even going to read that code.

If it's in the draw routine then it's getting called every single loop. What you want to do is cache it in memory and re-build the cache when the data changes from incoming packets.

Then you can render that without all the calculations.
Link to comment
Share on other sites

  • 5 months later...
Little tip: It involves calling a sub to re-initialise the values every time you change maps, and the drawing sub has been modified to just render the already calculated values, and that alone.

If you're stuck for that, look at how the actual map drawing itself works, and look at how beforehand, all of the TilesetX/Y, Tileset, etc, values have already been initialised and calculated for use, and aren't just looping every call.
Link to comment
Share on other sites

OK then if i get this right, cache is just Storing the data in a temporary file on client side so the server wont need to send each time?

i need to take the info from the cache and not to calculate each time right?
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...