![]() |
[Feature] Adding New Layers - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51) +----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44) +------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13) +------ Thread: [Feature] Adding New Layers (/showthread.php?tid=2171) |
[Feature] Adding New Layers - Anthony - 23-09-2008 This tutorial will guide you through adding more layers to a vanilla MS4(3.68) and try and give an explanation as to what is doing what. *Adding this will require you to delete all your maps. If you want to save them then you will need to create a converter. I am not telling you how to create a converter. So when I go to add something new, regardless of what it is I like to start in the server ![]() Server Side The next thing I like to do is add whatever I am adding to the UDT which needs it. A UDT is a User Defined Type. That's all those Type PlayerRec, Type UserRec, TypePlayerInvRec and so on. These are all in modTypes, duh. modTypes Under the TileRec UDT add in the new layers you want. I am going to add in two new ones. Mine looks like this now. Code: Type TileRec modHandleData If you don't know, modHandleData does exactly what it's name says. Handles data. All the incoming packets from the client are sorted here and then just done whatever with. So find the HandleMapData sub. In this sub you will have to add your new layers in which you added to the TileRec UDT in the last step. Why? Because later you will edit the client side which sends the data to the server, it needs to be received somehow. Anyways, you can see the code that looks like this: Code: Map(MapNum).Tile(x, y).Ground = Val(Parse(n)) Code: Map(MapNum).Tile(x, y).Ground = Val(Parse(n)) modServerTCP Find the MapCache_Create sub. Find this line: Code: MapData = MapData & SEP_CHAR & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 Code: MapData = MapData & SEP_CHAR & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Mask2 & SEP_CHAR & .Anim & SEP_CHAR & .Anim2 & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 Client Side modTypes Add your new types to the UDT. Keep them in the same order as the server! modHandleData Find the HandleMapData sub. You should already know how to do this part. Add your new layers in here. Once again, keep it in order. Don't forget to change the n + # and n = n + # to their new appropriate values. modClientTCP Sub SendMap. Remember this: Code: Packet = Packet & SEP_CHAR & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 frmMirage Add however many new options to the map editor as you need. I only need two so I am putting a new option called optMask2 and one called optAnim2. modGameEditors Find the MapEditorMouseDown sub. If you look at it it should be pretty obvious what needs to happen. Code: With Map.Tile(CurX, CurY) Code: If frmMirage.optMask2.Value Then .Mask2 = EditorTileY * TILESHEET_WIDTH + EditorTileX Code: If Button = 2 Then Sub MapEditorClearLayer Add your new layers in here so they can get cleared properly if you press the clear button. modDirectDraw7 This module handles all the games drawing procedures. This includes drawing layers to the game screen ![]() Sub BltMapTile. I am going to explain something here quickly, I honestly don't know exactly why (maybe somebody could tell me haha) but the way Mirage draws things to the screen is in an order of first to last. The last things are drawn above everything before it. Get it? So if you look at the BltMapTile sub you can see that first the ground is drawn, then the Mask. So since I am just adding a new mask layer (Mask2) I will add it underneath the code for the first mask layer. Follow? This will allow for the Mask2 layer to be drawn over the regular, default Mask layer. Code: If .Mask > 0 Then Code: If .Mask > 0 Then Sub BltMapFringeTile This sub is where all the Fringe layers are drawn so if you want to add another Fringe layer you would go about doing the same thing here as you did with the previous mask layer. Now you are ready to test it! Delete all the maps in your client folder and your server folder. Start the server. Start the client. Enjoy. This is my first tutorial for MS4. Horrah. I tested this and it works. Post if you have any problems or questions. Re: [Feature] Adding New Layers - Mattyw - 26-09-2008 Code: If .Anim2 > 0 Then Should work for Animation 2 right? :S Well, it is overwriting Animation 1, supposed to? Or is it just supposed to blend with it? :S Re: [Feature] Adding New Layers - Anthony - 26-09-2008 Your code looks right but I believe the two animation layers aren't really necessary. They would sort of cancel each other out and be useless. The way it works is similar to the Mask and Mask2 layers. Mask goes below Mask2. Anim will appear underneath Anim2. Get it? So maybe if you wanted o have a animated 32x32 tile with say, a 16x16 flashing light on top of it or something it would be useful. You could go into the GameLoop and find the MapAnimTimer (I think?) code and create a new way to animate. Having two different animation times would allow things to not look so "flash. flash. flash" you know? Re: [Feature] Adding New Layers - Mattyw - 26-09-2008 Thought so, thanks. Also, how do I make a Fringe Animation? Re: [Feature] Adding New Layers - Ravuya - 29-10-2008 Have a slight problem When I login and it goes onto the game screen its error and says Compile Error: Method or data member not found at this bit Code: If .Mask2 > 0 Then Re: [Feature] Adding New Layers - timster0 - 15-11-2008 I'm getting a wierd error when I try to enter my game. "End With without With" Code: ' Is there an animation tile to draw? Re: [Feature] Adding New Layers - Anthony - 15-11-2008 It's exactly what it says. There is an End With without a With. Look at your code and find out where the With is missing or remove the End With if it's not needed. Re: [Feature] Adding New Layers - genusis - 16-11-2008 add and end if before else just after end with Re: [Feature] Adding New Layers - Pix€l - 20-03-2009 Hello, I am French I have a hard time understanding your tutorial :oops: , a Persson to integrate it in my source? (I translated into French MS4) http://www.megaupload.com/?d=YJUWEFV9 Thx , PIx€L ![]() Re: [Feature] Adding New Layers - Anthony - 03-04-2009 This is slightly more updated but it doesn't really matter. At the time people were asking for a tutorial that worked with the current MS4 without having to think about it and just able to copy and paste. So I made this. This post is old and dead anyways. You look like you're trying to start conflict. ![]() Re: [Feature] Adding New Layers - Matt - 03-04-2009 James Wrote:Wouldn't the old "extra layers" tutorial still work? I don't see a real difference... The entire system for blitting the layers and stuff has been changed. |