Marathon Unity

Discuss and unveil current Marathon projects.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

This is a project to recreate the Marathon game engine in Unity.
Since this is now at a stage where some people might be interested in looking at it:
Marathon Unity

There are no binaries until the thing is much more complete, however it is at the point where it should just run, so for the curious, the instructions are: download the free version of unity, open the project, then open the scene called StartScene, click the big play button in the Unity UI.

Be warned, its got a long way to go. Here is my road map, which will show whats done and what still to go.

-get unity to read map files
-get the basic map geometry drawing as unity game objects
-get unity to read shapes files
-convert all textures to unity materials
-get the textures applying to the level
-convert the collection of hacks that make up marathons platforms into actual platform objects
-make the platforms go up and down
-get basic switches working so doors can open and close
-placeholder fps player controller
-get basic impossible space working
-advanced impossible space (where you can see into both polygons simultaneously)
-lighting
-full control panels (tags, light switches etc)
-platform triggers

-liquids
-get map items spawning (ammo, scenery etc)
-sort out the landscape textures
-get physics file loading into unity
-get the sound file loading
-- at this point the code will require a major cleanup as all the data structures should be in place
-recreate marathons physics
-rebuild the fps controller
-get sounds in the map
-merged map files
-terminals
-in game ui
-weapons/inventory
-enemy ai
-saving/loading games
-out game menus
-probably a bunch of stuff that I've forgotten/not thought of.

*mml files + loading external resources
*scripting - some level of script support should be possible, but i have no idea how practical it will be to support existing lua scripts
*any grarphical extras - realtime lighting, rendering the terminal texts onto the terminals in the game etc
*creation of sloping walls/floors
*ability to connect polygons via floor/ceiling
*some sort of editor to allow for creating all that

There will be bugs. Anyone interested in helping in any way, if you know the files inside and out you may be able to tell me exactly what im doing wrong, otherwise creating the simplest possible map that has the error would go a long way to tracking down the problem. Also, im more than happy to accept code ;)
Finally, impossible space has some limitations (and a bunch of bugs) at the moment (basically it works in my test map, in the maze on Arrival, ye olde 5-D Space and in Ne Cede Malis (which i dont think was meant to have any, but has ended up providing a surprisingly good test case)
Finally finally, the current player has the entirely arbitrary top speed of 7, and the camera is 0.7 wu off the ground, has a bunch of jank when riding platforms and generally doesn't feel much like marathon. Its going to stay like that until the physics files are loaded and working, at which point i will want feedback on weather or not the controller is perfect. Whats there right now is a placeholder. The controls are w-a-s-d + e is action, hold control to get the mouse cursor back.

If all of that was tl;dr, I'll just leave these here...
https://www.acinonyx.me/shtuff/Arrival.jpg
https://www.acinonyx.me/shtuff/ne%20cede%20lights.jpg
https://www.acinonyx.me/shtuff/5d%20space.jpg
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Can't wait to find enough free time to try this out.

A good test map for advanced impossible space is Couch Fishing.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

So i just looked at couch fishing, and yep. its getting confused ;)
I can see whats happening, because the impossible area covers 3 polygons, its getting confused when its trying to calculate the volume, and then clipping the geometry in the wrong place. That should be reasonably easy to fix.
The only real limitation at the moment should be that I can only put one hole into any given polygon, so if the same polygon has 2 separate volumes of impossible space, and the player can see into both at the same time, then the far away area will be left with overlapping polygons. I havent decided weather to add more clipping planes so i can make 2 or 4 holes, or to just secretly cut the offending polygons into 2 when assembling the level.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Oddly, some of this code is familiar to me, as if it were from an old dream...

If it would help to have a loader for the physics and sounds files along the lines of the Weland stuff, I could probably port those easily from Aleph One.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

treellama wrote:Oddly, some of this code is familiar to me, as if it were from an old dream...
Weland has been invaluable, and everything was namespaced beautifully, so i could drop the code in almost unmodified, hopefully there wont be any megalomaniacal AIs to deal with... (well, outside of the game at least)

And having a weland like loader for the physics and sounds would be extremely helpful :)

Also, I started looking for a collection of test maps to use and I went through the trilogy release cd added Missed Island. Are there any other maps that did crazy things that bungie probably never though of without using any Aleph One features that would make good test cases?
User avatar
The Man
Vidmaster
Posts: 1203
Joined: Aug 6th '08, 05:23
Location: Sarasota, FL
Contact:

Gemini Station is the top example that comes to mind. I don't know if anyone ever put the shapes patch up, but it's playable without it, IIRC; some stuff will just look very stupid.

This project sounds cool and I'll look into it at some point.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Getting Unity 3D working in Linux looks a little tricky for my tastes. I forked the project and started working on a sound file importer, though. Pull requests to follow in a week or two.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Well, Gemini station didnt even load, so i guess that makes it a good test case. (it does now, but there seem to be some out of range values in the map file.)

trellama, look here for the official unofficial linux builds of unity https://forum.unity.com/threads/unity-o ... es.350256/
(im using Mint, and it was a one-click install to get unity going, although you also need vs code to get an interactive debugger, otherwise any editor will work to edit the code.)
I look forward to being able to have sounds :)
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

I issued a pull request for sound file support. You should be able to load a sound permutation in an audio clip and play it. Figuring out all the pitch/obstruction stuff will be challenging; I might be able to help based on Marathon 2's behavior, but I sure don't understand Unity3D.

Physics file loading is straightforward so I'll tackle that next.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Thanks treellama.

I've got the sounds loading in and converted to unity AudioClips, and i can play them back, so it all seems to be working :)
There all sorts of filters you can apply to unity's audio sources, so the pitch stuff shouldn't be a problem, i'll have to read the docs on how it handles the obstruction tho. It looks like it supports all sorts of 3d sound stuff so it might be fairly easy to add different reverb effects for large rooms and so on down the track, which would be pretty cool.

Also, where is the terminal data stored in the map file? Thats the last thing i want to get loading before i start cleaning up the code that handles the world now that i have a reasonable handle on both how unity works, and how the maps are put together.

Also, I started to look at the physics last night, but i didn't get much past reading the source code for how A1 is loading the files, so feel free ignore what little is in there, since you have a much better understanding of how the data is stored than me im sure.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Awesome!

The terminal texts and images, as well as chapter screens and sounds, are stored in the resource fork of the map file. Because resource fork support is limited to Mac OS, various hacks are used to make it work cross-platform. One way is to encode the files as MacBinary. Another way is to store the resources in the wad file as tags in fake levels (index higher than 255). This is how Marathon 2 for Windows 95 did it. A third way is to have the resource fork be a separate file. I don't think it's worth supporting the third approach, I rarely see that, and it's possible to convert between the three.

Weland doesn't currently support any of these, but it knows how to extract the map data from each variation. One approach could be to add resource support to Wadfile.cs--I'm willing to do that if you want. It might help to have it in Weland in the future anyway?

Another way would be to require users to split the map with Atque first. That produces a directory with individual levels, terminals (stored as plain text), images (stored as BMP), etc. That might be easier to get started with, but less convenient to users.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Hmm... The only advantage to reading a separate file that i can really see would be that it would mean you could just zip the thing on osx and share the zip since iirc osx splits the resource forks into a separate file when you do that, however im guessing that people are used to using one of the other 2 methods, so thats probably not necessary. Which leaves the other 2 methods, and reading the resource forks on osx.

I assume the macbinary files are the most common solution? Thats probably the best place to start, if thats working, then in the worst case, we could just tell people to convert those maps in other formats, or even just include a version of atque that just does that.

I'll have a look at atque, although i cant seem to get it to compile (it looks like it doesnt like that fact that i have wxwidgets 3, since thats where the errors are, unless there is something else that you know about that would cause the errors?)

Actually, do A1 maps with embedded scripts and such store those in a similar way, or does that work differently? because it would be good to get that stuff loading as well, even if it gets ignored until the base game is working properly.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

For most common, it's probably a tie between MacBinary and fake levels. The first is the way a lot of classic scenarios got converted, and the second is what Atque uses so any new scenarios would use that.

Embedded scripts (Lua and MML) and shapes patches are stored in the resources like terminal texts, yep.

Atque from Git master compiles against wxwidgets 3, or you can compile without wxwidgets support using a configure option. That creates two command line utilities, atques and atquem, that split and merge respectfully.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Well, i downloaded Atque again and it works. I'm not sure where i got the other version from, but it seems to be from 2012, so...

It sounds like getting the macbinary resources working is critical, but it would be good to get the fake levels as well. That said, i'll take whatever you want to make :)

Also, theres a bunch of stuff that i cant find in the data files anywhere, is it just hard coded, or am I just missing something? (i've just added some definitions to the gameController.cs file, but if they should be loaded from somewhere, obviously id want to do that).
-the definitions for the items (ammo, guns etc) as they appear in the world.
-the definitions for the scenery items appearances
-which scenery items are breakable, do they have any health, what effects to play when they break, and when
-which scenery items block the player, and is that still true if you break them
-which textures to use for the medias
-what colour they are when you are in them
-how much damage do they do, what screen effect is used when they do?
-can they affect your swimming in any way, or oxygen usage?
User avatar
The Man
Vidmaster
Posts: 1203
Joined: Aug 6th '08, 05:23
Location: Sarasota, FL
Contact:

I can answer the last one of those: They all work exactly the same way for swimming and oxygen consumption. The oxygen usage formula is linked here. I don't currently comprehend it very well because it's C++ and I barely remember the language.

I think most of those things are hard-coded into the engine, though they can almost all be customised. I don't know where they're defined, though.
“People should not be afraid of their governments. Governments should be afraid of their people.” —V, V for Vendetta (Alan Moore)

“The trouble is that we have a bad habit, encouraged by pedants and sophisticates, of considering happiness as something rather stupid. Only pain is intellectual, only evil interesting. This is the treason of the artist: a refusal to admit the banality of evil and the terrible boredom of pain. If you can’t lick ’em, join ’em. If it hurts, repeat it. But to praise despair is to condemn delight, to embrace violence is to lose hold of everything else. We have almost lost hold; we can no longer describe happy man, nor make any celebration of joy.” —Ursula K. Le Guin, “The Ones Who Walk Away from Omelas”

“If others had not been foolish, we should be so.” —William Blake, The Marriage of Heaven and Hell

“The law cannot protect anyone unless it binds everyone; and it cannot bind anyone unless it protects everyone.” —Frank Wilhoit

Last.fm · Marathon Chronicles · Marathon Eternal 1.2 · Where Monsters Are in Dreams · YouTube Vidmaster’s Challenge
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

I guess it just feels like you move slower when you are in lava...
As for the rest, i just want to make sure theres nothing in the data files that im overlooking - it never even occurred to me that some scenery items are different to others until i got them loading in the game and started crashing into puddles of blood.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

As far as I know those are all hard-coded. They can be overridden in Aleph One by MML (before that, scenarios would mod the actual Marathon Infinity binary to change them). Useful files in the Aleph One source:

GameWorld/item_definitions.h
GameWorld/scenery_definitions.h
GameWorld/media_definitions.h
RenderOther/fades.h
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Those look like they have everything i need. I've been a bit busy with other things this week, but I've started cleaning up the level generation code. I'll also try to add some hooks for loading mml.
I went through the spec (is the wiki page fully up to date?) and it looks like most things should be fairly straight forward, but there will be some things that are problematic.
The main ones look to be loading custom shaders - the main shader im using should handle all the basic effects (bump mapping, glow maps etc) but it looks like you can also define completely custom shaders, which will cause problems for any realtime lights and shadows later, and also for the impossible space, since im using clipping planes in the shader to acheive the effect.
The other big thing is going to be loading 3d models since unity has no built in support for loading anything other than its own model format at runtime, so i'll have to either find some libraries, or look at porting the A1 model code to c#, or maybe look at what it takes to get c code running in unity and try to use it directly - assuming that it makes something that is remotely like a unity mesh.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

I think MML would be a low priority. Bump maps and 3D models are really kind of gimmicks, you don't need them to play Marathon 2 or Infinity. I'm not aware of any scenario that uses 3D models or custom shaders, as it happens!
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

Yeah, it is. I basically just want to avoid doing anything that will make life difficult when i get that far. Likewise with the lua scripting, im not sure that it will be practical to support that at all - people have got lua running as a run time language, but many of the game objects end up being quite different to A1 once they have loaded that it will probably be a significant effort to get even basic scripts running correctly.
Thats definitely last on the list though.
User avatar
The Man
Vidmaster
Posts: 1203
Joined: Aug 6th '08, 05:23
Location: Sarasota, FL
Contact:

I think Lua would be more important than bump maps etc., because a lot of scenarios use Lua to alter gameplay – Phoenix, for example, would run completely differently without Lua (there are portions where monsters and the player will die if they cross below a certain z threshold, for example, and without Lua, the player would just get stuck with no way to escape; similarly, there are powerups that regenerate the player’s health for awhile). I use similar scripting in my own scenario (again with the “kill stuff below z threshold”, plus a script that drains the player’s oxygen on certain polygons in one level). MML can also alter game behaviour. I’d say anything that alters gameplay is more important than cosmetics, and 3D models etc. are really just cosmetics at the moment.

That said, of course the original game doesn’t use Lua at all, and I think it’d certainly be more important to get the original trilogy working than it would to get scenarios working. I can’t recall any major total conversions other than Phoenix that use Lua, or for that matter that use MML for any purpose other than altering the hard-coded game stuff spoken about above, or cosmetics (e.g., fog).
“People should not be afraid of their governments. Governments should be afraid of their people.” —V, V for Vendetta (Alan Moore)

“The trouble is that we have a bad habit, encouraged by pedants and sophisticates, of considering happiness as something rather stupid. Only pain is intellectual, only evil interesting. This is the treason of the artist: a refusal to admit the banality of evil and the terrible boredom of pain. If you can’t lick ’em, join ’em. If it hurts, repeat it. But to praise despair is to condemn delight, to embrace violence is to lose hold of everything else. We have almost lost hold; we can no longer describe happy man, nor make any celebration of joy.” —Ursula K. Le Guin, “The Ones Who Walk Away from Omelas”

“If others had not been foolish, we should be so.” —William Blake, The Marriage of Heaven and Hell

“The law cannot protect anyone unless it binds everyone; and it cannot bind anyone unless it protects everyone.” —Frank Wilhoit

Last.fm · Marathon Chronicles · Marathon Eternal 1.2 · Where Monsters Are in Dreams · YouTube Vidmaster’s Challenge
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

I definitely intend to support some sort of scripting, what that will be is still up in the air.
Im currently leaning towards C# as it should be fairly easy to also give access to the various game objects that way, and you can also have access to the entire unity api, which would mean that the scripts can do just about anything.
On the other hand, lua would mean that there is the potential to make things compatible with existing scripts, however id have to write a bunch of wrapper functions that are secretly twiddling all sorts of things in the background for the lua scripts to interact with in order to get the compatibility happening, and that would not only be a lot of work, but i can see it going wrong very quickly if the script does anything complex, and tracking down bugs there would probably be a nightmare.
My plan at the moment for A1 scenario support is that once i get M2/Infinity working, i'll go through big scenarios and see whats needed to get them working, probably starting with M1A1 so that all three main games are playable, and that only uses mml, so i'll probably start there.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

In order to read standalone physics files, I'm going to have to refactor Wadfile.cs. That's change requires a little extra thinking, and I've been busy with other work, but I hope to get to it soon.

There's a Unity dependency in Wadfile that I don't think is used. I'm going to remove it because it's easier for me to test without compiling all that stuff in (I still haven't gotten around to getting the engine working). Was there a reason for that to be in there?
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

I think i just added it so that i could log to the console in Unity. There is a Debug.Log line in there which can go.
it is needed in the shapes code as i changed it to make Texture2Ds instead of using System.Drawing, but i cant see anything thats needing it in wadfile (except that Debug.Log() line), so feel free to remove it - its not like its hard to put back if there is some reason for it to be there.
User avatar
Alex
Born on Board
Posts: 24
Joined: Mar 11th '18, 12:21
Location: Low Earth Orbit.

So I have found some more time to look at this again, and re-created marathons physics model, which was my general goal before making binaries.
So for anyone still interested: https://github.com/Trichosurus/munity/releases

It should be able to load any marathon map/data files, however lots of things are not yet working.
The physics are not yet being read from the map, so they are hard coded to the standard values for now. That said, let me know if you think i have things working correctly. (I assumed that the values would all be in WU/Tick, but they appear to be half that for the acceleration variables?)
There are a bunch of adjustments that can be made to the physics in the settings, play with them if you think they are set wrong.
Also, let me know about any bugs in stuff that should be working (im sure there are lots) - the main things that im looking at are: there are some glitches with that landscape textures, and if you composite 2 textures on top of eachother, they wont be displayed correctly. Also if a platform extends into impossible space, it will generally cause problems. This can be fixed by turning on the occlusion culling, but it will mean that the first time a level is loaded will take some time. There are also some limitations with impossible space - it should generally work, however putting more that 2 levels of space on top of eachother will probably confuse it.
The sounds are loading, thanks to treellama, however only the ambient and random sounds are hooked up at the moment.
Also, the sprites are not displaying correctly yet.

There are also some things that are different, although i cant think of a good reason to change them, so unless someone thinks they will cause problems, they will remain:
The first thing is that it runs at about a thousand fps. This has some implications for flickering lights, but that should be about it.
The second is that untextured void will either show as white or transparent depending on the circumstances.
Finally, should be no bouncy walls, invisible walls, or accidental teleportation to nearby polygons.

Lastly, i have tested the linux and mac builds, but i dont have a windows machine to test on, so someone let me know if it works at all... :)
Post Reply