FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login

    Access ArmyBrain in mod

    Scheduled Pinned Locked Moved Modding & Tools
    9 Posts 3 Posters 829 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
      rigomate
      last edited by

      Is there a possibility to access this function: GetArmyBrain()

      from inside a hook of a mod, when running a replay?

      GetArmyBrain() returns the ArmyBrains global variable.
      No matter how I try, I get error messages saying that I can not access that global variable or function.

      Any pointers would be appreciated!
      Cheers!

      1 Reply Last reply Reply Quote 0
      • R
        relentless
        last edited by

        You need to pass the parameter of the brain's nickname.
        e.g if you had 3 players called bob, jim, sam you would say

        brain = GetArmyBrain('sam')

        1 Reply Last reply Reply Quote 0
        • JipJ
          Jip
          last edited by

          The function is not available during blueprint loading or on the user layer. It is only available in the sim layer. See also:

          • User global functions: https://github.com/FAForever/fa/blob/deploy/fafdevelop/engine/User.lua
          • Sim global functions: https://github.com/FAForever/fa/blob/deploy/fafdevelop/engine/Sim.lua
          • Shared global functions: https://github.com/FAForever/fa/blob/deploy/fafdevelop/engine/Core.lua

          A work of art is never finished, merely abandoned

          1 Reply Last reply Reply Quote 0
          • R
            rigomate
            last edited by rigomate

            Hi Jip,

            Thanks a lot.

            So this would explain why for example the Phantom X mod has access to the ArmyBrains global variable, because it is not a UI mod?

            https://github.com/FAForever/faf-phantomx/blob/b088e4b40c808174ad9bee4ab787758349e0a8dd/lua/PhantomSim.lua#L178

            Because I guess if I UI mod would have access to ArmyBrains it could influence the game simulation.

            In the end what I am trying to do work out, is how to fix Hussars Scoreboard Kill notification.
            https://github.com/FA-mods/SupremeScoreBoard

            What broke the kill notification is basically this change in the FA Core.
            https://github.com/FAForever/fa/pull/4016

            Earlier the DoGameResult would receive also the score results, after the change it is only the defeat.

            So the Scoreboard UI mod does not know anymore who performed a kill, it only knows an ACU was defeated, hence it always shows that a ctrl+k happened.

            So I wondered how I could get access to the kills information. This is why I wanted to read out the Armybrains, because it seems this info could be extracted from there.

            Cheers!

            1 Reply Last reply Reply Quote 0
            • R
              rigomate
              last edited by

              Ok, I did some digging.
              Surely the ArmyBrains can only be accessed if I were to use a mod, which is not a ui_only mod.

              Hence my Idea: if a fellow streamer were to modify the fafreplay file saying to run it with a patched version of SupremeScoreBoard, which is patched to be a sim mod, and that has access to the armybrains.
              Then the replay would still be replayed just as it was played (not causing desyncs), because the armybrains is only read, and never modified. Right?

              This might be an ugly way to do it, but hey it should work, I guess.

              1 Reply Last reply Reply Quote 0
              • JipJ
                Jip
                last edited by

                The solution is to introduce a sync event that sends the information to the UI layer. We can look into that. Then in the UI layer you can interpret the event and create an announcement

                A work of art is never finished, merely abandoned

                R 1 Reply Last reply Reply Quote 1
                • R
                  rigomate @Jip
                  last edited by

                  @jip

                  Wow, that would be very cool.
                  I was wondering also about this solution, but was not sure I could recommend something that would introduce changes into the core of FAF.

                  I might even do it myself. The dev process is well documented.
                  I will come up with a pull request in the future then.

                  If I get stuck on the way I will seek help.

                  Cheers!

                  JipJ 1 Reply Last reply Reply Quote 0
                  • JipJ
                    Jip @rigomate
                    last edited by

                    @rigomate said in Access ArmyBrain in mod:

                    I was wondering also about this solution, but was not sure I could recommend something that would introduce changes into the core of FAF.

                    Everyone can make contributions 🙂

                    @rigomate said in Access ArmyBrain in mod:

                    I might even do it myself. The dev process is well documented.

                    I'm glad to read that, as we spent a lot of time to improve it in 2022.

                    @rigomate said in Access ArmyBrain in mod:

                    If I get stuck on the way I will seek help.

                    Find us on the official Discord server, the navigate to the suggestions channel:

                    7bc4c26f-1696-4307-9ddb-394648d51297-image.png

                    We're all there to help you with this and I'm looking forward to the pull request 🙂

                    A work of art is never finished, merely abandoned

                    R 1 Reply Last reply Reply Quote 1
                    • R
                      rigomate @Jip
                      last edited by

                      @jip
                      Ok, the pull request is there and ready.

                      https://github.com/FAForever/fa/pull/4789

                      Thanks for your help, this had been fun.
                      I never did even a single line of Lua before.

                      But I have to say, Lua is cool.

                      Cheers!

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