After a few weeks work, I have finally finished my first real projects. Announcing...*drum roll*...PATRIOTIC PARTICLES!!! (it makes sense if you consider my username
)
Effects Trailer (fixed...it works now!)
All four of these special effects (dust, dirt chunks, sparks, and precipitation (mainly snow)) can be easily and visually edited in the editor I made, and then exported to a single line of code for each one! This line of code you will type when you want to use an effect. It is recommended that you read through this post to find out how everything works before you use Partriotic Particles.
This is the editor. Simple add in your own images to the folder where you save this, adn go down to the "Load Effects" area to set the filename.
:
The effects in the images below were created by Agent Dink (thanks pal ). I will not be distributing those, but am giving out my complete functions I wrote for the use of the community.
His website:
[href]www.silver-dawn.net[/href]
The code for the editor (I may change this if there are bugs dicovered!):
rem created by Uncle Sam (Samuel K.)
rem do not redistribute this program!
rem set settings
set display mode 1024,768,32
sync rate 60
sync on
hide mouse
set camera range 1,10000000000
color backdrop 0
rem load effects
gosub LoadEffects
make matrix 1,2000,2000,1,1
position matrix 1,-500,-1500,-500
rem position and point camera
position camera 100,50,100
point camera 200,50,200
rem initialize variables
EFFECT=1
startingeffect=1
parameternum=1
cangonext=1
cangoback=1
exportstring$=""
rem end of program loop
do
rem print instructions
set cursor 0,0
print "FPS: ";screen fps()
print "Polygons: ";statistic(1)
print "Press 'n' to move to the next parameter."
print "Press 'b' to move to the previous parameter."
print "Press the up and down arrow key to increase and decrease the parameter values."
print "Press the number keys to cycle through effects 1,2,3 and 4."
print "Press 's' to export."
print "---------------------------------"
if inkey$()="1" then EFFECT=1:parameternum=1:startingeffect=1:TurnPrecipitationOff()
if inkey$()="2" then EFFECT=2:parameternum=1:startingeffect=1:TurnPrecipitationOff()
if inkey$()="3" then EFFECT=3:parameternum=1:startingeffect=1:TurnPrecipitationOff()
if inkey$()="4" then EFFECT=4:parameternum=1:startingeffect=1
rem control smoke requests
if EFFECT=1
if startingeffect=1
maxsize=200
faderate=1
scalerate=2
liftrate#=.5
imode=1
smokewindspeed#=.1
smokewinddirection#=90
startingeffect=0
endif
desiredposx#=200-rnd(25)+rnd(25)
desiredposy#=20
desiredposz#=200-rnd(25)+rnd(25)
if inkey$()="s"
exportstring$="RequestSmoke(fillinthisxposition,fillinthisyposition,fillinthiszposition," + str$(maxsize) + "," + str$(faderate) + "," + str$(scalerate) + "," + str$(liftrate#) + "," + str$(smokewindspeed#) + "," + str$(smokewinddirection#) + "," + str$(imode) + ")"
if file exist("Smoke.txt")=1 then delete file "Smoke.txt"
open to write 1,"Smoke.txt"
write string 1,exportstring$
close file 1
endif
print "max size: ";maxsize
print "fade rate: ";faderate
print "scale rate: ";scalerate
print "lift rate#: ";liftrate#
print "image mode: ";imode
print "wind speed#: ";smokewindspeed#
print "wind direction#: ";smokewinddirection#
if inkey$()="n"
if cangonext=1
if parameternum<7
parameternum=parameternum+1
cangonext=0
endif
endif
else
cangonext=1
endif
if inkey$()="b"
if cangoback=1
if parameternum>1
parameternum=parameternum-1
cangoback=0
endif
endif
else
cangoback=1
endif
select parameternum
case 1
print "---------------------------------"
print "CURRENT: max size"
if upkey()=1
maxsize=maxsize+1
endif
if downkey()=1
if maxsize>100
maxsize=maxsize-1
endif
endif
if maxsize<100 then maxsize=100
endcase
case 2
print "---------------------------------"
print "CURRENT: fade rate"
if upkey()=1
if faderate<10
faderate=faderate+1
endif
endif
if faderate>10 then faderate=10
if downkey()=1
if faderate>0
faderate=faderate-1
endif
endif
if fadrate<0 then faderate=0
endcase
case 3
print "---------------------------------"
print "CURRENT: scale rate"
if upkey()=1
scalerate=scalerate+1
endif
if downkey()=1
if scalerate>1
scalerate=scalerate-1
endif
endif
if scalerate<1 then scalerate=1
endcase
case 4
print "---------------------------------"
print "CURRENT: lift rate#"
if upkey()=1
liftrate#=liftrate#+.1
endif
if downkey()=1
liftrate#=liftrate#-.1
endif
endcase
case 5
print "---------------------------------"
print "CURRENT: image mode"
if upkey()=1
if canupsimagemode=1
if imode<3
imode=imode+1
canupsimagemode=0
endif
endif
else
canupsimagemode=1
endif
if downkey()=1
if candownsimagemode=1
if imode>1
imode=imode-1
candownsimagemode=1
endif
endif
else
candownsimagemode=1
endif
endcase
case 6
print "---------------------------------"
print "CURRENT: wind speed#"
if upkey()=1
smokewindspeed#=smokewindspeed#+.1
endif
if downkey()=1
smokewindspeed#=smokewindspeed#-.1
endif
endcase
case 7
print "---------------------------------"
print "CURRENT: wind direction#"
if upkey()=1
smokewinddirection#=wrapvalue(smokewinddirection#+1)
endif
if downkey()=1
smokewinddirection#=wrapvalue(smokewinddirection#-1)
endif
endcase
endselect
if smokecounter=5
RequestSmoke(desiredposx#,desiredposy#,desiredposz#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imode)
smokecounter=0
else
smokecounter=smokecounter+1
endif
endif
rem control dirt clod requests
if EFFECT=2
if startingeffect=1
maxsize=120
gravityrate#=.1
scalerate=1
life=100
liftrate#=3
imode=1
radius#=1
startingeffect=0
endif
desiredposx#=200-rnd(25)+rnd(25)
desiredposy#=70
desiredposz#=200-rnd(25)+rnd(25)
if inkey$()="s"
exportstring$="RequestDirtClod(fillinthisxposition,fillinthisyposition,fillinthiszposition," + str$(maxsize) + "," + str$(gravityrate#) + "," + str$(life) + "," + str$(liftrate#) + "," + str$(radius#) + "," + str$(imode) + ")"
if file exist("DirtClods.txt")=1 then delete file "DirtClods.txt"
open to write 1,"DirtClods.txt"
write string 1,exportstring$
close file 1
endif
print "size: ";maxsize
print "gravity#: ";gravityrate#
print "life: ";life
print "lift rate#: ";liftrate#
print "image mode: ";imode
print "radius#: ";radius#
if inkey$()="n"
if cangonext=1
if parameternum<6
parameternum=parameternum+1
cangonext=0
endif
endif
else
cangonext=1
endif
if inkey$()="b"
if cangoback=1
if parameternum>1
parameternum=parameternum-1
cangoback=0
endif
endif
else
cangoback=1
endif
select parameternum
case 1
print "---------------------------------"
print "CURRENT: size"
if upkey()=1
maxsize=maxsize+1
endif
if downkey()=1
if maxsize>100
maxsize=maxsize-1
endif
endif
if maxsize<100 then maxsize=100
endcase
case 2
print "---------------------------------"
print "CURRENT: gravity"
if upkey()=1
gravityrate#=gravityrate#+.1
endif
if downkey()=1
if gravityrate#>0
gravityrate#=gravityrate#-.1
endif
endif
if gravityrate#<0 then gravityrate#=0
endcase
case 3
print "---------------------------------"
print "CURRENT: life"
if upkey()=1
life=life+1
endif
if downkey()=1
if life>0
life=life-1
endif
endif
if life<0 then life=0
endcase
case 4
print "---------------------------------"
print "CURRENT: lift rate#"
if upkey()=1
liftrate#=liftrate#+.1
endif
if downkey()=1
if liftrate#>0
liftrate#=liftrate#-.1
endif
endif
if liftrate#<0 then liftrate#=0
endcase
case 5
print "---------------------------------"
print "CURRENT: image mode"
if upkey()=1
if imode=1
imode=2
endif
endif
if downkey()=1
if imode=2
imode=1
endif
endif
endcase
case 6
print "---------------------------------"
print "CURRENT: radius#"
if upkey()=1
radius#=radius#+.1
endif
if downkey()=1
if radius#>0
radius#=radius#-.1
endif
endif
if radius#<0 then radius#=0
endcase
endselect
rem if dirtcounter=5
RequestDirtClod(desiredposx#,desiredposy#,desiredposz#,maxsize,gravityrate#,life,liftrate#,radius#,imode)
rem dirtcounter=0
rem else
rem dirtcounter=dirtcounter+1
rem endif
endif
rem control spark requests
if EFFECT=3
if startingeffect=1
maxsize=120
gravityrate#=0
scalerate=1
liftrate#=.1
radius#=.3
faderate=1
imode=1
startingeffect=0
endif
if inkey$()="s"
exportstring$="RequestSpark(fillinthisxposition,fillinthisyposition,fillinthiszposition," + str$(maxsize) + "," + str$(gravityrate#) + "," + str$(scalerate) + "," + str$(liftrate#) + "," + str$(radius#) + "," + str$(faderate) + "," + str$(imode) + ")"
if file exist("Sparks.txt")=1 then delete file "Sparks.txt"
open to write 1,"Sparks.txt"
write string 1,exportstring$
close file 1
endif
desiredposx#=200-rnd(50)+rnd(100)
desiredposy#=40-rnd(10)+rnd(20)
desiredposz#=200-rnd(50)+rnd(100)
print "size: ";maxsize
print "gravity#: ";gravityrate#
print "faderate: ";faderate
print "scalerate: ";scalerate
print "lift rate#: ";liftrate#
print "image mode: ";imode
print "radius#: ";radius#
if inkey$()="n"
if cangonext=1
if parameternum<7
parameternum=parameternum+1
cangonext=0
endif
endif
else
cangonext=1
endif
if inkey$()="b"
if cangoback=1
if parameternum>1
parameternum=parameternum-1
cangoback=0
endif
endif
else
cangoback=1
endif
select parameternum
case 1
print "---------------------------------"
print "CURRENT: size"
if upkey()=1
maxsize=maxsize+1
endif
if downkey()=1
if maxsize>100
maxsize=maxsize-1
endif
endif
if maxsize<100 then maxsize=100
endcase
case 2
print "---------------------------------"
print "CURRENT: gravity"
if upkey()=1
gravityrate#=gravityrate#+.1
endif
if downkey()=1
if gravityrate#>0
gravityrate#=gravityrate#-.1
endif
endif
if gravityrate#<0 then gravityrate#=0
endcase
case 3
print "---------------------------------"
print "CURRENT: faderate"
if upkey()=1
faderate=faderate+1
endif
if downkey()=1
if faderate>1
faderate=faderate-1
endif
endif
if life<0 then life=0
endcase
case 4
print "---------------------------------"
print "CURRENT: scale rate"
if upkey()=1
scalerate=scalerate+1
endif
if downkey()=1
if scalerate>1
scalerate=scalerate-1
endif
endif
if scalerate<1 then scalerate=1
endcase
case 5
print "---------------------------------"
print "CURRENT: lift rate#"
if upkey()=1
liftrate#=liftrate#+.1
endif
if downkey()=1
if liftrate#>0
liftrate#=liftrate#-.1
endif
endif
if liftrate#<0 then liftrate#=0
endcase
case 6
print "---------------------------------"
print "CURRENT: image mode"
if upkey()=1
if imode=1
imode=2
endif
endif
if downkey()=1
if imode=2
imode=1
endif
endif
endcase
case 7
print "---------------------------------"
print "CURRENT: radius#"
if upkey()=1
radius#=radius#+.1
endif
if downkey()=1
if radius#>0
radius#=radius#-.1
endif
endif
if radius#<0 then radius#=0
endcase
endselect
rem if dirtcounter=5
RequestSpark(desiredposx#,desiredposy#,desiredposz#,maxsize,gravityrate#,scalerate,liftrate#,radius#,faderate,imode)
rem dirtcounter=0
rem else
rem dirtcounter=dirtcounter+1
rem endif
endif
rem control spark requests
if EFFECT=4
if startingeffect=1
flakesize=125
gravityrate#=1
matrixoradvancedterrain=1
spinspeed#=0
windspeed#=0
density=1
imode=2
groundnum=1
winddirection#=90
windvariant#=0
fadelevel=30
startingeffect=0
schanged=1
endif
if inkey$()="s"
exportstring$="RequestPrecipitation(fillinthisx1position,fillinthisz1position,fillinthisyposition,fillinthisx2position,fillinthisz2position," + str$(flakesize) + "," + str$(gravityrate#) + "," + str$(matrixoradvancedterrain) + "," + str$(spinspeed#) + "," + str$(windspeed#) + "," + str$(density) + "," + str$(groundnum) + "," + str$(winddirection#) + "," + str$(windvariant#) + "," + str$(fadelevel) + "," + str$(imode) + ")"
if file exist("Sparks.txt")=1 then delete file "Sparks.txt"
open to write 1,"Sparks.txt"
write string 1,exportstring$
close file 1
endif
desiredposx1#=100
desiredposz1#=100
desiredposy#=120
desiredposx2#=200
desiredposz2#=200
print "particle size: ";flakesize
print "gravity#: ";gravityrate#
print "fade level: ";fadelevel
print "spin speed#: ";spinspeed#
print "density (recommended 0 or 1!): ";density
print "matrix or advanced terrain (1 or 2). Must be changed in your game only: ";matrixoradvancedterrain
print "ground number. Must be changed in your game only: ";groundnum
print "windspeed#: ";windspeed#
print "winddirection#: ";winddirection#
print "windvariant#: ";windvariant#
print "image mode: ";imode
if inkey$()="n"
if cangonext=1
if parameternum<11
parameternum=parameternum+1
cangonext=0
endif
endif
else
cangonext=1
endif
if inkey$()="b"
if cangoback=1
if parameternum>1
parameternum=parameternum-1
cangoback=0
endif
endif
else
cangoback=1
endif
select parameternum
case 1
print "---------------------------------"
print "CURRENT: flake size"
if upkey()=1
flakesize=flakesize+1
schanged=1
endif
if downkey()=1
if flakesize>100
flakesize=flakesize-1
schanged=1
endif
endif
if flakesize<100 then flakesize=100
endcase
case 2
print "---------------------------------"
print "CURRENT: gravity"
if upkey()=1
gravityrate#=gravityrate#+.1
schanged=1
endif
if downkey()=1
if gravityrate#>0
gravityrate#=gravityrate#-.1
schanged=1
endif
endif
if gravityrate#<0 then gravityrate#=0
endcase
case 3
print "---------------------------------"
print "CURRENT: fade level"
if upkey()=1
if fadelevel<100
fadelevel=fadelevel+1
schanged=1
endif
endif
if downkey()=1
if fadelevel>0
fadelevel=fadelevel-1
schanged=1
endif
endif
if life<0 then life=0
endcase
case 4
print "---------------------------------"
print "CURRENT: spin speed#"
if upkey()=1
spinspeed#=spinspeed#+.1
schanged=1
endif
if downkey()=1
spinspeed#=spinspeed#-.1
schanged=1
endif
endcase
case 5
print "---------------------------------"
print "CURRENT: density (recommended 0 or 1!)"
if upkey()=1
density=density+1
schanged=1
endif
if downkey()=1
if density>0
density=density-1
schanged=1
endif
endif
if density<0 then density=0
endcase
case 6
print "---------------------------------"
print "CURRENT: matrix or advanced terrain (1 or 2). Must be changed in your game only."
endcase
case 7
print "---------------------------------"
print "CURRENT: ground number. Must be changed in your game only."
endcase
case 8
print "---------------------------------"
print "CURRENT: wind speed#"
if upkey()=1
windspeed#=windspeed#+.1
schanged=1
endif
if downkey()=1
if windspeed#>0
windspeed#=windspeed#-.1
schanged=1
endif
endif
if windspeed#<0 then windspeed#=0
endcase
case 9
print "---------------------------------"
print "CURRENT: wind direction#"
if upkey()=1
winddirection#=wrapvalue(winddirection#+1)
schanged=1
endif
if downkey()=1
winddirection#=wrapvalue(winddirection#-1)
schanged=1
endif
endcase
case 10
print "---------------------------------"
print "CURRENT: wind variant#"
if upkey()=1
windvariant#=windvariant#+.1
schanged=1
endif
if downkey()=1
if windvariant#>0
windvariant#=windvariant#-.1
schanged=1
endif
if windvariant#<0 then windvariant#=0
endif
endcase
case 11
print "---------------------------------"
print "CURRENT: image mode"
if upkey()=1
if imode=1
imode=2
schanged=1
endif
endif
if downkey()=1
if imode=2
imode=1
schanged=1
endif
endif
endcase
endselect
if schanged=1
TurnPrecipitationOn(desiredposx1#,desiredposz1#,desiredposy#,desiredposx2#,desiredposz2#,flakesize,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnum,winddirection#,windvariant#,fadelevel,imode)
schanged=0
endif
endif
rem this section of code sohuld always be executed:
rem handle smoke
gosub HandleSmoke
rem handle dirt clods
gosub HandleDirtClods
rem handle sparks
gosub HandleSparks
rem handle precipitation
gosub HandlePrecipitation
rem syncronize
sync
rem end of program loop
loop
rem request smoke (x#,y#,z#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imagemode)
function RequestSmoke(desiredposx#,desiredposy#,desiredposz#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imode)
Dsmokepositionx#(CurrentDSmoke(0))=desiredposx#
Dsmokepositiony#(CurrentDSmoke(0))=desiredposy#
Dsmokepositionz#(CurrentDSmoke(0))=desiredposz#
Dsmoking(CurrentDSmoke(0))=1
Dsmokesize(CurrentDSmoke(0))=maxsize
Dsmokefadespeed(CurrentDSmoke(0))=faderate
Dsmokescalerate(CurrentDSmoke(0))=scalerate
Dsmokeliftrate#(CurrentDSmoke(0))=liftrate#
DSmokeImageMode(CurrentDSmoke(0))=imode
DSmokeWindDirection#(0)=smokewinddirection#
DSmokeWindSpeed#(0)=smokewindspeed#
if DSmokeImageMode(CurrentDSmoke(0))=3
Dsmokefade(CurrentDSmoke(0))=60
endif
CurrentDSmoke(0)=CurrentDSmoke(0)+1
if CurrentDSmoke(0)>500 then CurrentDSmoke(0)=1
endfunction
rem request dirt clod (x#,y#,z#,size,gravityrate#,life,liftrate#,radius#,imagemode)
function RequestDirtClod(desiredposx#,desiredposy#,desiredposz#,size,gravityrate#,dlife,liftrate#,dradius#,cimode)
Dclodpositionx#(CurrentDClod(0))=desiredposx#
Dclodpositiony#(CurrentDClod(0))=desiredposy#
Dclodpositionz#(CurrentDClod(0))=desiredposz#
Dcloding(CurrentDClod(0))=1
Dclodsize(CurrentDClod(0))=size
DclodGravity#(CurrentDClod(0))=liftrate#
DclodGravityRate#(CurrentDClod(0))=gravityrate#
Dclodlife(CurrentDClod(0))=dlife
Dclodradius#(CurrentDClod(0))=dradius#
Dcloddirection(CurrentDClod(0))=rnd(360)
DclodImageMode(CurrentDClod(0))=cimode
if DclodImageMode(CurrentDClod(0))=1
set object transparency 30500+CurrentDClod(0),2
set alpha mapping on 30500+CurrentDClod(0),70
else
ghost object on 30500+CurrentDClod(0)
fade object 30500+CurrentDClod(0),70
endif
CurrentDClod(0)=CurrentDClod(0)+1
if CurrentDClod(0)>500 then CurrentDClod(0)=1
endfunction
rem request spark (x#,y#,z#,maxsize,gravityrate#,scalerate,liftrate#,radius#,faderate,imagemode)
function RequestSpark(desiredposx#,desiredposy#,desiredposz#,maxsize,gravityrate#,scalerate,liftrate#,dradius#,faderate,simode)
Sparkpositionx#(CurrentSpark(0))=desiredposx#
Sparkpositiony#(CurrentSpark(0))=desiredposy#
Sparkpositionz#(CurrentSpark(0))=desiredposz#
Sparking(CurrentSpark(0))=1
Sparksize(CurrentSpark(0))=maxsize
SparkGravity#(CurrentSpark(0))=liftrate#
SparkGravityRate#(CurrentSpark(0))=gravityrate#
Sparkscalerate(CurrentSpark(0))=scalerate
Sparkradius#(CurrentSpark(0))=dradius#
Sparkdirection(CurrentSpark(0))=rnd(360)
Sparkfaderate(CurrentSpark(0))=faderate
SparkImageMode(CurrentSpark(0))=simode
if SparkImageMode(CurrentSpark(0))=1
set object transparency 31000+CurrentSpark(0),2
set alpha mapping on 31000+CurrentSpark(0),70
else
ghost object on 31000+CurrentSpark(0)
fade object 31000+CurrentSpark(0),70
endif
CurrentSpark(0)=CurrentSpark(0)+1
if CurrentSpark(0)>500 then CurrentSpark(0)=1
endfunction
rem turn Precipitation on (x1#,z1#,y#,x2#,z2#,size,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnum,winddirection#,windvariant#,fadelevel,imagemode)
function TurnPrecipitationOn(desiredposx1#,desiredposz1#,desiredposy#,desiredposx2#,desiredposz2#,size,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnum,winddirection#,windvariant#,fadelevel,snimode)
StormOn(0)=1
SnowStormLocx1#(0)=desiredposx1#
SnowStormLocy#(0)=desiredposy#
SnowStormLocz1#(0)=desiredposz1#
SnowStormLocx2#(0)=desiredposx2#
SnowStormLocz2#(0)=desiredposz2#
SnowGroundNum(0)=groundnum
SnowGravity#(0)=gravityrate#
SnowImageMode(0)=snimode
SnowMatrixorAT(0)=matrixoradvancedterrain
for t=1 to 501
SnowdesSpin(t)=rnd(3)
next t
for t=1 to 501
SnowWindSpeed#(t)=windspeed#
next t
SnowDensity(0)=density
SnowSpinSpeed#(0)=spinspeed#
SnowWindDirection#(0)=winddirection#
SnowWindSpeed#(0)=windspeed#
SnowWindVariant#(0)=windvariant#
for t=31501 to 32000
scale object t,size+rnd(100),size+rnd(100),size+rnd(100)
next t
for t=31501 to 32000
if SnowImageMode(0)=1
set object transparency t,2
set alpha mapping on t,100-fadelevel
else
ghost object on t
fade object t,100-fadelevel
endif
next t
endfunction
rem turn precipitation off (no parameters)
function TurnPrecipitationOff()
StormOn(0)=0
endfunction
rem handle smoke
HandleSmoke:
for CDSmoke=30000 to 30500
arraycount=CDSmoke-29999
if Dsmoking(arraycount)=1
show object CDSmoke
Dsmokepositionx#(arraycount)=newxvalue(Dsmokepositionx#(arraycount),DsmokeWindDirection#(0),DsmokeWindSpeed#(0))
Dsmokepositionz#(arraycount)=newzvalue(Dsmokepositionz#(arraycount),DsmokeWindDirection#(0),DsmokeWindSpeed#(0))
position object CDSmoke,Dsmokepositionx#(arraycount),Dsmokepositiony#(arraycount),Dsmokepositionz#(arraycount)
point object CDSmoke,camera position x(),camera position y(),camera position z()
scale object CDSmoke,Dsmokescale(arraycount),Dsmokescale(arraycount),Dsmokescale(arraycount)
if DSmokeImageMode(arraycount)=1
set object transparency CDSmoke,2
set alpha mapping on CDSmoke,Dsmokefade(arraycount)
else
ghost object on CDSmoke
fade object CDSmoke,Dsmokefade(arraycount)
endif
if Dsmokefade(arraycount)>=0+Dsmokefadespeed(arraycount)
Dsmokefade(arraycount)=Dsmokefade(arraycount)-Dsmokefadespeed(arraycount)
endif
if Dsmokescale(arraycount)<Dsmokesize(arraycount)
Dsmokescale(arraycount)=Dsmokescale(arraycount)+Dsmokescalerate(arraycount)
endif
Dsmokepositiony#(arraycount)=Dsmokepositiony#(arraycount)+Dsmokeliftrate#(arraycount)
if Dsmokescale(arraycount)>=Dsmokesize(arraycount)
Dsmoking(arraycount)=0
Dsmokescale(arraycount)=0
Dsmokefade(arraycount)=100
Dsmokefadespeed(arraycount)=0
position object CDSmoke,0,0,0
ghost object off CDSmoke
set object transparency CDSmoke,0
hide object CDSmoke
DSmokeImageMode(arraycount)=0
endif
endif
next CDSmoke
return
rem handle dirt clods
HandleDirtClods:
for CSmoke=30501 to 31000
arraycount=CSmoke-30500
if DCloding(arraycount)=1
show object CSmoke
position object CSmoke,Dclodpositionx#(arraycount),Dclodpositiony#(arraycount),Dclodpositionz#(arraycount)
point object CSmoke,camera position x(),camera position y(),camera position z()
scale object CSmoke,Dclodsize(arraycount),Dclodsize(arraycount),Dclodsize(arraycount)
Dclodpositionx#(arraycount)=newxvalue(Dclodpositionx#(arraycount),Dcloddirection(arraycount),Dclodradius#(arraycount))
Dclodpositionz#(arraycount)=newzvalue(Dclodpositionz#(arraycount),Dcloddirection(arraycount),Dclodradius#(arraycount))
Dclodgravity#(arraycount)=Dclodgravity#(arraycount)-Dclodgravityrate#(arraycount)
Dclodpositiony#(arraycount)=Dclodpositiony#(arraycount)+Dclodgravity#(arraycount)
if Dclodlife(arraycount)<=0
Dcloding(arraycount)=0
rem scale object CSmoke,0,0,0
position object CSmoke,0,0,0
ghost object off CSmoke
set alpha mapping on CSmoke,0
set object transparency CSmoke,0
hide object CSmoke
else
Dclodlife(arraycount)=Dclodlife(arraycount)-1
endif
endif
next CSmoke
return
rem handle sparks
HandleSparks:
for CSmoke=31001 to 31500
arraycount=CSmoke-31000
if Sparking(arraycount)=1
show object CSmoke
position object CSmoke,Sparkpositionx#(arraycount),Sparkpositiony#(arraycount),Sparkpositionz#(arraycount)
point object CSmoke,camera position x(),camera position y(),camera position z()
scale object CSmoke,Sparkscale(arraycount),Sparkscale(arraycount),Sparkscale(arraycount)
Sparkpositionx#(arraycount)=newxvalue(Sparkpositionx#(arraycount),Sparkdirection(arraycount),Sparkradius#(arraycount))
Sparkpositionz#(arraycount)=newzvalue(Sparkpositionz#(arraycount),Sparkdirection(arraycount),Sparkradius#(arraycount))
if SparkScale(arraycount)<Sparksize(arraycount)
Sparkscale(arraycount)=Sparkscale(arraycount)+Sparkscalerate(arraycount)
endif
Sparkgravity#(arraycount)=Sparkgravity#(arraycount)-Sparkgravityrate#(arraycount)
Sparkpositiony#(arraycount)=Sparkpositiony#(arraycount)+Sparkgravity#(arraycount)
if SparkImageMode(arraycount)=1
set object transparency CSmoke,2
set alpha mapping on CSmoke,Sparkfade(arraycount)
else
ghost object on CSmoke
fade object CSmoke,Sparkfade(arraycount)
endif
if Sparkfade(arraycount)>=0+Sparkfaderate(arraycount)
Sparkfade(arraycount)=Sparkfade(arraycount)-Sparkfaderate(arraycount)
else
Sparking(arraycount)=0
Sparkscale(arraycount)=100
Sparkfade(arraycount)=100
ghost object off CSmoke
set alpha mapping on CSmoke,0
set object transparency CSmoke,0
scale object CSmoke,0,0,0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
next CSmoke
return
rem handle precipitation
HandlePrecipitation:
for CSmoke=31501 to 32000
arraycount=CSmoke-31500
if Snowing(arraycount)=1
snowspeed#=Snowradius#(0)
Snowpositiony#(arraycount)=Snowpositiony#(arraycount)-Snowgravity#(0)
Snowpositionx#(arraycount)=newxvalue(Snowpositionx#(arraycount),SnowWindDirection#(0),SnowWindSpeed#(0)+rnd(SnowWindVariant#(0)))
Snowpositionz#(arraycount)=newzvalue(Snowpositionz#(arraycount),SnowWindDirection#(0),SnowWindSpeed#(0)+rnd(SnowWindVariant#(0)))
position object CSmoke,Snowpositionx#(arraycount),Snowpositiony#(arraycount),Snowpositionz#(arraycount)
select SnowSpinSpeed#(0)
case 0
point object CSmoke,camera position x(),camera position y(),camera position z()
endcase
endselect
select SnowdesSpin(arraycount)
case 0
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)+SnowSpinSpeed#(0))
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)+SnowSpinSpeed#(0))
endcase
case 1
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)-SnowSpinSpeed#(0))
endcase
case 2
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)+SnowSpinSpeed#(0))
endcase
case 3
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)-SnowSpinSpeed#(0))
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)+SnowSpinSpeed#(0))
endcase
endselect
if Snowpositionx#(arraycount)<SnowStormLocx1#(0) or Snowpositionx#(arraycount)>SnowStormLocx2#(0) or Snowpositionz#(arraycount)<SnowStormLocz1#(0) or Snowpositionz#(arraycount)>SnowStormLocz2#(0)
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
if SnowMatrixorAT(0)=1
if Snowpositiony#(arraycount)<=get ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowpositiony#(arraycount)=get ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
if SnowMatrixorAT(0)=2
if Snowpositiony#(arraycount)<=get terrain ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowpositiony#(arraycount)=get terrain ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
else
if StormOn(0)=1
if rnd(500)<=SnowDensity(0)
Snowpositionx#(arraycount)=SnowStormLocx1#(0)+rnd(SnowStormLocx2#(0)-SnowStormLocx1#(0))
Snowpositiony#(arraycount)=SnowStormLocy#(0)
Snowpositionz#(arraycount)=SnowStormLocz1#(0)+rnd(SnowStormLocz2#(0)-SnowStormLocz1#(0))
Snowing(arraycount)=1
show object CSmoke
endif
endif
endif
next CSmoke
return
rem load effects
LoadEffects:
rem load smoke
dim CurrentDSmoke(0)
dim DSmokeImageMode(501)
dim Dsmoking(501):dim Dsmokescale(501):dim Dsmokesize(501):dim Dsmokefade(501):dim Dsmokefadespeed(501):dim Dsmokescalerate(501):dim Dsmokeliftrate#(501):dim Dsmokepositionx#(501):dim Dsmokepositiony#(501):dim Dsmokepositionz#(501)
CurrentDSmoke(0)=1
for t=1 to 500
Dsmokefade(t)=100
next t
dim DSmokeWindDirection#(0)
dim DSmokeWindSpeed#(0)
load image "dust.png",500
make object plain 30000,50,50
texture object 30000,500
set object collision off 30000
set object ambient 30000,0
hide object 30000
for t=30001 to 30500
clone object t,30000
hide object t
next t
rem load dirt clods
dim CurrentDClod(0):dim Dcloding(501):dim Dclodsize(501):dim DclodGravity#(501):dim DclodGravityrate#(501):dim Dclodlife(501):dim Dclodradius#(501):dim Dcloddirection(501):dim Dclodliftrate#(501):dim Dclodpositionx#(501):dim Dclodpositiony#(501):dim Dclodpositionz#(501)
dim DclodImageMode(501)
CurrentDClod(0)=1
load image "dirt.png",501
make object plain 30501,10,10
texture object 30501,501
set object collision off 30501
set object ambient 30501,0
hide object 30501
for t=30502 to 31000
clone object t,30501
hide object t
next t
rem load sparks
dim CurrentSpark(0):dim Sparking(501):dim Sparkscale(501):dim Sparksize(501):dim SparkGravity#(501):dim SparkGravityrate#(501):dim Sparkscalerate(501):dim Sparkradius#(501):dim Sparkdirection(501):dim Sparkliftrate#(501):dim Sparkfaderate(501):dim Sparkfade(501):dim Sparkpositionx#(501):dim Sparkpositiony#(501):dim Sparkpositionz#(501)
dim SparkImageMode(501)
CurrentSpark(0)=1
for t=1 to 501
Sparkscale(t)=100
next t
load image "spark.png",502
make object plain 31001,1,1
texture object 31001,502
set object ambient 31001,0
set object collision off 31001
hide object 31001
for t=31002 to 31500
instance object t,31001
hide object t
next t
for t=0 to 502
RequestSpark(1,1,1,1,1,1,1,1,1,1)
next t
rem load snow
dim Snowing(501):dim SnowGravity#(0):dim SnowWindSpeed#(501):dim SnowMatrixorAT(0):dim SnowRadius#(0):dim SnowDensity(0):dim SnowSpinSpeed#(0):dim SnowDesSpin(501)::dim Snowpositionx#(501):dim Snowpositiony#(501):dim Snowpositionz#(501)
dim SnowImageMode(501)
dim SnowStormLocx1#(0):dim SnowStormLocy#(0):dim SnowStormLocz1#(0)
dim SnowStormLocx2#(0):dim SnowStormLocz2#(0)
dim SnowGroundNum(0)
dim SnowWindDirection#(0)
dim SnowWindVariant#(0)
dim StormOn(0)
load image "snowflake.bmp",503
make object plain 31501,1,1
texture object 31501,503
set object ambient 31501,0
set object collision off 31501
hide object 31501
for t=31502 to 32000
instance object t,31501
hide object t
next t
return
Here are the functions in an actual "game" example.
The first function is:
RequestSmoke(desiredposx#,desiredposy#,desiredposz#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imagemode)
This function is used to request a smoke effect. Most of the the parameters are self explanatory. The imagemode parameter is used to adjust the transparency mode to match the of image.
NOTE: THE IMAGE MODE MUST BE EITHER 1, 2, OR, 3!!! Typically, .png images use mode 1 and bmp images use mode 2. The 3rd mode is a second form of mode 2. Since mode 2 can be kind of solid looking with certain images, change a mode 2 effect to mode 3 and it will take care of the problem, althoguh the effect amy appear a little smaller.
This is a screenshot of the above function at work, showing an upturned car starting to smoke before the blow (pardon the poor landscape
):
Also, below I took the same function (even though it is made to be used for smoke) and used another image in the place of the smoke image to make a flame effect, even though the function wasn't written for this.
The car is now upon the point of exploding:
The dirt clod function, for the second effect:
RequestDirtClod(desiredposx#,desiredposy#,desiredposz#,size,gravityrate#,life,liftrate#,radius#,imagemode)
Only has image mode 1 or 2! Typically, for all functions, image mode 1 is for .png images, and image mode 2 is for .bmp images, bu this may vary!
The spark function (this one is difficult to see, so you must get the video...and even then, it is not as good as it is when you use it live
)
RequestSpark(desiredposx#,desiredposy#,desiredposz#,maxsize,gravityrate#,scalerate,liftrate#,radius#,faderate,imagemode)
Only has image mode 1 or 2!
And the precipitation function (mainly snow...it works best that way, although you
can use it to make rain)
TurnPrecipitationOn(desiredposx1#,desiredposz1#,desiredposy#,desiredposx2#,desiredposz2#,size,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnumber,winddirection#,windvariant#,fadelevel,imagemode)
Use this only once, before your loop, or it will keep resetting. To turn off the precipitation, type
Only has image mode 1 or 2!
And here is the image I made for the function, which you can use royalty free! It looks better when you add it in:
Videos: (sorry if the effects look slow in the videos; that's because of FRAPS):
Video of Dust
Dust (about 30 secs long, 3.28 megs)
Video of Flames:
Flames (about 30 secs long, 3.03 megs)
Video of Dirt Clods:
Dirt Clods (about 30 secs long, 3.24 megs)
Video of Sparks:
Sparks (about 30 secs long, 3.26 megs)
Video of Snow:
Snow (about 30 secs long, 2.28 megs)
This is how it works:
For the dust function, the parameters are:
PARAMETER-------
DATA TYPE------------
DESCRIPTION
x#------------------------real--------------------x position of effect
y#------------------------real--------------------y position of effect
z#------------------------real--------------------z position of effect
maxsize-------------------integer-----------------maximum size of effect (must be > or = 100!)
faderate------------------integer-----------------rate of effect's image fading
scalerate-----------------integer-----------------rate of effect scaling
liftrate#-----------------real--------------------rate of effect rising
smokewindspeed#-----------real--------------------the wind speed
smokewinddirection#-------real--------------------the direction of the wind
imagemode----------------integer----------------image mode of effect (1, 2 or 3!)
For the dirt clod function, the parameters are:
PARAMETER-------
DATA TYPE------------
DESCRIPTION
x#------------------------real--------------------x position of effect
y#------------------------real--------------------y position of effect
z#------------------------real--------------------z position of effect
maxsize-------------------integer-----------------maximum size of effect (must be > or = 100!)
gravityrate#--------------real--------------------gravitional pull on effect
clodlife------------------integer-----------------life of effect
liftrate#-----------------real--------------------rate of effect lifting
clodradius#---------------real--------------------radius of effect
imagemode----------------integer----------------image mode of effect (1 or 2!)
For the spark function, the parameters are:
PARAMETER-------
DATA TYPE------------
DESCRIPTION
x#------------------------real--------------------x position of effect
y#------------------------real--------------------y position of effect
z#------------------------real--------------------z position of effect
maxsize-------------------integer-----------------maximum size of effect (must be > or = 100!)
gravityrate#--------------real--------------------gravitional pull on effect
scalerate------------------integer-----------------rate of effect scaling
liftrate#-----------------real--------------------rate of effect lifting
clodradius#---------------real--------------------radius of effect
faderate------------------integer-----------------rate of effect's image fading
imagemode----------------integer-----------------image mode of effect (1 or 2!)
For the precipitation function, the parameters are:
PARAMETER-------
DATA TYPE------------
DESCRIPTION
x1#-----------------------real--------------------x1 position of effect
z1#------------------------real-------------------z1 position of effect
y#------------------------real--------------------the y position where the snow falls from
x2#-----------------------real--------------------x2 position of effect
z2#------------------------real-------------------z2 position of effect
size---------------------integer-----------------size of effect (must be > or = 100!)
gravityrate#--------------real--------------------gravitional pull on effect
matrixoradvancedterrain---integer-----------------specify a 1 if you are using a matrix or a 2 if you are using advanced terrain. put a 3 if you are using neither.
spinspeed#-----------------real--------------------speed of snow flake spinning (best to not use this...looks weird and kind of neat at the same time!)
windspeed#-----------------real--------------------the wind speed
density------------------integer-----------------density of storm (you might as well make it 1 or 0)
groundnum----------------integer------------------the number of your matrix or advanced terrain
winddirection#------------real--------------------the direction of the wind
windvariant#------------intege--------------------with this high, the wind effects each snowflake differently, so that they overlap in a nice looking way.
fadelevel---------------integer-------------------1-100. The higher this is, more faded the snow is.
imagemode---------------integer-----------------image mode of effect (1 or 2!)
This is the code for the functions:
rem request smoke (x#,y#,z#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imagemode)
function RequestSmoke(desiredposx#,desiredposy#,desiredposz#,maxsize,faderate,scalerate,liftrate#,smokewindspeed#,smokewinddirection#,imode)
Dsmokepositionx#(CurrentDSmoke(0))=desiredposx#
Dsmokepositiony#(CurrentDSmoke(0))=desiredposy#
Dsmokepositionz#(CurrentDSmoke(0))=desiredposz#
Dsmoking(CurrentDSmoke(0))=1
Dsmokesize(CurrentDSmoke(0))=maxsize
Dsmokefadespeed(CurrentDSmoke(0))=faderate
Dsmokescalerate(CurrentDSmoke(0))=scalerate
Dsmokeliftrate#(CurrentDSmoke(0))=liftrate#
DSmokeImageMode(CurrentDSmoke(0))=imode
DSmokeWindDirection#(0)=smokewinddirection#
DSmokeWindSpeed#(0)=smokewindspeed#
if DSmokeImageMode(CurrentDSmoke(0))=3
Dsmokefade(CurrentDSmoke(0))=60
endif
CurrentDSmoke(0)=CurrentDSmoke(0)+1
if CurrentDSmoke(0)>500 then CurrentDSmoke(0)=1
endfunction
rem request dirt clod (x#,y#,z#,size,gravityrate#,life,liftrate#,radius#,imagemode)
function RequestDirtClod(desiredposx#,desiredposy#,desiredposz#,size,gravityrate#,dlife,liftrate#,dradius#,cimode)
Dclodpositionx#(CurrentDClod(0))=desiredposx#
Dclodpositiony#(CurrentDClod(0))=desiredposy#
Dclodpositionz#(CurrentDClod(0))=desiredposz#
Dcloding(CurrentDClod(0))=1
Dclodsize(CurrentDClod(0))=size
DclodGravity#(CurrentDClod(0))=liftrate#
DclodGravityRate#(CurrentDClod(0))=gravityrate#
Dclodlife(CurrentDClod(0))=dlife
Dclodradius#(CurrentDClod(0))=dradius#
Dcloddirection(CurrentDClod(0))=rnd(360)
DclodImageMode(CurrentDClod(0))=cimode
if DclodImageMode(CurrentDClod(0))=1
set object transparency 30500+CurrentDClod(0),2
set alpha mapping on 30500+CurrentDClod(0),70
else
ghost object on 30500+CurrentDClod(0)
fade object 30500+CurrentDClod(0),70
endif
CurrentDClod(0)=CurrentDClod(0)+1
if CurrentDClod(0)>500 then CurrentDClod(0)=1
endfunction
rem request spark (x#,y#,z#,maxsize,gravityrate#,scalerate,liftrate#,radius#,faderate,imagemode)
function RequestSpark(desiredposx#,desiredposy#,desiredposz#,maxsize,gravityrate#,scalerate,liftrate#,dradius#,faderate,simode)
Sparkpositionx#(CurrentSpark(0))=desiredposx#
Sparkpositiony#(CurrentSpark(0))=desiredposy#
Sparkpositionz#(CurrentSpark(0))=desiredposz#
Sparking(CurrentSpark(0))=1
Sparksize(CurrentSpark(0))=maxsize
SparkGravity#(CurrentSpark(0))=liftrate#
SparkGravityRate#(CurrentSpark(0))=gravityrate#
Sparkscalerate(CurrentSpark(0))=scalerate
Sparkradius#(CurrentSpark(0))=dradius#
Sparkdirection(CurrentSpark(0))=rnd(360)
Sparkfaderate(CurrentSpark(0))=faderate
SparkImageMode(CurrentSpark(0))=simode
if SparkImageMode(CurrentSpark(0))=1
set object transparency 31000+CurrentSpark(0),2
set alpha mapping on 31000+CurrentSpark(0),70
else
ghost object on 31000+CurrentSpark(0)
fade object 31000+CurrentSpark(0),70
endif
CurrentSpark(0)=CurrentSpark(0)+1
if CurrentSpark(0)>500 then CurrentSpark(0)=1
endfunction
rem turn Precipitation on (x1#,z1#,y#,x2#,z2#,size,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnum,winddirection#,windvariant#,fadelevel,imagemode)
function TurnPrecipitationOn(desiredposx1#,desiredposz1#,desiredposy#,desiredposx2#,desiredposz2#,size,gravityrate#,matrixoradvancedterrain,spinspeed#,windspeed#,density,groundnum,winddirection#,windvariant#,fadelevel,snimode)
StormOn(0)=1
SnowStormLocx1#(0)=desiredposx1#
SnowStormLocy#(0)=desiredposy#
SnowStormLocz1#(0)=desiredposz1#
SnowStormLocx2#(0)=desiredposx2#
SnowStormLocz2#(0)=desiredposz2#
SnowGroundNum(0)=groundnum
SnowGravity#(0)=gravityrate#
SnowImageMode(0)=snimode
SnowMatrixorAT(0)=matrixoradvancedterrain
for t=1 to 501
SnowdesSpin(t)=rnd(3)
next t
for t=1 to 501
SnowWindSpeed#(t)=windspeed#
next t
SnowDensity(0)=density
SnowSpinSpeed#(0)=spinspeed#
SnowWindDirection#(0)=winddirection#
SnowWindSpeed#(0)=windspeed#
SnowWindVariant#(0)=windvariant#
for t=31501 to 32000
scale object t,size+rnd(100),size+rnd(100),size+rnd(100)
next t
for t=31501 to 32000
if SnowImageMode(0)=1
set object transparency t,2
set alpha mapping on t,100-fadelevel
else
ghost object on t
fade object t,100-fadelevel
endif
next t
endfunction
rem turn precipitation off (no parameters)
function TurnPrecipitationOff()
StormOn(0)=0
endfunction
rem handle smoke
HandleSmoke:
for CDSmoke=30000 to 30500
arraycount=CDSmoke-29999
if Dsmoking(arraycount)=1
show object CDSmoke
Dsmokepositionx#(arraycount)=newxvalue(Dsmokepositionx#(arraycount),DsmokeWindDirection#(0),DsmokeWindSpeed#(0))
Dsmokepositionz#(arraycount)=newzvalue(Dsmokepositionz#(arraycount),DsmokeWindDirection#(0),DsmokeWindSpeed#(0))
position object CDSmoke,Dsmokepositionx#(arraycount),Dsmokepositiony#(arraycount),Dsmokepositionz#(arraycount)
point object CDSmoke,camera position x(),camera position y(),camera position z()
scale object CDSmoke,Dsmokescale(arraycount),Dsmokescale(arraycount),Dsmokescale(arraycount)
if DSmokeImageMode(arraycount)=1
set object transparency CDSmoke,2
set alpha mapping on CDSmoke,Dsmokefade(arraycount)
else
ghost object on CDSmoke
fade object CDSmoke,Dsmokefade(arraycount)
endif
if Dsmokefade(arraycount)>=0+Dsmokefadespeed(arraycount)
Dsmokefade(arraycount)=Dsmokefade(arraycount)-Dsmokefadespeed(arraycount)
endif
if Dsmokescale(arraycount)<Dsmokesize(arraycount)
Dsmokescale(arraycount)=Dsmokescale(arraycount)+Dsmokescalerate(arraycount)
endif
Dsmokepositiony#(arraycount)=Dsmokepositiony#(arraycount)+Dsmokeliftrate#(arraycount)
if Dsmokescale(arraycount)>=Dsmokesize(arraycount)
Dsmoking(arraycount)=0
Dsmokescale(arraycount)=0
Dsmokefade(arraycount)=100
Dsmokefadespeed(arraycount)=0
position object CDSmoke,0,0,0
ghost object off CDSmoke
set object transparency CDSmoke,0
hide object CDSmoke
DSmokeImageMode(arraycount)=0
endif
endif
next CDSmoke
return
rem handle dirt clods
HandleDirtClods:
for CSmoke=30501 to 31000
arraycount=CSmoke-30500
if DCloding(arraycount)=1
show object CSmoke
position object CSmoke,Dclodpositionx#(arraycount),Dclodpositiony#(arraycount),Dclodpositionz#(arraycount)
point object CSmoke,camera position x(),camera position y(),camera position z()
scale object CSmoke,Dclodsize(arraycount),Dclodsize(arraycount),Dclodsize(arraycount)
Dclodpositionx#(arraycount)=newxvalue(Dclodpositionx#(arraycount),Dcloddirection(arraycount),Dclodradius#(arraycount))
Dclodpositionz#(arraycount)=newzvalue(Dclodpositionz#(arraycount),Dcloddirection(arraycount),Dclodradius#(arraycount))
Dclodgravity#(arraycount)=Dclodgravity#(arraycount)-Dclodgravityrate#(arraycount)
Dclodpositiony#(arraycount)=Dclodpositiony#(arraycount)+Dclodgravity#(arraycount)
if Dclodlife(arraycount)<=0
Dcloding(arraycount)=0
rem scale object CSmoke,0,0,0
position object CSmoke,0,0,0
ghost object off CSmoke
set alpha mapping on CSmoke,0
set object transparency CSmoke,0
hide object CSmoke
else
Dclodlife(arraycount)=Dclodlife(arraycount)-1
endif
endif
next CSmoke
return
rem handle sparks
HandleSparks:
for CSmoke=31001 to 31500
arraycount=CSmoke-31000
if Sparking(arraycount)=1
show object CSmoke
position object CSmoke,Sparkpositionx#(arraycount),Sparkpositiony#(arraycount),Sparkpositionz#(arraycount)
point object CSmoke,camera position x(),camera position y(),camera position z()
scale object CSmoke,Sparkscale(arraycount),Sparkscale(arraycount),Sparkscale(arraycount)
Sparkpositionx#(arraycount)=newxvalue(Sparkpositionx#(arraycount),Sparkdirection(arraycount),Sparkradius#(arraycount))
Sparkpositionz#(arraycount)=newzvalue(Sparkpositionz#(arraycount),Sparkdirection(arraycount),Sparkradius#(arraycount))
if SparkScale(arraycount)<Sparksize(arraycount)
Sparkscale(arraycount)=Sparkscale(arraycount)+Sparkscalerate(arraycount)
endif
Sparkgravity#(arraycount)=Sparkgravity#(arraycount)-Sparkgravityrate#(arraycount)
Sparkpositiony#(arraycount)=Sparkpositiony#(arraycount)+Sparkgravity#(arraycount)
if SparkImageMode(arraycount)=1
set object transparency CSmoke,2
set alpha mapping on CSmoke,Sparkfade(arraycount)
else
ghost object on CSmoke
fade object CSmoke,Sparkfade(arraycount)
endif
if Sparkfade(arraycount)>=0+Sparkfaderate(arraycount)
Sparkfade(arraycount)=Sparkfade(arraycount)-Sparkfaderate(arraycount)
else
Sparking(arraycount)=0
Sparkscale(arraycount)=100
Sparkfade(arraycount)=100
ghost object off CSmoke
set alpha mapping on CSmoke,0
set object transparency CSmoke,0
scale object CSmoke,0,0,0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
next CSmoke
return
rem handle precipitation
HandlePrecipitation:
for CSmoke=31501 to 32000
arraycount=CSmoke-31500
if Snowing(arraycount)=1
snowspeed#=Snowradius#(0)
Snowpositiony#(arraycount)=Snowpositiony#(arraycount)-Snowgravity#(0)
Snowpositionx#(arraycount)=newxvalue(Snowpositionx#(arraycount),SnowWindDirection#(0),SnowWindSpeed#(0)+rnd(SnowWindVariant#(0)))
Snowpositionz#(arraycount)=newzvalue(Snowpositionz#(arraycount),SnowWindDirection#(0),SnowWindSpeed#(0)+rnd(SnowWindVariant#(0)))
position object CSmoke,Snowpositionx#(arraycount),Snowpositiony#(arraycount),Snowpositionz#(arraycount)
select SnowSpinSpeed#(0)
case 0
point object CSmoke,camera position x(),camera position y(),camera position z()
endcase
endselect
select SnowdesSpin(arraycount)
case 0
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)+SnowSpinSpeed#(0))
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)+SnowSpinSpeed#(0))
endcase
case 1
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)-SnowSpinSpeed#(0))
endcase
case 2
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)+SnowSpinSpeed#(0))
endcase
case 3
yrotate object CSmoke,wrapvalue(object angle y(CSmoke)-SnowSpinSpeed#(0))
xrotate object CSmoke,wrapvalue(object angle x(CSmoke)+SnowSpinSpeed#(0))
endcase
endselect
if Snowpositionx#(arraycount)<SnowStormLocx1#(0) or Snowpositionx#(arraycount)>SnowStormLocx2#(0) or Snowpositionz#(arraycount)<SnowStormLocz1#(0) or Snowpositionz#(arraycount)>SnowStormLocz2#(0)
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
if SnowMatrixorAT(0)=1
if Snowpositiony#(arraycount)<=get ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowpositiony#(arraycount)=get ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
if SnowMatrixorAT(0)=2
if Snowpositiony#(arraycount)<=get terrain ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowpositiony#(arraycount)=get terrain ground height(SnowGroundNum(0),Snowpositionx#(arraycount),Snowpositionz#(arraycount))
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
if SnowMatrixorAT(0)=3
if Snowpositiony#(arraycount)<=0
Snowing(arraycount)=0
position object CSmoke,0,0,0
hide object CSmoke
endif
endif
else
if StormOn(0)=1
if rnd(500)<=SnowDensity(0)
Snowpositionx#(arraycount)=SnowStormLocx1#(0)+rnd(SnowStormLocx2#(0)-SnowStormLocx1#(0))
Snowpositiony#(arraycount)=SnowStormLocy#(0)
Snowpositionz#(arraycount)=SnowStormLocz1#(0)+rnd(SnowStormLocz2#(0)-SnowStormLocz1#(0))
Snowing(arraycount)=1
show object CSmoke
endif
endif
endif
next CSmoke
return
rem load effects
LoadEffects:
rem load smoke
dim CurrentDSmoke(0)
dim DSmokeImageMode(501)
dim Dsmoking(501):dim Dsmokescale(501):dim Dsmokesize(501):dim Dsmokefade(501):dim Dsmokefadespeed(501):dim Dsmokescalerate(501):dim Dsmokeliftrate#(501):dim Dsmokepositionx#(501):dim Dsmokepositiony#(501):dim Dsmokepositionz#(501)
CurrentDSmoke(0)=1
for t=1 to 500
Dsmokefade(t)=100
next t
dim DSmokeWindDirection#(0)
dim DSmokeWindSpeed#(0)
load image "dust.png",500
make object plain 30000,50,50
texture object 30000,500
set object collision off 30000
set object ambient 30000,0
hide object 30000
for t=30001 to 30500
clone object t,30000
hide object t
next t
rem load dirt clods
dim CurrentDClod(0):dim Dcloding(501):dim Dclodsize(501):dim DclodGravity#(501):dim DclodGravityrate#(501):dim Dclodlife(501):dim Dclodradius#(501):dim Dcloddirection(501):dim Dclodliftrate#(501):dim Dclodpositionx#(501):dim Dclodpositiony#(501):dim Dclodpositionz#(501)
dim DclodImageMode(501)
CurrentDClod(0)=1
load image "dirt.png",501
make object plain 30501,10,10
texture object 30501,501
set object collision off 30501
set object ambient 30501,0
hide object 30501
for t=30502 to 31000
clone object t,30501
hide object t
next t
rem load sparks
dim CurrentSpark(0):dim Sparking(501):dim Sparkscale(501):dim Sparksize(501):dim SparkGravity#(501):dim SparkGravityrate#(501):dim Sparkscalerate(501):dim Sparkradius#(501):dim Sparkdirection(501):dim Sparkliftrate#(501):dim Sparkfaderate(501):dim Sparkfade(501):dim Sparkpositionx#(501):dim Sparkpositiony#(501):dim Sparkpositionz#(501)
dim SparkImageMode(501)
CurrentSpark(0)=1
for t=1 to 501
Sparkscale(t)=100
next t
load image "spark.png",502
make object plain 31001,1,1
texture object 31001,502
set object ambient 31001,0
set object collision off 31001
hide object 31001
for t=31002 to 31500
instance object t,31001
hide object t
next t
for t=0 to 502
RequestSpark(1,1,1,1,1,1,1,1,1,1)
next t
rem load snow
dim Snowing(501):dim SnowGravity#(0):dim SnowWindSpeed#(501):dim SnowMatrixorAT(0):dim SnowRadius#(0):dim SnowDensity(0):dim SnowSpinSpeed#(0):dim SnowDesSpin(501)::dim Snowpositionx#(501):dim Snowpositiony#(501):dim Snowpositionz#(501)
dim SnowImageMode(501)
dim SnowStormLocx1#(0):dim SnowStormLocy#(0):dim SnowStormLocz1#(0)
dim SnowStormLocx2#(0):dim SnowStormLocz2#(0)
dim SnowGroundNum(0)
dim SnowWindDirection#(0)
dim SnowWindVariant#(0)
dim StormOn(0)
load image "snowflake.bmp",503
make object plain 31501,1,1
texture object 31501,503
set object ambient 31501,0
set object collision off 31501
hide object 31501
for t=31502 to 32000
instance object t,31501
hide object t
next t
return
Simply put this code at the end or anywher inside your program loop, possibly right before the sync command, although this may not affect their performance:
rem handle dirt smoke
gosub HandleDirtSmoke
rem handle dirt clods
gosub HandleDirtClods
rem handle sparks
gosub HandleSparks
Also don't forget to load the effects! Put this code before your program loop, and make sure you have some images in the folder for it to load!........