Difference between revisions of "SetTileSourceLightColor"

From NWN Lexicon
Jump to: navigation, search
(See Also)
 
Line 41: Line 41:
 
====Remarks====
 
====Remarks====
  
You must call RecomputeStaticLighting() after calling this function in order for the changes to occur visually for the players.
+
You must call [[RecomputeStaticLighting]]() after calling this function in order for the changes to occur visually for the players.
  
 +
Instead of a TILE_SOURCE_LIGHT_COLOR_ you can ''try'' and use 255 as the parameter to turn the light off. Even in NWN:EE newest lighting it bugs and fails to turn off, needing an area transition to fix.
 
<br />
 
<br />
  
 
====Known Bugs====
 
====Known Bugs====
  
It is reported that it is almost impossible for torches (the source lights themselves) to turn off properly, if at all.
+
It is reported that it is almost impossible for torches (the source lights themselves) to turn off properly, if at all. See note above in remarks - an area transition may help (not very useful however!).
  
 +
You also have problems in
  
 
Lighting changes are not recorded in a saved game, so when the save is loaded, the area regresses to its original lighting.  
 
Lighting changes are not recorded in a saved game, so when the save is loaded, the area regresses to its original lighting.  

Latest revision as of 22:34, 26 June 2020



SetTileSourceLightColor(location, int, int)

Sets the source light color for a tile.

void SetTileSourceLightColor(
    location lTileLocation,
    int nSourceLight1Color,
    int nSourceLight2Color
);

Parameters

lTileLocation

The location of the tile to change the light color. See description this is not an actual "location", but the X, Y of the tile.

nSourceLight1Color

TILE_SOURCE_LIGHT_COLOR_*

nSourceLight2Color

TILE_SOURCE_LIGHT_COLOR_*


Description

Set the source light color on the tile located at lTileLocation.

While whacky lTileLocation is actually a location made up of the area, a X, Y vector which is strictly the tile X, Y (eg: 2, 3 is tile 2 across, 3 up), which is obtainable from a real location by dividing the X and Y by 10. See the code example from Bioware's own cutscene file.



Remarks

You must call RecomputeStaticLighting() after calling this function in order for the changes to occur visually for the players.

Instead of a TILE_SOURCE_LIGHT_COLOR_ you can try and use 255 as the parameter to turn the light off. Even in NWN:EE newest lighting it bugs and fails to turn off, needing an area transition to fix.

Known Bugs

It is reported that it is almost impossible for torches (the source lights themselves) to turn off properly, if at all. See note above in remarks - an area transition may help (not very useful however!).

You also have problems in

Lighting changes are not recorded in a saved game, so when the save is loaded, the area regresses to its original lighting.

A workaround for this is to apply the change again in the area OnEnter script.


Example

void main()
{
    // This assumes these paramters:
    object oPC = GetFirstPC();
    location lLoc = GetLocation(oPC);
 
    int nSourceColor1 = TILE_SOURCE_LIGHT_COLOR_PALE_BLUE;
    int nSourceColor2 = TILE_SOURCE_LIGHT_COLOR_PALE_DARK_YELLOW;
 
    // You must re-generate the location to be an X,Y grid of tiles instead of a X,Y location by meter.
    vector vPos = GetPositionFromLocation(lLoc);
    vPos.x /= 10;
    vPos.y /= 10;
    lLoc = Location(GetArea(OBJECT_SELF), vPos, 0.0);
    SetTileSourceLightColor(lLoc, nSourceColor1, nSourceColor2);
    RecomputeStaticLighting(GetArea(oPC));
}

Version

1.64

See Also

functions: 

SetFogColor SetTileMainLightColor

constants: 

TILE_SOURCE_LIGHT_* Constants



 author: Tom Cassiotis, editor: Jasperre, additional contributor(s): Charles Feduke, Jasperre, Ruben