Rainfall script core

Maps, modifications, add-ons, projects, and other releases for Zandronum. Also includes announcers.
Post Reply
Klofkac
Forum Regular
Posts: 481
Joined: Sat Jun 09, 2012 1:31 pm
Location: Ask Grandvoid servers

Rainfall script core

#1

Post by Klofkac » Tue Jun 04, 2013 10:22 pm

Hello, I have made the generalized rainfall script core, based on render distance (yes, like Minecraft chunk loading) around player. It has customizeable parametres - the rendering distance and the rain strength (higher number = more dense rain).

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.
The script

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
}
I hope this core is enough to customize it for your needs.
Last edited by Klofkac on Tue Jun 04, 2013 10:24 pm, edited 1 time in total.
𝕂𝕝𝕠𝕗𝕜𝕒𝕔

User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

RE: Rainfall script core

#2

Post by ibm5155 » Tue Jun 04, 2013 10:42 pm

Hmm, It rains only where you see it?
and, does it work right on places with 3d floors and where there´s a sky on the top?

Well the script looks cool :)
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Post Reply