Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 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_HighIndexCall DrawActionMsg(I)Next I```in Render Graphics and under it add```' Render the minimapDrawMiniMap```At the bottom of modTypes add```' Mini Map DataPublic MiniMapPlayer(1 To MAX_PLAYERS) As MiniMapPlayerRecPublic MiniMapNPC(1 To MAX_MAP_NPCS) As MiniMapNPCRecPublic Type MiniMapPlayerRecx As Longy As LongEnd TypePublic Type MiniMapNPCRecx As Longy As LongEnd 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 * 4MiniMapNPC(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 * 4MiniMapNPC(I).y = MapNpc(I).y * 4```Now at the bottom of modGraphics add```Public Sub DrawMiniMap()Dim i As Long, Z As LongDim X As Integer, Y As IntegerDim direction As ByteDim CameraX As Long, CameraY As Long, playerNum As LongDim MapX As Long, MapY As LongDim CameraXSize As Long, CameraYSize As LongCameraXSize = MAX_MAPX * 32 + 1' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo ErrorHandlerMapX = Map.MaxXMapY = Map.MaxY' Draw OutlineFor X = 0 To MapXFor Y = 0 To MapYCameraX = 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 YNext X' Draw Tile AttributeFor X = 0 To MapXFor Y = 0 To MapYCameraX = CameraXSize - (MapX * 4) + (X * 4)CameraY = 55 + (Y * 4)Select Case Map.Tile(X, Y).TypeCase TILE_TYPE_BLOCKEDRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 0, 200)Case TILE_TYPE_WARPRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(75, 0, 155, 200)Case TILE_TYPE_ITEMRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 155, 0, 200)Case TILE_TYPE_SHOPRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 125, 0, 200)End SelectNext YNext X' Draw Player dotFor i = 1 To Player_HighIndexIf IsPlaying(i) ThenIf GetPlayerMap(i) = GetPlayerMap(MyIndex) And (Not i = MyIndex) ThenSelect Case Player(i).PKCase 0CameraX = 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 1CameraX = 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 SelectEnd IfEnd IfNext i' Draw NPC dotFor i = 1 To MAX_MAP_NPCSIf MapNpc(i).num > 0 ThenSelect Case NPC(i).BehaviourCase NPC_BEHAVIOUR_ATTACKONSIGHTCameraX = 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_ATTACKWHENATTACKEDCameraX = 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_SHOPKEEPERCameraX = 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_FRIENDLYCameraX = 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_GUARDCameraX = 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 SelectEnd IfNext i' Draw Tile AttributeFor X = 0 To MapXFor Y = 0 To MapYFor i = 1 To Map.CurrentEventsIf Map.MapEvents(i).Visible = 1 ThenIf Map.MapEvents(i).X = X ThenIf Map.MapEvents(i).Y = Y ThenCameraX = CameraXSize - (MapX * 4) + (X * 4)CameraY = 55 + (Y * 4)Select Case Map.MapEvents(i).ShowNameCase 0 ' TileRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 0, 155, 200)Case 1 ' SpriteRenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 255, 0, 200)End SelectEnd IfEnd IfEnd IfNext iNext YNext X' Error handlerExit SubErrorHandler:HandleError "DrawMiniMap", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd 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 More sharing options...
TheLordOfTheManor Posted September 30, 2012 Share Posted September 30, 2012 Will this work with any DX8 version? Like dragon eclipse? Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 Now you should do what Robin advised in the original tutorial, cache the data into memory rather then setting it every draw loop. Link to comment Share on other sites More sharing options...
iSnow Posted September 30, 2012 Share Posted September 30, 2012 So, I know features like these keep getting put out for EA, but this would in theory work all the same with 3.0 no? Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 Should work in any of the DX8 versions. Might have to make some changes depending on what engine you use though. Link to comment Share on other sites More sharing options...
jcsnider Posted September 30, 2012 Share Posted September 30, 2012 You need to get visible events to show on the minimap too.. heads up. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 Cleaned up the code a little and also fixed a small bug I had in the ' Draw Player dot.And ya Jcsinder, I'll work on adding it so the visible events show up also. I tried before but ducked it up so I have to retry that part later when I have time. Link to comment Share on other sites More sharing options...
hisherwin Posted September 30, 2012 Share Posted September 30, 2012 I thought there is a Problem on Eclipse 3.0 , on unrecovable Dx8 error ? is that already fixed? Link to comment Share on other sites More sharing options...
Link Posted September 30, 2012 Share Posted September 30, 2012 > Will this work with any DX8 version? Like dragon eclipse?I don't remember Dragon Eclipse being DirectX8 related, but maybe I should double check…although I have used it. Link to comment Share on other sites More sharing options...
clark Posted September 30, 2012 Share Posted September 30, 2012 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 More sharing options...
TheLordOfTheManor Posted September 30, 2012 Share Posted September 30, 2012 > I don't remember Dragon Eclipse being DirectX8 related, but maybe I should double check…although I have used it.It is. The old buggy version isn't. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 Updated the original post with a new DrawMiniMap sub and a new image. With the new code and image it now displays events on the map also. Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 Like i said before, cache the equations instead of calculating them every loop. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 What exactly do you mean by that? Can you give some kind of example. Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 The CameraX and CameraY is a great example, why should that be calculated every loop, rather then updating it when the player successfully moves. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 I'm not sure still what exactly you mean or how it would be done… Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 > I'm not sure still what exactly you mean or how it would be done…> Why do you do so many checks? Cache the positions and re-set them when packets arrive. Don't just re-calculate everything each loop.> > Caching is your friend. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 Again, saying the same thing over and over isn't going to help me get it done. I don't know how I would do that which is why I asked for an example of how its done… Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 I'll look into it right now, just let me go to the bathroom. Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 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 MiniMapNpcRecPublic Type MiniMapNpcRec x As Long y As LongEnd 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 More sharing options...
matthewpull Posted September 30, 2012 Share Posted September 30, 2012 Can someone give me a list of what colour means what please? Link to comment Share on other sites More sharing options...
Ertzel Posted September 30, 2012 Author Share Posted September 30, 2012 White/Pink = EmptyRed/Pink = Block TileBlue/Pink = Warp TileGreen/Pink = Item TileOrange/Pink = Shop TileGreen Dot = PlayerRed Dot = PK PlayerBlack Dot = NPC Attack On SightOrange Dot = NPC ShopPurple Dot = All other NPC'sYellow Dot = Event NPC'sBlue 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 More sharing options...
matthewpull Posted September 30, 2012 Share Posted September 30, 2012 Thanks. Link to comment Share on other sites More sharing options...
Ganjika Posted September 30, 2012 Share Posted September 30, 2012 > I don't remember Dragon Eclipse being DirectX8 related, but maybe I should double check…although I have used it.The newest and latest dragon eclipse is Dx8/Nightly, Does this work in a Dx8/Nightly Environment and in a Eclipse Origins setup? Link to comment Share on other sites More sharing options...
JohnPony Posted September 30, 2012 Share Posted September 30, 2012 > 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now