FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    Supcom/Moho engine rewrite

    Scheduled Pinned Locked Moved Contribution
    16 Posts 12 Posters 1.1k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      SlightlyGrilled
      last edited by SlightlyGrilled

      Hello, I have made an attempt at making a drop in replacement for supcoms Moho engine.

      The latest exes:
      Mac
      https://upload.disroot.org/r/Ruv6XWA3#wTu4NeQg/SvvKWHGL/Y7Z5k0qRnYoYJoUka+Ej3arog=
      Windows
      https://upload.disroot.org/r/q2XTdA0V#rTfciPHkfYNsX5bRLmBEeauD1BliPu8WrPebsCqWFjY=
      Linux
      https://upload.disroot.org/r/8FAj9fnz#ZHyZiptsQo4EmI53hP6sn2y2ea3NrL8OVosy61PgbRE=

      Now first off the bat this was of course made with ai, but please before the pitch forks are raised.

      • this whole post has been done by hand
      • I did a large amount of research in to supcoms Moho engine, both for this project and many years ago when I tired (and massively failed to do this in c++) and I want to believe I carefully guided the ai in what I wanted and what I believe is important for this style of engine
      • I am also an senior dev with over 15+ years of experience, so I’m not just some script kiddy spluting out the game.
      • I have really done this in good faith, supcom is one of my all time favourite games and I really wish for it to live for ever

      That said, I also want to say straight away this wouldn’t have been any near as possible if it wasn’t for the huge huge amount of effort all the people working on faf and other communities have put in over the years to supcom, so a huge thank you to them.

      It’s also certainly not finished, it’s one of those 90% takes 10% of the time, and the last 10% takes 90%, but I wanted to get this out there.

      I guess first off, tech wise.

      • its written in rust
      • Its a drop in replacement (although requires currently faf github checked out and supcom installed on your pc, or atleast its files)
      • uses luau for the lua with both patches both to the lua vm, and also lua source code translation for all gpg specific changes they made.
      • I hope the luau in the future allows for using luau typed version of lua
      • shaders are written in wesl
      • it is cross platform (well at least windows and Mac)
      • it supports up to 63 player multiplayer. (I think it can go higher, but it's currently a performance trade off and I figured 63 was enough to compete against a certain other rts game 😛 )
      • it works with faf lua unchanged, apart from some very small bits I had to shim.
      • 64bit
      • has testing and benchmarking

      It's fast. (This was super important to me, what’s the point if we can’t go fast?)
      With a 60min game of 4x4 on setons of ai vs ai runs at 4x real speed. and a 1v1 can run at 180x realtime on my Mac.
      This is really limited by the ai logic in lua, I have test maps with 16k units all pathfinding and shooting at each other, all running well above base game speed.

      And I’m 100% sure it could be improved further.

      Of course many things are still not working correctly, particularly the graphics are not an exact match.

      I also imagine a lot of work needs to be done on the look and feel of things, such as unit movement etc…

      It also doesn’t support save games at the moment or replays.

      Although with where i have got it to, im sure it won't belong before it's basically a mirror to the current game.

      I really hope this is well received, I know ai was used, but I did actually put a good amount of effort in to planning this, and just general slow build up of knowledge over the years.

      After a bit more work i will open source it 🙂

      here are some videos of the game

      4 v 4 networked game between windows and mac (2 on windows, 6 on mac)
      https://youtu.be/OiNBzXKnppc

      an 4v4 full ai game
      https://youtu.be/GotWNzX6Xgs
      00c60896-dc45-4d06-be4f-b6e4ce384b2f-image.png

      a 63 ai player game (although could be people)
      https://youtu.be/u5EUMRxeL0Q
      d2a14893-0c86-41ad-aace-1e2fcfeb83e7-image.png

      bf7c4b1f-7349-4474-9af2-83d985bdb09c-image.png

      1 Reply Last reply Reply Quote 11
      • L Offline
        lycanrising
        last edited by

        63 ai player game (although could be people)
        🥲 what!!!!

        1 Reply Last reply Reply Quote 0
        • nomadsN Offline
          nomads
          last edited by

          Great job, keep going!

          1 Reply Last reply Reply Quote 0
          • LimeZ3_L Offline
            LimeZ3_
            last edited by

            gj

            Make t3 mex, not war

            1 Reply Last reply Reply Quote 0
            • GiebmasseG Offline
              Giebmasse Team Lead FAF Association Board Moderator Admin
              last edited by

              Impressive, curious for more!

              1 Reply Last reply Reply Quote 0
              • R Offline
                randomko
                last edited by

                A brilliant job, especially considering that the team next door have been making Sanctuary for several years and are still very much a work in progress. Hope you manage to get as close as possible to the original supcom

                1 Reply Last reply Reply Quote 0
                • XanoxisX Offline
                  Xanoxis
                  last edited by Xanoxis

                  I hope this project and anything around it can work out, especially if it can push the development of FAF even further.

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    SlightlyGrilled
                    last edited by

                    So here is a "working" build, but first I just wanted to address the work, Yes of course I have made this with heavy amounts of AI, and I know that kind of sucks, especially for those that have worked so hard on faf over the years.

                    In no way do i want this work to take away from that hard work.
                    What I hope, is that those people will be empowered by this project, they can already achieve magic with asm patches to the exe, imagine what can be done when they have real code to work with.

                    I have no doubt that many many people understand fafs lua better than me, have better understand of graphics/pathfinding/supcoms quirks and behaviours/etc...
                    And I am excited to see what they will be capable of achieve with this work.

                    I do plan to give the whole project to faf, code and all, and then you guys can do as you see fit with it.
                    I just hope it helps and empowers the community. (I guess the ends justify the means???)


                    Here is both an mac and windows exe. its to big to include here, so (and i can't believe this.. a link to limewire of all places... happy to share the file another means this was just the first google hit)
                    https://limewire.com/d/kIwte#CQnpfbOgYt

                    When launching either they will attempt to find faf and supcom, if they can't they will ask you to give it to them.

                    you need the latest faf

                    Although it does not intergrate in to faf currently.

                    I explain networking below, but to play together:

                    • someone must host the game using the multiplayer option in the main menu, create a game as usual
                    • They will be give a long code in the chat, its also copied to the clipboard
                      eab77297-d68e-4719-9af5-5b7418dcd2a2-image.png
                    • Others can then join via the multiplayer option in the menu, putting that string in to the ip address section, and 1 in the port section
                      like below (note the code doesn't match in this screenshot cos i took it at different times)
                      connection-with-iroh.jpeg

                    Now as said before while the game "works", its really really is far from perfect, many things are broken or not working as expected.
                    I also have only been able to test, on an old windows machine, a surface laptop, and a new mac.
                    I don't have anything with an amd card, so god knows if those work.

                    If you get crashes, give me the logs to look at, although i make no promises 🙂 im only human (even if ai can help...)

                    I have zero idea about mod support, i haven't had the time to look at it, in theory it should work, or at least i originally set up the ground works for it.

                    Bugs:
                    There will endless bugs of that im sure, every time i launch the game i notice bugs, and i'm just a casual noob player.

                    • behaviour bugs (the tanks don't work like that, gunships don't hover like that, navy pathfinding is just awful right now)
                    • crashes (i'm guessing this will mostly be graphics card related)
                    • missing functionality (the novax doesn't work at all)
                    • look and feel of graphics (particles are all over the place, like projectiles, the uef t3 defence, or transports and gunships, the list goes on...)

                    I haven't tested many things, as i just haven't had the time and wanted to get this build out to people to mess around with.

                    Really this project is a proof of concept, i think it will take the faf community time if they choose to make this a real replacement)

                    If you have things not working please give me the log file, it should be next to the exe.

                    Networking:
                    So I’m really excited about the networking.

                    First off it uses this fantastic library called Iroh, which does p2p with nat punch though. It will attempt to create direct p2p connections between players, and if not possible it will route the connection through a relay, at the moment this uses iroh public server which has zero guarantee about uptime and through put, but faf could easily host their own one.

                    When creating a lobby, the game will give you a long random string, others simply need to paste that in to ip direct connection, plus any port number between 1-65k

                    and it should connect :fingers_crossed:

                    The game still uses udp underneath although its got a reliability layer on top, and I believe connections through irohs relay are tcp, if your direct connected its udp.

                    I have zero idea how well this will actually work in the real world, but I have played a game with a friend.

                    Next is player input.
                    (now I could be wrong) but my understanding of how supcom does its input syncing is:

                    • sim ticks along at 100ms, player input it sent every tick, but with a 500ms(I think?) delay, as all players need to have this input from every other player in order for the game to continue, thats what causes hitches with bad connections. As the game pauses waiting for input.

                    What this version does.
                    Fundamentally its the same, however instead of a fixed 500ms, each player has a dynamic input step. All ticks still need an input step.
                    but each player now measures their latency/ping to others, and picks an input delay for themselves.

                    all their input is then marked with that delay. which comes in as (please apply this input in 5 ticks (or 500ms))

                    or if they have a very fast connection (please apply this input in 2 ticks (200ms))

                    The upside to this is bad connections should cause as much less hitching to everyone.

                    The down side is unfairness, a very laggy player can cause the delay of inputs to rise for those connected to them with a bad connection (as it could just be a bad connection between only 2 people).

                    I would purpose that there is an option to lock the input delay.

                    I hope this means people with high ping can still play in games, even though it does still impact people by delaying their inputs. But should minimise freezes.

                    To show this all off, there is now a ping table bit of ui. You can see it with ctrl + shift + p, or on Mac cmd + shift + p

                    it's a grid showing the whole mesh of connections between everyone, so all players can understand the network layout of the mesh.

                    it shows the current max game speed for each player, and their input delay

                    This should help understand when 2 players have a bad connection to each other, but good to everyone else

                    This screen shot is with faked players and numbers, but give you an idea, of course hopefully in a real game you don't see that much red
                    6cd16127-1047-4911-80b9-160a753aa631-image.png

                    Perf
                    Here is a crazy 64,000 airplanes fighting, of course its completely laggy, but it's somewhere in the realm of vaguely playable, the main bottleneck for graphics is the particles which would need moving to be gpu accelerated, as they are currently processed all on the cpu.
                    https://youtu.be/gTWnagf_Gak
                    also for those that want it, here is a tracey profile of that, proving that it can use more than 1 core! although its still mostly single threaded unless the scale is really high.
                    75822429-07c0-4c5a-b59d-55a1eefa5b95-image.png

                    I did test 63 players locally and it brought my machine to its knees...
                    31e4b0e2-f4c1-4ed6-99fe-6e7b7c74296e-image.png

                    I have patched the faf lobby in this exe to allow 64 players, although no map supports that, i've included an edited flat map that should support it. Everyone would need this map, the exe does not support transferring files yet.
                    I honestly have no idea how well it will work.
                    flat_63.v0001.zip

                    1 Reply Last reply Reply Quote 6
                    • S Offline
                      snoog
                      last edited by

                      Pretty funny (and awesome) seeing this here today. I was just reading about new AI models and their reverse engineering capabilities and was thinking about giving something like this a shot. Looks pretty damn sweet so far. Who'd ever imagine potential 64p SupCom? Love that you having a "working" MP version already, and that connection grid.

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        J_W_W
                        last edited by

                        This sounds to be excessively awesome, great effort out of nowhere!
                        haven't tried it yet, will definately keep an eye on it.

                        Just a great fan of the game myself, knowing and hearing of the bottlenecks that would require a new engine (or a rewrite) to fix.
                        And then to realise the opportunities this possibly opens up for further improvements makes this even more awesome.
                        Hope this endeavour will soon flourish!
                        Also makes one wonder if a single knowledgeable person with AI assistance is already capable of delivering such a feat that would take an entire team many months to pull off is slighty unnerving (if AI is this capable now already...).

                        1 Reply Last reply Reply Quote 0
                        • Brutus5000B Offline
                          Brutus5000 FAF Server Admin
                          last edited by

                          Does your engine run the lua code for the game patch?

                          He said, "I've been to the year 3000
                          Not much has changed, but they live underwater
                          And your great-great-great-granddaughter
                          Is playin' FAF, playin' FAF"

                          1 Reply Last reply Reply Quote 0
                          • GiebmasseG Offline
                            Giebmasse Team Lead FAF Association Board Moderator Admin
                            last edited by

                            I ran it yesterday on linux with latest FAF game files.

                            1 Reply Last reply Reply Quote 1
                            • A Offline
                              arkenflame
                              last edited by

                              Do you plan to share on github? Would love to follow along!

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                Darien_
                                last edited by

                                Also keen to follow/contribute if you are able to share a GitHub link.

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  SlightlyGrilled
                                  last edited by

                                  Hello, I'm back, and I believe I'm even closer to feature parity with base supcom now!

                                  Before anything, the exes:
                                  Mac
                                  https://upload.disroot.org/r/Ruv6XWA3#wTu4NeQg/SvvKWHGL/Y7Z5k0qRnYoYJoUka+Ej3arog=
                                  Windows
                                  https://upload.disroot.org/r/q2XTdA0V#rTfciPHkfYNsX5bRLmBEeauD1BliPu8WrPebsCqWFjY=
                                  Linux
                                  https://upload.disroot.org/r/8FAj9fnz#ZHyZiptsQo4EmI53hP6sn2y2ea3NrL8OVosy61PgbRE=


                                  Many nasty little bugs have been squashed.
                                  Don't miss the particle video 🎆

                                  But first performance!

                                  I wasn't happy with the fps in that 64k air fight, after all it's only 64k, that's rookie numbers for modern computers.

                                  While I can't do much about the 200-300ms of time spent in the lua (as a rule of this project is not to edit the faf/supcom lua, it must be a drop in replacement), I can certainly improve the rendering speed.

                                  and in this modern age computers come with many cores, so best put them to good use.

                                  The rendering loop is made up of a few stages

                                  • intel
                                  • strategic icons
                                  • minimap
                                  • interpolate positions
                                  • animation
                                  • lod selection
                                  • particles
                                  • ui
                                  • issuing draw calls

                                  before this was all serial in a single render thread.

                                  now its broken down, in to two main threads, with workers for more parallel work

                                  First LODs

                                  Then

                                  • intel
                                  • strategic icons
                                  • ui

                                  at the same time

                                  • interpolate positions
                                  • animation
                                  • particles

                                  as can be scene here
                                  37ad76e8-32d2-49e7-81c1-f5e324f58d7f-image.png

                                  Then the next thing was the draw submits to wgpu. Now we're long past the days of direct9 and being bound to a single thread.

                                  We can record the commands all in parallel.
                                  87166459-df35-479c-87f8-4855eff252d5-image.png

                                  Along with some work to batch process units

                                  we end up with a full frame looking like this
                                  e5762e9a-bfae-4e48-847b-da983caeeaef-image.png

                                  You can really see the difference vs before
                                  331b26a5-3d14-4a91-8246-12611c2e6c30-image.png

                                  This brings the 64k air fight from about 15fps up to 70-100fps.
                                  While the main sim only runs about 2.5-3x slower than the default speed!

                                  and can all be seen below in full technicolour!
                                  https://youtu.be/UVgRPUpkJp0

                                  And for extra fun, you can see the whole sim tick for that fight here, look at all that lua (in blue/cyan on the sim thread)!
                                  Every bit that isn't rips through as many cores as it can
                                  182367bc-0289-44d7-990b-c2bd53e94a38-image.png


                                  On to bugs/improvements, and there are many!

                                  Replays!

                                  Now these are only compatible with my version and only with the version that created them.

                                  The game will save out your last 100 replays, and you can access them in the replay menu.

                                  They are stored along side the exe
                                  7e49e8ac-8b69-4069-bdf7-dc05781db97d-image.png

                                  Particles!!!

                                  So supcoms particles where kind of gpu accelerated, well not full compute shader, but they wrote all the info to buffers, then let the vertex shader go to town.

                                  Also particles where just horrible broken in my version.

                                  We now in 2026 do the same! (along with my 2nd fav unit to show it off (don't worry fatboy, you're still number 1)
                                  edab2356-79a0-43b5-af79-5375ddb3b5eb-image.png
                                  ac95ae90-adcf-4c30-9ed7-44918a8849e3-image.png

                                  Actually I believe really you need to see the Video to really do particles justice 🙂
                                  https://youtu.be/qlK1FC12H1o

                                  Map gen

                                  the map actually looks correct (or more so) now.
                                  Before 😕
                                  c154d317-8c4a-4d15-9e22-1975b2decbde-image.png

                                  After!
                                  6b6ac47f-ab49-458f-9104-2a533dd7bd3d-image.png

                                  Before
                                  2400916e-bb90-4a5d-acc7-ade6f44e663c-image.png
                                  After
                                  d6a0edd0-7045-4435-abd9-f6d606062477-image.png

                                  Before
                                  cef78e14-ab79-4539-a61f-d6c079f2e616-image.png
                                  After
                                  f653cb5e-b9ed-4999-b62b-a56e60f3f1c7-image.png

                                  Glowing Mexs!

                                  53c7d4b1-454a-429f-bdc2-9a0f561b6aba-image.png

                                  Rings!

                                  Now they work for hover and select, and just generally work
                                  79a26918-e1dc-439b-8126-003547059224-image.png

                                  Factory upgrades

                                  Gone are the days of waiting for factory to upgrade before queue those machines are war, now you can queue up builds as you would expect
                                  5c560bc4-fb37-4bb9-8939-b962bdcab33d-image.png

                                  The un pictured rest

                                  • you can queue mex upgrades
                                  • upgrading radar no longer shows the next ring level
                                  • reclaim numbers now show in the ui
                                  • you can no longer click on enemy units to see their orders! what a shame cheating will never be so easy again.
                                  • engineers will now help the target they are assisting when that target assist
                                  • random bright boxes on dying aircraft
                                  • veterancy works!
                                  • macos track pad scroll no longer sends you for a spin
                                  • Some better fps stats, we now list vram, ram usage, render cpu and gpu time (this screenshot is from the 64k air fight)
                                    d7fdabb7-7548-47bb-bfa8-a31f513c7ebf-image.png
                                  1 Reply Last reply Reply Quote 1
                                  • S Offline
                                    SlightlyGrilled
                                    last edited by

                                    And another quick update with a requested 10k vs 10k airfight video 😄

                                    https://www.youtube.com/watch?v=BrD_8Py4gX0
                                    image.png

                                    the dead rest...
                                    image.jpg

                                    1 Reply Last reply Reply Quote 2

                                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                    With your input, this post could be even better 💗

                                    Register Login
                                    • First post
                                      Last post