Author Topic: lighting ???  (Read 338 times)

Legacy_dragonlandon

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
lighting ???
« on: October 27, 2011, 05:26:26 pm »


               how do i get the campfires and torches lamp post....  ect...

to come on at a designated time  ( night ) and turn off ( morning )

any help would be greatly appreciated. a tutorial and old post


thank you

landon
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
lighting ???
« Reply #1 on: October 27, 2011, 07:07:16 pm »


               The lamp posts in NWN will glow regardless of a script that is placed to turn them off or on due to a bug in how the engine recalculates light effects. So even if you turn them off during the day, the glow from the placeable still remains.

If you have a lamp post that does not give off ambient lighting, you can use the below script and attach it to the placeables heartbeat. Make sure the STATIC BOX is UNCHECKED.

Another trick is to use an invisible placeable with the STATIC BOX unchecked, then placing it over a tileset lamp or something if you did not want to use the tileset light options (flickering flames).

void main()
{
if (GetIsNight() && GetLocalInt(OBJECT_SELF,"lightme")==0)
{
SetLocalInt(OBJECT_SELF,"lightme",1);
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
effect light = EffectVisualEffect( VFX_DUR_LIGHT_ORANGE_5 );

ApplyEffectToObject( DURATION_TYPE_PERMANENT, light, OBJECT_SELF, 6.0 );
RecomputeStaticLighting(GetArea(OBJECT_SELF));
}
else if (GetIsDay() && GetLocalInt(OBJECT_SELF,"lightme")==1)
{
   SetLocalInt(OBJECT_SELF,"lightme",0);
   effect eLoop;
   object oGlowingThing = OBJECT_SELF;
   eLoop = GetFirstEffect ( oGlowingThing );
   while ( GetIsEffectValid ( eLoop ) )
       {

       int iType = GetEffectType ( eLoop );
       if ( iType == EFFECT_TYPE_VISUALEFFECT )
           {
           RemoveEffect ( oGlowingThing, eLoop );
           }
       eLoop = GetNextEffect ( oGlowingThing );
       }
   RecomputeStaticLighting(GetArea(oGlowingThing));
}
}


This will create an orange glow off the placeable at night and remove it during the day.

FP!
               
               

               
            

Legacy_dragonlandon

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
lighting ???
« Reply #2 on: October 28, 2011, 06:07:29 pm »


               thank you for that script. i can see a use or two for it but.... how do i get campfires and torches to light at night and extiguish during the day


landon
               
               

               


                     Modifié par dragonlandon, 28 octobre 2011 - 05:07 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
lighting ???
« Reply #3 on: October 28, 2011, 06:45:11 pm »


               Torches on tilesets will remain on, regardless of scripting. This is because the RecomputeStaticLighting script command will not reset the ambient lighting for that tile, even if you turn the tileset torches off via a script, they stay on. You would need to turn off any tileset torches and place your own.

Campfires are the same if it's a tileset campfire.

Placeable campfires or torches can be turned off or on by using the script below. Again, make sure the placeable has its STATIC box UNCHECKED. The script is the same as the one above, I just inserted removal or additions of the placeables ACTIVATED or DEACTIVATED status.

void main()
{
if (GetIsNight() && GetLocalInt(OBJECT_SELF,"lightme")==0)
{
SetLocalInt(OBJECT_SELF,"lightme",1);
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
effect light = EffectVisualEffect( VFX_DUR_LIGHT_ORANGE_20 );
//effect light = EffectVisualEffect( VFX_DUR_LIGHT_BLUE_5 );

ApplyEffectToObject( DURATION_TYPE_PERMANENT, light, OBJECT_SELF, 6.0 );
RecomputeStaticLighting(GetArea(OBJECT_SELF));
}
else if (GetIsDay() && GetLocalInt(OBJECT_SELF,"lightme")==1)
{
   SetLocalInt(OBJECT_SELF,"lightme",0);
   effect eLoop;
   object oGlowingThing = OBJECT_SELF;
   eLoop = GetFirstEffect ( oGlowingThing );
   while ( GetIsEffectValid ( eLoop ) )
       {

       int iType = GetEffectType ( eLoop );
       if ( iType == EFFECT_TYPE_VISUALEFFECT )
           {
           RemoveEffect ( oGlowingThing, eLoop );
           PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
           }
       eLoop = GetNextEffect ( oGlowingThing );
       }
   RecomputeStaticLighting(GetArea(oGlowingThing));
}
}


Due take note, when the placeable campfire is DEACTIVATED, the glow of the fire still remains, even though the fire itself is no longer flickering. This is the same issue I noted regarding the placeable lanterns.

The torches, found under - Placeables - Standard - Building Adornments - Torch Bracket - will work fine when DEACTIVATED. They do not retain their glow as the placeable lanterns and campfires do.

FP!
               
               

               


                     Modifié par Fester Pot, 28 octobre 2011 - 05:47 .
                     
                  


            

Legacy_dragonlandon

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
lighting ???
« Reply #4 on: October 29, 2011, 04:48:42 pm »


               thank you very much

landon