Notes:
- Do NOT just copy and paste over this script!
- This script core is made to be modified and is not foolproof.
- If you aren't too good with ACS, I recommend you to use this with aid of a better coder.
- As the rain drop locations are being counted through the player positions, the activator should prefferably be console player.
- The script is clientside so it theoretically should be run for each player on a server separately.
Code: Select all
// You should redefine the numbers to avoid conflicts
#DEFINE RAINSTART 1
#DEFINE RAINSTOP 2
#DEFINE OUTSIDECHECK_TID 1
#DEFINE SECTORS_OUTSIDE 1 // The total count of outside sectors with unique tag
int OutsideSectors[SECTORS_OUTSIDE] = {1}; // The list of outside sector tags
// Render distance is distance around the player where raindrops spawn and should NOT be too high or expect runaway terminates or LAGS
script RAINSTART (int density, int renderdistance) CLIENTSIDE // Activator should be the console player!
{
// If you really need to have world as activator, use SetActivator(consoleplayer()+PLAYER_TID) here or similar
if(!density || !renderdistance) terminate; // Quick foolproof tests
int x,y;
//Feel free to include rainfall sounds here or other custom content
for(int i=0;i<SECTORS_OUTSIDE;i++) // just a thing to set fog and darker sky, I really hate that spam using one line each tag
{
Sector_SetColor(OutsideSectors[i],192,192,192);
Sector_SetFade(OutsideSectors[i],16,16,16);
//You can also change floor textures and such for all sectors with these tags
}
Spawn("MapSpot",0,0,0,OUTSIDECHECK_TID,0); // We have to check if raindrop spawn spot will be outside (ceiling texture F_SKY1/2)
while(true)
{
for(i=0;i<density*renderdistance*renderdistance;i++) // Render distance = how far might be the rain seen, the higher it is, the more raindrops can be spawned. It is 256 maptics * given argument
{
x=random(-FixedMul(renderdistance << 16, 256.0),FixedMul(renderdistance << 16, 256.0));
y=random(-FixedMul(renderdistance << 16, 256.0),FixedMul(renderdistance << 16, 256.0));
// The next part is made to be "universal", so it can check f_sky1 ceiling on other maps, if it were map specific, you could set it differently
// For example, every sector considered "outside" would have ceiling height of 1024, making the whole thing only SetActorPosition(OUTSIDECHECK_TID,x+GetActorX(0),y+GetActory(0),1016.0,0);
// If you do not make the next 4 lines of the code more specific, expect runaway script terminations!
for (int j=-8;j<=8;j++)
if(SetActorPosition(OUTSIDECHECK_TID,x+GetActorX(0),y+GetActory(0),GetActorCeilingZ(OUTSIDECHECK_TID)-(j*64.0),0)) break; // Let's try different
if(j>=8) { continue; } // If we failed to move the test map spot, do not spawn the rain drop. I recommend you to have this check here, modified or not. GetActorPosition(OUTSIDECHECK_TID,GetActorX(OUTSIDECHECK_TID),GetActorY(OUTSIDECHECK_TID),GetActorCeilingZ(OUTSIDECHECK_TID)-8.0,0); // Move the map spot to the ceiling
if(CheckActorCeilingTexture(OUTSIDECHECK_TID, "F_SKY1") || CheckActorCeilingTexture(OUTSIDECHECK_TID, "F_SKY2")) // Unfortunately, we cannot check sector tag... Let's check the sky texture instead! Again, you can remove F_SKY2 condition if you do not use it.
spawnspot("RainDrop",OUTSIDECHECK_TID,0,0); //use actor name of the rain drop you will use.
}
delay(1);
}
}
script RAINSTOP (void) CLIENTSIDE //Turn the rain off!
{
//Again, you should add another checks for console player...
//Feel free to include stopping rainfall sounds here or other custom content
for(int i=0;i<SECTORS_OUTSIDE;i++)
{
Sector_SetColor(OutsideSectors[i],255,255,255);
Sector_SetFade(OutsideSectors[i],0,0,0);
}
Thing_Remove(OUTSIDECHECK_TID);
ACS_Terminate(1,0); //STOP DA RAINDROP SPAWN
}