Blue

[WIP] KotOR JS - A Game Engine For K1 & K2 Written In JavaScript

Recommended Posts

kotor-js-logo.png.5e7b26ac81a71c8d7b1b916b55642417.png

///// 01. Background /////
A couple of years back I had an idea to create a new modding suite for both KotOR games. My original idea was something along the lines of Kotor Tool on steroids with a built in 3d module editor. As time went on I learned a lot about the game and it's systems getting me to a point where my editor could load an entire module complete with 3d models, sound, waypoints, triggers, walkmeshes, and more. I then realized my knowledge of the underlying engine wasn't up to snuff because I kept making bad design choices on how I linked everything together. Fast forward about a year later after I've poured through about all the Docs and Resources I could find on the original games and the NWN Engine they spawned from. The project has now expanded to include game engines for both games. Yeah I know what you are thinking "Well that escalated quickly" and I have to agree because I never thought I would ever attempt to recreate the original KotOR games let alone in JavaScript lol.

///// 02. The Big Question /////

And now to the big question i'm sure a few of you have asked at this point... Why write something like this in JS? Well because it's fun. I do a lot of work with JS when i'm working on websites and am constantly blown away by everything it can do. It's also cross platform and at it's core platform independent. The original scope was also just for a Modding Suite with some 3d sprinkled in so it made more sense then.

///// 03. The Other Big Question /////

Why not just write your stuff in C++ and contribute to the xoreos team. Well that's simple i'm not even close to being well versed enough in C++ to contribute in any meaningful way to that project. I mean for the most part I can look at C++ code and understand it and get the gist of what it's trying to do. I wouldn't have even had a shot at this if it wasn't for them I owe so much to what they have discovered so far :bow:. I do wish them well and hope that once I publish the code they can hopefully find some stuff they can port the their project. And yes I do plan on making this an opensource project so anyone can contribute.

///// 04. Credit /////

I want to be sure and give credit where credit is due. I am totally standing on the shoulders of everyone who came before me. I could not have gotten this far if not for all the people who have shared their knowledge on these and other forums. @bead-v @DrMcCoy to name a few were instrumental in helping me get this far as the MDL/MDX format was really the bane of my existence for a while. Also all of the tool makers who shared source code allowing us to follow in their footsteps. I can't begin to mention everyone by name but if you have put anything out there in regards to cracking a file format or how the internal game mechanics work there is a good chance I have read it and have been helped by it!

///// 05. End Game /////

I really don't have an endgame per se. I just really have a lot of fun doing this in my spare time. I would love to someday have the entire game playable with this engine and finish the modding suite. In the mean time I will post updates when I have stuff to show.

///// 06. Ok That's Enough Talk /////

Source Code: https://github.com/KobaltBlu/KotOR.js/

I'm sure by now you're ready for me to show something. So without further delay here is some footage from TSL enjoy!

 

 

 

///// Screenshots /////

2113814165_screens_0001_Layer4.thumb.jpg.71138b7a3e227fda841586beb184f066.jpg

 

I copied the post template from this thread https://deadlystream.com/topic/6088-wip-star-maps-revamp/

screens_0000_Layer 5.jpg

screens_0002_Layer 3.jpg

screens_0003_Layer 2.jpg

screens_0004_Layer 1.jpg

  • Like 10

Share this post


Link to post
Share on other sites

Ye gods, Javascript. Although it does seem to be the flavour of the month. You seem to have made remarkable progress with it. Looks far more complete than Xoreos does, at least the last version of it that I tested. It seems like there are noticeable rendering issues with VFX and transparency. You might want to talk to @ndix UR about those. And no combat yet by the looks. What would put the rough completion percentage at?

I think you should make that derpy Atton grin the logo for the project.

  • Like 2

Share this post


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

Ye gods, Javascript. Although it does seem to be the flavour of the month. You seem to have made remarkable progress with it. Looks far more complete than Xoreos does, at least the last version of it that I tested. It seems like there are noticeable rendering issues with VFX and transparency. You might want to talk to @ndix UR about those. And no combat yet by the looks. What would put the rough completion percentage at?

I think you should make that derpy Atton grin the logo for the project.

Win 95 in Electron now that just brings a smile to my face 😃. Yeah combat won't work until I get more of the scripting actions working. I did try to hard code some combat stuff early on until I realized it was controlled with scripts for the most part so I put it on the back burner for the moment. Without counting I think i'm close to a hundred or so script actions handled but there are like 8 hundred or so in TSL. Good thing is i've written both games to share code for the most part so K1 get the benefits TSL gets in that department.

Percentage wise it's honestly hard for me to say at this point as most of the games rely on scripting and every time I add code to handle a new script action more of the game comes alive. It's still really early I guess is all I really feel safe saying at this point.

11 hours ago, DarthParametric said:

I think you should make that derpy Atton grin the logo for the project.

lol good one 😄! Yeah the Atton grin is weird bastila's legs do something similar in both games. Could be something to do with skin weights but i'm not sure. 

Thanks for the feedback! :thumbup:

Share this post


Link to post
Share on other sites

Still using OpenGL I take it? I'll be curious to see the outputs of your finalised renderer and how/whether it improves over Odyssey (mostly when it comes to custom content). Particularly whether or not it could be altered to the point of adding additional, modern functionality.

  • Like 1

Share this post


Link to post
Share on other sites

Yeah it's using WebGL which was originally based off of opengl es I believe. Though WebGL 2 is now the current standard I'm not sure if the Rendering Engine I'm using fully supports it yet.

BTW I'm using Three.js to handle all the opengl interfacing. I'm still using the built in shaders that come with it which supports pretty much all the stuff KotOR seems to require except the animated bumpmaps for water... I'm probably going to have to write a custom shader for that.

What kind of modern functionality are you thinking about?

Share this post


Link to post
Share on other sites

Holy hell this is amazing.

 

Man, can I contribute? I'm a JS developer and this is a lot more impressive of a project than my little modding tool I was working on!

  • Like 4
  • Haha 1

Share this post


Link to post
Share on other sites
2 hours ago, VarsityPuppet said:

I’m conflicted about this because I dislike JavaScript but this is amazing work! Great job @Blue!

I understand where you are coming from. I felt if I was going to throw my hat in the ring I needed to do something different and the xoreos team are definitely doing things the right way building it in C++. I also felt JS would be more accessible for collaboration and ease of testing. Thanks for the feedback! 😃

 

1 hour ago, Canderis said:

Holy hell this is amazing.

 

Man, can I contribute? I'm a JS developer and this is a lot more impressive of a project than my little modding tool I was working on!

I would love to get some contributors on board! I've been working on cleaning up the code and trying to get it as presentable as possible. I also want to make sure the project structure and design principals are set before I open it up just yet that way people coming in know where to start and where things should go... I will keep you posted :thumbup:

 

15 minutes ago, zbyl2 said:

That's pretty awesome, congrats.

 

What's xoeros?

xoreos is an open source implementation of BioWare's Aurora engine and its derivatives, licensed under the terms of the GNU General Public License version 3 (or later). The goal is to have all games using this engines working in a portable manner, starting from Neverwinter Nights and ending with Dragon Age II. - This is the description from their GitHub project page.

https://github.com/xoreos/xoreos | https://xoreos.org/

  • Like 2
  • Light Side Points 1

Share this post


Link to post
Share on other sites

Damn, this is impressive. Good work! 😀

And yes, it is further along than xoreos, from a raw playability standpoint. By what you're skipping, It's mostly "just" (without trying to downplay your work) script functions, though, yes? From the underlying code framework, systems and concepts that are missing in the code, I assume it's probably quite similar to xoreos, correct?

How does the start of KotOR look for you? That's where we're "stuck" at the moment, in the first room with Trask, because there is a lot of party management stuff necessary there.

I'm certainly curious and interested in your code, how you solved certain things, and what I could pilfer for xoreos ;). So please, do get the code ready.

The main issue for xoreos, though, is that we need people to work on it, if you allow me my recruitment spiel here. You can reach me here, by mail, on Freenode IRC, wherever :P

(I also think that you're selling yourself way short if you think you couldn't meaningfully contribute to xoreos. For the most part, C++ isn't some wildly different animal from JS. It's not, say, Haskell.)

xoreos, too, is of course also just standing on the shoulders of giants, building on work by others. I too owe a lot to those, and also to the people here. <3

In either case, again nice work, and good luck :)!

Feel free to contact me if you have any questions about xoreos' code, or would like to talk shop or something :P

  • Like 3

Share this post


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

What kind of modern functionality are you thinking about?

Well "modern" in the sense of stuff that was bog standard about 10+ years ago, but is still streets ahead of what Odyssey does. Actual discrete specular maps for one thing. Breaking apart the intertwining of bump/normal maps and cube maps for another. Nothing crazy. Basically the level of stuff they had in Odyssey's successor Eclipse would be fantastic. I'm not sure how far along Xoreos is with implementing Eclipse stuff, but there might be some info to be had there.

Btw @DrMcCoy I didn't intend that to as quite as harsh a slight against Xoreos as it obviously came across as. The last build I tried was Chodo, which is probably an unfair comparison as I see you have a new build out now. I'll have to give it a spin. Phaethon sounds interesting as well. Maybe @bead-v @VarsityPuppet @JCarter426 should consider putting their efforts towards expanding that for their needs rather than creating something from scratch.

Share this post


Link to post
Share on other sites

JavaScript? You working with Tyvokka to run KOTOR in Netscape?

This is all very interesting. A new module editor is the next big thing a lot of us want to see... we've even been talking about how it could be done with KOTORMax. But your screenshots look a lot like the Dragon Age Toolset and a live preview like what it has would be very handy.

  • Like 2

Share this post


Link to post
Share on other sites
12 hours ago, DrMcCoy said:

Damn, this is impressive. Good work! 😀

And yes, it is further along than xoreos, from a raw playability standpoint. By what you're skipping, It's mostly "just" (without trying to downplay your work) script functions, though, yes? From the underlying code framework, systems and concepts that are missing in the code, I assume it's probably quite similar to xoreos, correct?

How does the start of KotOR look for you? That's where we're "stuck" at the moment, in the first room with Trask, because there is a lot of party management stuff necessary there.

I'm certainly curious and interested in your code, how you solved certain things, and what I could pilfer for xoreos ;). So please, do get the code ready.

The main issue for xoreos, though, is that we need people to work on it, if you allow me my recruitment spiel here. You can reach me here, by mail, on Freenode IRC, wherever :P

(I also think that you're selling yourself way short if you think you couldn't meaningfully contribute to xoreos. For the most part, C++ isn't some wildly different animal from JS. It's not, say, Haskell.)

xoreos, too, is of course also just standing on the shoulders of giants, building on work by others. I too owe a lot to those, and also to the people here. ❤️

Wow! thanks for the praise. I've always looked up to the work you and your team are doing, so coming from you that means a lot.

I agree the term "further along" is misleading because i'm building off of THREE.js as my base which comes with a scene graph, lighting, shaders, materials, and all that jazz. If i'm not mistaken you all are building all of that stuff from scratch. If I was having to do all of that myself for the past two years i'm sure I would have given up by now.

Here is what I have so far on the Endar Spire. Things kinda go off the rails once Trask opens the door. I'm only firing a few scripts like onSpawn, onUse, OnDialogue, and a few module specific ones. Heartbeats loop endlessly for the most part so I haven't turned them back on until I can spend some more time looking into why. I know one of the culprits is GetNextObjectInArea, my current implementation just uses GetFirstObjectInArea instead which causes while loops to continuously loop. I believe GetNextObjectInArea is supposed to return invalid once it exhausts itself. I think if I can get a few more of these core functions working I may be able to get a little farther without using the console.

 

And thanks for encouraging me to contribute to xoreos. I'll be sure to see if there is anyway I can think to be of help. My main drawback is fear of proper memory management because most of the languages I have spent the most time with manage memory for me... though that has gotten me into trouble a few times on this project already. I can also now see the benefits of having the power to capture and release memory at will.

13 hours ago, DrMcCoy said:

In either case, again nice work, and good luck :)!

Feel free to contact me if you have any questions about xoreos' code, or would like to talk shop or something :P

Thanks! I sure will 😀.

12 hours ago, DarthParametric said:

Well "modern" in the sense of stuff that was bog standard about 10+ years ago, but is still streets ahead of what Odyssey does. Actual discrete specular maps for one thing. Breaking apart the intertwining of bump/normal maps and cube maps for another. Nothing crazy. Basically the level of stuff they had in Odyssey's successor Eclipse would be fantastic. I'm not sure how far along Xoreos is with implementing Eclipse stuff, but there might be some info to be had there.

Ok yeah that would be a nice addition.

12 hours ago, JCarter426 said:

This is all very interesting. A new module editor is the next big thing a lot of us want to see... we've even been talking about how it could be done with KOTORMax. But your screenshots look a lot like the Dragon Age Toolset and a live preview like what it has would be very handy.

The editor has taken a major step back since I merged the code bases back together. I'll try to free up some time to clean it up so it can be messed with once I publish the code. Thanks for the feedback :thumbup:

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, DarthParametric said:

Btw @DrMcCoy I didn't intend that to as quite as harsh a slight against Xoreos as it obviously came across as.

Huh, it didn't come across as harsh, though? It's all good, I'm not slighted in the slightest (:D), as far as I'm concerned we're good. We're all good :). Heck, I don't want any beef or rivalries with anybody, I want us all to help each other along. That's one of the reasons I'm in FLOSS to begin with.

And yes, this KotOR JS project is obviously further along, and that's absolutely fine, and great work. I mean, this (and this, a bit later) is the current state of KotOR in xoreos, more or less, still stuck in the first room. There's only a handful of script functions implemented. The intro cinematic doesn't work play, and you can't get Trask to open the door.

Similarily, there's a person implementing their own NWN2 engine over on the Neverwinter Vault. The renderer is way further along than xoreos, with proper shaders and everything.

I'd of course be happy to have more contributors to xoreos, the xoreos-tools and Phaethon, but I can also understand that people want to do their own thing.

Sorry for taking up this much space here, I just wanted to be absolutely clear on that.

  • Light Side Points 2

Share this post


Link to post
Share on other sites

I am extremely pleased to learn that you have plans underway to recreate the Odyssey engine for the KotOR series, Blue. This is an extremely important project you are working on, as it will open up KotOR to more extensive modding. Projects such as yours (as well as the Xoreos project) will be a huge asset to the KotOR modding community. 

It was great to see a screenshot of the 3D module editor you have planned! Something like this is an incredible achievement.

Looking forward to playing KotOR in an open source engine, with extended modding capabilities!

I’ll be keeping an eye on this thread, with keen interest. Thanks for all your hard work!!

Share this post


Link to post
Share on other sites
On 9/2/2018 at 12:13 PM, DarthParametric said:

I think you should make that derpy Atton grin the logo for the project.

I'll just leave these here:

Spoiler

NaGhifO.png

LEyyBFl.png

  • Haha 2
  • Light Side Points 1

Share this post


Link to post
Share on other sites

Frankly, I'd advise against using assets from the games as logo or promotional material. Likewise, I'd advise against having game assets in the project repository. That's just a legal minefield.

  • Thanks 1

Share this post


Link to post
Share on other sites

I came here to mention some things that always bothered me and which seem to be hardcoded.

  • I really hope for a possibility to make extensive edits to the GUI, especially the party selection screen. For the Handmaiden and the Disciple to appear for both genders and not be PartySwapped.
  • More appearance.2da columns for both games.
  • If the engine will be the same for both games, it would be great to have saber forms etc. in K1.
  • Also, the possibility of adding animations to saber forms.

Is there a chance for them to be included in the new engine?

  • Light Side Points 1

Share this post


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

I'll just leave these here:

  Hide contents

NaGhifO.png

LEyyBFl.png

Haha that is great!

2 hours ago, DrMcCoy said:

Frankly, I'd advise against using assets from the games as logo or promotional material. Likewise, I'd advise against having game assets in the project repository. That's just a legal minefield.

Oh my bad i'll be sure to look into that. I appreciate the heads up :thumbup:

1 hour ago, superSzym said:

I came here to mention some things that always bothered me and which seem to be hardcoded.

  • I really hope for a possibility to make extensive edits to the GUI, especially the party selection screen. For the Handmaiden and the Disciple to appear for both genders and not be PartySwapped.
  • More appearance.2da columns for both games.
  • If the engine will be the same for both games, it would be great to have saber forms etc. in K1.
  • Also, the possibility of adding animations to saber forms.

Is there a chance for them to be included in the new engine?

Those all sound like great ideas! My main focus at the moment is to get everything running as close to the original as possible. Once that is complete I would love to look into new features and things of the sort. :) 

Thanks for the feedback :thumbup:

 

  • Like 1

Share this post


Link to post
Share on other sites

Different saber style animation, or at least different ready animations, was going to be in the game. The animations.2da file has rows for them. I'm not sure if anything else was actually finished, or remains in the actual game that references these though

Share this post


Link to post
Share on other sites

Greetings and Happy Thanksgiving everyone!

I've been hard at work over the last few months. I'm close to putting out a new code release, and I'm in the process of working on a new update video for it. In the mean time I wanted to throw up a quick video showing the progress I've made on Dynamic Lighting and Animated Lip Syncing.

Some of the things I've been working on for the next code release are:

  • Handling more NWScript actions (I currently have a bug where While loops loop endlessly. I haven't had time to track it down and fix it yet... )
  • I'm rewriting the collision detection system to use the AABB trees in the models to more efficiently handle which faces to pass to the RayCaster.
  • Reworked the lighting system to handle FadingLights properly (They now fade in and fade out properly)
  • Lip Syncing data in the .LIP files are now read in and processed during conversations.
  • Reworked the emitter system and most Fountain type emitters seem to work like they should. I still need to add support for Chunk emitters and the other types.
  • Added support for weather emitters that are in the fx_snow.mdl and fx_rain.mdl files.
  • And a ton of other small improvements and changes.

 

  • Like 8

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.