Manual contents tab -> Engine Functions --> Materials & Praticles --> effect, effect_local

Read this section and

manual contents tab --> Engine Objects --> Particle --> all of this.

Ask questions in this thread


Code:
// helper function: sets the vector to random direction and length
function vec_randomize (VECTOR* vec, var range)
{
   vec_set(vec,vector(random(1)-0.5,random(1)-0.5,random(1)-0.5));
   vec_normalize(vec,random(range));
}

// helper function: fades out a particle
function p_alphafade(PARTICLE *p)
{
    p.alpha -= p.skill_a*time_step;
    if (p.alpha <= 0) p.lifespan = 0;
}

function p_fountain(PARTICLE* p)
{
   VECTOR vTemp;
   vec_randomize(vTemp,2);
   vec_add(p.vel_x,vTemp);
   vec_set(p.blue,vector(random(255),random(255),255));
   set(p, MOVE | BRIGHT | TRANSLUCENT);
   p.alpha = 100;
   p.size = 2;
   p.gravity = 0.2;
   p.skill_a = 3; // fade factor
   p.event = p_alphafade;
}

function main()
{
  level_load(NULL);
  video_window(NULL,NULL,0,"Particle demo");
  vec_set(camera.x,vector(-150,0,50));
  vec_set(sky_color,vector(50,0,0)); // dark blue

  while(1)
  {
     effect(p_fountain,maxv(1,40*time_step),vector(0,0,0),vector(0,0,5));
     wait(1);
  }
}



The effect() instruction is like ent_create for particles.

The p_fountain() function is like a PANEL* define it sets up the members of the particle effect and sets up it's behavior. You can also think of it like a entity action function that is placed last in ent_create("model", location , entity action); ..

The p.event = p_alphafade and p_alphafade() is kinda like a entity event function for particles.

Ask more as needed. I don't think I can do better then the information in AUM 64 ( just noticed this AUM is c-script but compare it to the code above from the manual and you should be able to see the difference you need to change to make it work)

Last edited by Malice; 06/20/13 18:14.