function wood_gib_action(){
VECTOR speed, abspeed;
vec_fill(speed, 0);
vec_fill(abspeed, 0);
ANGLE angle_speed;
vec_fill(angle_speed, 0);
set(my, FLAG2 |SHADOW);
c_setminmax(my);
// Initiate
speed.x = 5 * (random(10) - 5);
speed.y = 5 * (random(10) - 5);
speed.z = random(35) + 5;
angle_speed.pan = random(35) + 35;
angle_speed.tilt = random(35) + 35;
angle_speed.roll = random(35) + 35;
my.roll = random(180); //Start with random orientation
my.pan = random(180);
my.push = -1; // Allow player/enemies to pass through
// Animate gib realtime
my.skill9 = random(50);
while(my.skill9 > -35){
abspeed.x = speed.x * time_step;
abspeed.y = speed.y * time_step;
abspeed.z = speed.z * time_step;
my.pan += angle_speed.pan * time_step;
my.tilt += angle_speed.tilt * time_step;
my.roll += angle_speed.roll * time_step;
c_move(my, nullvector, abspeed, IGNORE_PASSABLE | IGNORE_FLAG2);
if(HIT_TARGET){
speed.z = -(speed.z / 2);
if(speed.z < 0.25){
vec_fill(speed, 0);
vec_fill(angle_speed, 0);
// fix rotation, to it looks lying correctly on the floor
my.tilt = 0;
my.roll = 0;
}
}
speed.z -= 2 * time_step;
my.skill9 -= 1 * time_step;
wait(1);
}
// Fade gib to nothingness
set(my, TRANSLUCENT);
my.alpha = 100;
while(my){
my.alpha -= 5 * time_step;
if(my.alpha <= 0){ break; }
wait(1);
}
safe_remove(my);
}
void main(){
shadow_stencil = 2;
warn_level = 6;
fps_max = 60;
level_load("");
wait(3);
camera.arc = 90;
vec_set(camera.x, vector(-439, 0, 323));
vec_set(camera.pan, vector(0, -36, 0));
level_ent = ent_create(CUBE_MDL, nullvector, NULL);
vec_set(level_ent.scale_x, vector(128, 128, 0.1));
c_setminmax(level_ent);
set(level_ent, POLYGON);
int i = 0;
var counter = 1;
while(!key_esc){
counter += time_frame / 16;
if(counter > 1){ // spawn each second
for(i = 0; i < 32; i++){
ent_create(CUBE_MDL, vector(0, 0, 32), wood_gib_action);
}
counter -= 3;
}
// slow down framerate for testing
if(key_e){ fps_max = 20; }
else{ fps_max = 60; }
DEBUG_VAR(fps_max, 0);
wait(1);
}
}