Raining inside the houses

Posted By: Mythran

Raining inside the houses - 12/06/07 18:14

How do i prevent the rain to pass throught the models?
When it's raining and i enter the house, it's raining inside...

Thanks in advance
Posted By: Scorpion

Re: Raining inside the houses - 12/06/07 19:39

-make a trigger, that turns rain off, if youare in the house
-use ent_move with a raindrop and destroy if it collides
-use c_content to check if the position of the raindrop is in a solid block (but hee is the disadvantage, that they can fall "trough" the wall if they are too fast)
Posted By: Mythran

Re: Raining inside the houses - 12/06/07 23:36

The middle one seems to be what i want, can you be more specific about how to implement such a code?
Thanks
Posted By: Scorpion

Re: Raining inside the houses - 12/07/07 18:18

you create randomly single rainsdrops over the players position (must be entites/sprites)
and just move them down with a c_move:
Code:
c_move(me,nullvector,vector(0,0,-10),IGNORE_PASSABLE)


and after that move you can check the trace_hit varialbe if something was hit => move the entity up again.
Posted By: Futurulus

Re: Raining inside the houses - 12/08/07 23:00

Yikes, though -- c_move with raindrops will be SLOOOOWWW...

Using c_trace might be faster, and you can use it with particles too. Trace from the current position to the next position, and if it hits something, destroy it:
Code:
var endpos[3]; // VECTOR endpos in Lite-C
vec_set(endpos, my.x);
vec_add(endpos, my.vel_x);
c_trace(my.x, endpos, IGNORE_PASSABLE || IGNORE_PASSENTS);
if(trace_hit) {my.lifespan = 0;}


Posted By: Mythran

Re: Raining inside the houses - 12/09/07 00:05

I don't use lite-c
Do i place it in the raining function?
Posted By: Futurulus

Re: Raining inside the houses - 12/09/07 01:03

You'd put it in the action or particle function for your raindrops. If you're using entities instead of particles, use ent_remove(me) instead of my.lifespan = 0.
Posted By: badapple

Re: Raining inside the houses - 12/09/07 10:20

you could do a trace instruction upwards to look for a roof every so often
and create a global var ...say var im_inside=0; and if trace hits a roof
above you can change im_inside=1; , in the while loop that controls your rain
put an if statement like so

while(1)
{
if(im_inside==0)
{
rain
}
else
{wait(1);
}
wait(1);
}

know what i mean?
Posted By: Scorpion

Re: Raining inside the houses - 12/09/07 15:12

c_move is slow if you use GLIDE...else its not that slow-if you compare it with c_trace. So don't Yike around
Posted By: Mythran

Re: Raining inside the houses - 12/09/07 16:12

Thanks alot for all you're help
Posted By: xXxGuitar511

Re: Raining inside the houses - 12/10/07 16:33

If your geometry is relatively simple, then you can precalculate the drops falltime first, so you won't need to do traces or movement on each drop.

Ask Sp|ke, I don't have the code anymore, but he might...
Posted By: Moerk

Re: Raining inside the houses - 12/10/07 23:02

Here is a code i made for you!

Code:

bmap the_rain = "rain.pcx";

function remove_me();
function fall();
function raindrops();



function main
{
level_load("YOURMAP.wmb"); // load your map
wait(3);
raindrops(); // start the weather effect
}

function raindrops()
{
while(1)
{
vec_set(temp, vector(random(1000)-500,random(1000)-500,300)); // Choose your size its in a random area between 1000 and -500 quants. it starts on a high of 300 quants
ent_create("rain.pcx", temp, fall); // create the raindrops
sleep(0.2); // Choose your own speed, you can also use wait
}

}

function fall()
{
my.enable_entity = on; // sensitive for entitys (player)
my.enable_block = on; // sensitive for blocks (level)
my.event = remove_me; // The event who starts when he hit a entity or a block
while(my != 0) // while i´m not removed
{
c_move(my, vector(0,0,-8*time_step), nullvector, 0); //c_move without "glide" you can change the numbers in vector if you want ti drop it more fast and maybe a bit angular
wait(1);
}
}

function remove_me() // the event
{
if(EVENT_TYPE == EVENT_block) // if raindrops hit a wall or a buildung or whatever
{
wait(3); // you can take a higher value if you want your raindrops life longer. better do that if you need snow
ent_remove(my); // remove raindrop
}
if(EVENT_TYPE == EVENT_entity)
{
wait(3);
ent_remove(my);
}
}



You can change your weathereffect if you use variables. For example you can create a variable with the name "rain_amount = 0.2" you can use that in the sleep(rain_amount) in the raindrops function. In another script you can simply change this value and enforce the rainfall or damp it.

Greetings and have fun!
© 2024 lite-C Forums