Page 1 of 1

Trying to turn illumination off...

Posted: Mon Aug 14, 2006 6:57 am
by A Wanderer
I'm having an issue with the illumination of my placables not being in line with thier emitters, so I want to turn off all illumninations onentry into the area.

Do I reference each placable by tag name?

This code works on the actual placable:

Code: Select all


void main()
{
void SetPlaceableIllumination(object oFire=OBJECT_SELF,int bIllum=FALSE);
RecomputeStaticLighting(GetArea(OBJECT_SELF));
}

but I can't seem to reference the placable from the area events to shut off each placable's illumination, like so:

Code: Select all


void main()
{
void SetPlaceableIllumination(object oFire=wild_wander_campfire,int bIllum=FALSE);
RecomputeStaticLighting(OBJECT_SELF);
}

Where wild_wander_campfire is the tag of the campfire for which I want illumination shut off.

Also, I've got a few screenshots of what I'm talking about, located in this Bioware thread:

http://nwn.bioware.com/forums/viewtopic ... 6&forum=46

Also, this is for part of my player house here on Avlis, so I hope this script is ok for use. If not, a work around would be much appreciated.

Posted: Mon Aug 14, 2006 7:06 am
by p0m
If this is for your player house, unfortunately you can't have any kind of custom scripts. If you're having issues with CEP lighting placeables, I'd make sure you check they have no onheartbeat scripts.

If it's a lighting issue, sometimes 'erasing' the terrain tile a few times will get it lined up right.

Also, a handy tip. Changing the lighting settings in the area properties will make it recalculate all lighting in the mod, so try to get the base lighting mood set before modifying the individual tiles' lighting.

Posted: Mon Aug 14, 2006 9:25 am
by Krator
Try changing the "Initial State" on the placeable to "Deactivated."

This custom script will not be allowed in your player house.

Posted: Mon Aug 14, 2006 2:38 pm
by A Wanderer
Krator wrote:Try changing the "Initial State" on the placeable to "Deactivated."

This custom script will not be allowed in your player house.
I've tried this, and it only turns the flame off. The illumination is still active, which I'm fairly certain can only be turned off by script.

I'll try the terrain erase 'reset', and see if that works. I've already tried changing the area lighting settings multiple times.

If none of that works, I guess I'll have to live with a bit of imperfection. lol

Posted: Mon Aug 14, 2006 2:40 pm
by A Wanderer
So lastly, how do I reference a placable or other object like an NPC? Is it just by tag name, or is there some prefixing?

Posted: Mon Aug 14, 2006 5:16 pm
by Marleh
Even if you can't deal with the lightsource directly, you can always try to rotate the placeable to make it less noticeable. Also, there are several sizes of fire placeables that are available. Perhaps see if one can be positioned in such a way that it blends the lights together?

CEP has a few different placeables that don't use the same lightsource, you could try those as well.

Posted: Mon Aug 14, 2006 6:36 pm
by A Wanderer
Thanks, Marleh.

Someone on the Bioware boards also suggested making a makeshift campsite out of other placables.

Turning it is a good idea.

I wonder if the in-game creatable campfire has the same illumination issue? I never stopped long enough to check.

Posted: Mon Aug 14, 2006 6:39 pm
by Marleh
It does. :) I've noticed it, but never really taken the time to examine the placeable to see why.

Posted: Mon Aug 14, 2006 9:21 pm
by CPU
Sindol's your Daddy!

There is already scripting available in NWN / Avlis to accomplish what you would like to do. It stops a light sources from emiting that most foul light when turned off. It does NOT work for most CEP lighting sources. Make sure to follow the directions exactly. I accept this script in player housing since it is already in Avlis:

ply_light_onoff Script
// John Janssen (Sindol)
// Name: ply_light_onoff.nss
// last modified: 23-03-2004, by Sindol

// Description: This script will turn a lightsource on or off when used.
// Instructions (with the tab on which to find the change):
// 1. Make sure the lightsource placable is "Usable" (Basic)
// 2. Turn the placable appearance to placable with "No Ambient" (Basic)
// 3. Put this script in the OnUsed handler for the lightsource placable (Scripts).
// 4. Set the default state of the placable to "Deactivated" (Advanced)

// Note: if your chosen lightsource placable does not have a "No Ambient"
// mode this will not work. Those lightsources do still emit light, even when
// their status is "deactivated". Use the default NWN script in that case.

void main()
{
if (GetLocalInt(OBJECT_SELF,"LightsOn") == 0) //light is off
{
effect eLight = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_10));
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLight, OBJECT_SELF);
SetLocalInt(OBJECT_SELF,"LightsOn",1);
}
else //light is on
{
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
effect eLight = GetFirstEffect(OBJECT_SELF);
while (GetIsEffectValid(eLight))
{
if (GetEffectSubType(eLight) == SUBTYPE_EXTRAORDINARY)
{
RemoveEffect(OBJECT_SELF, eLight);
}
eLight = GetNextEffect(OBJECT_SELF);
}
SetLocalInt(OBJECT_SELF,"LightsOn",0);
}
}

Posted: Mon Aug 14, 2006 9:29 pm
by Marleh
Sweet! So a character can light a fire in a campfire ring? Is the campfire placeable considered a lightsource for this script?
// Note: if your chosen lightsource placable does not have a "No Ambient"
// mode this will not work. Those lightsources do still emit light, even when
// their status is "deactivated". Use the default NWN script in that case.
Can't wait to get home and check this.

*sighs* if I'd only known, ah well.

Posted: Mon Aug 14, 2006 10:00 pm
by A Wanderer
=D Awesome!

Also, I'm pretty sure this will not work as a light source with ambient turned off. The flame emits no light, iirc when I was turning ambient off last night.

I'll jump back in it tonight, and see how it works. Thanks CPU and Sindol!

This little cave/house has a sweet feel to it (torch lit only), and it's pretty small (3x2), so this little light fix is really a noticable issue. Hope this is the fix!

I'll probably also end up turning the campfire so the ambient light is behind the flame... Or maybe I'll turn the campfire to off, and use a flame visual effect. The alignment on it is better.

Damn you work! I should be home building! lol

Posted: Mon Aug 14, 2006 10:38 pm
by Marleh
Pfft, 3x2 is huge for a washed out cave under a tree. Its almost as big as Moira's house in Mikona, if she hadn't added her rooftop garden.

And no peeking from the Adventurer's Guild Hall, Fifty!! *shakes fist*

Posted: Mon Aug 14, 2006 11:54 pm
by Moredo
LOL, so *that's* why Kered wanted a penthouse! :lol:

Kered Rose, lasts seen in Derome Delen buying Gnomish Binoculars.

Posted: Tue Aug 15, 2006 1:08 am
by A Wanderer
Marleh wrote:Pfft, 3x2 is huge for a washed out cave under a tree. Its almost as big as Moira's house in Mikona, if she hadn't added her rooftop garden.

And no peeking from the Adventurer's Guild Hall, Fifty!! *shakes fist*
To be fair, it's really a 2x2 since two of the tiles are water. =D

Posted: Tue Aug 15, 2006 1:24 am
by A Wanderer
Just tested that script, and the illumination does not fade. The flames go out, but the illumination is still there. In order to turn both the flame AND illumination off, you would have to add:

Code: Select all


void SetPlaceableIllumination(object oFire=OBJECT_SELF,int bIllum=FALSE); 
RecomputeStaticLighting(GetArea(OBJECT_SELF)); 

To turn it off, and the reverse (TRUE) to turn it back on.

Posted: Tue Aug 15, 2006 8:21 am
by jaythespacehound
Note you can't do:

Code: Select all

object oFire=object_tag
You have to do it this way:

Code: Select all

object oFire = GetObjectByTag("object_tag")
Note that this can go badly if two or more things have the same tag,
In that case you may wish to use the second variable in that function:

Code: Select all

object oName = GetObjectByTag("object_tag", int nNth = 0);
where nNth is the Nth object with this tag. (Default: 0)

Directly from the lexicon:
The nNth parameter has been determined to return the nNth object with the specified sTag starting at position 0. Outside of the current area, the scan will begin starting with the last (most recent) area added to the module following this hierarchy:

OBJECT_TYPE_STORE (128)
OBJECT_TYPE_PLACEABLE (64)
OBJECT_TYPE_WAYPOINT (32)
OBJECT_TYPE_AREA_OF_EFFECT (16) (spell effects, like web)
OBJECT_TYPE_DOOR (8)
OBJECT_TYPE_TRIGGER (4)
OBJECT_TYPE_ITEM (2)
OBJECT_TYPE_CREATURE (1)

A safer way to do it may be:

Code: Select all

object oFire = GetNearestObjectByTag(
"object_tag", object oTarget = OBJECT_SELF,
    int nNth = 1
);

Which returns the nNth nearest object to object oTarget (OBJECT_SELF) in this case.

Er hope that makes sense and was of some help,
Jay

EDIT: Er remember if this is for custom housing you can't make your own scripts unless you get permission etc :)

Posted: Tue Aug 15, 2006 8:49 am
by Calzier
Easiest solution is to use a pile of wood placeable and a flame placeable. Attach the on_off script (above) to the flame, and name the flame object 'fire' or something similar. Place the flame under the wood (adjust Z axis as required).

What then happens IG is that the pile of wood (or whatever) appears to be a fire that you can light and extinguish. This works great if you have a fireplace...

For a cave I'd suggest creating a fire-pit, using an appropriate placeable and a -ve Z axis, and place the wood/flame inside. You can always use a slight -ve z axis on the wood if it sticks up too much...

Posted: Tue Aug 15, 2006 2:13 pm
by A Wanderer
Awesome jay. =) I had figured it would be a GetObject, but didn't know what the function was. (I'm getting back to building a mod I started a while back, and I'm sure this is going to come in really handy)

For my 'house' I went with a campfire, no illumination, set it to usable and deactivated, then added a flame visual effect. I couldn't really get it to turn on and off, because both the campfire and the flame had to be set to usable (because I can't alter one object by clicking on another - via Jay's post above). It's fine though. The main thing was getting the illum and flame anim to line up properly. The flame visual lines up really nice.

The last thing I have to do with my place now is load all the door scripts (auto close, auto lock) and my one plot chest's auto lock script. I'm assuming those are ok to use, and if so where can they be found?

Posted: Tue Aug 15, 2006 3:06 pm
by PsiOmega
Everything you can use is found here.

Posted: Tue Aug 15, 2006 3:15 pm
by A Wanderer
PsiOmega wrote:Everything you can use is found here.
Ahh I have that. I need to look closer. :oops:

Posted: Tue Aug 15, 2006 8:09 pm
by CPU
The flames and light source should turn off IF you use the deactivated (no ambient) appearance / version of the placeable:
Turn the placable appearance to placable with "No Ambient" (Basic).
If you do not change the appearance, then the light source will stay. As I said, a number of the CEP placeables do not have a "No Ambient" version. those placeables cannot be used with this script. However, I have used this script repeated times (with non-CEP light sources) and it does work.

The chances of getting different versions or script variations into Avlis (especially for Player Housing) are near zero since there is a working version already.

Posted: Wed Aug 16, 2006 3:55 am
by A Wanderer
Turning the no ambient version flame animation on and off worked, if you want to always keep ambient off. My cave is torch lit only, so I need the ambience.

The problem really lies in the unaligned flame and ambience on the campfire (and the campfire with cauldron). I don't think there's a way to fix it other than turn off ambience for the campfire (and turn off the flame), and add a flame visual effect object instead. The flame visual effect object has better flame/ambience alignment.

To make the turning on and off fully functional (turn off both flame animation and ambience at the same time) with the flame object, I would have to turn off and on the flame visual effect object by clicking the deactivated campfire (not allowed, which is fine - plus I would have to add the ambience switch in the code). The second problem is both objects must not be static (the campfire can't be static anyway, because you can't change a static object from active to deactive), and since both are not static, you have basically two objects superimposed on one another, which makes clicking very weird.

No matter though, because I'm happy just getting the ambient light more in line with the flame animation. Before I superimposed the flame object it was way off, as is seen in the picture. Now it's almost aligned perfectly.

Posted: Wed Aug 16, 2006 4:24 am
by A Wanderer
Ahh I found out why I couldn't find any autoclose, etc scripts. You have to import the erf into the toolset. 'File' -> 'Import' This piece I found on the net. lol I'll put that in the FAQ.

Posted: Fri Aug 18, 2006 11:39 am
by jaythespacehound
Glad to hear you'll find some use for them :)
Jay