Mirage Source

Free ORPG making software.
It is currently Tue Apr 23, 2024 12:50 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1403 posts ]  Go to page 1, 2, 3, 4, 5 ... 57  Next
Author Message
PostPosted: Tue Sep 23, 2008 12:51 am 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
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 :D.

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
    Ground As Integer
    Mask As Integer
    Mask2 As Integer
    Anim As Integer
    Anim2 As Integer
    Fringe As Integer
    Type As Byte
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
End Type

So honestly, the next place to go I don't really know xD so I am going to use the search option(Ctrl + F) and type in Ground and press search till something obvious comes up. Seems as if our next place is:

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))
            Map(MapNum).Tile(x, y).Mask = Val(Parse(n + 1))
            Map(MapNum).Tile(x, y).Anim = Val(Parse(n + 2))
            Map(MapNum).Tile(x, y).Fringe = Val(Parse(n + 3))
            Map(MapNum).Tile(x, y).Type = Val(Parse(n + 4))
            Map(MapNum).Tile(x, y).Data1 = Val(Parse(n + 5))
            Map(MapNum).Tile(x, y).Data2 = Val(Parse(n + 6))
            Map(MapNum).Tile(x, y).Data3 = Val(Parse(n + 7))

            n = n + 8

It's probably pretty obvious what you need to do here right? I like to keep things organized myself, so instead of being lazy and adding them to the bottom I added them to the same spots that the UDT has them sorted out. I advise you do the same. If you are adding more than two layers ensure you change all the n + # to the correct ones, don't forget the n = n + #. Mine looks like this now.

Code:
            Map(MapNum).Tile(x, y).Ground = Val(Parse(n))
            Map(MapNum).Tile(x, y).Mask = Val(Parse(n + 1))
            Map(MapNum).Tile(x, y).Mask2 = Val(Parse(n + 2))
            Map(MapNum).Tile(x, y).Anim = Val(Parse(n + 3))
            Map(MapNum).Tile(x, y).Anim2 = Val(Parse(n + 4))
            Map(MapNum).Tile(x, y).Fringe = Val(Parse(n + 5))
            Map(MapNum).Tile(x, y).Type = Val(Parse(n + 6))
            Map(MapNum).Tile(x, y).Data1 = Val(Parse(n + 7))
            Map(MapNum).Tile(x, y).Data2 = Val(Parse(n + 8))
            Map(MapNum).Tile(x, y).Data3 = Val(Parse(n + 9))
           
            n = n + 10

Wow this is fun haha. We are learning something I hope? Next step...

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

Once again, you will need to add your new layers names in here someplace. As previous, I recommend keeping everything in the same order. So add your new layers in here. Mine looks like this.

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

Notice how it is all in order. This is important when sending/receiving packets.

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

Make it work. Keep it in order! xD.

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)
                If frmMirage.optGround.Value Then .Ground = EditorTileY * TILESHEET_WIDTH + EditorTileX
                If frmMirage.optMask.Value Then .Mask = EditorTileY * TILESHEET_WIDTH + EditorTileX
                If frmMirage.optAnim.Value Then .Anim = EditorTileY * TILESHEET_WIDTH + EditorTileX
                If frmMirage.optFringe.Value Then .Fringe = EditorTileY * TILESHEET_WIDTH + EditorTileX
                Call BltMap
            End With

Add in your new layers to this section. I have a new layer called Mask2 and one called Anim2 so I would add these lines.

Code:
If frmMirage.optMask2.Value Then .Mask2 = EditorTileY * TILESHEET_WIDTH + EditorTileX
If frmMirage.optAnim2.Value Then .Anim2 = EditorTileY * TILESHEET_WIDTH + EditorTileX

Scroll down some till you find this:

Code:
    If Button = 2 Then
        If frmMirage.optLayers.Value Then
            With Map.Tile(CurX, CurY)
                If frmMirage.optGround.Value Then .Ground = 0
                If frmMirage.optMask.Value Then .Mask = 0
                If frmMirage.optAnim.Value Then .Anim = 0
                If frmMirage.optFringe.Value Then .Fringe = 0
                Call BltMap
            End With
        Else

This section checks if you are pressing the right click button on the mouse, or Button 2. You need to do basically the same thing here as you did in the last step, just without so much stuff. Got it? Good. Now scroll down past a few other subs until you find...

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 ;). Scroll down till you find...

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
                    If TempTile(X, Y).DoorOpen = NO Then
                        rec.Top = (.Mask \ TILESHEET_WIDTH) * PIC_Y
                        rec.Bottom = rec.Top + PIC_Y
                        rec.Left = Int(.Mask Mod TILESHEET_WIDTH) * PIC_X
                        rec.Right = rec.Left + PIC_X
                        Call DDS_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DDS_Tile, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                    End If
                End If

I am going to add my new layer, Mask2 right underneath this code. So now this part in my BltMapTile sub looks like this:

Code:
                If .Mask > 0 Then
                    If TempTile(X, Y).DoorOpen = NO Then
                        rec.Top = (.Mask \ TILESHEET_WIDTH) * PIC_Y
                        rec.Bottom = rec.Top + PIC_Y
                        rec.Left = Int(.Mask Mod TILESHEET_WIDTH) * PIC_X
                        rec.Right = rec.Left + PIC_X
                        Call DDS_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DDS_Tile, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                    End If
                End If
               
                If .Mask2 > 0 Then
                    If TempTile(X, Y).DoorOpen = NO Then
                        rec.Top = (.Mask2 \ TILESHEET_WIDTH) * PIC_Y
                        rec.Bottom = rec.Top + PIC_Y
                        rec.Left = Int(.Mask2 Mod TILESHEET_WIDTH) * PIC_X
                        rec.Right = rec.Left + PIC_X
                        Call DDS_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DDS_Tile, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                    End If
                End If

It's pretty straight forward and shouldn't be too difficult. The same goes for the Anim layers. Just duplicate the current one and change the names accordingly. One more thing though, if you are adding an extra fringe layer then you will have to find...

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.


Last edited by Anthony on Fri Jan 16, 2009 9:12 pm, edited 2 times in total.

Top
 Profile  
 
PostPosted: Fri Sep 26, 2008 4:00 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Sep 12, 2008 11:18 pm
Posts: 176
Location: England.
Code:
                If .Anim2 > 0 Then
                    rec.Top = (.Anim2 \ TILESHEET_WIDTH) * PIC_Y
                    rec.Bottom = rec.Top + PIC_Y
                    rec.Left = Int(.Anim2 Mod TILESHEET_WIDTH) * PIC_X
                    rec.Right = rec.Left + PIC_X
                    Call DD_MiddleBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                End If


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


Top
 Profile  
 
PostPosted: Fri Sep 26, 2008 4:28 pm 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
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?


Top
 Profile  
 
PostPosted: Fri Sep 26, 2008 8:14 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Sep 12, 2008 11:18 pm
Posts: 176
Location: England.
Thought so, thanks.

Also, how do I make a Fringe Animation?


Top
 Profile  
 
PostPosted: Wed Oct 29, 2008 12:08 am 
Offline
Regular
User avatar

Joined: Sun Mar 23, 2008 2:34 pm
Posts: 85
Location: Ireland
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
                    If TempTile(X, Y).DoorOpen = NO Then
                        rec.Top = (.Mask2 \ TILESHEET_WIDTH) * PIC_Y
                        rec.Bottom = rec.Top + PIC_Y
                        rec.Left = Int(.Mask2 Mod TILESHEET_WIDTH) * PIC_X
                        rec.Right = rec.Left + PIC_X
                        Call DD_LowerBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                    End If
                End If

_________________
ンラスナ ラノチモニ


Top
 Profile  
 
PostPosted: Sat Nov 15, 2008 8:07 pm 
Offline
Knowledgeable
User avatar

Joined: Sun Feb 10, 2008 7:40 pm
Posts: 200
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?
                    If .Anim > 0 Then
                        rec.Top = (.Anim \ TILESHEET_WIDTH) * PIC_Y
                        rec.Bottom = rec.Top + PIC_Y
                        rec.Left = (.Anim Mod TILESHEET_WIDTH) * PIC_X
                        rec.Right = rec.Left + PIC_X
                        Call DDS_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DDS_Tile, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
                    End If
                End If

            End [color=#BF0000]With[/color]
        Next Y
    Next X

_________________
I is back!


Top
 Profile  
 
PostPosted: Sat Nov 15, 2008 9:10 pm 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
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.


Top
 Profile  
 
PostPosted: Sun Nov 16, 2008 1:13 am 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
add and end if before else just after end with

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
PostPosted: Fri Mar 20, 2009 10:22 pm 
Offline
Regular

Joined: Thu Mar 19, 2009 9:42 am
Posts: 30
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 :)


Top
 Profile  
 
PostPosted: Fri Apr 03, 2009 5:42 pm 
Offline
Banned
User avatar

Joined: Mon Jun 05, 2006 9:22 pm
Posts: 394
Location: USA
Wouldn't the old "extra layers" tutorial still work? I don't see a real difference...


Top
 Profile  
 
PostPosted: Fri Apr 03, 2009 6:02 pm 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
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. :P


Top
 Profile  
 
PostPosted: Fri Apr 03, 2009 6:53 pm 
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.


Top
  
 
PostPosted: Wed Dec 01, 2021 7:50 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 3:59 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Econ


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:00 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
54.8


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:01 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Bett


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:02 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Bett


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:03 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Comp


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:04 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Jewe


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:05 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
What


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:06 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Fris


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:08 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Brad


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:09 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Cent


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:10 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Disn


Top
 Profile  
 
PostPosted: Tue Dec 28, 2021 4:11 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 484199
Skag


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1403 posts ]  Go to page 1, 2, 3, 4, 5 ... 57  Next

All times are UTC


Who is online

Users browsing this forum: wanai and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group