Sign in to follow this  
Salk

[KotOR] Help with adding a sleeping (prone) NPC

Recommended Posts

Hello!

I am trying (without much success) to do something that should be quite simple but for me it isn't. :)

There are a series of beds in a few rooms and I would like to add a few NPCs there making them look they are asleep. They are just going to be props, no interaction other than just a sleeping sound/text.

What I did was to spawn such NPC and use ActionPlayAnimation(ANIMATION_LOOPING_DEAD_PRONE, 1.0, -1.0). The first problem is that the creature doesn't spawn where I want. Apparently the Z position value seems to not make any difference so that it always spawns on the floor. Not only that but also the X and Y position coordinates don't translate well.

Furthermore, while ANIMATION_LOOPING_DEAD_PRONE is not too bad, it is not really ideal. Is there any better workaround? Ideally it should be something like the comatose Kreia in Peragus.

Thanks for reading and for possible help.

Cheers! 

Share this post


Link to post
Share on other sites

Creatures can only spawn where there is a walkable walkmesh. Placeable beds will have nonwalkable walkmeshes (to prevent you clipping into them). If this is TSL, your best bet would be to create a new placeable that uses a full body model creature. You don't want to do this in K1 for a publicly released mod because of the placeables.2da row limit.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks  for the advice, DP.

I am working on K1. 

I have already come to your same conclusion by checking the Peragus101 module. I noticed there is a placeable called MorgueKreia that's been used there. 

I'll try and investigate the possibility of creating a placeable even if there is a limit since I believe there is still some space available in my own placeables.2da file. After all I would need only one single slot.

Where would you recommend I'd start looking into how to create a placeable that uses a full body model creature? What tools are needed for it?

Cheers!

Share this post


Link to post
Share on other sites

You don't want to create an actual placeable model. You want a regular creature model, just full body (assuming it is a creature with a separate head). Then you just add a new row to placeables.2da and specify your creature model. Look at some of the vanilla "siiters" for examples of how to do it (rows 199-212).

In order to get it to animate, you'll need to add a an ANIMLOOP animation to it. The existing supermodels only have sitting, sitting & drinking, and sitting & playing Pazaak (ANIMLOOP01 through 03, respectively). You'll need to add a copy of whatever animation you want to use onto your model and name it ANIMLOOPXX (available numbers are 04-10). You should then be able to set the animation state in the UTP and/or script it.

Alternatively, you could stick with a regular creature and rely on editing the level model in order to create a suitable walkmesh to allow it to lie on a bed. The Ebon Hawk module does this, for example, in order to place the player and Visas on the med bay bed in cutscenes in TSL.

  • Like 2

Share this post


Link to post
Share on other sites

I believe the Peragus morgue also has a bed with a walkmesh on it (probably the one with Kreia?) that could be used as a reference, but I could remember wrong.

Share this post


Link to post
Share on other sites

Any surface you want a creature to be placed on must have a walkable walkmesh. In your example, both Kreia's bed and the one with torch corpse on it have a walkable walkmesh chunk in the middle of their respective beds (along with a surrounding non-walkable barrier to prevent the player getting on there).

Share this post


Link to post
Share on other sites

Huh, I always thought that the torch body was a placeable (and as such, doesn’t need a walkable position to be on).

Share this post


Link to post
Share on other sites

I think they are both actually placeables. Or at least there is a placeable Kreia corpse. But there is also a stunt Kreia creature in the module as well, so I don't know which one they used (or whether TSLRCM made any changes).

Share this post


Link to post
Share on other sites

Very interesting.

Thanks for all the valuable information, DP.

I think you should be cloned. 😄

Cheers!

Share this post


Link to post
Share on other sites
10 minutes ago, Salk said:

I think you should be cloned

I'll say. So many replacement body parts I could harvest. If anyone knows of a secret Island-like setup, let me know. I'll also happily take a ScarJo clone.

  • Haha 2

Share this post


Link to post
Share on other sites

One more question: what tools do I need to do the job?

It's unexplored territory for me.

Share this post


Link to post
Share on other sites

Editing models (either creatures or levels) will require Max/GMax with the KOTORMax script and MDLEdit. Although on the creature side you could conceivably mash something together purely by editing ASCII models in a text editor.

Share this post


Link to post
Share on other sites
Posted (edited)

Hello again.

I installed Gmax (the cost of 3dsMax is way out of my pockets) and then the KOTORMax plugin, following the installation instructions. The software seems to have installed correctly.

From what I understand I need to use MDLedit to load the relevant room model and the save it as ASCII and then load that file into GMax by using KotorMax's Import function under the MDL loading menu?

For starters, how do I know which room is the room I want? Kotor Tool shows me a series of files (m10ab_13a-m10ab_25a). I can see the whole module layout loading it into Kotor Toolset but it doesn't seem to tell me which room is which (although I guess you can use the coordinates to figure out their position).

Then I would like to add to that room a walkable walkmesh area inside one of the beds to spawn my creature on. Probably I would like to do it for other rooms too.

Does the .wok file needs to be modified as well? I assume that the relevant .wok file is the one that shares the same room number.

GMax and KOTORMax with all those options seem quite daunting to me but I hope that what I need to do isn't going to be too complicated.

Cheers!

PS - I am attaching a screenshot of my Gmax window. I can see the bed where I want to place my creature but I really have no idea how to add/edit the mesh there.

bed.jpg

Edited by Salk
Added screenshot

Share this post


Link to post
Share on other sites
On 6/25/2019 at 1:59 AM, Salk said:

For starters, how do I know which room is the room I want? Kotor Tool shows me a series of files (m10ab_13a-m10ab_25a).

I find it easiest to import the entire area with KOTORMax's area tools. That way you can see the whole thing and not have to hunt down each room, and you can still export a room individually by selecting its base when you're done.

On 6/25/2019 at 1:59 AM, Salk said:

Then I would like to add to that room a walkable walkmesh area inside one of the beds to spawn my creature on. Probably I would like to do it for other rooms too.

It's not super complicated, but the engine is very particular about what it wants.

  • Only one walkmesh per room.
  • The walkmesh must be a trimesh (not an editable poly or any other type of object). Safest thing is to apply an Edit Mesh modifier or convert to editable mesh when you're done editing.
  • The walkmesh can't be self-intersecting or have any gaps. Both of these lead to unpredictable issues. So it's best to work from one mesh, extruding, cutting, or creating polys where necessary, and not build it with different objects and try to merge them later.
  • The walkmesh uses a special material to configure what areas are walkable, with a sub-material for the different surface types.
On 6/25/2019 at 1:59 AM, Salk said:

I can see the bed where I want to place my creature but I really have no idea how to add/edit the mesh there.

In this case, there's already walkmesh where the beds are. That part of the floor is set to non-walkable:

Spoiler

iBHp0MV.png

You want to chop up that pink rectangle up so it has a walkable surface covering the bed. Working with trimeshes can be a pain, so I prefer to add an Edit Poly modifier first and remove unwanted edges like so:

Spoiler

dfourb3.png

Once the part we want to edit is actually a real rectangle, editing the geometry is a lot easier.

Spoiler

R9X8hJV.png

Just make sure to make it a mesh again when you're done.

 

  • Thanks 1
  • Light Side Points 1

Share this post


Link to post
Share on other sites

I can't thank you enough for the wonderful tutorial there, JC!

I wouldn't have ever figured it out by myself.

How do you get into that very nice, clean view that shows so clearly the bed's walkmesh, the room and very little else? I have such a messy view in my own Perspective window.

If I get stuck somewhere in the process I hope I can ask for your advice again. 

Cheers!

Share this post


Link to post
Share on other sites

Hello, JC!

I figured out how to select the walkmesh to work with and hide the rest and as first step I just wanted to see if I could make the whole pink area walkable like the rest of the floor so under Edit Mesh I chose Select Face and changed the material from 7 to 10 (for 2 faces) turning the whole floor black.

Then I tried to export it using MDL Exporting and I got an ASCII file which I later imported into MDLEdit and Saved as Binary. That produced three files: one .mdl, one .mdx and one .wok. I placed them into Override to test it but I couldn't even enter the room anymore.

There must be something wrong I am doing at exporting or reconverting from ASCII because just to test this I have imported the room file and exported again following the same steps above without changing anything and the result is the same: the room cannot be entered and on top of that the cursor could highlight a footlocker that was placed in the neighboring room like if the walls were not there to obstruct visibility.

To export I selected by name and chose M10ab_14a as Odyssey Base.

Also I don't have the Edit Poly menu under Modifier List and I couldn't find it either in the menu list. The closest was Turn To Poly or Edit Patch?

Thanks for your patience.

Share this post


Link to post
Share on other sites

If you don't decompile the vanilla binary model alongside the vanilla binary walkmesh then you won't retain the proper room links in your ASCII, hence why you can't enter the room in your compiled version. You'll need to start from scratch. Extract the WOKs from BIFs -> models.bif -> Walkmesh. Put the appropriate WOK alongside the MDL/MDX when decompiling with MDLEdit. It will store the appropriate room link information in the ASCII model for KMax to properly re-export later.

  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Salk said:

Also I don't have the Edit Poly menu under Modifier List and I couldn't find it either in the menu list. The closest was Turn To Poly or Edit Patch?

Gmax might not have it, unfortunately. You can right-click and convert to an editable poly, so long as you right-click and convert it back to an editable mesh when you're done editing, and reapply the walkmesh modifiers. Should be functionally the same - doing it with a modifier is just more convenient since it does it non-destructively, but that's why 3ds Max costs hundreds of dollars.

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, JCarter426 said:

Gmax might not have it, unfortunately. You can right-click and convert to an editable poly, so long as you right-click and convert it back to an editable mesh when you're done editing, and reapply the walkmesh modifiers. Should be functionally the same - doing it with a modifier is just more convenient since it does it non-destructively, but that's why 3ds Max costs hundreds of dollars.

I will still try to make it work despite Gmax's limtation although it does sound quite a complex task for me.

Said that, and for reference, since it seems like you have already done the job, could you share your result with me to check how you did it and, if I fail, to use it in my game?

Thanks.

Share this post


Link to post
Share on other sites

Thanks!

I am working on M10ab_14a but I can still look at how you did your work on this one so I am really grateful.

Cheers!

Share this post


Link to post
Share on other sites

By the way, I suppose the least bad of the existing animations I can use to simulate sleeping was the one I used first (ANIMATION_LOOPING_DEAD_PRONE)?

If someone has other suggestions, they are welcome.

Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this