Hello everyone,
I am trying very hard not to be too annoying :),
I wanted to learn how to use particles and surfed the
internet a bit, found a "Particle Effect Builder"-program and
played around a bit until I got something to work that I seem to understand mostly.
My only problem that I can't solve is:
The emitter keeps generating particles and the particles do not disappear. The "lifespan" of a particle does not have any actual effect for me. In the "Particle Effect Builder"-program everything seems to work fine, but as code it does not.
The code here is all generated with this program,
the emitter is placed in my mainfunction and is working, the only problem is.. well, the particles wont disappear.
/////////////////////////////////untitled.c/////////////////////////////////
//
//Generated by Parted by Martin Coumont (redphoenix)
//
//LiteC Script file from 15.10.2014 ; 15:31:15:
//
//////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
/////////////////////////////////header/////////////////////////////////
#ifndef PARTED_VECTOR_DEF
#define PARTED_VECTOR_DEF
VECTOR* parted_temp_vec = { x=0;y=0;z=0; }
VECTOR* parted_temp2_vec = { x=0;y=0;z=0; }
ANGLE* parted_temp_ang = { pan=0;tilt=0;roll=0; }
#endif
#ifndef PARTED_RANGEFUNC_DEF
#define PARTED_RANGEFUNC_DEF
function range(x,y,z) {
z+=y;
if(x >= y && x <= z) return(1);
return(0);
}
#endif
/////////////////////////////////particle code/////////////////////////////////
function Base_Effect_base_event(PARTICLE* p) {
p.vel_x = sinv(p.skill_d*3.6+180)*p.skill_x;
p.vel_y = cosv(p.skill_d*3.6)*p.skill_y;
p.vel_z = p.skill_z;
if(p.creator)vec_rotate(p.vel_x,p.creator.pan);
p.skill_d = (p.skill_d + time_step*(var)0.100)%100;
}
function Base_Effect_base(PARTICLE* p) {
p.size = 200.000;
p.alpha = 100.000;
p.red = 255;
p.green = 255;
p.blue = 0;
p.skill_c = 0.5;
p.vel_x = random(10.000)+(-5.000);
p.vel_y = random(10.000)+(-5.000);
p.vel_z = (50.000);
if(p.creator)vec_rotate(p.vel_x,p.creator.pan);
p.lifespan = 1;
p.gravity = 0.000;
p.flags = BRIGHT | MOVE;
p.skill_x = p.vel_x;
p.skill_y = p.vel_y;
p.skill_z = p.vel_z;
p.event = Base_Effect_base_event;
}
/////////////////////////////////timetableemitter actions/////////////////////////////////
action Base_Effect_emitter() {
var my_time;my_time = 0;
var timetable_num;timetable_num = 0;
var eff_frac; eff_frac = 0;
wait(1);
while(my) {
my_time += time_step/16;
if(my_time >= 0.000)my_time = 0;
timetable_num = 1;
parted_temp_vec.x = 0.000;
parted_temp_vec.y = 0.000;
parted_temp_vec.z = 0.000;
vec_rotate(parted_temp_vec,my.pan);
vec_add(parted_temp_vec,my.x);
eff_frac += 0.075*timetable_num*time_step*6.25;
if(eff_frac >= 1){
effect(Base_Effect_base,integer(eff_frac),parted_temp_vec,nullvector);
eff_frac -= integer(eff_frac);
}
wait(1);
}
}
/////////////////////////////////creation/////////////////////////////////
function effect_create(VECTOR* position) {
if(!position)position = nullvector;
wait(3);
you = ent_create(NULL,position,Base_Effect_emitter);
if(you) {
set(you,PASSABLE);
set(you,INVISIBLE);
}
}
(Right now, I think the lifespan of one particle should be 1 Frame/Tick, so it should disappear super fast if it would work)
Thanks for any help