Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weather System
#1
Always wanted weather for your game?

Always thought you could do it yourself?

Tried the weather from the old forms and aren't happy with it's results?

You've come to the right place! This is from Konfuze's source, or whatever they wanna call it now..(Elysium... Diamond..?) Anyways...

Don't add this unless you've saved your code.

Level of Dificulty: 1/5(Just C&P and Understand...)

First, and foremost, back up your code.

Second, Open the Server.

This is the only thing you have to add.

Change
Code:
' Lets change the weather if its time to
    If WeatherSeconds >= 60 Then
        i = Int(Rnd * 3)
        If i  GameWeather Then
            GameWeather = i
            Call SendWeatherToAll
        End If
        WeatherSeconds = 0
    End If

To read

Code:
' Lets change the weather if its time to
    If WeatherSeconds >= 18600 / 2 Then
        i = Int(Rnd * 3)
        If i  GameWeather Then
            GameWeather = i
            Call SendWeatherToAll
            Call PutVar(FileName, "Weather", "Weather", Trim(GameWeather))
        End If
        WeatherSeconds = 0
    End If

That just checks for half a day(12 hours, irl) and changes the weather randomly.

Also, uncomment this line
Code:
WeatherSeconds = WeatherSeconds + 1

That's important. Keeps the time for weather.

Now, close the server. You're done with it. (AHMAGAWD, THAT WAS EASY!!1)

Next, open the client. Open modDirectX.

Put this in there
Code:
Sub BltWeather()
Dim i As Long

    Call DD_BackBuffer.SetForeColor(RGB(0, 0, 200))
    
    If GameWeather = WEATHER_RAINING Then
        For i = 1 To MAX_RAINDROPS
            If DropRain(i).Randomized = False Then
                If frmMirage.tmrRainDrop.Enabled = False Then
                    BLT_RAIN_DROPS = 1
                    frmMirage.tmrRainDrop.Enabled = True
                    If frmMirage.tmrRainDrop.Tag = "" Then
                        frmMirage.tmrRainDrop.Interval = 200
                        frmMirage.tmrRainDrop.Tag = "123"
                    End If
                End If
            End If
        Next i
    ElseIf GameWeather = WEATHER_SNOWING Then
        For i = 1 To MAX_RAINDROPS
            If DropSnow(i).Randomized = False Then
                If frmMirage.tmrSnowDrop.Enabled = False Then
                    BLT_SNOW_DROPS = 1
                    frmMirage.tmrSnowDrop.Enabled = True
                    If frmMirage.tmrSnowDrop.Tag = "" Then
                        frmMirage.tmrSnowDrop.Interval = 200
                        frmMirage.tmrSnowDrop.Tag = "123"
                    End If
                End If
            End If
        Next i
    Else
        If BLT_RAIN_DROPS > 0 And BLT_RAIN_DROPS  RainIntensity Then
    tmrRainDrop.Enabled = False
    Exit Sub
End If
If BLT_RAIN_DROPS > 0 Then
        If DropRain(BLT_RAIN_DROPS).Randomized = False Then
            Call RNDRainDrop(BLT_RAIN_DROPS)
        End If
    End If
    BLT_RAIN_DROPS = BLT_RAIN_DROPS + 1
    If tmrRainDrop.Interval > 30 Then
        tmrRainDrop.Interval = tmrRainDrop.Interval - 10
    End If
End Sub

Private Sub tmrSnowDrop_Timer()
If BLT_SNOW_DROPS > RainIntensity Then
    tmrSnowDrop.Enabled = False
    Exit Sub
End If
If BLT_SNOW_DROPS > 0 Then
        If DropSnow(BLT_SNOW_DROPS).Randomized = False Then
            Call RNDSnowDrop(BLT_SNOW_DROPS)
        End If
    End If
    BLT_SNOW_DROPS = BLT_SNOW_DROPS + 1
    If tmrSnowDrop.Interval > 30 Then
        tmrSnowDrop.Interval = tmrSnowDrop.Interval - 10
    End If
End Sub

And that should be it. If you have any problems whatsoever, or if I'm missing anything, please tell me. This is as easy as I could get it, ripped from Elysium to work for MSE.

Sorry I can't explain what any of it does. I don't understand DirectX too well to do so. Maybe someone else could explain?
Reply
#2
Err, i may be wrong but is there not a weather editing interface missing?
Reply
#3
Nah. If they want more weather, they can build off this one.
Reply
#4
Isn't this DragoonsMaster's weather system which he released ages ago on the old forums.
Reply
#5
No idea.

Came from Konfuze. xD
Reply
#6
In that case, yes, the rain it was based off of DragoonsMaster's code a while back =P He just had rain and I added other shit... But yeah, credit goes to him Wink
Reply
#7
Also if you add the weather command from Konfuze, don't forget to fix the security hole Tongue
Reply
#8
You forgot to include the DropRainRec...

Code:
Type DropRainRec
    x As Long
    y As Long
    Randomized As Boolean
    Speed As Byte
End Type
Reply
#9
Erik Wrote:You forgot to include the DropRainRec...

Code:
Type DropRainRec
    x As Long
    y As Long
    Randomized As Boolean
    Speed As Byte
End Type

Thank you.

I edited and updated the tutorial. Heheh, nice catch.
Reply
#10
GameBoy Wrote:Also if you add the weather command from Konfuze, don't forget to fix the security hole Tongue
lol yeah xD It's not really that bad though.... >
Reply
#11
what the security hole? never hear about it

would'nt this make a weather on every map even in a house?
Reply
#12
You can extend this easily. Add a new type to maps (indoor), if the map is indoor don't use weather. I think this was in Deloria Source.

The weather security hole was quite easy to fix. If you check the packet handler on the server you'll notice it doesn't properly check to see if a moderator is changing the weather, there's only a check on the client to see if a moderator has entered the command which means with a simple packet editor, anybody can change the weather. So make sure you do server checks as well as client checks. Very important
Reply
#13
What I dont like is how you are using a timer for the raindrop/snow drop.

Use a function like GetTickCount

Code:
Public Declare Function GetTickCount lib "Kernel32" as long()

Code:
Global SnowDropTimer1 as long  'Our Tick based timer
Global Constant SnowDropTimer2 = 100 'Our constant time in MS
Global IsRaining as boolean 'Is it raining?


Put it somewhere
Code:
SnowDropTimer1 = GetTickCount + SnowDropTimer2

Code:
If GetTickCount => SnowDropTimer1 Then
SnowDropTimer1 = GetTickcount + SnowDropTimer2       'You've got to update the information
   Call IIf(IsRaining, IsRaining = False, IsRaining = True) 'If it is raining, then it isnt. If it isnt, then it is. :)
End If

...Use the rest for your imagination Tongue
[/code]
Reply
#14
Not my code. xD

This is just a straigt rip. Tongue
Reply
#15
Ooohhh ok. Anwyays timers arent that good to use, because they work on depending the computer speed not by..pure seconds. Dont want to cause any seizures now do we? Tongue
Reply
#16
Lol, yeah, that's mine xD
I'm not reading forums that frequently now... I just got into college and I don't have my computer here ><
Omg , that's OLD xD
Good luck with it. I still use it on my game and it works pretty good.
Reply
#17
Variable not Defined Sad Call PutVar(FileName, "Weather", "Weather", Trim(GameWeather))
Reply
#18
Slevin, make sure that u have Function FileName and/or it defined in modTypes. (look at another blank source and compare/contrast)

----------

EDIT: Lmao when i just tried to add this i get samething rofl!


------------

EDIT AGAIN:
Add this:
Code:
Dim FileName As String

Under:
Code:
Dim DidWalk As Boolean

Which is in the Sub GameAI()
Reply
#19
In the Weather Packet, im having an error on AddText

Says: Wrong number of arguments or invalid property assignment.

Any idea?

Heres my whole packet:

Code:
' ::::::::::::::::::::
    ' :: Weather packet ::
    ' ::::::::::::::::::::
    If (LCase(Parse(0)) = "weather") Then
        If Val(Parse(1)) = WEATHER_RAINING And GameWeather  WEATHER_RAINING Then
            Call AddText("You see drops of rain falling from the sky above!", frmMirage.txtChat, BrightGreen)
        End If
        If Val(Parse(1)) = WEATHER_SNOWING And GameWeather  WEATHER_SNOWING Then
            Call AddText("You see snow falling from the sky above!", frmMirage.txtChat, BrightGreen)
        End If
        
        If Val(Parse(1)) = WEATHER_NONE Then
            If GameWeather = WEATHER_RAINING Then
                Call AddText("The rain beings to calm.", frmMirage.txtChat, BrightGreen)
            ElseIf GameWeather = WEATHER_SNOWING Then
                Call AddText("The snow is melting away.", frmMirage.txtChat, BrightGreen)
            End If
        End If
        GameWeather = Val(Parse(1))
        RainIntensity = 100
        If MAX_RAINDROPS  RainIntensity Then
            MAX_RAINDROPS = RainIntensity
            ReDim DropRain(1 To MAX_RAINDROPS) As DropRainRec
            ReDim DropSnow(1 To MAX_RAINDROPS) As DropRainRec
        End If
    End If

------------

Oh and the link for snow isn't working Wink
Reply
#20
Its because you don't "Add text" in MS. I'm not to sure but I think you need to change it to
Code:
Call globalmsg

Check for other subs, maybe the attack one, and see how the broadcast a global message. And for the snow, make your own in paint.
Reply
#21
Sry about all the bugs. That's very old but it was developed for my game, witch is quite different.
Reply
#22
Update it xD.

And for the GlobalMsg, already tried that and it gives me an error on it and says..

Wrong number of arguments or invalid property assignments

Sad

-----------
EDIT:

MAJOR FIX FOR IT! I fixed it, it just wansn't registering straight so i had compared it to a previous call add text, well heres the correct packet Smile.

Code:
If (LCase(Parse(0)) = "weather") Then
        If Val(Parse(1)) = WEATHER_RAINING And GameWeather  WEATHER_RAINING Then
            Call TextAdd(frmMirage.txtChat, "You see rain drops falling from the sky above!", True)
        End If
        If Val(Parse(1)) = WEATHER_SNOWING And GameWeather  WEATHER_SNOWING Then
            Call TextAdd(frmMirage.txtChat, "You see snow falling from the sky above!", True)
        End If
        
        If Val(Parse(1)) = WEATHER_NONE Then
            If GameWeather = WEATHER_RAINING Then
                Call TextAdd(frmMirage.txtChat, "The rain beings to calm.", True)
            ElseIf GameWeather = WEATHER_SNOWING Then
                Call TextAdd(frmMirage.txtChat, "The snow is melting away.", True)
            End If
        End If
        GameWeather = Val(Parse(1))
        RainIntensity = 100
        If MAX_RAINDROPS  RainIntensity Then
            MAX_RAINDROPS = RainIntensity
            ReDim DropRain(1 To MAX_RAINDROPS) As DropRainRec
            ReDim DropSnow(1 To MAX_RAINDROPS) As DropRainRec
        End If
    End If
Reply
#23
This doesn't really fix it,, I used your packet and I still have the error.
---------------------------------------------------------------------------------
EDIT:

I have a RTE 5: Invalid Procedure call or Argument at Line:

Code:
Call DD_BackBuffer.BltFast(DropSnow(i).x + DropSnow(i).Speed, DropSnow(i).y + DropSnow(i).Speed, DD_SnowSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

In Sub:

[code]

Sub BltWeather()
Dim i As Long

Call DD_BackBuffer.SetForeColor(RGB(0, 0, 200))

If GameWeather = WEATHER_RAINING Then
For i = 1 To MAX_RAINDROPS
If DropRain(i).Randomized = False Then
If frmMirage.tmrRainDrop.Enabled = False Then
BLT_RAIN_DROPS = 1
frmMirage.tmrRainDrop.Enabled = True
If frmMirage.tmrRainDrop.Tag = "" Then
frmMirage.tmrRainDrop.Interval = 200
frmMirage.tmrRainDrop.Tag = "123"
End If
End If
End If
Next i
ElseIf GameWeather = WEATHER_SNOWING Then
For i = 1 To MAX_RAINDROPS
If DropSnow(i).Randomized = False Then
If frmMirage.tmrSnowDrop.Enabled = False Then
BLT_SNOW_DROPS = 1
frmMirage.tmrSnowDrop.Enabled = True
If frmMirage.tmrSnowDrop.Tag = "" Then
frmMirage.tmrSnowDrop.Interval = 200
frmMirage.tmrSnowDrop.Tag = "123"
End If
End If
End If
Next i
Else
If BLT_RAIN_DROPS > 0 And BLT_RAIN_DROPS
Reply
#24
idk o-O, but i was just stating that the fix i posted was for the error on that packet cuz he uses a different way of adding text.
Reply
#25
MS does use the addtext sub. Just search for it.

Anything added without the addtext sub, is serverside.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)