DMH-Online

Dungeon Masters Helper · Est. 2005

Areas Scripts

NWN Script: change_lighting.htm

Author Sticky: Post Working Scripts Here
Rehevkor Posted: Thursday, 04 July 09:31AM
Dynamic Area Lighting Change script

This script allows you to have the lighting for an entire area change on-the-fly, even if you're in the area. It makes for some great quest completion effects. I can also imagine that having the entire dungeon go pitch black when the player steps on a trigger could be interesting as well

The comments cover the use of it, and little has to be changed to adapt it for your own module. If you find any bugs, e-mail me and complain 


NWScript:
////////////////////////////////
//Dynamic Area Lighting Change//
////////////////////////////////
//Created by: Rehevkor        //
//Created on: 7/4/2002        //
////////////////////////////////
//jcestep17@hotmail.com       //  
////////////////////////////////
/* 
    You can place this script in almost any event, trigger, or whatever.
    Be sure that you change every occurance of 8.0 in the script below to relfect the dimensions
    of your map. If it has odd dimensions, such as 4.0 x 12.0, replace the relevant lines below
    like this: 
    while ((fx < 4.0) && (fy < 12.0))
    and:
    if(fx >= 4.0)
    That if statement should always be changed to the width of the map, never the height.
    My personal reason for writing it was
    to have an entire crypt begin pitch black, and when you complete the quest it suddenly lights up.
    Very cool effect. Have fun with this script :)    
    Here is a list of the lighting color constants that you can replace TILE_MAIN_LIGHT_COLOR_WHITE with
    TILE_MAIN_LIGHT_COLOR_AQUA
    TILE_MAIN_LIGHT_COLOR_BLACK
    TILE_MAIN_LIGHT_COLOR_BLUE
    TILE_MAIN_LIGHT_COLOR_BRIGHT_WHITE
    TILE_MAIN_LIGHT_COLOR_DARK_AQUA
    TILE_MAIN_LIGHT_COLOR_DARK_BLUE
    TILE_MAIN_LIGHT_COLOR_DARK_GREEN
    TILE_MAIN_LIGHT_COLOR_DARK_ORANGE
    TILE_MAIN_LIGHT_COLOR_DARK_PURPLE
    TILE_MAIN_LIGHT_COLOR_DARK_RED
    TILE_MAIN_LIGHT_COLOR_DARK_YELLOW
    TILE_MAIN_LIGHT_COLOR_DIM_WHITE
    TILE_MAIN_LIGHT_COLOR_GREEN
    TILE_MAIN_LIGHT_COLOR_ORANGE
    TILE_MAIN_LIGHT_COLOR_PALE_AQUA
    TILE_MAIN_LIGHT_COLOR_PALE_BLUE
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_AQUA
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_BLUE
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_GREEN
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_ORANGE
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_PURPLE
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_RED
    TILE_MAIN_LIGHT_COLOR_PALE_DARK_YELLOW
    TILE_MAIN_LIGHT_COLOR_PALE_GREEN
    TILE_MAIN_LIGHT_COLOR_PALE_ORANGE
    TILE_MAIN_LIGHT_COLOR_PALE_PURPLE
    TILE_MAIN_LIGHT_COLOR_PALE_RED
    TILE_MAIN_LIGHT_COLOR_PALE_YELLOW
    TILE_MAIN_LIGHT_COLOR_PURPLE
    TILE_MAIN_LIGHT_COLOR_RED
    TILE_MAIN_LIGHT_COLOR_WHITE
    TILE_MAIN_LIGHT_COLOR_YELLOW
*/
void main()
{    
    //Variable Declarations for  pinpointing a tile on the map
    vector vTile = Vector(0.0, 0.0, 0.0);
    location lTile = Location(GetObjectByTag("AreaTag", 0), vTile, 0.0); //Use your own AreaTag here
    float fx = 0.0;
    float fy = 0.0;
    while ((fx < 8.0) && (fy < 8.0))
    {
        vTile = Vector(fx, fy, 0.0);
        lTile = Location(GetObjectByTag("AreaTag", 0), vTile, 0.0); //Use your own AreaTag here
        SetTileMainLightColor (lTile, TILE_MAIN_LIGHT_COLOR_WHITE, TILE_MAIN_LIGHT_COLOR_WHITE);
        SetTileSourceLightColor (lTile, TILE_MAIN_LIGHT_COLOR_WHITE, TILE_MAIN_LIGHT_COLOR_WHITE);
        fx = fx + 1.0;
        if(fx >= 8.0)
        {
            fy = fy + 1.0;
            fx = 0.0;
        }
    }
    RecomputeStaticLighting(GetObjectByTag("AreaTag")); //Again, use your own AreaTag here
}



_________________
Black Knight: Have at you!
Arthur: You are indeed brave, sir knight, but the fight is mine.
B. Knight: Oh, had enough eh?
Arthur: Look, you stupid bastard. You've got no arms left!
B. Knight: Yes I have.
Arthur: Look!
B. Knight: Just a flesh wound!
 

⌂ All Scripts ← PreviousNext → 👁 Category List

All Areas Scripts

📄 ambient_npc_ani 📄 area_spawner 📄 change_lighting 📄 clean_trash_001 📄 clean_trash_002 📄 clean_trash_003 📄 despawn_mobs 📄 despawn_mobs_002 📄 disable_sound 📄 full_edge_transition_001 📄 full_edge_transition_002 📄 full_edge_transition_003 📄 full_edge_transition_004 📄 full_edge_transition_004a 📄 get_pcs 📄 guard_patrols 📄 keyed_transitions 📄 random_enc_001 📄 random_enc_002 📄 random_enc_003 📄 random_enc_004 📄 random_enc_006 📄 random_enc_009 📄 random_encounter_005 📄 random_interiors 📄 random_interiors_001a 📄 restrict_access 📄 sitting_area