Sitting

Hi there,
I’ve been grappling with chairs. This has very likely come up elsewhere, but I can’t find a good answer to my problem, so here I am.
I am attempting to use chairs from the CEP that are sittable, but when the character sits on them, they do not face properly. Indeed, they face precisely 180 the wrong direction.

Now, I can kind of fix this, if I place this in the OnUse script of the chair:

SetObjectVisualTransform(GetLastUsedBy(), OBJECT_VISUAL_TRANSFORM_ROTATE_X, GetFacing(oChair)-180, OBJECT_VISUAL_TRANSFORM_LERP_LINEAR, 1.0, TRUE);

However, the problem with doing this, is that when they get up from the chair, they are now walking backwards.

Using the sitting animation directly has the same problem, and the additional issue that they just get right back up, even if the duration is zero (supposedly this makes it go forever.)

Is there a way to face them back around properly when they get up from the chair, or a better way to do this otherwise?

-May

Interestingly, some further experimentation shows its one specific chair (“Rocking Chair”) that exhibits this behaviour. The others seem to sit correctly. It always seems to point the character 90 degrees regardless of the direction the chair is pointed.

Any ideas why that may be and how to fix it?
-May

The easiest method is to make the chair static, then paint an invisible object on it with the chair name and script.

This can also be used to make characters sit on chairs and benches that are part of the tileset.

Or just edit the PWK and make sure that the Use node Y-axis is not at 0 - if it is, move it’s Y-axis position to like -0.25 or so.

This seems to be it, though I’m not sure that I want to wade through the hak to fix it myself. I’ll probably use Proleric’s suggestion to static it and use the sit point, that seems the path of least resistance.

Thanks for the quick response either way!
-May

Is the arrow in the toolset oriented as in the example? Which is your chair in question?

The chair in question is “Chair: Rocking 1* (Janus)”. In the toolset, the arrow points the right way, but the sitting orientation is wrong (IIRC it’s always East). @Pstemarie rightly suggests that the Use Node needs fixing.

I guess we could do that in the next release of CEP 2.x without harm to existing modules - I can’t imagine that anyone would rely on such behaviour. A whole bunch of chair use nodes were fixed in the past without complaint - they must have missed this one.

There is another variant “Chair: Rocking 2 (NWN2)* (thegeorge)” which works normally. However, the sitter clips into the chair, as the model is too large. I’d be more cautious about changing that, just in case anyone relies on it, but I guess builders can scale the chair if they wish.

You are correct, it seems to always point at absolute 90 degrees, regardless of chair orientation.

There’s more than one chair like that in the CEP. Many of them seem to be the older nwn2 chairs brought in over a decade ago. I thought maybe they were fixed, but it’s a tall order no matter who you are. As a work around and as Proleric cited above, I use a script on an invis placeable. I’ll even give the invis object the NW_CHAIR tag for npc’s to use if so established in their settings. Here’s just one example:

void main()
{
    object oPlayer = GetLastUsedBy ();
    object oChair = OBJECT_SELF;
    object oArea = GetArea(oChair);
    object oFakeChair = GetLocalObject(oChair, "oFakeChair"); //Previously created FakeChair

    if(!GetIsObjectValid(oPlayer))return; //Doubt that this will happen... but, who knows...

    float fChair = GetFacing(oChair);
    vector vChair = GetPosition(oChair);
    vector vFakeChair = vChair;

    //Reason why people end up facing the wrong direction is because placeables must be close to ground level
    vFakeChair.z = IntToFloat(FloatToInt(vChair.z));

    //If the object is already close to ground level... no need to create a fake chair
    if((vChair.z + 0.01 > vFakeChair.z) && (vChair.z - 0.01 < vFakeChair.z))
        oFakeChair = oChair;

    //Fake Chair needed
    if(vChair.z < 0.0)vFakeChair.z -= 1.0;

    //If no fake chair, create one.
    location lFakeChair = Location(oArea,vFakeChair,fChair);
    if((oFakeChair != oChair) && !GetIsObjectValid(oFakeChair))
        oFakeChair = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_invisobj",lFakeChair,FALSE);

    SetLocalObject(oChair,"oFakeChair",oFakeChair);

    //Is someone already sitting?
    if(GetIsObjectValid(GetSittingCreature(oFakeChair)))return;

    //Sit on the Fake Chair :)
    AssignCommand(oPlayer, ActionSit(oFakeChair));
}

Thanks. I made a lot things with models and texteditor recently. But I’m still learning. I’ll have a look into this.

1 Like

I had a look into the matter. The orientation of the pwk has nothing to do with the sitting orientation.

I inserted “orientation 0 0 -1 -1.5708” into the node “damage74” and the problem was gone.
zlc_e24.zip (4.8 KB)

But this fix turns the chair by 90 degrees, so it’s not useable in cep.

I was referring to the POSITION of the Use node in the PWK file, not the orientation of the pwk dummy in the MDL file.

If you look at the PWK file for the chair, you’ll probably find that the Use node is positioned at 0 0 0 (might have a different Z height). Generally, in all other instances of this issue with other chairs (and the invisible plc itself), the issue was resolved by changing the position of the Use node in the Y-Axis. This has NO affect on the model orientation and thus can be implemented without breaking anything. Essentially, because of the way the sitting animations works, all CC chairs should be setup like the chairs in the OC - have the same orientation, Use node position, same seat height, etc.

Yes, changing the orientation of the Damage node in the MDL will change the orientation of the entire chair because the chair geometry is linked to the Damage node.

2 Likes

This is true. Sadly this chair is not built like this. Better use it as firewood :slight_smile:

Thankfully the method mentioned above of making it static and just placing a sit node (also known as “Invisible Chair”) manually works quite well for taming theres. A workaround to be certain, but it does indeed work, for those of us script monkies who haven’t done modelling side work (hi!)

I re-tested all the chairs in CEP 2.x.

There are only three with this issue:
“Chair: Rocking 1* (Janus)”
“Chair: Egypt* (PLUSH HYENA of DOOM)”
“Chair: Throne: Egypt* (PLUSH HYENA of DOOM)”

Fix is on the wishlist for CEP 2.71.

There are quite a few clipping issues, but, as previously mentioned, it’s probably safer to let builders work around them, rather than change something modules might depend on. The workarounds are - invisible chair, resize chair, fix the model.

2 Likes

I appreciate the attention to detail. Indeed, as suggested, the invisible chair method works for others - I use it for many benches I want to have different seating spots on.

2 Likes