Author Topic: Turn off tile lights, solved? It seems not, oh well.  (Read 369 times)

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« on: May 23, 2012, 06:53:21 pm »


               I haven't had a chance to test this yet, but I just found this in the Lexicon.  It seems BubaDragon had figured out how to turn off tile light sources.

They did what we all did, tried changing the lighting to black, and it didn't work. So they got crafty and figured out what the actual 'off' value was, and plugged that back in.

According to the tutorial there, they claim it worked. I haven't had a chance to try it out yet, but if true, could be handy for a lot of people.
               
               

               


                     Modifié par Leurnid, 23 mai 2012 - 09:18 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #1 on: May 23, 2012, 07:03:24 pm »


               Then the tricky part of associating Light 1 or 2 with a particular light.
               
               

               
            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #2 on: May 23, 2012, 07:36:01 pm »


               BubaDragon's script was causing me aesthetic issues (I am weird like that), so I copied a similar one by "elchwang" from the Vault and included the 'off' value (255) in the comments, if anybody cares.

This isn't my code, I have included it for fast and easy testing of the value.


/*.
Two short custom functions.  The first changes the main lighting to be uniform
in every tile within a given area.  The second does the same for source
lighting.  Five input variables need to be defined in the function, as follows:

(1&2)  int iRows and int iColumns are the number of tile rows and columns,
respectively, in the intended target area.

(3&4)  int iColor1 and iColor2 are the intended primary and secondary light
colors.  See below for a listing of the TILE_MAIN_LIGHT_COLOR and
TILE_SOURCE_LIGHT_COLOR constants and their int values.

(5)  object oArea is the intended target area, default set to be whatever called
the script (i.e., can be left unspecified if called by a handle within the
intended area's Area Properties).

Send all comments to elchwang on the official NWN url or post on this site.
(Created by elchwang, v1.00, 3JAN03)
*/

//Use this function for main light color.
void SetAreaMainLightColor(int iRows, int iColumns, int iColor1, int iColor2, object oArea = OBJECT_SELF)
{
int iXAxis;
int iYAxis;
for (iXAxis = 0; iXAxis < iRows; iXAxis++)
 {
  float fXAxis = IntToFloat(iXAxis);
  for (iYAxis = 0; iYAxis < iColumns; iYAxis++)
   {
    float fYAxis = IntToFloat(iYAxis);
    vector vTile = Vector(fXAxis, fYAxis, 0.0);
    location lTile = Location(oArea, vTile, 0.0);
    SetTileMainLightColor(lTile, iColor1, iColor2);
   }
 }
RecomputeStaticLighting(oArea);
}

//Use this function for source light color.
void SetAreaSourceLightColor(int iRows, int iColumns, int iColor1, int iColor2, object oArea = OBJECT_SELF)
{
int iXAxis;
int iYAxis;
for (iXAxis = 0; iXAxis < iRows; iXAxis++)
 {
  float fXAxis = IntToFloat(iXAxis);
  for (iYAxis = 0; iYAxis < iColumns; iYAxis++)
   {
    float fYAxis = IntToFloat(iYAxis);
    vector vTile = Vector(fXAxis, fYAxis, 0.0);
    location lTile = Location(oArea, vTile, 0.0);
    SetTileSourceLightColor(lTile, iColor1, iColor2);
   }
 }
RecomputeStaticLighting(oArea);
}

/*
A listing of tile lighting color constants and their int values:

int TILE_MAIN_LIGHT_COLOR_BLACK             = 0;
int TILE_MAIN_LIGHT_COLOR_DIM_WHITE         = 1;
int TILE_MAIN_LIGHT_COLOR_WHITE             = 2;
int TILE_MAIN_LIGHT_COLOR_BRIGHT_WHITE      = 3;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_YELLOW  = 4;
int TILE_MAIN_LIGHT_COLOR_DARK_YELLOW       = 5;
int TILE_MAIN_LIGHT_COLOR_PALE_YELLOW       = 6;
int TILE_MAIN_LIGHT_COLOR_YELLOW            = 7;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_GREEN   = 8;
int TILE_MAIN_LIGHT_COLOR_DARK_GREEN        = 9;
int TILE_MAIN_LIGHT_COLOR_PALE_GREEN        = 10;
int TILE_MAIN_LIGHT_COLOR_GREEN             = 11;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_AQUA    = 12;
int TILE_MAIN_LIGHT_COLOR_DARK_AQUA         = 13;
int TILE_MAIN_LIGHT_COLOR_PALE_AQUA         = 14;
int TILE_MAIN_LIGHT_COLOR_AQUA              = 15;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_BLUE    = 16;
int TILE_MAIN_LIGHT_COLOR_DARK_BLUE         = 17;
int TILE_MAIN_LIGHT_COLOR_PALE_BLUE         = 18;
int TILE_MAIN_LIGHT_COLOR_BLUE              = 19;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_PURPLE  = 20;
int TILE_MAIN_LIGHT_COLOR_DARK_PURPLE       = 21;
int TILE_MAIN_LIGHT_COLOR_PALE_PURPLE       = 22;
int TILE_MAIN_LIGHT_COLOR_PURPLE            = 23;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_RED     = 24;
int TILE_MAIN_LIGHT_COLOR_DARK_RED          = 25;
int TILE_MAIN_LIGHT_COLOR_PALE_RED          = 26;
int TILE_MAIN_LIGHT_COLOR_RED               = 27;
int TILE_MAIN_LIGHT_COLOR_PALE_DARK_ORANGE  = 28;
int TILE_MAIN_LIGHT_COLOR_DARK_ORANGE       = 29;
int TILE_MAIN_LIGHT_COLOR_PALE_ORANGE       = 30;
int TILE_MAIN_LIGHT_COLOR_ORANGE            = 31;

int TILE_SOURCE_LIGHT_COLOR_BLACK             = 0;
int TILE_SOURCE_LIGHT_COLOR_WHITE             = 1;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_YELLOW  = 2;
int TILE_SOURCE_LIGHT_COLOR_PALE_YELLOW       = 3;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_GREEN   = 4;
int TILE_SOURCE_LIGHT_COLOR_PALE_GREEN        = 5;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_AQUA    = 6;
int TILE_SOURCE_LIGHT_COLOR_PALE_AQUA         = 7;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_BLUE    = 8;
int TILE_SOURCE_LIGHT_COLOR_PALE_BLUE         = 9;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_PURPLE  = 10;
int TILE_SOURCE_LIGHT_COLOR_PALE_PURPLE       = 11;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_RED     = 12;
int TILE_SOURCE_LIGHT_COLOR_PALE_RED          = 13;
int TILE_SOURCE_LIGHT_COLOR_PALE_DARK_ORANGE  = 14;
int TILE_SOURCE_LIGHT_COLOR_PALE_ORANGE       = 15;

//per BubaDragon's investigation, off=255  *n8

*/

//void main(){}  //This line is for debugging purposes only.


               
               

               


                     Modifié par Leurnid, 23 mai 2012 - 06:39 .
                     
                  


            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #3 on: May 23, 2012, 08:06:34 pm »


               I don't have access to the toolset atm, but it seems it might be handy to get the location of an object, convert those coords to tile coords (aoff the top of my head, isn't that float to int, and divide by 10?) and call these functions with that...

So you could have a non-emitting candle, lets say, you click it, floating text "you blow the candle out", and the tile lighting dims, or for tile light sources, you have a usable inv. object at the torch location that toggles the torch off... of course, the latter is obviously dependant on that 255 value actually killing the light (and hot spot).
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #4 on: May 23, 2012, 09:11:46 pm »


               I don't believe a hot spot from a point source light is directly related to tile lighting.

We already have the method to recompute area lighting which recalculates the hotspots. The trick to making that work is timing the execution of the recompute area lighting method. I have been doing this with dynamic lights and have no problem with it.

IF that is all you are going for, I highly recommend spending more time on calibrating the timing just right. It is possible. Trust me. I've got player placeable candles, lanterns and torches and they all work. These are items that when placed in the area convert to a light shedding placeable. They create a hot spot. Then when picked up (converting back from placeable to item) after a delay the hot spot is wiped out.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #5 on: May 23, 2012, 09:29:52 pm »


               255 doesn't seem to work for me.  '<img'>

I tested with my own function:

void SetAreaSourceLightColor(object oArea, int iColor1, int iColor2)
{
    vector vTile;
    location lTile;
    float fH = IntToFloat(GetAreaSize(AREA_HEIGHT, oArea));
    float fW = IntToFloat(GetAreaSize(AREA_WIDTH, oArea));
    float fX = 0.0;
    float fY = 0.0;
    while ((fX < fW) && (fY < fH))
    {
        vTile = Vector(fX, fY, 0.0);
        lTile = Location(oArea, vTile, 0.0);
        SetTileSourceLightColor (lTile, iColor1, iColor2);
        fX = fX + 1.0;
        if(fX >= fW)
        {
            fY = fY + 1.0;
            fX = 0.0;
        }
    }
    RecomputeStaticLighting(oArea);
}


It just turns the torches to a redish orange color.
               
               

               


                     Modifié par GhostOfGod, 23 mai 2012 - 08:33 .
                     
                  


            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #6 on: May 23, 2012, 10:03:06 pm »


               Tile based light sources do have hot spots, and it was either the hot spot or the soft light effect that wouldn't shut off when you set the light to BLACK (0), but settiing it to 255, according to that tutorial, fixes the 'can't really turn area lighting off' issue.

*edit, actually, I think it was the entire thing that wouldn't turn off on a tile light, come to think of it... it was the soft light on VFX that won't shut off.

I personally have had issues if the player(s?) get more than 4 tiles away from a dynamic (VFX) light source while it is on, turning it off does not eliminate soft cast-off just the hard light does extinguish regardless of the timing on the recompute area lighting... I have run it from 0.1 to 12.0 seconds, and it won't scrub the soft light, just the hard light (VfX don't have hotspots, obviously)

Standard light emitting objects I have had no issue with getting to turn off though... tileset and VFX as I described above though, no reasonable amount of recompute delay will fix.
               
               

               


                     Modifié par Leurnid, 23 mai 2012 - 09:15 .
                     
                  


            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #7 on: May 23, 2012, 10:04:24 pm »


               Thanks GOG, I haven't been able to test it yet.

Well, that is disappointing.  I was hopeful that there had been a solution hiding in the bushes all along.

On the 'making lemonade' front, it would seem values beyond 15 can be used... do they simply loop the primary 16 colors, or is there a pallet of light colors out there that are not documented?
               
               

               


                     Modifié par Leurnid, 23 mai 2012 - 09:06 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #8 on: May 23, 2012, 10:13:43 pm »


               

Leurnid wrote...

On the 'making lemonade' front, it would seem values beyond 15 can be used... do they simply loop the primary 16 colors, or is there a pallet of light colors out there that are not documented?


Just tested that too. After 15 it just gives that one color all the way up to 255 then starts over.
               
               

               


                     Modifié par GhostOfGod, 23 mai 2012 - 09:14 .
                     
                  


            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Turn off tile lights, solved? It seems not, oh well.
« Reply #9 on: May 23, 2012, 10:16:21 pm »


               That lemonade sucks, but I blame the lemons, not you, GoG.
               
               

               


                     Modifié par Leurnid, 23 mai 2012 - 09:16 .