Author Topic: Illumination  (Read 330 times)

Legacy_Llionei

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Illumination
« on: February 18, 2011, 07:18:58 pm »


               Could someone take a look at that script? The idea was that at the entrance to the area all torches and braziers are off at any time of day, etc. Partially  it succeeded, but it all works only on the first two torches, and the rest of them burn and give light. The script is in OnEnter area. Any suggestions?

object oTorch = GetFirstObjectInArea(OBJECT_SELF);
int nTime = GetIsNight() || GetIsDusk();
int nNth = 0;

if(!GetIsPC(oPC)) return;
while (GetIsObjectValid(oTorch))
{
string sTag = GetTag(oTorch);
if (sTag == "Torch1")
{
if(nTime == TRUE)
{
AssignCommand(oTorch, ActionPlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE));
SetPlaceableIllumination(oTorch, FALSE);
}
else
{
AssignCommand(oTorch, ActionPlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE));
SetPlaceableIllumination(oTorch, FALSE);
}
}
nNth++;
oTorch = GetObjectByTag("Torch1", nNth);
}
RecomputeStaticLighting(OBJECT_SELF);


               
               

               


                     Modifié par Llionei, 18 février 2011 - 07:20 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Illumination
« Reply #1 on: February 18, 2011, 08:10:26 pm »


               you probably ran into the same issue as I did.



RecomputeStaticLightning does not work in whole are, only in the small part of it where are players



therefore if you run this script, the first torches near you will be fine but torches on the other side of module will still glow



Possible workarounds:

- disable placeable glow feature and use rather light VFX

- make a two placeables one without glow and one normal and replace them, destroy glowing and create there non-glowing and vice versa. I think I do use this workaround, but I am not sure now if it solved the main issue with RecomputeStaticLighning, very probably not...

               
               

               
            

Legacy_Llionei

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Illumination
« Reply #2 on: February 19, 2011, 10:33:05 am »


               Thanks, ShaDoOoW.

I should come up with it earlier. Facepalm. It's so obvious to change model of non-glowing placeable to a torch or brazier. Now it works fine, just as I planned.
               
               

               
            

Legacy_Dark Ruler

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Illumination
« Reply #3 on: February 19, 2011, 03:42:00 pm »


               I'm sorry but if what you're looking for is to get the lights off all the time you could run a script that if it's day it deactivates torch if it's night it deactivates torch anyway, and if you want to activate torch at night you could do it too.
PS: This script isn't my doing:

Meant to be placed on the OnHeartbeat event of a placeable light.

//:: j_light_daynight.nss
//:: Based on NW_O2_ONOFF.nss
//:: Copyright © 2001 Bioware Corp.

//:: Modified By:  Moondog
//:: Modified On:  June 21, 2002
//:: Changed from an on/off switch for lights to
//:: automatically turning a light on during the
//:: night and off during the day.
//:: This is an OnHeartbeat script for placeable
//:: lights.
//:: Original Created By:  Brent
//:: Original Created On:  January 2002
void TurnOnLight();
void TurnOffLight();
void main()
{
//runonce
   if (GetLocalInt (OBJECT_SELF,"RUNONCE") != 1)
   {
       SetLocalInt (OBJECT_SELF,"RUNONCE", 1);
       PlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);
       SetPlaceableIllumination (OBJECT_SELF, FALSE);
       SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);
       RecomputeStaticLighting (GetArea(OBJECT_SELF));
   }

//normal heartbeat
   if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 0 && GetIsNight() == TRUE)
   {
       TurnOnLight(); //if you want it to always have the lights deactivated just put "TurnOffLight()"
                            //without the quotes
   }
   else if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 1 && GetIsDay() == TRUE)
   {
       TurnOffLight();
   }
}
void TurnOnLight()
{
   PlayAnimation (ANIMATION_PLACEABLE_ACTIVATE);
   SetPlaceableIllumination (OBJECT_SELF, TRUE);
   SetLocalInt (OBJECT_SELF,"NW_L_AMION",1);
   RecomputeStaticLighting (GetArea(OBJECT_SELF));
}
void TurnOffLight()
{
   PlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);
   SetPlaceableIllumination (OBJECT_SELF, FALSE);
   SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);
   RecomputeStaticLighting (GetArea(OBJECT_SELF));
}

Hope it helped '<img'>
               
               

               


                     Modifié par Dark Ruler, 19 février 2011 - 03:43 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Illumination
« Reply #4 on: February 19, 2011, 05:50:21 pm »


               Sorry I wouldnt recommed your (bioware) way of doing this to anyone. First it does not work properly  because already mentioned issue in RecomputeStaticLightning, second its heartbeat....
               
               

               
            

Legacy_Dark Ruler

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Illumination
« Reply #5 on: February 19, 2011, 06:26:32 pm »


               Sorry about that, i forgot about the recomputestatic lighting thing, but you could use the script oon area enter too i believe so the heartbeat thing isn't really needed... anyways, I'm not that good at scripting (only know the basics) so i could be wrong. Thanks for getting my attention for the resource consuming anyway ShaDoOoW, apreciated '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Illumination
« Reply #6 on: February 19, 2011, 06:30:55 pm »


               well if you want to make it totally correct you will need a heartbeat, but only one, module. There you must run a script in every area in which is player and that will turns the lights on/off too.



Otherwise if a player would stay in area the lights wouldn't change until someone else would enter. But thats a really small glitch. OnArea is just a good way to do this.
               
               

               
            

Legacy_Dark Ruler

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Illumination
« Reply #7 on: February 19, 2011, 08:29:20 pm »


               Right again ;P. thanks for the advice '<img'>