gControl0010 = GUI_PickTexture("fx/spells/harvest","Texture");

gControl0009 = GUI_Slider(
	1.00,
   "Air Resistance",
   0,10);

gControl0008 = GUI_Slider(
	750.00,
   "Max Initial Velocity",
   0,2000);

gControl0007 = GUI_Slider(
	450.00,
   "Min Initial Velocity",
   0,2000);

gControl0006 = GUI_Slider(
   2500.00,
   "Particles Per Second",
   0,5000);

gControl0005 = GUI_Slider(
   0.06,
   "Effect Time",
   0,10);

gControl0004 = GUI_Slider(
   1000.00,
   "Age",
   0,5000);

gControl0003 = GUI_Slider(
	2.00,
   "Scale Per Second",
   0,3);

gControl0002 = GUI_Slider(
   1.00,
   "Start Scale",
   0,1);

gControl0001 = GUI_Slider(
	40.00,
   "Particles Count",
   0,100);

gBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
   "Blend Mode",
   {
      { description="Normal", value=kBlendNormal},
      { description="Additive Alpha", value=kBlendAdditiveAlpha},
      { description="Subtractive", value=kBlendSubtractive},
      { description="Multiplicative", value=kBlendMultiplicative},
      { description="Opaque", value=kBlendOpaque}
   }
);

gFadeSpeed1 = GUI_Slider(
   916.00,
   "White Fade Speed",
   0,2000);
-- ------------------------------------------------------------
-- Initialization phase

-- Define our custom particle properties
pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member

-- dLocus is a data source: An external connection to the particle
-- system. Here we define dLocus for FluidFX, since FluidFX doesn't know
-- to provide the data source; in the game it's defined in
-- swarm.cpp as a data source, and it gets the mouse position.
 if not dLocus then
   dLocus= Vec2(0,0) ;
 end

SetBlendMode(gBlendMode);
SetTexture(gControl0010);

SetNumParticles(gControl0001);

-- ------------------------------------------------------------
-- Action Phase

-- Particle Initialization Rules.
--
-- The following rules define how particles are created.
--
-- Any parameter below in initialization or animation rules that
-- is a scalar, Color(), or Vec2() can alternaly take a function
-- that returns the same type--and most functions can take any type
-- and will return that same type. The exception is any function
-- that's expecting a scalar in certain parameter positions.

-- Pick one of two positions randomly, and add dLocus.
-- dLocus is defined in swarm.cpp and added to the random
-- range
pPosition:Init( dLocus );

pVelocity:Init( f2dRadius(fRange(gControl0007, gControl0008)));
pScale:Init( gControl0002 );
pAge:Init(0);

-- ------------------------------------------------------------
pVelocity:Anim (pVelocity - fTimeScale(pVelocity) * gControl0009);

pPosition:Anim( pPosition + fTimeScale(pVelocity) );

pScale:Anim( pScale + fTimeScale(gControl0003) );

pColor:Anim(fAlpha(pColor, fFade( pAge, 1, 700, 0.4, 300, 0.0)));

pAge:Anim( pAge+fAge() );

Anim( fExpire( fGreater(pAge,gControl0004) ) );

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

gActive = true;
gTime = 0;
function Update(seconds)
   if gActive then
      gTime = gTime + seconds;
      CreateParticles( seconds * gControl0006 );
      if gTime > gControl0005 then 
        gActive = false;
        gTime = 0;
      end
   end
end
