home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer 5.14
/
2000-11_-_Disc_5.14.iso
/
Goodies
/
3DGameStudio
/
Mission
/
particle.wdl
< prev
next >
Wrap
Text File
|
2000-02-08
|
5KB
|
156 lines
/////////////////////////////////////////////////////////////////////////
// WDL prefabs for particles
/////////////////////////////////////////////////////////////////////////
// Some common definitions
BMAP spark_map,<particle.pcx>;
SKILL scatter_color { RED 250; GREEN 250; BLUE 250; }
SKILL scatter_range { RED -100; GREEN -245; BLUE -245; }
SKILL scatter_lifetime { VAL 50; }
SKILL scatter_size { VAL 100; }
IFDEF ACKNEX_VERSION414;
SKILL scatter_gravity { VAL 0.5; }
SKILL scatter_spread { VAL 6; }
IFELSE;
SKILL scatter_gravity { VAL 4; }
SKILL scatter_spread { VAL 100; }
ENDIF;
/////////////////////////////////////////////////////////////////////////
SYNONYM scatter_map { TYPE BMAP; DEFAULT spark_map; }
SKILL particle_pos {}
SKILL particle_speed {}
SKILL scatter_speed { X 0; Y 0; Z 0; }
/////////////////////////////////////////////////////////////////////////
// The particle_fade action lets a particle fade away
SKILL fade_lifetime { VAL 8; }
SKILL fade_color { RED 255; GREEN 200; BLUE 0; }
SKILL fade_targetcolor { RED 128; GREEN 128; BLUE 128; }
ACTION particle_fade {
IF (MY_AGE == 0) { // just born?
MY_SIZE = 100;
MY_SPEED.X = RANDOM(2)-1;
MY_SPEED.Y = RANDOM(2)-1;
MY_SPEED.Z = RANDOM(2)-1;
MY_COLOR.RED = fade_color.RED;
MY_COLOR.GREEN = fade_color.GREEN;
MY_COLOR.BLUE = fade_color.BLUE;
} ELSE {
MY_COLOR.RED += (fade_targetcolor.RED - MY_COLOR.RED)*0.2;
MY_COLOR.GREEN += (fade_targetcolor.GREEN - MY_COLOR.GREEN)*0.2;
MY_COLOR.BLUE += (fade_targetcolor.BLUE - MY_COLOR.BLUE)*0.2;
IF (MY_AGE > fade_lifetime) { SET MY_ACTION,NULL; }
}
}
/////////////////////////////////////////////////////////////////////////
// The particle_tumble action lets a particle tumble around
// for 0.5 seconds, then disappear.
SKILL tumble_lifetime { VAL 8; }
ACTION particle_tumble {
IF (MY_AGE == 0) { // just born?
MY_SPEED.X = RANDOM(0.3)-0.15;
MY_SPEED.Y = RANDOM(0.3)-0.15;
MY_SPEED.Z = RANDOM(0.3)-0.15;
MY_SIZE = 30;
MY_COLOR.RED = scatter_color.RED * 0.75;
MY_COLOR.GREEN = scatter_color.GREEN * 0.3;
MY_COLOR.BLUE = scatter_color.BLUE * 0.3;
}
IF (MY_AGE > tumble_lifetime) {
SET MY_ACTION,NULL;
}
}
/////////////////////////////////////////////////////////////////////////
// The particle_scatter action will scatter particles in all directions,
// then let them fall to the ground.
ACTION particle_scatter {
IF (MY_AGE == 0) { // just born?
MY_SPEED.X = scatter_speed.X + RANDOM(scatter_spread);
MY_SPEED.Y = scatter_speed.Y + RANDOM(scatter_spread);
MY_SPEED.Z = scatter_speed.Z + RANDOM(scatter_spread);
MY_SIZE = scatter_size;
MY_COLOR.RED = scatter_color.RED;
MY_COLOR.GREEN = scatter_color.GREEN;
MY_COLOR.BLUE = scatter_color.BLUE;
SET MY_MAP,scatter_map;
// SET MY_FLARE,ON; //$$$
RETURN;
}
// Add gravity
MY_SPEED.Z -= scatter_gravity;
// Maybe add random term to age
// MY_AGE += RANDOM(0.05);
IF (MY_AGE >= scatter_lifetime) {
SET MY_ACTION,NULL;
}
}
// The same, but with a particle trace behind
ACTION particle_traces {
CALL particle_scatter;
// A particle itself may EMIT further particles
EMIT 1,MY_POS,particle_tumble;
}
// The same, but with a color range
ACTION particle_range {
CALL particle_scatter;
IF (MY_AGE > 0) {
MY_COLOR.RED += scatter_range.RED*MY_AGE/scatter_lifetime;
MY_COLOR.GREEN += scatter_range.GREEN*MY_AGE/scatter_lifetime;
MY_COLOR.BLUE += scatter_range.BLUE*MY_AGE/scatter_lifetime;
}
}
// The same, but emits a sphere, with color range
ACTION particle_sphere {
CALL particle_scatter;
IF (MY_AGE == 0) {
NORMALIZE MY_SPEED,scatter_spread;
} ELSE {
MY_COLOR.RED += scatter_range.RED*MY_AGE/scatter_lifetime;
MY_COLOR.GREEN += scatter_range.GREEN*MY_AGE/scatter_lifetime;
MY_COLOR.BLUE += scatter_range.BLUE*MY_AGE/scatter_lifetime;
}
}
// This action may be called to initalize the scattering
ACTION scatter_init {
particle_pos.X = MY.X;
particle_pos.Y = MY.Y;
particle_pos.Z = MY.Z;
scatter_speed.X = -scatter_spread*0.5; // to compensate for the first random
scatter_speed.Y = -scatter_spread*0.5;
scatter_speed.Z = -scatter_spread*0.5;
}
/////////////////////////////////////////////////////////////////////////
// The particle_shot action lets a particle fly in shot_speed
// direction for 2 seconds, then disappear.
SKILL shot_lifetime { VAL 32; }
SKILL shot_speed { }
ACTION particle_shot {
IF (MY_AGE == 0) { // just born?
MY_SPEED.X = shot_speed.X;
MY_SPEED.Y = shot_speed.Y;
MY_SPEED.Z = shot_speed.Z;
MY_SIZE = 100;
MY_COLOR.RED = 255;
MY_COLOR.GREEN = 0;
MY_COLOR.BLUE = 200;
}
IF (MY_AGE > shot_lifetime) {
SET MY_ACTION,NULL;
}
}
/////////////////////////////////////////////////////////////////