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

    Looking For help with mod

    Scheduled Pinned Locked Moved Modding & Tools
    9 Posts 3 Posters 754 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.
    • CaliberC
      Caliber
      last edited by

      I am trying to create a noob freindly eco mod however my understanding of script is very limited.

      I am trying to reduce the mass cost of units based on their tech level but i dont now how to right that in script, could somebody show me how this is done, bellow is a simple mod i copied from another.Untitled.jpg

      I need that effect applied to tech levels at different scales, thankyou.

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

        @Zukko

        local OldModBlueprintsFunction = ModBlueprints
        function ModBlueprints(all_blueprints)
            OldModBlueprintsFunction(all_blueprints)
            -- loop over all blueprints
            for id,bp in all_blueprints.Unit do
                -- get the tech level / mass scale for this unit
                local CostMassScale = 0
                if bp.CategoriesHash.TECH1 then
                    CostMassScale = 0.4
                elseif bp.CategoriesHash.TECH2 then
                    CostMassScale = 0.6
                elseif bp.CategoriesHash.TECH3 then
                    CostMassScale = 0.8
                elseif bp.CategoriesHash.EXPERIMENTAL then
                    CostMassScale = 1.0
                end
                -- check if we have an Economy table with BuildCostMass
                if bp.Economy.BuildCostMass then
                    LOG("Changing BuildCostMass for unit ["..id.."] from "..(bp.Economy.BuildCostMass).." to "..(bp.Economy.BuildCostMass * CostMassScale).."")
                    bp.Economy.BuildCostMass = bp.Economy.BuildCostMass * CostMassScale
                end
                -- check if we have an Enhancements table
                if bp.Enhancements then
                    -- loop over all table entries and check for mass cost
                    for index, enhancement in bp.Enhancements do
                        -- doe the enhancment has BuildCostMass ?
                        if enhancement.BuildCostMass then 
                            LOG("Changing BuildCostMass for enhancement on unit ["..id.."] from "..(enhancement.BuildCostMass).." to "..(bp.Enhancements[index].BuildCostMass * CostMassScale).."")
                            bp.Enhancements[index].BuildCostMass = bp.Enhancements[index].BuildCostMass * CostMassScale
                        end
                    end
                end
            end
        end
        
        1 Reply Last reply Reply Quote 2
        • CaliberC
          Caliber
          last edited by

          @Uveso

          Thank you very much, that works perfectly!

          There is one more thing i need help on to finish the mod if you have time?

          The aim of the mod is to make things easier for new players by reducing apm aswell as reduce the advantages that a higher rated player will have against newer players, one of these ideas is to remove reclaim.

          I thought about removing the ability for engineers and commanders but this would prove highly impractal for placing buildings ontop of trees etc, so the only way i can imagine achieving this would be to remove the economy gained from reclaiming.

          Do you now how or even if this ispossible, thanks again.

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

            Create a new text file and name it 'Prop.lua'

            Copy the file to your mod into:
            \Mods\YOURMOD\hook\lua\sim\

            now edit the file
            (\Mods\YOURMOD\hook\lua\sim\Prop.lua)

            copy this into the prop.lua file:

            -- Saving the Prop class, so we can hook it
            local oldProp=Prop
            -- create a new Prop class based on the original oldProp class
            Prop = Class(oldProp) {
                -- overwrite the original GetReclaimCosts function with our own:
                GetReclaimCosts = function(self, reclaimer)
                    -- Set reclaim parameter
                    local ReclaimTime = 1 -- Don't set it to 0 or we will devide by 0 later
                    local MassReclaim = 0
                    local EnergyReclaim = 0
                    -- return the new raclaim values
                    return ReclaimTime, EnergyReclaim, MassReclaim
                end,
            }
            

            This will set the reclaim time to 1 tick and reclaim cost/gain to 0

            1 Reply Last reply Reply Quote 1
            • CaliberC
              Caliber
              last edited by

              @Uveso

              Thats brilliant thankyou, your help is most appreciated

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

                You are welcome!

                1 Reply Last reply Reply Quote 0
                • CaliberC
                  Caliber
                  last edited by

                  @uveso

                  After a few days of trying to balance this mod i have thought of a much better idea for a noob friendly hands off ecocomy mod
                  than before.

                  Is it possible to make all mass extractors increase their production once built increase by 1 mass ps every minute with a max cap of 30 mass production per second ?

                  So that after a 28 minute game a tech 1 extractor would reach 30 mass per second

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

                    All of that is possible - yes. It is best to join the #modding-general channel on the official discord and ask for help there. That way more people can assist you than just Uveso 🙂

                    A work of art is never finished, merely abandoned

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

                      @Zukko
                      like Jip already stated, almost everything is possible. Just a matter of time to code it.

                      So yes you can increase the mass output like you descibed.

                      Its also possible to lower or increase the buildcost of all stuff and also change the build time.
                      Like the cheat option for the AI you could make a handicap function for one or all players.

                      But this will need deep knowledge about the game function to mod this.
                      So join us in the discord that jip already posted.

                      @Jip
                      As always, thank you for you help 😄

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