Amazing weather script, translation to Lite-C needed!

Posted By: FutureRaptor

Amazing weather script, translation to Lite-C needed! - 09/20/10 04:03

I am making a car game and have been looking for good weather systems in Lite-C. Mystymood isnt really good enough for me but I have found weather script that does. The problem is that it is .wdl and I need somebody to translate it to lite-c for me if possible. Would be very nice thx.
The tutorial for it can be found here http://www.coniserver.net/coni_users/web_users/pirvu/aum/aumonline_e/ it is tutorial Aum65, Workshops, Weather Effects. Will give credit in my game to the person who translates if somebody is keen enough to do so.
Posted By: 3dgs_snake

Re: Amazing weather script, translation to Lite-C needed! - 09/21/10 07:20

Hello,
This is the Lite-C weather script you needed, translated from George's C-Script weather code :

#include <acknex.h>
#include <default.c>

#define CONTENT_SOLID 3

/////////////////////////////////////////////////////////////////////////////////////////////

var rain_on = 0;
var snow_on = 0;
var fog1_on = 0;
var fog2_on = 0;
var fog3_on = 0;
var fog4_on = 0;

var rain_handle; // handle for the rain.wav sound
var snow_handle; // handle for the snow.wav sound

var day = 0;

/////////////////////////////////////////////////////////////////////////////////////////////

BMAP *snow_tga = "snow.tga";

/////////////////////////////////////////////////////////////////////////////////////////////

STRING *work40_wmb = "work40.wmb";

STRING *rain_tga = "rain.tga";

/////////////////////////////////////////////////////////////////////////////////////////////

SOUND *rain_wav = "rain.wav";
SOUND *snow_wav = "snow.wav";

/////////////////////////////////////////////////////////////////////////////////////////////

function fade_snow(PARTICLE *p);
function snow_particles(PARTICLE *p);
function toggle_snow();
function snow_sound();

function rain_sprites();
function toggle_rain();
function rain_sound();

function toggle_fog();

function toggle_daynight();

/////////////////////////////////////////////////////////////////////////////////////////////

function main()
{
video_mode = 7; // 800x600 pixels
video_depth = 32; // 32 bit mode
video_screen = 1; // start in full screen mode
d3d_lightres = 128;

fps_max = 60;
max_entities = 30000;

level_load (work40_wmb);

on_s = toggle_snow;
on_r = toggle_rain;
on_f = toggle_fog;
on_d = toggle_daynight;
}

action players_code () // simple player and 1st person camera code
{
player = my; // I'm the player
set( my, INVISIBLE ) ; // no need to see player's model in 1st person mode
while (1)
{
// move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed
c_move (my, vector(6 * (key_cuu - key_cud) * time_step, 4 * (key_cul - key_cur) * time_step, 0), nullvector, IGNORE_PASSABLE | GLIDE);
vec_set (camera.x, player.x); // use player's x and y for the camera as well
camera.z += 30; // place the camera 30 quants above the player on the z axis (approximate eye level)
camera.pan -= 5 * mouse_force.x * time_step; // rotate the camera around by moving the mouse
camera.tilt += 3 * mouse_force.y * time_step; // on its x and y axis
player.pan = camera.pan; // the camera and the player have the same pan angle
wait (1);
}
}

/////////////////////////////////////////////////////////////////////////////////////////////

function toggle_snow()
{
snow_on += 1;
snow_on %= 2;
VECTOR snow_origin;
var i;
while (!player) {wait (1);}
snow_sound();
while (snow_on)
{
i = 0;
while (i < 50) // that's a "while without wait" loop
{
snow_origin.x = player.x + 1000 - random(2000);
snow_origin.y = player.y + 1000 - random(2000);
snow_origin.z = player.z + 300;
effect(snow_particles, 1, &snow_origin, normal);
i += 1;
}
if(random(1) > 0.7)
{
c_move (player, nullvector, vector((-1 + random(1)) * time_step, 0, 0), IGNORE_PASSABLE | GLIDE);
}
wait (1);
}
}

function snow_particles(PARTICLE *p)
{
VECTOR particle_direction;
particle_direction.x = random(5) - 15;
particle_direction.y = (1 - random(2)) / 10;
particle_direction.z = -5 - random(7);

vec_add(p.vel_x, &particle_direction);
p.alpha = 30 + random(65);
p.bmap = snow_tga;
p.size = 3;
set(p,BRIGHT | MOVE) ;
p.event = fade_snow;
}

function fade_snow(PARTICLE *p)
{
p.alpha -= 1.2 * time_step;
if (p.alpha < 0) {p.lifespan = 0;}
}

function snow_sound()
{
if (snow_on)
{
snow_handle = snd_loop(snow_wav, 50, 0);
}
else
{
snd_stop(snow_handle);
}
}

/////////////////////////////////////////////////////////////////////////////////////////////

function toggle_rain()
{
rain_on += 1;
rain_on %= 2;
VECTOR rain_origin;
var i;
while (!player) {wait (1);}
rain_sound();
while (rain_on)
{
i = 0;
while (i < 30) // that's a "while without wait" loop
{
rain_origin.x = player.x + 500 - random(1000);
rain_origin.y = player.y + 500 - random(1000);
rain_origin.z = player.z + 300;
ent_create(rain_tga, &rain_origin, rain_sprites);
i += 1;
}
rain_origin.x = player.x + 100 - random(200);
rain_origin.y = player.y + 100 - random(200);
rain_origin.z = player.z + 500;
ent_create(rain_tga, &rain_origin, rain_sprites);
wait (1);
}
}

function rain_sprites()
{
set ( my, PASSABLE | TRANSLUCENT | BRIGHT /*| UNLIT*/ ) ; // remove the comment to increase the brightness of the rain sprites
my.alpha = 20 + random(75);
my.ambient = 40 + random(60);

while (my.alpha > 0)
{
if (c_content(my.x, 0) == CONTENT_SOLID)
{
my.alpha = 0;
}
my.z -= (25 + random(30)) * time_step;
wait (1);
}
ent_remove(my);
}

function rain_sound()
{
if (rain_on)
{
rain_handle = snd_loop(rain_wav, 50, 0);
}
else
{
snd_stop(rain_handle);
}
}

/////////////////////////////////////////////////////////////////////////////////////////////

function toggle_fog()
{
fog1_on += 1;
fog1_on %= 2;
if (fog1_on)
{
camera.fog_start = 10;
d3d_fogcolor1.red = 55;
d3d_fogcolor1.green = 55;
d3d_fogcolor1.blue = 55;
fog_color = 1;
while (fog1_on)
{
camera.fog_end = 1000 + 400 * sin(0.05 * total_frames * time_step);
wait (1);
}
}
else
{
fog_color = 0;
}
}

/////////////////////////////////////////////////////////////////////////////////////////////

ENTITY *fading_ent =
{
type = "fader.mdl";
layer = 10;
alpha = 0;
pan = 90;
flags = TRANSLUCENT | SHOW;
view = camera;
x = 250; // 250 quants ahead of the view
y = 0;
z = 0;
}

function toggle_daynight()
{
day += 1;
day %= 2;
if (day)
{
while (day)
{
camera.ambient = minv(100, camera.ambient + 1 * time_step);
fading_ent.alpha = maxv(0, fading_ent.alpha - 1 * time_step);
wait (1);
}
}
else // night
{
while (!day)
{
camera.ambient = maxv(-100, camera.ambient - 1 * time_step);
fading_ent.alpha = minv(70, fading_ent.alpha + 1 * time_step);
wait (1);
}
}
}

/////////////////////////////////////////////////////////////////////////////////////////////


Regards.
Posted By: bodden

Re: Amazing weather script, translation to Lite-C needed! - 09/21/10 14:50

Good translation, thanks 3dgs_snake.

Day is a little bit dark, so you can play with the fading_ent.alpha and the camera.ambient. But this is a matter of taste (actually you don't have much rainy days, that are bright as hell)
Posted By: FutureRaptor

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 03:00

There are some errors, in the script. Can you fix it pls?
thx
Posted By: badapple

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 03:38

what errors are you getting?
Posted By: FutureRaptor

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 04:34

error in 'main' line 241: 'show' undeclared indentifier.
<flags = translucent / show; >
And btw if it makes any difference I am using A7 Pro.
oh yah and I tried fixing that with
flags = translucent / visible: and I am pretty sure it worked but then more errors come up...
Posted By: 3dgs_snake

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 05:05

What version of 3dgs are you using? Because normally my translation works just fine (except the dark day blush ). Some of the flags were replaced in earlier version :
- VISIBLE by SHOW
- TRANSPARENT by TRANSLUCENT

I Use A7 7.86 Com
Posted By: badapple

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 06:59

flags = translucent / show;

well for one thing

/ should be |

but im geussing thats just the way you wrote it here and not in your script

try this ... change flags to flags2 = TRANSLUCENT | SHOW;

and see what happens
Posted By: 3dgs_snake

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 07:25

If TRANSLUCENT is combined with SHOW, it is not working (Il will be really black because entity alpha will not work); try this instead :

ENTITY *fading_ent =
{
type = "fader.mdl";
layer = 10;
alpha = 0;
pan = 90;
flags = TRANSLUCENT;
flags2 = SHOW;
view = camera;
x = 250; // 250 quants ahead of the view
y = 0;
z = 0;
}

But I really think that the problem is with the A7 version (the SHOW flag).
Posted By: bodden

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 07:26

I tried it with A8.02, works fine.

FutureRaptor, did you save the file as *.c? Otherwise it will not be interpreted as liteC.
Posted By: Spirit

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 08:21

Works fine with A7 too.

Originally Posted By: FutureRaptor
And btw if it makes any difference I am using A7 Pro.

You have A7 Pro and your flags dont work?? Please let us know the version number.
Posted By: FutureRaptor

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 23:23

I am using a pretty old version of A7 (7.10). Thats is probably why the script doesnt work. The good thing is that I am upgrading right now to A8 PRO, 8.02.
Will try it and see if it works.
Posted By: FutureRaptor

Re: Amazing weather script, translation to Lite-C needed! - 09/22/10 23:35

Thank you very much everybody!It works fine with 8.02 PRO. The snow and fog were desperately needed in my game so know I finally got exactly what I needed. THE SOUNDS AND EFFECTS ARE AMAZING BTW. Will put all of your names in the credits of my game when I release it, in the HELP/OTHERS section. If any of you have a problem with that just say so and I will make sure I dont put your name in the credits. THX
Posted By: FutureRaptor

Re: Amazing weather script, translation to Lite-C needed! - 09/23/10 00:23

Just one thing if anybody can tell me how do add this to my game maybe change it up a bit because it doesnt work with a different level.
Posted By: gSet

Re: Amazing weather script, translation to Lite-C needed! - 10/14/10 17:22

Something I've noticed about the rain is that after it's ent_removed it doesn't seem to actually be removed from the video memory. I know this because I'm working on a crappy computer it gets real choppy real fast wink Anything that will help me out with this one?

Edit: Also, after I turn the rain off, it stays choppy.
Posted By: 3run

Re: Amazing weather script, translation to Lite-C needed! - 10/14/10 18:25

Same thing here... RAIN really eats FPS fast... Can't understand why... May be gSet is right, may be they aren't removed from video memory?
Posted By: gSet

Re: Amazing weather script, translation to Lite-C needed! - 10/14/10 18:52

I at least figured out that there must be an issue with the use of c_content, because when i ent_remove when the rain sprites' my.z is < 0, the fps doesn't drop nearly as significantly
Posted By: badapple

Re: Amazing weather script, translation to Lite-C needed! - 10/15/10 04:18

either a bot , or insane!
Posted By: 3run

Re: Amazing weather script, translation to Lite-C needed! - 10/20/10 22:25

Dudes, can any buddy post fixed version? In witch sprites will remove and sprite functions will remove too, after colliding with blocks. Cause I've converted it into LITE-C myself, but seems that sprites and it's functions aren't removing, tried alot of things to remove them, but couldn't get it to work proper... If you want me too, I can post my example here.
Posted By: TheShooter

Re: Amazing weather script, translation to Lite-C needed! - 10/22/10 14:24

Try VISIBLE, not SHOW
Posted By: 3run

Re: Amazing weather script, translation to Lite-C needed! - 10/23/10 17:28

No one got it fixed?
© 2024 lite-C Forums