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

    Where's the best beginner how to mod tutorial?

    Scheduled Pinned Locked Moved Modding & Tools
    14 Posts 7 Posters 1.0k 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
      Rama @QuietJoy
      last edited by

      @quietjoy

      I started with no modding experience and only very minimal coding experience. Being a total noob, I found this (somewhat outdated) guide a very useful starting point.

      https://supcom.fandom.com/wiki/Unit_Creation.

      Next was having a list of all the Supreme Commander LUA functions. Since the list doesn't really explain how these functions work, I would then search the FA GitHub to see how others had implemented them (note: you need to create a free GitHub account to be able to search for code).

      List of SC Lua functions:
      https://supcom.fandom.com/wiki/LUADOC_1.5.3599

      FA GitHub:
      https://github.com/FAForever

      And another useful step that is really helpful is to download a mod that is similar to what you are wanting to do and study their code to see how it is set up. Like, if you want to add your own unit, download a mod that adds a single new unit and see how the folders are organized, etc.

      Then, when you try running your mod and nothing happens, pull up the FAF log of the game and search for "error". If there are errors in your mod, it will usually tell you the exact line and function to check.

      One more useful resource is the Unit Database, if you are working on units. You can quickly check the GitHub of the unit, which will bring you to the unit's blueprint file. From there, you can quickly access the unit's script. If you aren't sure how to get something working, just check how a current unit that has those abilities works and use that as a template.

      https://faforever.github.io/spooky-db/#/

      This is a useful guide explaining what does what in the blueprint file.

      https://wiki.faforever.com/en/Development/Modding/Blueprints

      1 Reply Last reply Reply Quote 0
      • FreadyFishF Offline
        FreadyFish @QuietJoy
        last edited by

        @quietjoy

        Like everyone else, I suggest looking into other mods. I have my whole mods folder set up as a git repo, so I can track my experiments and revert anything that isn't working. Try to make small changes, run the game locally and see if it works. Check the log for errors, you can bind it with a hotkey (Debug category --> "Toggles the debugging log window"). Use LOG() or WARN() functions if you want to print values/messages to the log window.

        In general, I think you are better off just asking a bunch of questions here than trying to find a complete guide. Searching for specific solutions beyond the most basic things is usually futile.

        When changing units you can loop through all units and make changes based on the unit blueprint, like this:

        yourmodfolder/hook/lua/system/Blueprints.lua

        do
            local oldModBlueprints = ModBlueprints
        
            function ModBlueprints(all_bps)
                -- Run the original code of this function, so we don't override it. 
                -- Common practice when extending/hooking existing FAF functions
                oldModBlueprints(all_bps)
        
                for id, bp in all_bps.Unit do
        
                    if bp.Economy.StorageEnergy then
                        bp.Economy.StorageEnergy = bp.Economy.StorageEnergy * 2
                    end
        
                    if table.find(bp.Categories, "AIR") and not table.find(bp.Categories, "FACTORY") then
                        if bp.Intel.VisionRadius then
                            bp.Intel.VisionRadius = bp.Intel.VisionRadius * 1.5
                        end   
                    end
        
                    -- ...ETC
                end
            end
        end
        

        Anything specific you're stuck with at the moment?

        What kind of UI mod do you have in mind?

        1 Reply Last reply Reply Quote 0
        • QuietJoyQ Offline
          QuietJoy
          last edited by

          How would i do a simple UI mod, for example making it so when I click on a radar the game does not play any sound?

          1 Reply Last reply Reply Quote 0
          • QuietJoyQ Offline
            QuietJoy
            last edited by

            Politely bumping this again as i would like to make some basic sounds mods. I find the noise of the T2 mobile arties and Torpedo bombers to be like a drill in my brain. Nothing wrong with the sound as such but it's the constant incessant repetition of them is just absolutely brutal. As soon as anyone on the map makes a T2 arty unit and sets it firing at an enmy tmd, that's it, you are now hearing that noise for the next 20 mins on a loop. Brutal.
            If I'm better asking somewhere else (Discord??) please let me know, thanks 🙂

            maudlin27M R FreadyFishF 3 Replies Last reply Reply Quote 0
            • maudlin27M Offline
              maudlin27 @QuietJoy
              last edited by maudlin27

              @quietjoy said in Where's the best beginner how to mod tutorial?:

              If I'm better asking somewhere else (Discord??) please let me know, thanks 🙂

              You're (probably) better off asking elsewhere (Discord) - try the modding channel:
              https://discord.com/channels/197033481883222026/832710161847287819

              M27AI and M28AI developer; Devlogs and more general AI development guide:
              https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
              https://forum.faforever.com/topic/5331/m28ai-devlog-v130

              1 Reply Last reply Reply Quote 1
              • R Offline
                Resin_Smoker @QuietJoy
                last edited by Resin_Smoker

                @quietjoy Unit specific sounds maybe hard to modify as just a UI based mod. Specifically your looking at a UI mod that has interaction with the SIM side of the game. While it's not impossible, it isn't going to be easy.

                Question: Are you referring to their attack sounds or their on selection sounds? If it's the latter, this shouldn't be too much to mod, as you'd be telling the UI to ignore a specific set of units sound events during mouse-over or on-click. Unfortunately, most of my experience has been with SIM side mods otherwise I'd try building this for you.

                Kykhu Oss https://youtu.be/JUgyGTgeZb8
                Unit Thrower https://youtu.be/iV8YBXVxxeI
                Beam Tentacle https://youtu.be/le5SNwHvC4c
                Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                1 Reply Last reply Reply Quote 1
                • FreadyFishF Offline
                  FreadyFish @QuietJoy
                  last edited by FreadyFish

                  @quietjoy Missed your messages, feel free to @ me next time. Here is a working example SelectionSounds.zip

                  mods/SelectionSounds/hook/lua/ui/game/selection.lua

                  function PlaySelectionSound(newSelection)
                      if playSelectionSound then
                          for k, unit in newSelection do
                              local bp = unit:GetBlueprint()
                  
                              if EntityCategoryContains(categories.TECH1 * categories.STRUCTURE * categories.RADAR, unit) then
                                  return
                              end
                  
                              if bp.Audio.UISelection then
                                  PlaySound(bp.Audio.UISelection)
                                  return
                              end
                          end
                      end
                  end
                  

                  Check the FAF files in the fa/lua/ui folder, to see what you can "hook", thats how you override the base files. Often you want to store the original function and run it after your code, but in this case it's not useful. Will not be compatible with other mods that hooks this function though.

                  https://github.com/FAForever/fa/blob/b3e14934761f3a8da7adbd845bcf2d52aeefb9e9/lua/ui/game/selection.lua

                  Check fa/units to see what categories you want to target, or you could target specific unit IDs.

                  Actually, I decided to update the code to be more useful for your needs:

                  local disableSoundsForUnitIDs = {
                      "url0001", -- Cybran commander
                      "url0105" -- Cybran engineer
                  }
                  
                  local disableSoundsForUnitCategories = {
                      categories.STRUCTURE * categories.RADAR,
                      categories.BOMBER * categories.ANTINAVY,
                  
                      -- Add mobile artillery as an exercise, you can find suitable categories to target in the unit file :)
                  }
                  
                  function PlaySelectionSound(newSelection)
                      if playSelectionSound then
                          for k, unit in newSelection do
                              local bp = unit:GetBlueprint()
                  
                              -- LOG(unit:GetUnitId()) -- Uncomment to print unit id in log when selecting them
                  
                              local unitID = unit:GetUnitId()
                  
                              if contains(disableSoundsForUnitIDs, unitID) then
                                  return
                              end
                  
                              for k, v in disableSoundsForUnitCategories do
                                  if EntityCategoryContains(v, unit) then
                                      return
                                  end
                              end
                  
                              if bp.Audio.UISelection then
                                  PlaySound(bp.Audio.UISelection)
                                  return
                              end
                          end
                      end
                  end
                  
                  function contains(table, val)
                      for i, v in ipairs(table) do
                          if v == val then
                              return true
                          end
                      end
                      return false
                  end
                  
                  
                  R 1 Reply Last reply Reply Quote 0
                  • R Offline
                    Resin_Smoker
                    last edited by Resin_Smoker

                    I picked up modding by simply following the examples left by the game dev's. Going into the Lua, projectile, moho and Unit folders can be enlightening and intimidating all at the same time. One of the strongest tools here is your zip file compiler, as they often have search capabilities for files and keywords within files. Makes looking for example material a snap.

                    Note: Don't mod the original files, ever! Strongly suggest making them read-only when you intend to browse.

                    Kykhu Oss https://youtu.be/JUgyGTgeZb8
                    Unit Thrower https://youtu.be/iV8YBXVxxeI
                    Beam Tentacle https://youtu.be/le5SNwHvC4c
                    Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                    Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                    1 Reply Last reply Reply Quote 1
                    • R Offline
                      Resin_Smoker @FreadyFish
                      last edited by

                      @freadyfish would be cool if the selection sounds for units could be toggled by the UI. Essentially using a options toggle to active a table of units provided by the player.

                      Kykhu Oss https://youtu.be/JUgyGTgeZb8
                      Unit Thrower https://youtu.be/iV8YBXVxxeI
                      Beam Tentacle https://youtu.be/le5SNwHvC4c
                      Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                      Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                      FreadyFishF 1 Reply Last reply Reply Quote 0
                      • FreadyFishF Offline
                        FreadyFish @Resin_Smoker
                        last edited by

                        @resin_smoker

                        Indeed!

                        If anyone wants to collaborate: https://github.com/FreadyFishFAF/SelectionSounds

                        It is not at the top of my priority to add the UI but if you or someone wants to work on it I'll be there to help!

                        I uploaded it to the mod vault. By default it will disable all selection sounds if not configured otherwise.

                        R 1 Reply Last reply Reply Quote 0
                        • R Offline
                          Resin_Smoker @FreadyFish
                          last edited by Resin_Smoker

                          @freadyfish for now your fine with an override mod, but I'd suggest moving towards a UI based method at some point. Simple reason, its more likely to be widely adopted, and thus less like to viewed as SIM cheater mod.

                          As for helping out, hit me or any of the other mod-dev's up if you get mega stuck.

                          Kykhu Oss https://youtu.be/JUgyGTgeZb8
                          Unit Thrower https://youtu.be/iV8YBXVxxeI
                          Beam Tentacle https://youtu.be/le5SNwHvC4c
                          Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                          Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

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