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!

    Force a gameover with mods

    Scheduled Pinned Locked Moved Modding & Tools
    9 Posts 4 Posters 788 Views
    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.
    • R Offline
      Raquaza
      last edited by Raquaza

      I was wondering if it was possible to make a mod to force a game to end, without killing the coms outright.

      If it was possible to do and also to make it an option in lobby (off;5min;10min;15min;30min) it could make for some interesting games

      And I guess also have it show up a countdown counter UI element ingame, but I think it would be a little bit more complex

      1 Reply Last reply Reply Quote 1
      • ValkiV Offline
        Valki
        last edited by

        I think you'd want it to force a score victory, but yes - I might actually try more custom games with such an option.

        1 Reply Last reply Reply Quote 0
        • UvesoU Offline
          Uveso
          last edited by

          @Raquaza

          Some ideas:
          Most score or mex output after 30 minutes wins.
          Kill all enemy factories to win
          1st who builds an experimental wins. (excluding monkey lord)

          End game conditions based on unit count or time is easy to implement.
          We could first build this as external mod and later implement it to the game itself.

          So yes, its possible.

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

            Yes, building these functionalities would be my focus, but at this point I'd be asking if anyone has any insights on what to touch on for the win conditions (code wise) and mostly for the ui side of the mod since I would love it to make very modular to create a lot more gametypes

            1 Reply Last reply Reply Quote 0
            • UvesoU Offline
              Uveso
              last edited by

              These are the victory conditions:
              https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L3

              local victoryCategories = {
                  demoralization=categories.COMMAND,
                  domination=categories.STRUCTURE + categories.ENGINEER - categories.WALL,
                  eradication=categories.ALLUNITS - categories.WALL,
              }
              

              demoralization: game ends when we have no ACU left (Unit with blueprint category 'COMMAND')
              domination: game ends if we have not structures or engineers left.
              eradication: game ends if we have no unit left (except walls)

              Here is the function that checks the victory:
              https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L42
              This line is getting the Victory options:

              local categoryCheck = victoryCategories[scenarioInfo.Options.Victory]
              

              This is the line where the victoyCategories are checked:
              https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L55

              And this leads to the function that is actually checking the real units against the victoryCategories:
              https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L9

              So the function AllUnitsInCategoryDead() returns true if all units depending on the victoryCategories table are dead.

              You can modify the game here to return true or false to end the game for a player.

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

                Interesting stuff, for the past hour I've been trying to get some of those elements modified/working through mods but I will need a bit more time to have something worthwhile (and not prone to crashing on startup).

                The only doubt I'd have at this moment would be the ability to end the game after a certain time, since it doesn't seem I can change the original function and I'd have to make a parallel function to check the time, but maybe I can disable the original function based on the victory condition?

                Oh and also, there isn't a good way to modify the lobbyOptions file apart from copying the file, scrolling through the options and then replace the wanted element with a copy of itself, right?

                1 Reply Last reply Reply Quote 0
                • UvesoU Offline
                  Uveso
                  last edited by Uveso

                  I am sorry you can't modify the lobby with a mod.
                  Mods will be loaded on game scenario start (when you leave the lobby).

                  So ignore the options for a while.

                  in case you need help with your mod, please zip your mod and post it here.
                  This way we can test it and add some lines if needed.

                  [Edit] Options for mods will be available soon:
                  https://github.com/FAForever/fa/pull/3144

                  1 Reply Last reply Reply Quote 0
                  • arma473A Offline
                    arma473
                    last edited by

                    If you mod decides that the game should be over, it could instantly kill all ACUs from the losing side.

                    It could even do something like add 50,000 health to the ACUs for the winning team, to make it much less likely that they would die (whether from ACU explosions or for some other reason).

                    1 Reply Last reply Reply Quote 0
                    • UvesoU Offline
                      Uveso
                      last edited by

                      @arma473

                      yes, exploding ACUs would look awesome, but its not needed codewise.
                      You can simply set who is winner and who not and just call the the endgame function.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post