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

[EA] MiniMap


Ertzel
 Share

Recommended Posts

The following is [iHero's MiniMap](http://www.touchofdeathforums.com/community/index.php?/topic/124321-eo-minimap-12/) system for EO converted to work with EA.

(If you already used the old tutorial I made for this, remove it all and start with the new one)

In modGraphics find```
For I = 1 To Action_HighIndex

Call DrawActionMsg(I)

Next I
```in Render Graphics and under it add```
' Render the minimap

DrawMiniMap
```

At the bottom of modTypes add```
' Mini Map Data

Public MiniMapPlayer(1 To MAX_PLAYERS) As MiniMapPlayerRec

Public MiniMapNPC(1 To MAX_MAP_NPCS) As MiniMapNPCRec

Public Type MiniMapPlayerRec

x As Long

y As Long

End Type

Public Type MiniMapNPCRec

x As Long

y As Long

End Type
```

Find```
Sub SetPlayerX(ByVal Index As Long, ByVal x As Long)
```and under```
Player(Index).x = x
```add```
MiniMapPlayer(Index).x = x * 4
```

Find```
Sub SetPlayerY(ByVal Index As Long, ByVal x As Long)
```and under```
Player(Index).y = y
```add```
MiniMapPlayer(Index).y = y * 4
```

Find```
Private Sub HandleNpcMove(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```and under```
With MapNpc(MapNpcNum)

.x = x

.y = y
```add```
MiniMapNPC(MapNpcNum).x = x * 4

MiniMapNPC(MapNpcNum).y = y * 4
```

Find```
Private Sub HandleMapNpcData(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```and under```
.y = buffer.ReadLong
```add```
MiniMapNPC(I).x = MapNpc(I).x * 4

MiniMapNPC(I).y = MapNpc(I).y * 4
```

Now at the bottom of modGraphics add

```

Public Sub DrawMiniMap()

Dim i As Long, Z As Long

Dim X As Integer, Y As Integer

Dim direction As Byte

Dim CameraX As Long, CameraY As Long, playerNum As Long

Dim MapX As Long, MapY As Long

Dim CameraXSize As Long, CameraYSize As Long

CameraXSize = MAX_MAPX * 32 + 1

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

MapX = Map.MaxX

MapY = Map.MaxY

' Draw Outline

For X = 0 To MapX

For Y = 0 To MapY

CameraX = CameraXSize - (MapX * 4) + (X * 4)

CameraY = 55 + (Y * 4)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 255, 255, 150)

Next Y

Next X

' Draw Tile Attribute

For X = 0 To MapX

For Y = 0 To MapY

CameraX = CameraXSize - (MapX * 4) + (X * 4)

CameraY = 55 + (Y * 4)

Select Case Map.Tile(X, Y).Type

Case TILE_TYPE_BLOCKED

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 0, 200)

Case TILE_TYPE_WARP

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(75, 0, 155, 200)

Case TILE_TYPE_ITEM

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 155, 0, 200)

Case TILE_TYPE_SHOP

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 125, 0, 200)

End Select

Next Y

Next X

' Draw Player dot

For i = 1 To Player_HighIndex

If IsPlaying(i) Then

If GetPlayerMap(i) = GetPlayerMap(MyIndex) And (Not i = MyIndex) Then

Select Case Player(i).PK

Case 0

CameraX = CameraXSize - (MapX * 4) + (MiniMapPlayer(i).X)

CameraY = 55 + (MiniMapPlayer(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 255, 0, 200)

Case 1

CameraX = CameraXSize - (MapX * 4) + (MiniMapPlayer(i).X)

CameraY = 55 + (MiniMapPlayer(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(100, 0, 0, 200)

End Select

End If

End If

Next i

' Draw NPC dot

For i = 1 To MAX_MAP_NPCS

If MapNpc(i).num > 0 Then

Select Case NPC(i).Behaviour

Case NPC_BEHAVIOUR_ATTACKONSIGHT

CameraX = CameraXSize - (MapX * 4) + (MiniMapNPC(i).X)

CameraY = 55 + (MiniMapNPC(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 0, 0, 200)

Case NPC_BEHAVIOUR_ATTACKWHENATTACKED

CameraX = CameraXSize - (MapX * 4) + (MiniMapNPC(i).X)

CameraY = 55 + (MiniMapNPC(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(100, 0, 100, 200)

Case NPC_BEHAVIOUR_SHOPKEEPER

CameraX = CameraXSize - (MapX * 4) + (MiniMapNPC(i).X)

CameraY = 55 + (MiniMapNPC(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 125, 0, 200)

Case NPC_BEHAVIOUR_FRIENDLY

CameraX = CameraXSize - (MapX * 4) + (MiniMapNPC(i).X)

CameraY = 55 + (MiniMapNPC(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 255, 200)

Case NPC_BEHAVIOUR_GUARD

CameraX = CameraXSize - (MapX * 4) + (MiniMapNPC(i).X)

CameraY = 55 + (MiniMapNPC(i).Y)

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 255, 255, 200)

End Select

End If

Next i

' Draw Tile Attribute

For X = 0 To MapX

For Y = 0 To MapY

For i = 1 To Map.CurrentEvents

If Map.MapEvents(i).Visible = 1 Then

If Map.MapEvents(i).X = X Then

If Map.MapEvents(i).Y = Y Then

CameraX = CameraXSize - (MapX * 4) + (X * 4)

CameraY = 55 + (Y * 4)

Select Case Map.MapEvents(i).ShowName

Case 0 ' Tile

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 0, 155, 200)

Case 1 ' Sprite

RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 255, 0, 200)

End Select

End If

End If

End If

Next i

Next Y

Next X

' Error handler

Exit Sub

ErrorHandler:

HandleError "DrawMiniMap", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

Color Info

>! Event With Name = Yellow
>! Event Without Name = Dark Blue
>! Default tile = White
>! Block Tile = Red
>! Warp Tile = Purple
>! Item Tile = Green
>! PK Player = Dark Red
>! Non-PK = Light Green
>! NPC Attack On Sight = Black
>! NPC ATtack When Attacked = Dark Purple
>! NPC SHopkeeper = Orange
>! NPC Friendly = Pink
>! NPC Guard = Light Blue

To change any of the colors, simple edit the value used in```
D3DColorRGBA()
```at the end of the```
RenderTexture Tex_White
```line in```
Public Sub DrawMiniMap()
```for whatever color you want changed.

Example Ingame

>! ![](http://www.freemmorpgmaker.com/files/imagehost/pics/cf2831ecd53f42a5b77bf30028c174ed.png)
Link to comment
Share on other sites

  • Replies 73
  • Created
  • Last Reply

Top Posters In This Topic

Ertzel you are making nices tutorials but it would be great if you don't forget the others engine users ^^ hehe i'm also talking about dragon eclipse ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) keep it up !
Link to comment
Share on other sites

Do you mean something like this for NPC movement

```

' Draw NPC dot

For I = 1 To Npc_HighIndex

If MapNpc(I).num > 0 Then

Select Case Npc(I).Behaviour

Case NPC_BEHAVIOUR_ATTACKONSIGHT Or NPC_BEHAVIOUR_ATTACKWHENATTACKED

CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)

CameraY = 55 + (MiniMapNPC(I).y * 4)

RenderTexture Tex_MiniMap, CameraX, CameraY, NpcAttackerRect.Left, NpcAttackerRect.Top, NpcAttackerRect.Right - NpcAttackerRect.Left, NpcAttackerRect.Bottom - NpcAttackerRect.Top, NpcAttackerRect.Right - NpcAttackerRect.Left, NpcAttackerRect.Bottom - NpcAttackerRect.Top, D3DColorRGBA(255, 255, 255, 200)

Case NPC_BEHAVIOUR_SHOPKEEPER

CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)

CameraY = 55 + (MiniMapNPC(I).y * 4)

RenderTexture Tex_MiniMap, CameraX, CameraY, NpcShopRect.Left, NpcShopRect.Top, NpcShopRect.Right - NpcShopRect.Left, NpcShopRect.Bottom - NpcShopRect.Top, NpcShopRect.Right - NpcShopRect.Left, NpcShopRect.Bottom - NpcShopRect.Top, D3DColorRGBA(255, 255, 255, 200)

Case Else

CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)

CameraY = 55 + (MiniMapNPC(I).y * 4)

RenderTexture Tex_MiniMap, CameraX, CameraY, NpcOtherRect.Left, NpcOtherRect.Top, NpcOtherRect.Right - NpcOtherRect.Left, NpcOtherRect.Bottom - NpcOtherRect.Top, NpcOtherRect.Right - NpcOtherRect.Left, NpcOtherRect.Bottom - NpcOtherRect.Top, D3DColorRGBA(255, 255, 255, 200)

End Select

End If

Next I
```

then having```

Public MiniMapNPC(1 To MAX_MAP_NPCS) As MiniMapNpcRec

Public Type MiniMapNpcRec

x As Long

y As Long

End Type

```in modTypes and in HandleNpcMove having something like this```
MiniMapNPC(MapNpcNum).x = x

MiniMapNPC(MapNpcNum).y = y
```

Or did I get the wrong meaning of what you where saying?
Link to comment
Share on other sites

White/Pink = Empty

Red/Pink = Block Tile

Blue/Pink = Warp Tile

Green/Pink = Item Tile

Orange/Pink = Shop Tile

Green Dot = Player

Red Dot = PK Player

Black Dot = NPC Attack On Sight

Orange Dot = NPC Shop

Purple Dot = All other NPC's

Yellow Dot = Event NPC's

Blue Square = Event Tiles

(Although in the Eclipse Mega source I have this altered a little so Purple/White = Empty and White squares = Event Tiles)
Link to comment
Share on other sites

> Do you mean something like this for NPC movement
>
> ```
>
> ' Draw NPC dot
>
> For I = 1 To Npc_HighIndex
>
> If MapNpc(I).num > 0 Then
>
> Select Case Npc(I).Behaviour
>
> Case NPC_BEHAVIOUR_ATTACKONSIGHT Or NPC_BEHAVIOUR_ATTACKWHENATTACKED
>
> CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)
>
> CameraY = 55 + (MiniMapNPC(I).y * 4)
>
> RenderTexture Tex_MiniMap, CameraX, CameraY, NpcAttackerRect.Left, NpcAttackerRect.Top, NpcAttackerRect.Right - NpcAttackerRect.Left, NpcAttackerRect.Bottom - NpcAttackerRect.Top, NpcAttackerRect.Right - NpcAttackerRect.Left, NpcAttackerRect.Bottom - NpcAttackerRect.Top, D3DColorRGBA(255, 255, 255, 200)
>
> Case NPC_BEHAVIOUR_SHOPKEEPER
>
> CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)
>
> CameraY = 55 + (MiniMapNPC(I).y * 4)
>
> RenderTexture Tex_MiniMap, CameraX, CameraY, NpcShopRect.Left, NpcShopRect.Top, NpcShopRect.Right - NpcShopRect.Left, NpcShopRect.Bottom - NpcShopRect.Top, NpcShopRect.Right - NpcShopRect.Left, NpcShopRect.Bottom - NpcShopRect.Top, D3DColorRGBA(255, 255, 255, 200)
>
> Case Else
>
> CameraX = 780 - (MapX * 4) + (MiniMapNPC(I).x * 4)
>
> CameraY = 55 + (MiniMapNPC(I).y * 4)
>
> RenderTexture Tex_MiniMap, CameraX, CameraY, NpcOtherRect.Left, NpcOtherRect.Top, NpcOtherRect.Right - NpcOtherRect.Left, NpcOtherRect.Bottom - NpcOtherRect.Top, NpcOtherRect.Right - NpcOtherRect.Left, NpcOtherRect.Bottom - NpcOtherRect.Top, D3DColorRGBA(255, 255, 255, 200)
>
> End Select
>
> End If
>
> Next I
> ```
>
> then having```
>
> Public MiniMapNPC(1 To MAX_MAP_NPCS) As MiniMapNpcRec
>
> Public Type MiniMapNpcRec
>
> x As Long
>
> y As Long
>
> End Type
>
> ```in modTypes and in HandleNpcMove having something like this```
> MiniMapNPC(MapNpcNum).x = x
>
> MiniMapNPC(MapNpcNum).y = y
> ```
>
> Or did I get the wrong meaning of what you where saying?

Something like that yes, and where you would only calculate the positions when they are updated.

It doesn't seem like it, but calculating those positions every single loop can really hurt the engine in the long run.
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...