Privateer’s Hold Combat Demo

Below is a new standalone web build showing off many of the new features soon to be available in Daggerfall Tools for Unity 1.0.

Click the link below to explore Privateer’s Hold and vanquish foes with your trusty Ebony Dagger.

http://www.dfworkshop.net/web_demos/privateers-test2/privateers-test2.html

  • W, S, A, D to move.
  • Mouse move to look.
  • SHIFT to toggle run mode.
  • SPACE to jump.
  • LEFT-CLICK mouse to open doors, operate switches, etc.
  • RIGHT-CLICK and HOLD while moving mouse in different directions to attack enemies.
  • ESC to uncapture mouse.

Note: Position crosshair over enemies before attacking them. You will see a splash of blood when your blow connects.

Roadmap Update

I’m running behind on Release 3, however I’ve also managed to squeeze in features originally planned for 1.0 or later (such as weapon loading). My original plan was for Release 4 to be considered 1.0, but I’m so close to the finish line now that I’ve decided to push through and name the next release 1.0. This should be ready in another week or two, depending how much time I can allocate.

One feature that will be missing from 1.0 is improved content browsing directly from Unity’s editor. After reviewing what I want to achieve here and some limitations of editor scripts, I’ve decided to delay this feature to the post-1.0 pile. Creating a good user interface is always challenging, and there’s nothing functionally wrong with just typing in the name of the model/block/location you want to load. I will improve this, but I need to step back and clear my head before taking it on.

Once the 1.0 release is out, I’ll start work on a series of short YouTube tutorials to help newcomers with Daggerfall Tools for Unity. These will cover the basics of setting up a project all the way to creating a simple dungeon crawler with infinite levels. This will be a nice diversion and help me review the tools by actually putting them to work.

On a personal note, the development of these tools has been a lot of fun and I’ve not had to make the time sacrifices I made two years ago. I can get a lot done in an hour or two per day, plus a little extra on weekends, and I don’t need to miss out on any time with my family. Thanks to Unity doing most of the heavy lifting, I can take a new feature from concept to reality in very little time. <3 Unity.

Interiors Web Demo

I’ve uploaded a new web demo showing interior/exterior transitions of town buildings.

Wayrest Interiors
Controls: WSAD to move, SPACE to jump, SHIFT to toggle run, LEFTMOUSECLICK to activate doors, ESC to uncapture mouse.
www.dfworkshop.net/web_demos/wayrest-interiors-1a/wayrest-interiors-1a.html

I’m far from done with interiors, but the above demo is interesting in that all interiors are loaded procedurally. All interior models, layout data, and materials are converted in realtime from native binary data, right inside your web browser.

Essentially, Daggerfall’s world is being constructed from original binary data on another platform without emulation. The same could be done for an iOS or Android build, or any other platform supported by Unity. The total compressed build size is only 17MB.

Tools for Unity – Release 2

Daggerfall Tools for Unity Release 2 is now available. This version adds many new features, bug fixes, and small improvements over the initial version. The PDF Manual is also available.

Starting from this version, I no longer bundle Daggerfall Imaging and Daggerfall Modelling with the distribution. These tools are Windows-only and greatly increased the ZIP size. If anyone needs these tools, they’re available for download here as usual.

Patch notes for new version are below.

  • Added DaggerfallBillboardEditor script for additional billboard details.
  • Added enumerations for enemy mobile types in dungeons (e.g. GiantBat, SkeletalWarrior).
  • Added DungeonType enumeration to DFRegion (e.g. Crypt, Orc Stronghold, Vampire Haunt, etc.). Dungeon type is also displayed in Inspector when a dungeon is selected.
  • Added random encounter tables based on dungeon type.
  • Added animation support for atlased materials.
  • Added multi-facing enemy mobile billboard class.
  • Added enemy definitions for known enemy types.
  • Added animation groups for mobile units.
  • Added light import option for cities and dungeons.
  • Added enemy import options for dungeons.
  • Fixed minor RMB layout bug for non-combined city blocks.
  • Fixed minor billboard layout bug for city blocks.
  • Fixed minor ground plane tiling bug.
  • Fixed dungeon layout bug where RDB block positions on Z axis were reversed.
  • Fixed serialization bugs where native data is concerned. Unity does not like to serialize unsigned values. Opted to create Unity-compatible structures where needed rather than modify Daggerfall-native API structures. Removed [Serializable] flag from any API structs.
  • Moved MaterialReader and MeshReader to MonoBehaviour components on DaggerfallUnity singleton.
  • Moved material and mesh import options to their respective reader component.
  • Moved all mesh loading to MeshReader and removed ModelFile class. This eliminated some double-handling of data and slightly increased import times.
  • Added the ability to set preferred shader names on MaterialReader component. These are located using Shader.Find() during import.
  • Added the ability to set window modifier colours and brightness on MaterialReader
    component. This includes a custom window style option.
  • When loading Daggerfall files from API with the FileUsage.UseMemory option, FileProxy class will now look for a .bytes file of the same name in your Unity Resources folder (e.g. “arch3d.bsa.bytes”). This helps to create standalone builds (such as web builds) where the Arena2 folder is not required, or only partial Arena2 data is needed.
  • Limited full validation checks in DaggerfallUnity to editor mode. This allows builds with partial or no Arena2 data to launch correctly.
  • MeshReader, MaterialReader, and ContentLoader scripts are now set to FileUsage.UseMemory to support Resources file support as above.

Standalone Builds

One of the new features coming in Daggerfall Tools for Unity Release 2 is support for standalone builds where the Arena2 folder is not generally available. For example, the web builds I showed earlier would be considered standalone.

The toolset makes this possible using two complementary approaches. The first is just normal serialization of scene data. This is automatic and doesn’t require any work on your part. All of the materials and 3D models in your scene are just saved as you would expect, along with additional metadata about those resources. For example, every 3D mesh saves a list of default texture keys used to rebuild textures for climate swaps. You generally don’t need to think about this, it just works.

The second method is new to Release 2. When loading a file from Arena2 with FileUsage.UseMemory enabled (now the default), DaggerfallUnity will first try to use Resources.Load() to find that file from your Resources folder. This means you can add, for example, ARCH3D.BSA, BLOCKS.BSA, MAPS.BSA, and TEXTURE files to your Resources folder and load content in at runtime without the end user requiring a Daggerfall installation for your build. All you need to do is append “.bytes” to the end of any Arena2 files added to your Resources folder so Unity can load them as proper binary files. This works for every Arena2 file loaded through the API with FileUsage.UseMemory specified.

As an example of this, check out the new web player demo below. This loads a Wayrest city scene using normal serialized data for all of the models and materials. The sky however is created at runtime from SKY13.DAT in Resources. The entire build is 3.7MB (not counting the web player itself).

Wayrest Snow Scene (Point Filtering)
Controls: WSAD to move, SPACE to jump, SHIFT to toggle run, and ESC to uncapture mouse.
www.dfworkshop.net/web_demos/wayrest-snow-test1/wayrest-snow-test1.html

This freedom creates exciting opportunities for building Daggerfall projects directly for web or mobile platforms. You’re no longer limited by where Daggerfall can be installed. It’s all just binary data that Unity can use anywhere. I hope this freedom will inspire others to create amazing Daggerfall projects in the future.

Web Demo Test

I’ve uploaded a few simple Unity Web Player demos for my own test purposes. If anyone is interested, you can access them from the URLs below.

Controls are WSAD to move, mouse to look, Shift to toggle run, Space to jump, ESC to uncapture mouse.

If you have trouble launching the web player in Internet Explorer, try Chrome and see if that works.

Exterior (Daggerfall City)
http://www.dfworkshop.net/web_demos/daggerfallcity-test1/daggerfallcity-test1.html

Exterior (Daggerfall City, point filtering)
http://www.dfworkshop.net/web_demos/daggerfallcity-test2/daggerfallcity-test2.html

Dungeon (Privateer’s Hold)
http://www.dfworkshop.net/web_demos/privateers-test1/privateers-test1.html

This is a work-in-progress build, so don’t expect too much awesome just yet. These demos are mainly interesting in that I put them both together from an empty scene and uploaded in less than 10 minutes.

One more thing. I’ve disabled doors in the Privateer’s Hold test, as interacting with moving objects is still being written. You can get to the exit room without riding the throne up. See if you can remember how. ;)

Tools for Unity Roadmap

I’ve been thinking about the release structure leading up to v1.0 of Daggerfall Tools for Unity. Up until now, I’ve been building new features right across the spectrum. I’ll be working on monsters one day, then lighting the next, then improving the editor, then working on action scripts in dungeons, and so on. Each of these pieces must be worked over a few times before I’m happy. However, I’d like to keep the releases coming and can’t let myself become too distracted. I need to step up a little.

I’ve decided there are certain groups of features that work well together, and I’d like to zoom in on these features based on where they fit. There will be a little crossover, as some features like basic monsters are already in.

Here is the release schedule for the next few weeks.

Release1 – This is already out. Has all the fundamentals of importing Daggerfall content into Unity.

Release2 – Includes lighting update, a player controller, enemies import, building interiors, dungeon texture swaps, new editor stuff, and a bunch of small bug fixes and other improvements. Basically everything I’ve been working on up until now. Release2 will be ready in about a week. I’m also working on a Unity Web Player demo to go along with it.

Release3 – Targets dungeons. I will build out action records (e.g. opening doors, clicking levers, moving platforms, etc.), another pass at enemies, improving navmesh support, etc. The goal is to make it possible to fully explore a dungeon. This release will be up in about 2-3 weeks, and will include another Unity Web Player demo.

Release4 – This will be version 1.0. I will concentrate on improving content browsing, fixing bugs, and tightening up code. The only new features will in the editor, everything else is just polish. This will be ready in approximately 4 weeks. No further demos are planned at this stage.

Release5 and Beyond – We now enter post-1.0 updates. What happens here will be determined by my available time and interest shown in the tools. These will typically be small maintenance releases to fix bugs and the like. I will also be chipping away on some more demos and extensions to show off what is possible with Daggerfall Tools for Unity. This will be stuff like simple AI behaviours, adding weapons, adding spells, and using the API. I am also hoping to create a few tutorials to help you get started.

Light Import

I have nearly completed light import options for cities and dungeons. The Inspector panel for lights is below. Here you can choose to animate lights (a basic range flicker like Daggerfall), set a custom tag, and attach a custom script.

lightimportsettings

Part of getting lights working is setting the correct window texture in outdoor locations. The glass area of windows has a reserved index of 255 which needs to be substituted with appropriate daytime or nighttime colours. This is set using the climate panel of the location Inspector. This will also apply a self-illuminated shader to the windows so the right areas glow at night and appear slightly brighter by day. The window options are Day, Night, or Disabled.

windowsettings_night

Just like climate texture swaps and dungeon texture swaps, your window swaps can be set at any time in the editor or by script. You can easily change this while the game is running to simulate the change from night to day. Below is the same scene with day windows (single directional light) and night windows (full point lights).

windows_night

Dungeons & Dragonlings

Besides constructing horrible puns, I’ve been working on adding Daggerfall’s enemies into the toolkit. My first idea was to add something fast, but it turned into one of those rabbit-hole situations.

Sure it would be easy to just add basic monster templates, but wouldn’t it be great to actually import the correct enemies? Not just the fixed monsters like that first rat or imp in Privateer’s Hold, but support proper random encounter tables like those outlined in the Daggerfall Chronicles guide. And it all had to be easy to change once inside Unity, not just static information pulled from Daggerfall’s files.

The first thing I needed to work out was how did Daggerfall know which monster to spawn where? There are basically two kinds of enemy spawns, fixed and random. Both have an editor marker flat (from TEXTURE.199) in RDB blocks, so this was a good place to start. Fortunately, there’s only a few bytes of data in the record defining these flats, and for fixed monsters this was easy to find. The FactionID in flat resource structures also defines a monster (or mobile) ID. Basically, (FactionID & 0xFF) = MobileID. Range 0-42 are monsters like rat, imp, spriggan, etc. Range 128-146 are enemy adventurer types like Mage, Spellsword, etc.

Just to be sure I had this right, I wrote a quick tool to change IDs of every monster in S0000999.RDB (central dungeon block of Privateer’s Hold) then started a new game. As hoped, the first rat (ID=0) was now an Ancient Lich (ID=33), which promptly ate my level one character for breakfast. I tried not to think about all the ancient liches between myself and the dungeon exit.

I then documented everything into a spreadsheet by spawning each ID in turn, checking them in-game. This allowed me to build a starting template for each and every enemy’s texture file (male and female), animations, behaviour, affinity, corpse marker, and so on. The end result is EnemyBasics.cs where mobile enemies are simply defined. There are also new enumerations in DaggerfallUnityEnums.cs for MobileEnemies, MobileStates, MobileBehaviour, and MobileAffinity. This will be my foundation for adding enemy mobiles to the toolkit moving forward. I’m trying to keep everything just simple enough to get the job done. It’s up to you to build on from here.

I have added a new enemy name field to the DaggerfallBillboard editor script when you have a fixed enemy editor marker selected.

NewEnemyNameField

Next, I turned my sights on random encounters. Any Daggerfall nut knows about the various dungeon types (Crypt, Human Stronghold, Vampire Haunt, and so on), and that each dungeon type has a random encounter table described in the Daggerfall Chronicles guide book. I just had to work out which value defined the dungeon type.

Fortunately this was easy to find also. The upper 8 bits of the “Unknown2″ value in a location’s MapTable data actually defines the dungeon type. It follows the same order as listed in the Chronicles, with Crypt=0x0033, Orc Stronghold=0x0133, Human Stronghold=0x0233 and so on. You can just shift right by 8 bits (DungeonType >> 8) to get the index. I’ve added this information back to the API in DFRegion.cs and MapsFile.cs so it’s all read in for you when loading a location. I have also added a field to the DaggerfallLocation editor script to display the dungeon type in your Inspector.

NewDungeonTypeField

 

With that squared away, I created a basic set of random encounter tables, one per dungeon type, matching those described in Daggerfall Chronicles. This can be found in RandomEncounters.cs.

There’s obviously more to this, as the player’s level is also used to determine which monsters spawn from the encounter table, but this should be a good start and easy to build on. Like the enemy mobiles, my goal here is to make something just functional enough for you to build on with Unity. The more independent you are of the game files, the better.

Now that Daggerfall Tools for Unity has a good foundation of enemy definitions and encounter tables, I’ll be adding a foundation mobile type to the toolkit for ready-made enemies. When starting play mode (or instancing a dungeon from code) the editor markers will spawn an appropriate monster in-place. I’m going to help with this by setting up all the initial animation smarts, but it’s up to you to extend with spells, AI behaviours, pathfinding, and so on. The good news is that you can use all the typical Unity features and there’s a ton of great resources for scripting enemies in the Unity tutorials and on the Asset Store.

Time to wrap this post up. I’ll show more of Daggerfall Tools for Unity very soon, once the above data starts becoming visual.