|
2 registered members (Petra, 1 invisible),
6,267
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Amazing weather script, translation to Lite-C needed!
[Re: FutureRaptor]
#341869
09/21/10 07:20
09/21/10 07:20
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
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.
|
|
|
|
Entire Thread
|
Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/20/10 04:03
|
Re: Amazing weather script, translation to Lite-C needed!
|
3dgs_snake
|
09/21/10 07:20
|
Re: Amazing weather script, translation to Lite-C needed!
|
bodden
|
09/21/10 14:50
|
Re: Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/22/10 03:00
|
Re: Amazing weather script, translation to Lite-C needed!
|
badapple
|
09/22/10 03:38
|
Re: Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/22/10 04:34
|
Re: Amazing weather script, translation to Lite-C needed!
|
3dgs_snake
|
09/22/10 05:05
|
Re: Amazing weather script, translation to Lite-C needed!
|
badapple
|
09/22/10 06:59
|
Re: Amazing weather script, translation to Lite-C needed!
|
3dgs_snake
|
09/22/10 07:25
|
Re: Amazing weather script, translation to Lite-C needed!
|
bodden
|
09/22/10 07:26
|
Re: Amazing weather script, translation to Lite-C needed!
|
Spirit
|
09/22/10 08:21
|
Re: Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/22/10 23:23
|
Re: Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/22/10 23:35
|
Re: Amazing weather script, translation to Lite-C needed!
|
FutureRaptor
|
09/23/10 00:23
|
Re: Amazing weather script, translation to Lite-C needed!
|
gSet
|
10/14/10 17:22
|
Re: Amazing weather script, translation to Lite-C needed!
|
3run
|
10/14/10 18:25
|
Re: Amazing weather script, translation to Lite-C needed!
|
gSet
|
10/14/10 18:52
|
Re: Amazing weather script, translation to Lite-C needed!
|
badapple
|
10/15/10 04:18
|
Re: Amazing weather script, translation to Lite-C needed!
|
3run
|
10/20/10 22:25
|
Re: Amazing weather script, translation to Lite-C needed!
|
TheShooter
|
10/22/10 14:24
|
Re: Amazing weather script, translation to Lite-C needed!
|
3run
|
10/23/10 17:28
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|