|
|
|
|
|
|
|
|
SGT_FW
by Aku_Aku. 05/31/26 11:05
|
|
|
|
|
XTB
by pr0logic. 05/18/26 12:27
|
|
|
2 registered members (Grant, TipmyPip),
3,248
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Effects, effects, effects!
[Re: Realspawn]
#423106
05/24/13 07:59
05/24/13 07:59
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
nothing special, just 3run's weather script in a bit modified version (I hope some ideas can be useful for TUST). its settings are adjusted to be suitable in quality and performance not only for an outdoor shooter, but a bit faster RTS camera moves are also tolerated (rain is fine, snow is a bit too fast to keep fps), by placing the generator always in front of the camera, and a bit above of course. other tweaks: separate calls for rain and snow (lightning is commented out because I do not use it), and modified mist c_trace-ing (ignores group 1 what I use for invisible objects, and FLAG2 what I use for obstacles):
#ifndef MBweather_c
#define MBweather_c
/////////////////////////////////////////////////////////////////////////////////////////////
// entry: "Snow flake" bitmap
// help: This bitmap is used for the snow flakes
BMAP* weather_snow_bmp = "graphics\\snow.dds";
// entry: "Rain drop" bitmap
// help: This bitmap is used for the rain drops
BMAP* weather_drop_bmp = "graphics\\drop.dds";
// entry: "Rain mist" bitmap
// help: This bitmap is used for the rain mist
BMAP* weather_misty_bmp = "graphics\\smoke.dds";
// entry: "Lightning" bitmap
// help: This bitmap is used for the lightning effect
BMAP* weather_effect_bmp = "graphics\\effect.dds";
/////////////////////////////////////////////////////////////////////////////////////////////
// entry: "Rain" sound
// help: This (looping) wave file is used as the sound for the rain
SOUND* weather_rain_wav = "graphics\\rain.wav";
// entry: "Wind" sound
// help: This (looping) wave file is used as the sound for the wind
SOUND* weather_wind_wav = "graphics\\wind.wav";
// entry: "Thunder" sound
// help: This wave file is used as the sound for the thunder
SOUND* weather_thunder_wav = "graphics\\thunder.wav";
//////////////////////////////////////////////////////////////////////////////////////////////
var weather_on = 0;
var weather_areasize = 1500;
var weather_particle_density = 150;
var weather_randomness = 100;
var weather_falling_speed = 40;
var weather_particle_size = 20;
var weather_lightning_frequency = 0.95;
var weather_snow = 0;
var weather_mist = 1;
var weather_wind = 1;
var weather_lightning = 1;
ENTITY* weather_ent = NULL;
//////////////////////////////////////////////////////////////////////////////////////////////
var weather_temporary;
var weather_segment_length; // temporary length of the segment line
VECTOR* weather_segment_start = { x=0; y=0; z=0; } // starting point for the particle segment
VECTOR* weather_segment_end = { x=0; y=0; z=0; } // end of segment for the particle segment
var weather_line_length; // temporary length of the particle line
VECTOR* weather_line_start = { x=0; y=0; z=0; } // the lightning effect starts here
VECTOR* weather_line_end = { x=0; y=0; z=0; } // the lightning effect ends here
///////////////////////////////////////////////////////////////////////////////////////////////
void Weather_Init_Rain();
void Weather_Init_Snow();
void Weather_Init();
function particle_init(PARTICLE* p);
function fade_particles(PARTICLE* p);
function rain_mist(PARTICLE* p);
function fade_mist(PARTICLE* p);
function lightning_fade(PARTICLE* p);
function lightning_particle(PARTICLE* p);
function lightning_effect();
function particle_segment();
function particle_lightning();
function increase_brightness();
///////////////////////////////////////////////////////////////////////////////////////////////
void Weather_Init_Rain()
{
weather_on = 0;
wait(3);
// rain settings
weather_areasize = 750;
weather_particle_density = 125;
weather_randomness = 100;
weather_falling_speed = 40;
weather_particle_size = 20;
weather_lightning_frequency = 0.95;
weather_snow = 0;
weather_mist = 1;
weather_wind = 1;
weather_lightning = 1;
Weather_Init();
}
void Weather_Init_Snow()
{
weather_on = 0;
wait(3);
// rain settings
weather_areasize = 750;
weather_particle_density = 150;
weather_randomness = 150;
weather_falling_speed = 30;
weather_particle_size = 2.5;
weather_lightning_frequency = 1;
weather_snow = 1;
weather_mist = 0;
weather_wind = 1;
weather_lightning = 0;
Weather_Init();
}
// title: Snow and rain
// uses: minimum_x, minimum_y, maximum_x, maximum_y, particle_density, randomness, falling_speed, particle_size, lightning_frequency, snow, mist, wind, lightning;
// desc: Snow & rain effect; includes mist and lightning
void Weather_Init()
{
if(weather_particle_size == (var)0)
{
weather_particle_size = 1;
}
if(weather_lightning_frequency == (var)0)
{
weather_lightning_frequency = 0.95;
}
if((weather_particle_density == (var)0))
{
return;
}
weather_ent = ent_create( NULL, camera.x, NULL);
wait(1);
weather_on = 1;
if(!weather_snow) // raining?
{
ent_playloop(weather_ent, weather_rain_wav, 300);
}
if (weather_wind)
{
ent_playloop(weather_ent, weather_wind_wav, 200);
}
set(weather_ent, INVISIBLE);
set(weather_ent, PASSABLE);
VECTOR weather_generator;
vec_fill(weather_generator,0);
random_seed(0);
while(weather_on)
{
vec_set( weather_ent.x , camera.x ); // sound follows entity that follows camera
// vec_set( weather_generator , weather_ent.x );
weather_generator.x = camera.x + cosv(camera.pan) * (random(weather_areasize)); // - weather_areasize/2
weather_generator.y = camera.y + sinv(camera.pan) * (random(weather_areasize));
weather_generator.z = camera.z + 500;
// snow or rain
effect(particle_init, weather_particle_density, weather_generator, nullvector);
// // lightning
// if( (weather_lightning) && (random(1)>weather_lightning_frequency) )
// {
// vec_set(weather_line_start, weather_generator);
// vec_set(weather_line_end, vector(weather_generator.x+random(weather_areasize)-weather_areasize/2, weather_generator.y+random(weather_areasize)-weather_areasize/2, weather_generator.z - 500));
//
// lightning_effect();
//
//// snd_play(weather_thunder_wav, 100, 0);
//
// increase_brightness();
// }
wait(1);
}
ptr_remove(weather_ent);
weather_ent = NULL;
}
///////////////////////////////////////////
function particle_init(PARTICLE* p)
{
VECTOR temp;
temp.x = weather_randomness - random(2 * weather_randomness);
temp.y = weather_randomness - random(2 * weather_randomness);
temp.z = -weather_falling_speed - random(weather_falling_speed); // - 1
vec_set(p.vel_x, temp);
if(weather_snow)
{
p.bmap = weather_snow_bmp;
p.alpha = 80; // 80
}
else
{
p.bmap = weather_drop_bmp;
p.alpha = 60; // 80
}
p.size = weather_particle_size;
set(p, BRIGHT | MOVE);
// p.alpha = 60; // 80
p.event = fade_particles;
// p.skill_a = handle(weather_ent); // store "you"
}
function fade_particles(PARTICLE* p)
{
p.alpha -= 0.2 * time_step;
if(p.alpha < 5) // else , 0
{
p.lifespan = 0;
}
// else if(p.z < camera.z - 1000) // else , 100 ***
// {
// p.lifespan = 0;
// }
else
{
VECTOR temp;
vec_set(temp,p.x);
temp.z += -p.vel_z + 15; // above particle by speed distance
c_ignore(1,0);
c_trace( p.x, vector(p.x,p.y,p.z+p.vel_z), IGNORE_FLAG2 | IGNORE_PASSENTS | IGNORE_SPRITES | IGNORE_CONTENT ); // IGNORE_ME | IGNORE_YOU | *** not set IGNORE_MAPS | IGNORE_MODELS | IGNORE_PASSABLE
if(HIT_TARGET) // the particle is inside a solid?
{
if (weather_mist)
{
if((random(1) > 0.9)) // limit mist quantity 0.9
{
effect(rain_mist, 1, hit.x, nullvector); // generate mist (over hit surface)
}
}
p.lifespan = 0; // don't allow the particles to continue their movement if they have hit something solid
}
}
}
/////////////////////////////////////////////
function rain_mist(PARTICLE* p)
{
VECTOR temp;
temp.x = random(2) - 1;
temp.y = random(2) - 1;
temp.z = random(1) + 0.5; // play with this value
vec_set(p.vel_x, temp);
p.bmap = weather_misty_bmp;
p.size = 1;
p.lifespan = 500;
set(p, BRIGHT | MOVE);
p.gravity = 0;
p.alpha = 35; // 30 ***
p.event = fade_mist;
}
function fade_mist(PARTICLE* p)
{
p.alpha -= 1.5 * time_step;
p.size += 0.8 * time_step;
if(p.alpha < 0)
{
p.lifespan = 0;
}
}
/////////////////////////////////////////
function lightning_effect()
{
// define start and end positions of lightning strike:
vec_set(weather_temporary, weather_line_start);
vec_sub(weather_line_end, weather_line_start);
weather_line_length = vec_length(weather_line_end);
// create segments every 200 quants:
weather_line_end.x = (weather_line_end.x * 100) / weather_line_length;
weather_line_end.y = (weather_line_end.y * 100) / weather_line_length;
weather_line_end.z = (weather_line_end.z * 100) / weather_line_length;
// loop:
while(weather_line_length > 0)
{
vec_add(weather_line_start, weather_line_end);
vec_set(weather_segment_start, weather_temporary);
vec_set(weather_segment_end, weather_line_start);
weather_segment_end.x += random(60) - 30; // displace the lightning segments (don't make the lightning look like a straight stroke)
weather_segment_end.y += random(60) - 30;
weather_segment_end.z += random(60) - 30;
particle_segment();
weather_line_length -= 100; // keep the same value here
}
}
function lightning_fade(PARTICLE* p)
{
p.lifespan = 0;
}
function lightning_particle(PARTICLE* p)
{
VECTOR temp;
temp.x = random(2) - 1;
temp.y = random(2) - 1;
temp.z = random(2) - 1;
vec_set(p.vel_x, temp);
p.bmap = weather_effect_bmp;
p.size = 5;
set(p, MOVE | BRIGHT | TRANSLUCENT);
p.lifespan = 1;
p.event = lightning_fade;
}
function particle_segment()
{
// define start and end positions of lightning strike:
vec_set(weather_temporary, weather_segment_end);
vec_sub(weather_segment_end, weather_segment_start);
weather_segment_length = vec_length(weather_segment_end);
// create particles every 2. quant:
weather_segment_end.x = (weather_segment_end.x * 2) / weather_segment_length;
weather_segment_end.y = (weather_segment_end.y * 2) / weather_segment_length;
weather_segment_end.z = (weather_segment_end.z * 2) / weather_segment_length;
// loop:
while(weather_segment_length > 0)
{
effect(lightning_particle, 2, weather_segment_start.x, nullvector);
vec_add(weather_segment_start, weather_segment_end);
weather_segment_length -= 2; // same value here
}
}
function increase_brightness()
{
var temp = camera.ambient;
camera.ambient = 100;
wait(3);
camera.ambient = temp;
}
#endif
|
|
|
|
Entire Thread
|
Effects, effects, effects!
|
PadMalcom
|
05/17/13 11:50
|
Re: Effects, effects, effects!
|
sivan
|
05/17/13 12:35
|
Re: Effects, effects, effects!
|
Realspawn
|
05/21/13 15:39
|
Re: Effects, effects, effects!
|
sivan
|
05/24/13 07:59
|
Re: Effects, effects, effects!
|
PadMalcom
|
05/24/13 08:17
|
Re: Effects, effects, effects!
|
PadMalcom
|
05/27/13 12:40
|
Re: Effects, effects, effects!
|
sivan
|
05/27/13 15:31
|
Re: Effects, effects, effects!
|
PadMalcom
|
05/27/13 18:29
|
Re: Effects, effects, effects!
|
sivan
|
05/28/13 19:35
|
Re: Effects, effects, effects!
|
PadMalcom
|
05/29/13 08:51
|
|
|