Justn Posted September 6, 2012 Author Share Posted September 6, 2012 Hello this tutorial will show you how to add a simple Snow/Rain setting for your maps.. I will also show you how to make a button on your server panel to toggle the weather on and off… I know there is already another weather system posted but this one seems to have alot less code but use whatever one you want. This system was created by Captian Wabbit and I had paid him for this about a year ago. All Credits are to Wabbit and also Scott for fixing an issue.[![](http://www.freemmorpgmaker.com/files/imagehost/pics/fc32cefdaecbf071cfc5dde6126abb47.PNG)](http://www.freemmorpgmaker.com/files/imagehost/#fc32cefdaecbf071cfc5dde6126abb47.PNG)**-Client-**First off open your **client.vbp**.Next add the **rain.bmp** and **snow.bmp** files to your **Client/DataFiles/Graphics/** folder… Please note that these graphics arent mine and you **DO NOT** have premission to use them and are only included for testing…**In modtypes-**Find near the top: **Public Party As PartyRec**under it add:```Public RainDrop(0 To 200) As RainDropRec```Find : **maprec** and at the bottom before **End Type** add:```Weather As Long ' 0 = None 1 = Rain 2 = Snow```Then add this at the bottom of **modTypes:**```Public Type RainDropRecX As LongY As LongInMotion As LongEnd Type```**In modGameLogic-**In the **GameLoop** at the top find: **Dim tmr100 As Long** under it add:```Dim tmr10000 As Long, RainTick As Long, RainUpdateTick As Long```In the **GameLoop** towards the top look for:```' *** Start GameLoop ***Do While InGame Tick = GetTickCount ' Set the inital tick ElapsedTime = Tick - FrameTime ' Set the time difference for time-based movement FrameTime = Tick```Under it add:```' update rain If RainTick < Tick And Map.Weather > 0 Then GenerateRainWave If Map.Weather = 1 Then RainTick = Tick + 100 ' reset time ElseIf Map.Weather = 2 Then RainTick = Tick + 1000 End If End If If RainUpdateTick < Tick And Map.Weather > 0 Then UpdateRainDrops ' update If Map.Weather = 1 Then RainUpdateTick = Tick + 10 ElseIf Map.Weather = 2 Then RainUpdateTick = Tick + 50 End If End If```At the bottom of **ModGameLogic** add:```Public Sub GenerateRainDrop(ByVal RainIndex As Long)' generate raindropRainDrop(RainIndex).X = Rand(1, frmMain.picScreen.Width)RainDrop(RainIndex).Y = 0RainDrop(RainIndex).InMotion = 1End SubPublic Sub GenerateRainWave()Dim i As Long' generate a waveFor i = 1 To Rand(1, 3) GenerateRainDrop FindRainSlot If Map.Weather = 2 Then Exit SubNextEnd SubPublic Function FindRainSlot()Dim i As Long, RainMax As LongIf Map.Weather = 1 Then RainMax = 25 Else RainMax = 15' check if in motionFor i = 1 To RainMax If RainDrop(i).InMotion = 0 Then Exit For End IfNext' replace rainFindRainSlot = iEnd FunctionPublic Sub UpdateRainDrops()Dim i As Long, RainMax As LongIf Map.Weather = 1 Then RainMax = 25 Else RainMax = 15' loop through all raindropsFor i = 1 To RainMax If Not RainDrop(i).InMotion = 0 Then RainDrop(i).Y = RainDrop(i).Y + 5 ' if it's past the screen, reset. If RainDrop(i).Y > frmmain.picscreen.height Then RainDrop(i).InMotion = 0 End If End IfNextEnd Sub```**modClientTCP-**In Sub **SendMap** find: **Buffer.WriteByte .Moral** under it add:```Buffer.WriteLong .Weather```**frmEditor_MapProperties-**Find this line of Code: Private Sub cmdOk_Click()… Now Under: .BootY = Val(txtBootY.text) add:```.Weather = cmbWeather.ListIndex```**modDatabase-**In Sub **SaveMap** above this line: **Close #f** add:```Put #f, , Map.Weather```in Sub **LoadMap** above this line: **Close #f** add:```Get #f, , Map.Weather```**modGameEditors-**Find this in **MapEditorProperties:**```' rest of it .txtUp.text = CStr(Map.Up) .txtDown.text = CStr(Map.Down) .txtLeft.text = CStr(Map.Left) .txtRight.text = CStr(Map.Right) .cmbMoral.ListIndex = Map.Moral .txtBootMap.text = CStr(Map.BootMap) .txtBootX.text = CStr(Map.BootX) .txtBootY.text = CStr(Map.BootY)```Under it Add;```.cmbWeather.ListIndex = Map.Weather```**modDirectDraw7**Ok at the bottom of the **' gfx buffers** declerations add:```Public DDS_Rain As DirectDrawSurface7Public DDS_Snow As DirectDrawSurface7```Then right under those at the bottom of the **'descriptions** declerations add:```Public DDSD_Rain As DDSURFACEDESC2Public DDSD_Snow As DDSURFACEDESC2```Now in **InitSurfaces** find: **' load persistent surfaces**At the bottom of those add:```If FileExist(App.Path & "\data files\graphics\rain.bmp", True) Then Call InitDDSurf("rain", DDSD_Rain, DDS_Rain)If FileExist(App.Path & "\data files\graphics\snow.bmp", True) Then Call InitDDSurf("snow", DDSD_Snow, DDS_Snow)```Next Find this whole chunk of code:```' blt the hover iconFor i = 1 To Player_HighIndex If IsPlaying(i) Then If Player(i).Map = Player(MyIndex).Map Then If CurX = Player(i).X And CurY = Player(i).Y Then If myTargetType = TARGET_TYPE_PLAYER And myTarget = i Then ' dont render lol Else BltHover TARGET_TYPE_PLAYER, i, (Player(i).X * 32) + Player(i).xOffset, (Player(i).Y * 32) + Player(i).yOffset End If End If End If End IfNextFor i = 1 To Npc_HighIndex If MapNpc(i).Num > 0 Then If CurX = MapNpc(i).X And CurY = MapNpc(i).Y Then If myTargetType = TARGET_TYPE_NPC And myTarget = i Then ' dont render lol Else BltHover TARGET_TYPE_NPC, i, (MapNpc(i).X * 32) + MapNpc(i).xOffset, (MapNpc(i).Y * 32) + MapNpc(i).yOffset End If End If End IfNext```Under it add this:```' if map has rainIf Map.Weather > 0 And InMapEditor = False Then ' rain drops Dim G As Long, RainRect As DxVBLib.RECT, RainMax As Long ' check if we've loaded the raindrop If DDS_Rain Is Nothing Then Call InitDDSurf("rain.bmp", DDSD_Rain, DDS_Rain) ElseIf DDS_Snow Is Nothing Then Call InitDDSurf("snow.bmp", DDSD_Snow, DDS_Snow) End If ' setup raindrop rec With rec .Top = 0 .Bottom = 2 .Left = 0 .Right = 14 End With ' less drops for snow If Map.Weather = 1 Then RainMax = 25 Else RainMax = 15 ' loop through all raindrops For G = 1 To RainMax If RainDrop(G).InMotion = 1 Then ' render the rain If Map.Weather = 1 Then ' rain Call Engine_BltFast(Camera.Left + RainDrop(G).X, Camera.Top + RainDrop(G).Y, DDS_Rain, RainRect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Else ' snow Call Engine_BltFast(Camera.Left + RainDrop(G).X, Camera.Top + RainDrop(G).Y, DDS_Snow, RainRect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) End If End If NextEnd If```**modHandleData-**Ok in **Sub HandleMapDat**a above this: **ClearTempTile** add:```Map.Weather = Buffer.ReadLong```**Form Work: frmEditor_MapProperties:**Add a **combo box** and name it **CmbWeather**. Now in the **list** add These three things: **None, Rain, Snow**Should be it for the Client Side. Now for the easy Server Side:**Server-**Open your Server.vbp**modDataBase-**In Sub **SaveMap** above **Close #F** add:```Put #F, , Map(mapnum).Weather```In Sub **LoadMaps** above **Close #F** add:```Get #F, , Map(i).Weather```**modHandleData-**In Sub **HandleMapData** under: **Map(mapnum).Moral = Buffer.ReadByte** Add:```Map(mapnum).Weather = Buffer.ReadLong```**modServerTCP-**In Sub **mapcache_create** above:**MapCache(mapnum).Data = Buffer.ToArray()** Add:```Buffer.WriteLong Map(mapnum).Weather```**In modtypes-**Find : **maprec** and at the bottom before **End Type** add:```Weather As Long ' 0 = None 1 = Rain 2 = Snow```**Optional-**Now that is done you will have a working weather system… but always having to edit a maps weather everytime you want to turn it off and on is kinda lame.. I know there are better ways to have random or map by map toggle but here is a simple button i made to turn it off and on via the server...**Server AND CLIENT**modEnumerations-Add the following to both the client.vbp and server.vbp modenurmerations list:```SSendWeather```modGlobals-Add this to both the Server and Client modGlobals at the bottom:```Public Rainon As Boolean```**Server-**modServerTCPadd this to the bottom:```Sub SendWeather()Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong SSendWeatherIf Rainon = True Then Buffer.WriteLong 1Else Buffer.WriteLong 0End IfSendDataToAll Buffer.ToArray()Set Buffer = NothingEnd Sub```ModGeneral-In InitServer above:' Check if the directory is there, if its not make it add:```Rainon = False```modPlayer-IN sub JoinGame find: ' Send some more little goodies, no need to explain theseBelow the other Calls add:```Call SendWeather```Form Work frmServer:Make a command button somewhere on the server control panel. Double Click the new button and add this:```If Rainon = True Then Rainon = False Call SendWeatherElse Rainon = True Call SendWeatherEnd If```**Client-**modHandleData-Add this near the top under the other ones:```HandleDataSub(SSendWeather) = GetAddress(AddressOf HandleSendWeather)```Add this to the bottom of modHandleData:```Private Sub HandleSendWeather(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim Temp As ByteSet Buffer = New clsBufferBuffer.WriteBytes Data()Temp = Buffer.ReadLongIf Temp = 1 Then Rainon = TrueIf Temp = 0 Then Rainon = FalseSet Buffer = NothingEnd Sub```modDirectDraw7Find this line:```' if map has rainIf Map.Weather > 0 And InMapEditor = False Then```And change it too this:```' if map has rainIf Map.Weather > 0 And InMapEditor = False And Rainon = True Then```That should be it… If you have a bigger picscreen size and want more rain drops find all the maxrain numbers and make them higher =) Link to comment Share on other sites More sharing options...
JohnPony Posted September 6, 2012 Share Posted September 6, 2012 Thanks for contributing, looks pretty good. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 6, 2012 Share Posted September 6, 2012 Pictures for the pictureless? Cause pictures are always cool ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
hisherwin Posted September 6, 2012 Share Posted September 6, 2012 is this much different than my tut? Link to comment Share on other sites More sharing options...
AnonMica Posted September 6, 2012 Share Posted September 6, 2012 it is more cleaner than yours sherwin.. Link to comment Share on other sites More sharing options...
Growlith1223 Posted September 6, 2012 Share Posted September 6, 2012 I had that in the reply box but didn't feel like posting xD Link to comment Share on other sites More sharing options...
Link Posted September 7, 2012 Share Posted September 7, 2012 Nice that you posted this, but it would also be nice to post screen shot examples so that people could have an idea of what they're implementing. Link to comment Share on other sites More sharing options...
Zzbrandon Posted September 7, 2012 Share Posted September 7, 2012 Not really needed because 3.0 already has but awesome possum for 2.3 and 2.0 Link to comment Share on other sites More sharing options...
or3o Posted September 7, 2012 Share Posted September 7, 2012 its a good thing brandon. At the moment 2.3 is the official version and until a few bugs get sorted out i am sure plenty of users will be using 2.0/2.3 especially he people who began projects before 2.3 even existed ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
tslusny Posted September 7, 2012 Share Posted September 7, 2012 > its a good thing brandon. At the moment 2.3 is the official version and until a few bugs get sorted out i am sure plenty of users will be using 2.0/2.3 especially he people who began projects before 2.3 even existed ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)2.3 have still major bugs with event system. And Event system is slow. I reccomedding using Steins Eclopti or mine Eclipse Advanced Link to comment Share on other sites More sharing options...
Stein Posted September 7, 2012 Share Posted September 7, 2012 > 2.3 have still major bugs with event system. And Event system is slow. I reccomedding using Steins Eclopti or mine Eclipse AdvancedYeah no, both still have the same fundamental flaws minus a few bugfixes. Don't go recommend bum candy you know has issues please. 2.3 is more stable and functional than 3.0 in many ways, it's just the Event System that shares issues all over. Link to comment Share on other sites More sharing options...
Justn Posted September 7, 2012 Author Share Posted September 7, 2012 Screenshots look kinda stupid really needs a video to show how it looks =p[![](http://www.freemmorpgmaker.com/files/imagehost/pics/fc32cefdaecbf071cfc5dde6126abb47.PNG)](http://www.freemmorpgmaker.com/files/imagehost/#fc32cefdaecbf071cfc5dde6126abb47.PNG)[![](http://www.freemmorpgmaker.com/files/imagehost/pics/aeaeac19967a713e6dcc429c8c77a617.PNG)](http://www.freemmorpgmaker.com/files/imagehost/#aeaeac19967a713e6dcc429c8c77a617.PNG) Link to comment Share on other sites More sharing options...
Link Posted September 11, 2012 Share Posted September 11, 2012 So, I'm guessing you can change the images yourself, right? Link to comment Share on other sites More sharing options...
Justn Posted September 11, 2012 Author Share Posted September 11, 2012 Yep ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
PVJsquad Posted September 13, 2012 Share Posted September 13, 2012 why I found error ![-_-](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sleep.png)and if I Change To Rain The rain drop short while and after it Lost ? why ? Link to comment Share on other sites More sharing options...
Justn Posted September 13, 2012 Author Share Posted September 13, 2012 Hey I don't understand what u mean goldside? Can u explain it better or send me a pm? 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