Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Non-static placeable "initial state" variable - conditionally hiding placeables

Hi folks,

I've come across an interesting problem that doesn't seem to have a straightforward solution. The general idea is the following:

- I have an area which serves as the 'party camp'.
- Each companion has their own space within the camp including their tent and some other placeables specific to them (e.g. scattered books for the wizard, combat dummy and anvil for the fighter, etc.); About 10-20 placeables total per companion.
- I want these groups of placeables to spawn / despawn conditionally depending on whether the companion is a member of the party (e.g. has been recruited, hasn't left the party and isn't dead).

I've seen that non-static placeables have a "destroyed" initial state which makes them invisible, but I cannot find the name of the local variable that actually controls this state. The closest I have managed to find is X2_L_PLC_ACTIVATED_STATE, but this is merely a boolean between Active/Inactive states for lights,levers,etc.

Ideally, what I would like to do is spawn the entire camp (including placeables for all companions) and then conditionally set some of the placeables to a "destroyed" state or make them into hidden objects, but I can't seem to find either of those two functions. I don't want to destroy the objects permanently, in case they need to be reverted to 'visible' at a later date (when a new companion joins the party, for example).

I have considered the usual techniques for hidden objects (such as waypoints that spawn objects on top of them), but this will be very clunky in a small area housing ~150 separate waypoints. I've also considered 'teleporting' the unused objects to some inaccessible corner of the map while storing their previous location data inside the object in case it needs to be ported back, but again this seems a bit hacky.

Would anyone be able to recommend a better solution for this or am I out of luck?

Many thanks,


  • ProlericProleric Member Posts: 792
    edited August 2020
    The most robust method I've found is to lay down all the dynamic objects in the toolset initially. Give the same tag to every object belonging to a given henchman (or whatever). When you want a set to disappear, call a function called (say) HideStuff("tag") which builds a pseudo-array on the area (or module), named after the tag, storing the resref and location of every object with that tag, before destroying those objects.

    When you want the set to appear, call (say) RevealStuff("tag") which recreates all the objects in the array via CreateObject.

    The tables only need to be built once, strictly speaking.

    Another method is to apply EffectCutsceneInvisibility(), but that has at least two known bugs.

    Post edited by Proleric on
  • ProlericProleric Member Posts: 792
    // Hide all objects with a given tag.
    // The objects are recorded as area local variables, then deleted.
    void bh_hide(string sObject)
      object oObject    = GetObjectByTag(sObject, 0);
      int    n          = 0;
      while (GetIsObjectValid(oObject))
          SetLocalString  (GetModule(), sObject + IntToString(n), GetResRef(oObject));
          SetLocalLocation(GetModule(), sObject + IntToString(n), GetLocation(oObject));
          SetLocalInt     (GetModule(), sObject + IntToString(n), GetObjectType(oObject));
          oObject = GetObjectByTag(sObject, ++n);
    // Unhide specified objects
    void bh_unhide(string sObject, int bUnplot = TRUE)
      object oObject    = GetObjectByTag(sObject, 0);
      int    n          = 0;
      string sResRef    = GetLocalString(GetModule(), sObject + IntToString(n));
      while (sResRef != "")
          oObject = CreateObject(GetLocalInt(GetModule(), sObject + IntToString(n)), sResRef,
                                 GetLocalLocation(GetModule(), sObject + IntToString(n)), FALSE, sObject);
          SetPlotFlag(oObject, !bUnplot);
          sResRef = GetLocalString(GetModule(), sObject + IntToString(++n));
      SetLocalString(GetModule(), sObject + "0", ""); // So that if unhide is called twice, objects only created once

  • AornarAornar Member Posts: 4
    Thank you very much for your help - will definitely try this out today.

Sign In or Register to comment.