Page 1 of 1

CEP Light Fixtures

Posted: Fri Apr 27, 2007 12:51 pm
by Marleh
Several of the CEP light fixtures have a heartbeat script called zep_torch that tells it to turn on the light emitter for the placeable. When I remove these scripts, although the placeables animation is activated, it no longer emits light.

Supposedly there is a Bioware script that will simply add a light emitter to a placeable and is not a heartbeat script, but for the life of me I can't find the name of it. Does anyone have any ideas what this might be? Or how I can do this?

Thanks

Posted: Sat Apr 28, 2007 12:41 am
by 2Legit
I've used zep_onoff for CEP fixtures in past projects. I seem to recall it worked very well.


EDIT: I put the script in the OnUsed slot, just for reference.

Posted: Sat Apr 28, 2007 1:48 am
by Marleh
That would work if I wanted the lamps to turn on when a character used them, but I just want them lit - and not just lit, but giving off light, without the heartbeat.

Thanks for the idea though :)

Posted: Sat Apr 28, 2007 3:50 am
by PlasmaJohn
I just read thru CEP's script... and I feel soiled. What most Bioware placeables (now) do is provide a version that has an ambient light source as part of its model, no scripting needed. Unfortunately the placeable you want to use does not have the emitter so you need some method of adding a VFX effect to each placeable.

Maybe this will work. Add a creature to the area and set its appearance to Null Human and its portrait to something blank. Write an onspawn script that iterates through all objects in the area with the lamp's tag and apply a lighting effect to them. The final thing the script should do is destroy the creature.

The following script should be assigned to the creature's OnSpawn event. On the Advanced tab, click Variables and add a string LAMP_TAG with a value equal to the tag of the placeable(s) you want affected, in your case ZEP_LAMPPOST001.

Code: Select all

//: lightemup.nss

#include "zep_main_inc"

void main()
{
    string sTag = GetLocalString(OBJECT_SELF,"LAMP_TAG");
    if(sTag!="")
    {

        int index=0;
        object oLamp = GetNearestObjectByTag(sTag);
        while(GetIsObjectValid(oLamp))
        {
            string sLightConst = GetLocalString(oLamp,"CEP_L_LIGHTCONST");
            if(sLightConst == "")
                sLightConst="WHITE_5";
            int iLightVFX = ColorInit(sLightConst);

            effect eLight = EffectVisualEffect(iLightVFX);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT,eLight,oLamp);

            ++index;
            oLamp = GetNearestObjectByTag(sTag,OBJECT_SELF,index);
        }
    }

    // our work here is done
    DestroyObject(OBJECT_SELF);
}

Posted: Sat Apr 28, 2007 4:27 am
by Marleh
Thanks PJ!

:?

But for all that, *sighs* I think I'll just use the bioware lamppost.

Posted: Sat Apr 28, 2007 11:42 am
by Gorgon
I know there are a few that don't emit light, but from the sounds of it, you just want to replace the heartbeat script on the ones that do work.

Ditch the heartbeat and try nw_02_onoff in the OnUsed. You might have to set the light to deactivated as the initial state since some of the CEP ones started dark but with the animation on, and had to be switched off and on again to work right. Worked for the CEP lights I tested, but I'm sure I missed a few like the ones PJ mentioned. I wouldn't have a clue how to script a fix like he did, but this worked fine and avoided any of the nasty CEP/zep_ scripts.

Posted: Sat Apr 28, 2007 12:33 pm
by PlasmaJohn
The problem with an OnUsed script is that somebody needs to actively use it. Marleh is looking for an always on light source, not one that's switchable.

Posted: Sat Apr 28, 2007 2:08 pm
by Horred the Plague
Here is a script I wrote recently, to be plugged into the Area OnEnter slot. It only needs to fire once per a module reset:

Code: Select all

void main()
{
    object oLight = GetFirstObjectInArea(OBJECT_SELF);
    effect eLight;

    // This only has to be done the first time entering
    // an area, so save the performance hit
    if (GetLocalInt(OBJECT_SELF,"LIGHTS_ON"))
        return;

    while (GetIsObjectValid(oLight))
    {
        // Only target non-useable (static) placeables
        if (GetObjectType(oLight) == OBJECT_TYPE_PLACEABLE
              && !GetUseableFlag(oLight))
        {

            if (GetLocalInt(oLight,"NW_L_AMION") == 0)
            {
                // Add other types of light sources here
                if (GetTag(oLight)== "Candelabra")
                {
                    eLight = EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_20);
                    SetLocalInt(oLight,"NW_L_AMION",1);
                }
                else if (FindSubString(GetTag(oLight),"CHANDELIER") != -1)
                {
                    eLight = EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20);
                     SetLocalInt(oLight,"NW_L_AMION",1);
                }
                else if (FindSubString(GetTag(oLight),"TORCH") != -1)
                {
                    eLight = EffectVisualEffect(VFX_DUR_LIGHT_ORANGE_15);
                    SetLocalInt(oLight,"NW_L_AMION",1);
                }
                else if (FindSubString(GetTag(oLight),"CANDLE") != -1)
                {
                    eLight = EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_10);
                    SetLocalInt(oLight,"NW_L_AMION",1);
                }

                if(GetLocalInt(oLight,"NW_L_AMION") == 1)
                {
                    PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
                    //Use ActionDoCommand, so the light comes 'after' the placeable is 'on'
                    ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLight, OBJECT_SELF));
                }
            }
        }
        oLight = GetNextObjectInArea(OBJECT_SELF);
    }
    // Set this so that the script isn't parsed again this reset
    SetLocalInt(OBJECT_SELF,"LIGHTS_ON",TRUE);
} 
All you really have to do, for anything special you want, is to create a unique tag, assign your specific amount of light, and add a block of script like those above in the "add light source here" section. Add it at the top, so the default blocks don't trigger first.

Note that it would be very easy with a system like this, to set up a DM Wand function (and, I plan to)...so that a DM could turn all the lights on and off in an area, with the wave of a wand (twist of a ring). The best effect with this is achieved in areas where the lighting is set to Interior, Torch-Lit Only. ;)

There are also tile lights (static things like those torches pre-glued to walls) that can also be affected by scripting....but you have to use their [x.y] tile coordinates. Thus, this takes specific (per area) scripting.

P.S. Sorry for 20 edits in 10 minutes, if you were reading this, but I'm still waking up :lol:

EDIT: (Make that 21!) If you're working with an existing mod, that has a base OnAreaEnter script, add a block like this at the end of the script, and after the once/reset cutoff:

Code: Select all

ExecuteScript("[INSERT_SCRIPT_NAME]", OBJECT_SELF);

Code: Select all

    // This only has to be done the first time entering
    // an area, so save the performance hit
    if (GetLocalInt(OBJECT_SELF,"LIGHTS_ON"))
       {
            ExecuteScript("[INSERT_SCRIPT_NAME]", OBJECT_SELF);
            return;
        }

Posted: Sat Apr 28, 2007 9:31 pm
by CPU
The simple solution might to remove the hearbeat script and then just mess with the lighting aspects of the area. Using the area lighting attrbutes, you could duplicate the atmosphere you hope to create?

Posted: Sat Apr 28, 2007 10:46 pm
by Marleh
With a lot of manuevering of placeables, that does the trick. Thanks CPU! :)