Here's a random limb particle thingy I made for a game I'm working on. Basically the particles will attach to a limb. Use 1,2,3 to change the particle image, otherwise a random image will be used, which can be quite cool if you like lots of colors
.
REM Project: Limb Fire Functions
REM Created: 6/20/2007 7:03:08 AM
REM
REM ***** Main Source File *****
REM
sync on
sync rate 60
autocam off
randomize timer()
GOSUB SQ_LimbFireSetup
sz=200
`Load Image "Fire5.Bmp",1,1
`Load Image "Fire6.bmp",2,1
`Load Image "Fire7.bmp",3,1
rem MAKE FIRE IMAGES
CREATE BITMAP 1,100,100
for c = 1 to 40
ink rgb(0,155+rnd(100),rnd(255)),0
circle 50,50,c
next c
blur bitmap 1,5
get image 1,0,0,100,100,1
delete bitmap 1
CREATE BITMAP 1,100,100
for c = 1 to 40
ink rgb(255,rnd(255),255),0
circle 50,50,c
next c
blur bitmap 1,5
get image 2,0,0,100,100,1
delete bitmap 1
CREATE BITMAP 1,100,100
for c = 1 to 40
ink rgb(155+rnd(100),rnd(255),0),0
circle 50,50,c
next c
blur bitmap 1,5
get image 3,0,0,100,100,1
delete bitmap 1
CREATE BITMAP 1,100,100
for d = 1 to 1000
Color=rnd(1)
if Color>0 then ink rgb(0,100+rnd(155),0),0 : else : ink rgb(50+rnd(105),0,20),0
dot rnd(100),rnd(100)
next d
blur bitmap 1,5
get image 4,0,0,100,100
delete bitmap 1
`Make Object Sphere 1,5
MakePerson(1,30)
`Limb 1=head
` 2=body
` 3=right hand
` 4=left hand
limb=3
rem Set object 1's limb 3 on fire
SQ_CreateLimbFire(1,limb,1,100)
rem Adjust the size
SQ_SetLimbFireSize(1,limb,100,100)
rem Set the life
SQ_SetLimbFireLife(1,limb,70)
rem Set the randomization for spawning location
SQ_SetLimbFireRandomize(1,limb,1,1,1)
rem Set the fire particles to go up
SQ_SetLimbFireSpeed(1,limb,0,0.5,0)
SQ_ResetLimbFire(1,limb)
make matrix 1,10000,10000,60,60
position matrix 1,-5000,-10,-5000
prepare matrix texture 1,4,1,1
DO
text 0,0,str$(screen fps())
text 0,30,str$(img)
if val(inkey$())>0 then IMG=val(inkey$())
sIMG=IMG
if IMG<=0 or IMG>3 then sIMG=1+rnd(2)
SQ_SetLimbFireImage(1,limb,sIMG)
spd=1
inc x#,spd*(rightkey()-leftkey())
inc z#,spd*(upkey()-downkey())
inc y#,spd*(keystate(17)-Keystate(31))
position object 1,x#,y#,z#
position camera x#,y#+30,z#-150
point camera x#,y#,z#
if Spacekey() then SQ_HideLimbFire(1,limb) else SQ_ShowLimbFire(1,limb)
SQ_UpdateLimbFires()
SYNC
LOOP
END
function MakePerson(obj as integer,globalsize as float)
hs#=GlobalSize/3
rem Make body
Make object plain obj,1,1
body=FreeOBJ()
Make object sphere body,hs#*2
scale object body,50,100,50
rem Make head
head=FreeOBJ()
Make Object Sphere head,hs#
scale object head,100,125,100
rem Make left hand
lefthand=FreeOBJ()
Make Object Sphere lefthand,hs#/2
rem Make right hand
righthand=FreeOBJ()
Make Object Sphere righthand,hs#/2
rem Make meshes from the limbs for the object
MAKE MESH FROM OBJECT body,body
Make MEsh from object head,head
make mesh from object lefthand,lefthand
Make MESH From Object righthand,righthand
rem Add the meshes as limbs
ADD LIMB obj,1,Body
ADD LIMB obj,2,head
ADD LIMB OBJ,3,lefthand
ADD LIMB OBJ,4,righthand
rem Add OFfset the limbs to their proper positions
ResetLimbs(obj,HS#,2,1,3,4)
rem Delete the meshes as they're no longer being used
DELETE MESH Body
DELETE MESH Head
DELETE MESH LEftHand
DELETE MESH Righthand
rem Delete the objects as well
DELETE OBJECT Body
DELETE OBJECT Head
DELETE OBJECT LEftHand
DELETE OBJECT RightHand
endfunction
rem ==============================================
rem
rem RESET LIMBS
rem
rem ==============================================
function ResetLimbs(obj as integer,hs#,h,b,l,r)
OFFSET LIMB obj,b,0,0,0
OFFSET LIMB obj,h,0,hs#*1.5,0
OFFSET LIMB obj,l,hs#/-2,hs#/4,0
OFFSET LIMB obj,r,hs#/2,hs#/4,0
Rotate limb obj,b,0,180,0
Rotate limb obj,h,0,180,0
Rotate limb obj,l,0,180,0
Rotate limb obj,r,0,180,0
endfunction
function FreeOBJ()
repeat
inc TEMP
until object exist(TEMP)=0
endfunction TEMP
rem =======================================
rem
rem LIMB FIRE FUNCTIONS START HERE
rem
rem =======================================
END
SQ_LimbFireSetup:
TYPE SQ_LimbFire
Obj as integer
Limb as integer
Size as float
DeathHeight as float
StartY as float
X as float
Y as float
Z as float
XSize as float
YSize as float
img as integer
SlotOBJ as integer `For second slot
YDie `For second slot
NumOfOBjects as integer
XRnd as float
YRnd as float
ZRnd as float
Exist as boolean
TargetxSize as float
TargetySize as float
XSpeed as float
YSpeed as float
ZSpeed as float
Hidden as boolean
MaxLife as float
ENDTYPE
`SQ_LimbFire(Slot,Object Numbers)
DIM SQ_LimbFire(1000,1000) as SQ_LimbFire
GLOBAL SQ_MaxLimbFire as integer
Return
Function SQ_LimbFireExist(obj as integer,Limb as integer)
Slot=SQ_GetLimbFireSlot(obj,limb)
if SQ_LimbFire(Slot,1).Exist=1 then TEMP=1
Endfunction TEMP
Function SQ_CreateLimbFire(obj as integer,limb as integer,img as integer,NumOfObjects as integer)
Slot=SQ_FreeLimbSlot()
SQ_LimbFire(Slot,1).obj=obj
SQ_LimbFire(Slot,1).limb=limb
SQ_LimbFire(Slot,1).img=img
SQ_LimbFire(Slot,1).xsize=100
SQ_LimbFire(Slot,1).ysize=100
SQ_LimbFire(Slot,1).NumOfObjects=NumOfObjects
SQ_LimbFire(SLot,1).XRnd=10
SQ_LimbFire(Slot,1).YRND=10
SQ_LimbFire(Slot,1).ZRnd=10
SQ_LimbFire(Slot,1).DeathHeight=0
SQ_LimbFire(Slot,1).MaxLife=100
SQ_LimbFire(Slot,1).Exist=1
SQ_LimbFire(Slot,1).TargetXSize=10
SQ_LimbFire(Slot,1).TargetYSize=10
SQ_LimbFire(Slot,1).xSpeed=1
SQ_LimbFire(Slot,1).ySpeed=1
SQ_LimbFire(Slot,1).zSpeed=1
SQ_LimbFire(Slot,1).Hidden=0
FOR SQ_l = 1 to NumOfObjects
SQ_fo=SQ_FreeObject()
SQ_LimbFire(Slot,SQ_l).SlotOBj=SQ_fo
Make Object Plain SQ_fo,10,10
texture object SQ_fo,img
set object transparency SQ_fo,1
disable object zwrite SQ_fo
Ghost Object on sq_fo
set object ambient SQ_fo,0
next SQ_l
SQ_GetMaxLimbFire()
SQ_ResetLimbFire(obj,limb)
Endfunction
Function SQ_SetLimbFireSize(obj as integer,Limb as integer,XSize as float,YSize as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).XSize=XSize
SQ_LimbFire(slot,1).YSize=YSize
Endfunction
Function SQ_SetLimbFireDeathHeight(obj as integer,limb as integer,DeathHeight as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).MaxLife=DeathHeight
Endfunction
Function SQ_SetLimbFireLife(obj as integer,limb as integer,Life as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).MaxLife=Life
endfunction
Function SQ_SetLimbFireRandomize(obj as integer,limb as integer,XRnd as float,YRnd as float,ZRnd as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).XRnd=XRnd
SQ_LimbFire(slot,1).yRnd=yRnd
SQ_LimbFire(slot,1).zRnd=zRnd
endfunction
Function SQ_SetLimbFireTargetSize(obj as integer,limb as integer,xsize as float,ysize as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).TargetxSize=xSize
SQ_LimbFire(slot,1).TargetySize=ySize
Endfunction
Function SQ_SetLimbFireSpeed(obj as integer,limb as integer,xspeed as float,yspeed as float,zspeed as float)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).xSpeed=xSpeed
SQ_LimbFire(slot,1).ySpeed=ySpeed
SQ_LimbFire(slot,1).zSpeed=zSpeed
Endfunction
Function SQ_SetLimbFireImage(obj as integer,limb as integer,img as integer)
if Image Exist(img)=0 then SQ_LimbFireError("Image "+str$(img)+" does not exist in 'SQ_SetLimbFireImage("+str$(obj)+", "+str$(limb)+")'.")
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(slot,1).img=img
Endfunction
Function SQ_ResetLimbFire(obj as integer,limb as integer)
Slot=SQ_GetLimbFireSlot(obj,limb)
for o = 1 to SQ_LimbFire(Slot,1).NumOfObjects
SlotOBJ=SQ_LimbFire(Slot,o).slotobj
position object SlotOBJ,Limb Position X(Obj,Limb)-SQ_LimbFire(Slot,1).Xrnd/2+RND(SQ_LIMBFIRE(SLOT,1).xRND),Limb Position Y(Obj,Limb)-RND(SQ_LimbFire(Slot,1).YRNd),Limb Position Z(Obj,Limb)-SQ_LimbFire(Slot,1).zrnd/2+RND(SQ_LIMBFIRE(SLOT,1).zRND)
SQ_LimbFire(Slot,o).YDie=Object position y(SlotOBJ)+SQ_LimbFire(Slot,1).DeathHeight-SQ_LimbFire(Slot,1).YRND/2+rND(SQ_LimbFire(Slot,1).YRnd)
Value=RND(SQ_LimbFire(Slot,1).MaxLife)
SQ_LimbFire(Slot,o).DeathHeight=Value
position object slotobj,object position x(slotobj)+SQ_LimbFire(Slot,1).XSpeed*value,object position y(slotobj)+SQ_LimbFire(Slot,1).ySpeed*value,object position z(SlotObj)+SQ_LimbFire(Slot,1).zSpeed*value
next o
Endfunction
Function SQ_HideLimbFire(obj as integer,limb as integer)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(Slot,1).Hidden=1
Endfunction
Function SQ_ShowLimbFire(obj as integer,limb as integer)
Slot=SQ_GetLimbFireSlot(obj,limb)
SQ_LimbFire(Slot,1).Hidden=0
Endfunction
Function SQ_SizeLimbFireobject(obj as integer,xs as float,ys as float,zs as float)
xp#=xs/Object Size X(Obj,1)
yp#=ys/Object Size Y(Obj,1)
zp#=zs/Object Size Z(Obj,1)
Scale Object OBj,Object Size X(Obj,1)*xp#,Object size Y(OBj,1)*yp#,Object Size Z(Obj,1)*zp#
endfunction
Function SQ_UpdateLimbFires()
if SQ_MaxLimbFire<=0 then exitfunction
FOR l = 1 to SQ_MaxLimbFire
obj=SQ_LimbFire(l,1).obj
Limb=SQ_LimbFire(l,1).limb
Slot=l
for o = 1 to SQ_LimbFire(l,1).NumOfObjects
SlotObj=SQ_LimbFire(l,o).SlotOBJ
Position Object SlotOBJ,Object position x(SlotOBJ)+SQ_LimbFire(l,1).XSpeed,Object Position y(SlotOBJ)+SQ_LimbFire(l,1).ySpeed,Object position z(SlotOBJ)+SQ_LimbFire(l,1).ZSpeed
SQ_LimbFire(l,o).DeathHeight=SQ_LimbFire(l,o).DeathHeight-1
if SQ_LimbFire(l,o).DeathHeight<=0
SQ_LimbFire(l,o).DeathHeight=SQ_LimbFire(l,1).MaxLife
position object SlotOBJ,Limb Position X(Obj,Limb)-SQ_LimbFire(Slot,1).Xrnd/2+RND(SQ_LIMBFIRE(SLOT,1).xRND),Limb Position Y(Obj,Limb)-RND(SQ_LimbFire(Slot,1).YRNd),Limb Position Z(Obj,Limb)-SQ_LimbFire(Slot,1).zrnd/2+RND(SQ_LIMBFIRE(SLOT,1).zRND)
SQ_LimbFire(l,o).YDie=Object position y(SlotOBJ)+SQ_LimbFire(Slot,1).DeathHeight-SQ_LimbFire(Slot,1).YRND/2+rND(SQ_LimbFire(Slot,1).YRnd)
Texture Object SlotOBJ,SQ_LimbFire(Slot,1).img
if SQ_LimbFire(l,1).Hidden=1 then Exclude Object On SlotOBJ else Exclude Object Off SlotOBJ
SQ_SizeLimbFireObject(SlotOBJ,SQ_LimbFire(l,1).xsize,SQ_LimbFire(l,1).ysize,0)
Endif
xs#=object size x(SlotOBJ,1)
ys#=Object Size y(SlotOBJ,1)
`xs#=Curvevalue(SQ_LimbFire(l,1).TargetXSize,xs#,SQ_LimbFire(l,1).DeathHeight)
`ys#=Curvevalue(SQ_LimbFire(l,1).TargetYSize,ys#,SQ_LimbFire(l,1).DeathHeight)
`SQ_SizeLimbFireObject(SlotOBJ,xs#,ys#,0)
point object SlotOBJ,camera position x(),camera position y(),camera position z()
next o
Next l
Endfunction
function SQ_GetMaxLimbFire()
repeat
inc l
if SQ_LimbFire(l,1).Exist=0 then Foundit=l-1
until l=1000 or FoundIt>0
if foundit=0 then Foundit=1000
SQ_MAxLimbFire=Foundit
endfunction
function SQ_FreeLimbSlot()
repeat
inc TEMP,1
if TEMP>1000 then SQ_LimbFireError("No more limb fires could be created. You have too many! Delete some!")
Value=SQ_LimbFire(TEMP,1).Exist
until Value=0
endfunction TEMP
function SQ_GetLimbFireSlot(o as integer,l as integer)
s=0
repeat
inc s
if SQ_LimbFire(s,1).obj=o and SQ_LimbFire(s,1).limb=l then Found=1 : exit
until Found=1 or s=1000
TEMP=s
if s=1000 and Found=0 then TEMP=0
if TEMP=0 then SQ_LimbFireError("Object "+str$(obj)+", Limb "+str$(limb)+" does not exist as a Limb Fire Entity. In other words, it was never set up or you deleted it.")
endfunction TEMP
function SQ_FreeObject()
TEMP=99
repeat
inc TEMP,1
until Object Exist(TEMP)=0
endfunction TEMP
Function SQ_DeleteLimbFire(obj as integer,limb as integer)
Slot=SQ_GetLimbFireSlot(obj,limb)
for o = 1 to SQ_LimbFire(Slot,1).NumOfObjects
DELETE OBJECT SQ_LimbFire(Slot,o).SlotOBJ
next o
SQ_LimbFire(Slot,1).Exist=0
SQ_GetMaxLimbFire()
endfunction
Function SQ_LimbFireError(Error as string)
Exit Prompt Error,"SQ Limb Fire Functions"
End
Endfunction