<EDIT>
Update: Previously the entire world would light up, the system now uses a few extra parameters to only light up a few objects at random times (and at random amounts). So now, if you have like 5 cloud objects, some clouds will light up in the distance while others done, more realistic. (Added the param descriptions below and another video as well).
</EDIT>
A while back I posted an example of how to accomplish a semi-realistic thunder/lightning effect using DBP Native Commands. I've started using it a lot in my games so I decided to turn it into a function, so here it is;
FUNCTION Storm(MinAppend#,MaxAppend#,DecRate#,StartSound,EndSound,StartObj,EndObj,Probability)
FOR x = StartObj TO EndObj
SET OBJECT FOG x,1
NEXT x
IF Storm# <= 0
FOR x = StartObj TO EndObj
Fog = RND(Probability)
IF Fog > 0
SET OBJECT FOG x,0
ENDIF
NEXT x
PLAY SOUND StartSound+RND(EndSound-1)
Storm# = MinAppend# + RND(MaxAppend#)
ENDIF
DEC Storm#,.5
ENDFUNCTION Storm#
SYNTAX:
Storm# = Storm(MinAppend#,MaxAppend#,DecRate#,StartSound,EndSound,StartObj,EndObj,Probability)
MinAppend#: The shortest amount of time before the effect occurs.
MaxAppend#: The longest amount of time before the effect occurs.
DecRate#: The speed at which the counter decreases at. When the counter gets to 0 the effect occurs.
StartSound: The first sound number in a list of consecutive sounds to be played at random when the effect occurs
EndSound: The end sound number in a list... blah blah you get it.
FogFlag: (Removed)
StartObj: The first object in a series of consecutive objects to be randomly lit up
EndObj: Same as above but for the end object
Probability: The chance that an object has of lighting up (not in percentage). Increase this number to increase the chance (and in turn density) of lightning.
And finally, a video of the storm in action (shameless plug for my WIP
):
And a vid of the new function:
The above example uses these settings:
Storm# = Storm(0,50,.5,1,6,994,999,3)
And the example I gave with the other thread;
Note: To really appretiate the effect you'll need a sky sphere/box, however the function really shines with the addition of some clouds.
I might add in some lightning bolt strikes later tonight if Im bored, if not it really isn't too hard to add, just texture a plain with a lightning bolt image, point the plain to the camera, and position it off in the distance when the effect occurs.
<EDIT>
I've included 6 storm sounds in a rar file in this post's download below.
</EDIT>
Hope it helps,
- RUC'[b][/b]