Aller au contenu

Photo

Illumination


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Llionei

Llionei
  • Members
  • 14 messages
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 .


#2
Shadooow

Shadooow
  • Members
  • 4 471 messages
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...


#3
Llionei

Llionei
  • Members
  • 14 messages
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.

#4
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
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 :D

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


#5
Shadooow

Shadooow
  • Members
  • 4 471 messages
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....

#6
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
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 :)

#7
Shadooow

Shadooow
  • Members
  • 4 471 messages
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.

#8
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
Right again ;P. thanks for the advice :D