Saturday, November 17, 2012

Fixing another SLS bug: for usable placeables initially in on state.

In the SLS link there is a bug with usable placeables such as campfires that are designed to be turned on and off, when they are on to start with (startstate = on) in the variables of the placeable.

If they are on to start with, the first time you use an on placeable, it remains on. Subsequent times the placeable turns off/on correctly, but any vfx remains whether they are on or off (it actually gets recreated, effectively remaining "on").

In the function SLS2Initialize in ginc_sls2, the last section of the function looks like the following.

} else {
            if (sStartState=="off") {
            } else {
        // set light to relavant starting state

the line: SetLocalInt(oFitting,"sls2_state",SLS2_LIGHTSTATE_PERMAON);
should be SetLocalInt(oFitting,"sls2_state",SLS2_LIGHTSTATE_ON);

and the placeable will behave correctly, with initial use of the placeable correctly turning it off, and any associated vfx correctly appearing/disappearing based on state.

This is in addition to the nwn2 light tag bug (saving and reloading the game causes lights to lose their tags, breaking SLS.), which can be resolved for SLS via the following: (link)

in ginc_sls2, line 352 is:
string sLightTag = GetLocalString(oFitting,"lightTag");

comment that out and replace it with
            //work around tag bug. kamal
            object oLight = GetNearestObject(OBJECT_TYPE_LIGHT, oFitting, 1);
            string sLightTag = GetLocalString(oFitting,"lightTag");
            SetTag(oLight, sLightTag);
One last quirk: the vfxBlueprint variable on placeables that controls the vfx to be used, refers to the resref, not the tag. It wasn't obvious to me (going from my memory). SLS2 vfx do not have the same string for a tag and resref, while stock vfx do.