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
    75 Posts 37 Posters 4.6k Views 12 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

      A new version! (now working with faf 3841!)

      https://github.com/ThomasMonkman/rts-core-engine/releases/tag/v0.2.1

      Lua Debugging

      Thinking of developers, both for the game and modding, i have added debugging! you can see in the video below

      • breakpoints
      • conditional breakpoints
      • seeing variables
      • running code live in the console, such as in the video with SetHealth on the scout

      https://youtu.be/EZGhvC2t4Uk

      a9f6f45e-50b2-4efb-9548-d9295013842c-image.png

      this can even be used to debug mods! here is me stepping in to the hooked files of the RNGAI mod (credit to @relent0r)
      https://youtu.be/3pvMWk2clw0

      3bbeaa29-c283-46e7-9895-e373949dde72-image.png

      to try this your self, you can look here
      https://github.com/ThomasMonkman/rts-core-engine/blob/main/docs/guides/debugging-lua.md

      Improving the stats bar:

      The stats I use to see at a glance the performance of the game, both sim and rendering, but it was messy, time for a face lift. Thanks to @MayeulC for prompting and giving ideas for this work.

      33bc4a48-40c3-472d-b78b-1dcbe15bf08a-image.png

      hover on fps
      03eae585-6263-4639-bd48-0994bf1efabd-image.png

      hover on sim
      200b5f63-b83d-41bd-b412-662871149d22-image.png

      and to show off the networking, a very cool networking simulator, now you can pretend to be in Australia (or further) even if your not!
      8141d268-89d1-42fd-8d6a-e5c5215a76d6-image.png

      Next a series of bug fixes

      • Units turn for factory roll off
      • Trees now correctly blown away by explosions
      • Functions implemented that RNGAI used, which means RNGAI now works :), thanks relent0r
      • Mods and maps are loaded with case insentivity, so they now load on linux
      • Tree correctly blow away from explosions!
      • Blast damage now impacts shields
      • Diskwatch now reloads lua,textures,models, etc...
      • A vault folder without maps/ or mods/ still mounts
      • Closing the second monitor's window closes only that window, instead of shutting the game
      • Selection brackets are centred on the mesh, and range rings scale with the map when zoomed out
      • Intel is now fully parallel
      • Follow weapons are also now fully parallel
      • Improvements in movement with turning and corners
      • Aircraft refuel while being repaired, and dock at the nearest air staging platform
      • Eco stall for both mass and energy now handle like the base game

      Also thanks to:

      • MayeulC a PR for improving issue onboard, and for detailed bug reports
      • relent0r and an94 for bug reports
      1 Reply Last reply Reply Quote 1
      • S Offline
        SlightlyGrilled @Xiaomi
        last edited by

        @Xiaomi So yes your right, i think I'm approaching the ceiling on what can be done, although I'm sure there are always clever tricks to go further.

        Do bare in mind though that, that trace is a 64k air battle, the normal balance of the game simply doesn't run in to that kind of unit count, even if you played with 64 players.

        I do think a lua thread pool api could be introduced similar to love2d , but that would really only help with big chunks of work like ai and such.

        with this i would imagine some task api where you opt in to certain data (unit position, eco, intel, etc...) to be copied over to an isolated lua thread, then you would set a duration of ticks for the work to be completed in, such that it remains deterministic, if it hasn't completed in time the sim would wait.

        something a bit like this in the sim (this is pseudo code just to illustrate the idea)

        
        
        -- Plain-data arguments, deep-copied at post time
        local taskArgs = {
            thing = 5,
        }
        
        local dueInTicks = 10
        
        -- Which parts of the sim to copy over
        local unitsView = {
            fields     = { 'Position', 'Army', 'BlueprintId', 'Health' },
            categories = categories.MOBILE,
            armies     = 'enemies',
        }
        
        local access = {
            Units    = unitsView,
            Terrain  = true, 
            PathGrid = { 'Land', 'Amphibious' }, 
            Economy  = 'own',
        }
        
        -- Which task to run: a module path and a function in it
        local taskModule   = '/mods/myai/lua/tasks/threat.lua'
        local taskFunction = 'Compute'
        
        local pending = Pool.PostTask(taskModule, taskFunction, taskArgs, dueInTicks, access)
        
        -- do more stuff
        
        local ok, result = Pool.WaitForTask(pending)  -- resumes at exactly post tick + 10
        

        then the worker script

        
        function Compute(args, View)
            local units = View.Units
            local count = units.Count()
        
            for i = 1, count do
                local position = units.Position(i)
                local health   = units.Health(i)
                -- do stuff thats slow...
            end
        
            return args.thing * 42  -- plain data, handed back at the due tick
        end
        
        

        This has the advantage of allowing devs in the lua to break up work in to as many threads as they see fit, and with so many cores now available, more tasks are always better.

        https://love2d.org/wiki/love.thread

        There is also robloxs thread model where you can have read only access in parallel, and write access is then serialised.

        https://create.roblox.com/docs/scripting/multithreading


        but yes you are right, it is in conflict with how supcom was made, perhaps another possibility would be to allow some wasm runtime (still allowing scripting of a sorts, just compiled), but I'm not sure if those are actually that much faster than the luau vm.

        of course you could move the whole game to native code, but then you lose modding and such...

        interesting none the less

        1 Reply Last reply Reply Quote 0
        • X Offline
          Xiaomi
          last edited by

          @slightlygrilled Do you have an understanding of when your project will be ready for testing in fa-develop? For example, the developers of the project https://github.com/Draiget/faf-re believe that within 3 months the project will be ready for deployment. What are your estimates? It would be nice if you provided some competition.

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

            @Xiaomi So I think I'm fairly close, less than 3 months for sure, certainly if other people piled in, however I've kind of hit a point where it simply needs people testing/playing etc...

            But really ultimately it would need buy in from the faf development community.

            In terms of actually blockers other than bugs, it would be:

            • integration in to the faf desktop client, such as how faf launches the game (switching from the ice relay they use to the iroh one i've posted, or adapting to fafs ice relay)
            • integration in to the faf server eco system (sending stats, replays etc...)
            • the remaining functions that i've left as stubs for now, most likely the ones needed for faf to integrate.
            • probably more things that i forget for now, or simply don't know and would need the faf team to help with.

            In terms of code, nothing i really see as that hard.

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

              Wow, this is incredible!
              Screenshot 2026-11-24 221826.png

              A modded stress test with M28 AI, blackops, brewlan, battlepack, rks explosion, and a few of my own mods.
              ~6k units at -1 on a 9800x3d. The 32bit engine would have crashed from out of memory by this point XD

              Aside from some minor audio and shadow drawing bugs, I didn't notice any gameplay issues, and so far all the modded stuff seems to work just fine.
              Was not expecting this to be playable at all lol

              S 1 Reply Last reply Reply Quote 1
              • cychwa_klaymbergC Offline
                cychwa_klaymberg
                last edited by

                I really want FAF mod support and maps support

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

                  Its sweet that it works with mods, also doesn't crash to desktop after a match. Is there any way to launch it with initialization lua scripts to run things like Nomads?

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

                    What an incredible project! Potentially has the ability to release all the bottlenecks that have hamstrung FAF and serve as the basis of future projects to elevate it further.

                    I'd love to see if you could improve the transport loading/unloading behaviour to be more efficient and smooth. The pathing and drop off can get confused by the terrain and other units - something I could never manage to improve with lua edits.

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

                      A new version.

                      https://github.com/ThomasMonkman/rts-core-engine/releases/tag/v0.3.1

                      A lot has been done between this and my last post.

                      Major features are:

                      Doc website to show the engine api

                      Going off my previous posts, I love love love development productivity improvements.

                      This is a website that shows off the engine api, which is the way modders, and fafs lua talks to the engine.

                      • it's auto generated, so cannot go out of date, it's types and comments are created direct from engine code, so :fingers-crossed: can not be wrong.
                      • it's searchable
                      • shows what is and isn't supported currently (although I believe all functions mods and faf use are supported)
                      • shows new apis (such as the replay stuff) and apis I have decidedly decided to change

                      https://thomasmonkman.github.io/rts-core-engine/

                      Mod and Map Compatibility

                      I've spent some time running community ais, mods and maps, some of the following:

                      • m28
                      • RNGAI
                      • surival maps
                      • nomads
                      • LOUD
                      • brewlan

                      While I'm sure I've missed gaps on them, I hope people can enjoy playing them, and reporting back what does and doesn't work.

                      Any problems please report them, i will happily fix, its very hard for just me to test it all, and many of the mods im just not sure 100% how they work.

                      Nomads

                      Here is how to launch nomads, i've used the github checkout of nomads

                      https://github.com/FAForever/nomads

                      rts-core-engine.exe --init nomads/setup/init_devnomads.lua --session --faction 1=nomads
                      

                      and to jump straigh in to a game with

                      rts-core-engine.exe --init nomads/setup/init_devnomads.lua --session --player 1 --faction 1=nomads
                      

                      LOUD

                      For running loud you, you can just replace the Supreme Commander.exe in your steam folder with, my exe renamed.

                      I'm not really that familar with loud, and thus its hard to tell if its really working correctly or not, but I've been requested a few times to support it, and I'm more than happy to. So please give it a whirl and see if it works as expected 🙂

                      Surival maps

                      I love love these 😛 so i randomly pulled a few ones, and briefly tested them, please give it a go, and see 🙂

                      Other mods and maps

                      I'm more than happy to support mods and maps, I have found it difficult to know which ones work with the current version of faf, so if you send requests please put how you run it, what version of faf, or the base game, or LOUD, that you use.

                      I doesn't have to be with faf. I'm happy to try support any version of big robot battles in the year 3000

                      Compatibility

                      I've been running probes on the base game, to really go over every single thing in the base game to try and align behaviours, this involved hooking in to the base game, calling functionailty and logging out what happens, how functions react etc... this really helps the ai do a better job, instead of when it directly anaylises the games asm.

                      Perf

                      Quite a lot of work has been put in to this:
                      From my last 2.1 release:

                      • RNGAI about 20-30% faster
                      • M28 about 10% faster

                      Under normal pvp, I believe the game should run super fast, as it's not having to run the ai.
                      but even that should be faster too

                      The garbage collector currently runs every 10 seconds, that is now about 4x faster.

                      Stress test maps

                      I have posted some videos before of massive fights, i want to let others play with these, expect them to bring your computer to its knees 😛 (please post what sim ticks speed you get with your hardware, im very curious, for reference on the 63k air fight, with a m5 pro, i get 270-300ms/tick which is about -4 ~ -5)

                      land: 63 armies of 1000 tanks and 10 experimentals each

                      .\rts-core-engine.exe --no-audio --vault stress-tests --no-ai --armies 0 --player 1 --map /maps/stress_63/stress_63_scenario.lua --script stress-tests/land.lua
                      

                      air: 63 armies of 1000 fighters each

                      .\rts-core-engine.exe --no-audio --vault stress-tests --no-ai --armies 0 --player 1 --map /maps/stress_63/stress_63_scenario.lua --script stress-tests/air.lua
                      

                      air duel: 10k v 10k fighters, and you fly army 1

                      .\rts-core-engine.exe --no-audio --no-ai --armies 2 --player 1 --map /maps/SCMP_009/SCMP_009_scenario.lua --script stress-tests/air_duel.lua
                      

                      Big thank you to david1alvarez for reporting issues with SMD, and fatboy building as well, really helps me to make a better engine 🙂

                      The prs

                      • #66 and #68: the probe sweep. The first round fixed 86 differences, then rounds two to six followed.
                      • #94: seven differences found by the 23 Nov probe batch. #87 documents that batch's results.
                      • #90 and #93: weapon and damage follow-ups (NeedPrep, f32 armour, beam search, OnGotTarget timing).
                      • #71: abandoned builds decay as in the real game, and a repeated build order resumes the unit.
                      • #88: assisting a shield generator regenerates its shield.
                      • #89: SMDs share nukes out, and Fatboy works on the seabed and at cliffs.
                      • #98: an attack order's target is set only once the attacker is in range.
                      • #99: build callbacks fire when a factory or upgrade ends early.
                      • #108: added SetAlliedVictory.

                      AI and mods

                      • #101: M28AI plays full games, plus fixes for other mods and the stock AI.
                      • #109: --vault mounts a map's or mod's sounds folder.
                      • #102, #107 and #112: Lua translation fixes (--script files, bitwise brackets, restricted environments).

                      Interface

                      • #103 to #106: the interface's inline Lua API rewritten natively in Rust, in four PRs.
                      • #100: real WorldIsPlaying and SessionIsObservingAllowed.
                      • #79: camera zoom and pan feel like the real game.
                      • #67: strategic icons are crisp, with the army colour on the fill only.
                      • #77: the cursor no longer stays stale after switching windows.
                      • #78: interface tests start with a map and an army.

                      Rendering

                      • #95 and #97: far LOD meshes are posed by their LOD0 bones.
                      • #92: a Seraphim unit being built casts the shadow of the mesh that's drawn.

                      Performance and tooling

                      • #74: six changes to cut late-game sim cost.
                      • #86: Lua full-collection marking runs on rayon's pool.
                      • #70: capped game speeds hold their target.
                      • #96: the status bar's tick time includes the snapshot build.
                      • #69 and #73: Tracy filtering and levels, and headless snapshot timing.
                      • #72: all-AI probe games in the real game, and a frame-rate engine stat.
                      • #75: --headless-with-ui.
                      • #76: the __EngineStats values Lua reads are now filled in.
                      • #111: an API browser page and api.json from --dump-api.
                      • #127: selection on large groups of units is now faster, and has less effect on frame rate.

                      Bonus fun bug 🙂

                      For while i've noticed that the fat boy looked like ass when zoomed out, and i just assumed it was a bad LOD, but it kept nagging at me, and on futher looking, look at this mess 😄 turns out, i was mixing up render data between the normal model and LOD, and as we all love silly mistakes, here you can see the before and after fix 🙂

                      93473b18-aa85-4e2e-a791-e7be51827f8e-image.png
                      8a442fd7-ad82-4090-b124-32f55a8692af-image.png

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

                        @D4rkstalker oh wow!!! thank you very much for testing!

                        can you try again with the latest release i just posted above, it should be a bit faster ~10-30%, which might lift that -1 to real time 🙂

                        but also could you explain to me how you run those mods? i found that rks explosions doesn't work with the latest faf?

                        I've also fixed some bugs i had when running m28 ai, and some of the other mods you mentioned.

                        Also another favour if you don't mind 🙂 could you run the stress test with your bleeding fast 9800x3d! i would love to know how that cpu does!

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

                          @cychwa_klaymberg Hello! so mods and maps should just work if they are in your faf folders, of course any that don't please tell me the issues and i will have a look 🙂 but the aim is they should just work.

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

                            @RavenCurow Hello, in the post just above, I've listed how i managed to get nomads working.

                            you can pass an --init script in to the engine.

                            i briefly played a bit with nomads, but its been ages and ages since i played it, and Im not really sure what works and what doesn't, have a play and let me know 🙂 happy to help.

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

                              @Korbah Thank you very much 🙂 yes my hope is to allow supcom to push beyond it's current limits.

                              on the transports, I'm happy to improve on anything in the game, at the moment I've been trying to mimic the current game as close as possible baring a few things. (like unit intel only really updating once a second, now its 10/s)

                              how would you see transports improving? what would you like?

                              1 Reply Last reply Reply Quote 0
                              • R Offline
                                RavenCurow @SlightlyGrilled
                                last edited by

                                @SlightlyGrilled Nice, I was actually able to get my own custom faction working with it. It plays quite well. I look forward to seeing how things progress.

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

                                  At present, it appears to be working normally with LOUD - but there's no Steam connectivity (which LOUD utilizes for it's multiplayer hosting).

                                  There are some odd sound issues, with some units being excessive - but I haven't identified which units. Total Mayhem is a likely culprit, as they routinely overmodulated their audio files.

                                  Overall performance, based on the saturation tests I normally run for LOUD, indicates that the saturation point (where the SIM can no longer hold onto +10) is about 10% higher than the STEAM based EXE. Which appears to match what you're seeing from games with other AI.

                                  I haven't as of yet, pushed out to the memory limit, which would be something LOUD users would be greatly interested in, as games with 10k units, on 40/80k maps, are fairly common. I'll try to arrange that testing at my next opportunity.

                                  1 Reply Last reply Reply Quote 1

                                  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