Hi i got a major problem. my game crashes when i uses the effect function in C-Lite. i post a code snippet that uses the function.
Code:
// helper function: sets the vector to random direction and length
function vec_randomize (var* vec, var range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec,random(range));
}
// helper function: fades out a particle
function part_alphafade(PARTICLE *p)
{
p.alpha -= 2*time_step;
if (p.alpha <= 0) p.lifespan = 0;
}
// particle function: generates a fading explosion into vel direction
function effect_explo(PARTICLE *p)
{
var temp[3];
vec_randomize(temp,10);
vec_add (p.vel_x, temp);
p.alpha = 25 + random(25);
p.bmap = "blood.tga";
p.flags |= (BRIGHT | MOVE);
p.event = part_alphafade; // change to a shorter, faster function
}
function hit()
{
if(event_type == EVENT_ENTITY)
{
if(you.skill4 == 2)
{
you.skill3 -= 5;
}
if(you.skill66 == 0 && you != pl){
you.pan = ang(my.pan + 90);
}
ent_morph(me, "blood.tga");
my.flags |= OVERLAY;
my.event=NULL;
vec_scale(normal,10); // produce an explosion into the normal direction
effect(effect_explo,1,my.x,normal);
my.x = you.x;
my.y = you.y;
wait(1);
c_move(my,vector(0-10*speed,0,0),nullvector,GLIDE);
my.skill80=1;
}
if(event_type == EVENT_SURFACE)
{
my.event=NULL;
wait(1);
ent_remove(me);
}
}