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

[MOD] PJ Infrastructure Pack for play with AIx

Scheduled Pinned Locked Moved Modding & Tools
44 Posts 8 Posters 4.5k 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.
  • F
    foxy_pj
    last edited by foxy_pj 5 Dec 2024, 17:15 30 May 2021, 18:59

    Hi.
    After many months of modding and testing, a public release date arrived.

    Mod description:
    AI Upgradeable T2 & T3 E/M-Storage, T2+ & T3+ PGens, T2 & T3 & Exp HC Plant, T3+ MEX & T4 Shields
    This means that all players will get more resources including AI. Base siege will be more difficult and each resource building will be more valuable but more protected.
    I recommend playing against AIx with the BlackOps mod (fully compatible).

    Mod details:
    All below is AI upgrageble.
    T2 Power Gen is upgradable to T2+ shielded Power Gen with x2 output.
    T3 Power Gen is upgradable to T3+ shielded Power Gen with x2 output.
    T1 Energy storage is upgradable to T2 and then to T3 (properly balanced).
    T1 Mass storage is upgradable to T2 and then to T3 (properly balanced).
    T1 HC plant upgradable to T2 shielded then to T3 shielded and then to Exp shielded.
    T3 MEX is upgradable to T3+ shielded with a bit bigger output (properly balanced).
    T3 shields are upgradable to Exp shields with unique features for each nation.

    Download: [https://drive.google.com/file/d/1mtzdZg29W_h4vsOMUv3ZNlaSeJle4vYX/view?usp=sharing](link url)

    Please note, that all units are based on original game assets.

    Big thank you to Uveso and the whole modding community

    Kind regards
    PJ

    1 Reply Last reply Reply Quote 0
    • S
      speed2
      last edited by 30 May 2021, 19:12

      UserData will most probably be nonexistant category
      Looking in the xshields.lua file, its mentioning categories.VILLAGESHIELD
      I havent found this category in any of your units and its surely not a category from the base game units.

      F 1 Reply Last reply 30 May 2021, 20:28 Reply Quote 0
      • F
        foxy_pj
        last edited by foxy_pj 30 May 2021, 19:51

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • F
          foxy_pj @speed2
          last edited by foxy_pj 30 May 2021, 20:28

          @speed2 said in Need help with Ai to upgrade buildings.:

          UserData will most probably be nonexistant category
          Looking in the xshields.lua file, its mentioning categories.VILLAGESHIELD
          I havent found this category in any of your units and its surely not a category from the base game units.

          Thank you for your reply and pointing to an error. Categories.VILLAGESHIELD should be defined in shield unit.bp.
          Also I'm not getting any more 2nd error message about Injecting BuilderGroups.
          This has been ixed.
          Do you have any idea why AI doesn't upgrade buildings from this mod?
          Going to test mod now.

          1 Reply Last reply Reply Quote 0
          • U
            Uveso
            last edited by 30 May 2021, 23:27

            categories.VILLAGESHIELD is a category from the Nuclear Repulsor Shields mod
            https://forum.faforever.com/topic/357/nuclear-repulsor-shields-v21-for-all-game-versions

            The AI is not upgrading the Shields because i did not added a upgrade platoonformer to the mod.
            There are also no upgrade templates defined that are needed for an upgrade.

            Btw, i am really sure i never granted any permission to use Black Ops or Total Mayhem Units for other mods.
            So could you please delete the link here. (It's no longer private when you post it here)

            1 Reply Last reply Reply Quote 0
            • F
              foxy_pj
              last edited by foxy_pj 31 May 2021, 00:24

              Hi Uveso.
              Mod link has been removed (it has been posted for debuging purpose). Please note, i didn't directly take any units from Black Ops or Nuclear Repulsor Shields. These units has been taken from other mods available for download from FAF. That's why i was confused about categories.VILLAGESHIELD, and where it came from. How ever i can see AI upgrade function has been taken as example from Black Ops but doesn't work.
              Would you be able to help me please on how to make AI to upgrade storages (T1->T2->T3), extractors(T3->T3 shielded), power generator (T2-T2 adv, T3-T3 adv), HC (T3->Exp). All files are set. From what i can see it should work but it doesn't, AI connstructing new buildings but never upgrading them. Looks like i've missed something.

              1 Reply Last reply Reply Quote 0
              • U
                Uveso
                last edited by Uveso 31 May 2021, 09:05

                Well, adding a upgrade builder to a mod needs some work.

                I will use Black Ops unleashed Hydrocarbon Power Plant as example.

                First you need the PlatoonFormbuilder for upgrading the Hydro:
                https://github.com/Uveso/BlackOpsFAF-Unleashed/blob/master/lua/AI/AIBuilders/HydroCarbonUpgrade.lua

                local UCBC = '/lua/editor/UnitCountBuildConditions.lua'
                local EBC = '/lua/editor/EconomyBuildConditions.lua'
                
                BuilderGroup {
                    BuilderGroupName = 'BO-HydroCarbonUpgrade',
                    BuildersType = 'PlatoonFormBuilder',
                    Builder {
                        BuilderName = 'BO1 HydroUpgrade',
                        PlatoonTemplate = 'T1PowerHydroUpgrade',
                        Priority = 200,
                        BuilderConditions = {
                            { UCBC, 'HaveGreaterThanUnitsWithCategory', { 0, categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH1 } },
                            { UCBC, 'HaveLessThanUnitsInCategoryBeingBuilt', { 1, categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH2 } },
                            { EBC, 'GreaterThanEconIncome', { 2, 10 } },
                            { EBC, 'GreaterThanEconTrend', { 0.0, 0.0 } },
                        },
                        FormRadius = 10000,
                        BuilderType = 'Any',
                    },
                    Builder {
                        BuilderName = 'BO2 HydroUpgrade',
                        PlatoonTemplate = 'T2PowerHydroUpgrade',
                        Priority = 200,
                        BuilderConditions = {
                            { UCBC, 'HaveLessThanUnitsWithCategory', { 1, categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH1 } },
                            { UCBC, 'HaveGreaterThanUnitsWithCategory', { 0, categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH2 } },
                            { UCBC, 'HaveLessThanUnitsInCategoryBeingBuilt', { 1, categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH3 } },
                            { EBC, 'GreaterThanEconIncome', { 2.6, 60 } },
                            { EBC, 'GreaterThanEconTrend', { 0.0, 0.0 } },
                        },
                        FormRadius = 10000,
                        BuilderType = 'Any',
                    },
                }
                

                These are the builders with buildconditions and PlatoonTemplate names

                To inject the Buildergroup to the actual running AI you need a hook inside simInit.lua
                https://github.com/Uveso/BlackOpsFAF-Unleashed/blob/master/hook/lua/simInit.lua

                local OLDSetupSession = SetupSession
                function SetupSession()
                    OLDSetupSession()
                    import('/mods/BlackOpsFAF-Unleashed/lua/AI/AIBuilders/HydroCarbonUpgrade.lua')
                end
                

                This hook will load all BuilderGroups located in the file HydroCarbonUpgrade.lua

                Now we need to add the builders to every AI base and new opened expansion.
                To do so we need a hook inside AIAddBuilderTable.lua:
                https://github.com/Uveso/BlackOpsFAF-Unleashed/blob/master/hook/lua/AI/AIAddBuilderTable.lua

                local OLDAddGlobalBaseTemplate = AddGlobalBaseTemplate
                function AddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
                    SPEW('BlackOpsFAF-Unleashed: Injecting BuilderGroup "BO-HydroCarbonUpgrade"')
                    AddGlobalBuilderGroup(aiBrain, locationType, 'BO-HydroCarbonUpgrade')
                    OLDAddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
                end
                

                Now every base/expansion can call the upgradebuilder.

                To make the upgrade work we need an upgradetemplate.
                The upgradebuilder is using the PlatoonTemplate T1PowerHydroUpgrade
                So we need to create a PlatoonTemplate with the UnitUpgradeAI plan and a GlobalSquad named T1PowerHydroUpgrade:
                https://github.com/Uveso/BlackOpsFAF-Unleashed/blob/master/hook/lua/upgradetemplates.lua

                PlatoonTemplate {
                    Name = 'T1PowerHydroUpgrade',
                    Plan = 'UnitUpgradeAI',
                    GlobalSquads = {
                        {categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH1, 1, 1, 'support', 'None'},
                    }
                }
                PlatoonTemplate {
                    Name = 'T2PowerHydroUpgrade',
                    Plan = 'UnitUpgradeAI',
                    GlobalSquads = {
                        {categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH2, 1, 1, 'support', 'None'},
                    }
                }
                

                Finally we need the StructureUpgradeTemplates with unitIds so the AI knows how to upgrade to the right unit:

                -- earth structure upgrades
                table.insert(StructureUpgradeTemplates[1], {'ueb1102', 'beb1202'}) -- Hydrocarbon Power Plant. Upgrade from TECH1 to TECH2
                table.insert(StructureUpgradeTemplates[1], {'beb1202', 'beb1302'}) -- Hydrocarbon Power Plant. Upgrade from TECH2 to TECH3
                -- alien structure upgrades
                table.insert(StructureUpgradeTemplates[2], {'uab1102', 'bab1202'}) -- Hydrocarbon Power Plant. Upgrade from TECH1 to TECH2
                table.insert(StructureUpgradeTemplates[2], {'bab1202', 'bab1302'}) -- Hydrocarbon Power Plant. Upgrade from TECH2 to TECH3
                -- recycler structure upgrades
                table.insert(StructureUpgradeTemplates[3], {'urb1102', 'brb1202'}) -- Hydrocarbon Power Plant. Upgrade from TECH1 to TECH2
                table.insert(StructureUpgradeTemplates[3], {'brb1202', 'brb1302'}) -- Hydrocarbon Power Plant. Upgrade from TECH2 to TECH3
                -- seraphim structure upgrades
                table.insert(StructureUpgradeTemplates[4], {'xsb1102', 'bsb1202'}) -- Hydrocarbon Power Plant. Upgrade from TECH1 to TECH2
                table.insert(StructureUpgradeTemplates[4], {'bsb1202', 'bsb1302'}) -- Hydrocarbon Power Plant. Upgrade from TECH2 to TECH3
                

                Happy coding šŸ™‚

                F 1 Reply Last reply 31 May 2021, 10:40 Reply Quote 0
                • F
                  foxy_pj @Uveso
                  last edited by 31 May 2021, 10:40

                  @uveso
                  Hi Uveso.
                  Thank you for your reply. This all has been alredy done as i've followed your guide: https://forums.faforever.com/viewtopic.php?f=41&t=19591
                  And looked myself at Black Ops mod (That's why I've mentioned it in first post)
                  I think i know what is the issue. In file /hook/lua/AI/AIAddBuilderTable.lua i don't know how to define multiple Templates or Builder Groups in one file? I have these:

                  local OLDAddGlobalBaseTemplate = AddGlobalBaseTemplate
                  function AddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
                      SPEW('Pj_Infrastructure_Pack: Injecting BuilderGroups')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'XShields')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'Upgrade-HC')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'Upgrade-EXMEX')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'Upgrade-Storage-M')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'Upgrade-Storage-E')
                      AddGlobalBuilderGroup(aiBrain, locationType, 'Upgrade-PGen')
                      OLDAddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
                  end
                  

                  Could you help me please?

                  1 Reply Last reply Reply Quote 0
                  • U
                    Uveso
                    last edited by 31 May 2021, 17:38

                    I did only a quick overview.

                    First you need to delete the category VILLAGESHIELD from the file AIAddBuilderTable.lua
                    (Delete every * categories.VILLAGESHIELD)
                    This will resolve the error attempt to get as UserData a nil value

                    Adding several buildergrpups from the same file is no problem.
                    But you should rename the local save variable for your hook.

                    local OLDAddGlobalBaseTemplate = AddGlobalBaseTemplate
                    Change it to a unique name like
                    local InfrastructureAddGlobalBaseTemplate = AddGlobalBaseTemplate
                    Havig the same hook name in different mods can lead to deadloops (game freeze)
                    or simply overwriting a hook from another mod.

                    1 Reply Last reply Reply Quote 0
                    • U
                      Uveso
                      last edited by Uveso 31 May 2021, 17:51

                      Upgrade for pgens is wrong:

                      PlatoonTemplate {
                          Name = 'Upgrade-PGen-T2',
                          Plan = 'UnitUpgradeAI',
                          GlobalSquads = {
                              {categories.ENERGYPRODUCTION * categories.TECH2 * categories.ECONOMIC, 1, 1, 'support', 'None'},
                          }
                      }
                      

                      Unit UEpowerup_unit has category ENERGYPRODUCTION * TECH2 * ECONOMIC but can't be upgraded.
                      This template should only catch normal powergens, not the upgraded ones.
                      (same to all other PlatoonTemplates)

                      F 1 Reply Last reply 31 May 2021, 18:33 Reply Quote 0
                      • F
                        foxy_pj @Uveso
                        last edited by foxy_pj 31 May 2021, 18:33

                        @uveso

                        Thank you, I've corrected errors.

                        Could you please explain what I did wrong in Platoon template?
                        UEpowerup_unit is an upgraded version of UEB1201_unit
                        UEB1201_unit has category ENERGYPRODUCTION * TECH2 * ECONOMIC and upgradable via hook:

                        UnitBlueprint {
                            Merge = true,
                        	BlueprintId = "ueb1201",
                        	
                            Display = {
                                Abilities = {
                                    '<LOC ability_upgradable>Upgradeable',
                                },
                            },
                            Economy = {
                                BuildRate = 12,
                                BuildableCategory = {
                                    'uepowerup',
                                },
                                RebuildBonusIds = {
                                    "ueb1201",
                                    'uepowerup',
                                },
                            },
                            General = {
                        		UpgradesTo = 'uepowerup',
                                CommandCaps = {
                                    RULEUCC_Pause = true,
                                },
                            },
                        }
                        
                        1 Reply Last reply Reply Quote 0
                        • UvesoU
                          Uveso
                          last edited by 31 May 2021, 20:07

                          yes unit UEB1201 has categories ENERGYPRODUCTION * TECH2 * ECONOMIC
                          But unit UEpowerup has also categories ENERGYPRODUCTION * TECH2 * ECONOMIC

                          Now if you use the PlatoonTemplate and search for untis with the categories ENERGYPRODUCTION * TECH2 * ECONOMIC
                          what unit will you get ? - UEB1201 and UEpowerup.
                          You need to get sure that you only get UEB1201 with this PlatoonTemplate.

                          You can do this by adding a category like 'UPGRADED' to the unit UEpowerup.
                          Now if you want to get the UEB1201 unit, search for
                          ENERGYPRODUCTION * TECH2 * ECONOMIC - UPGRADED

                          {categories.ENERGYPRODUCTION * categories.TECH2 * categories.ECONOMIC - categories.UPGRADED, 1, 1, 'support', 'None'},
                          
                          F 1 Reply Last reply 1 Jun 2021, 10:13 Reply Quote 0
                          • Dragun101D
                            Dragun101
                            last edited by 31 May 2021, 21:21

                            If you are curious for a mod that handles upgrading. My own mod has added upgrading units for TA factions. Might be of interest of tou see the other work you need to do/add.

                            I’m a shitty 1k Global. Any balance or gameplay suggestions should be understood or taken as such.

                            Project Head and current Owner/Manager of SCTA Project

                            1 Reply Last reply Reply Quote 0
                            • F
                              foxy_pj
                              last edited by foxy_pj 6 Jan 2021, 11:08 1 Jun 2021, 00:04

                              @Dragun101
                              Thank you Dragun101. Will check your mod. Would you be ble to point to files of interest for me?

                              1 Reply Last reply Reply Quote 0
                              • F
                                foxy_pj @Uveso
                                last edited by foxy_pj 6 Jan 2021, 12:35 1 Jun 2021, 10:13

                                @uveso
                                Thank you Uveso. I've implemented these changes for T2 and T3 Power Generators and T3 Shielded Extractors. How ever issue you've mentioned shouldn't affect HC T3 to Experimental upgrade (categories.HYDROCARBON * categories.ENERGYPRODUCTION * categories.TECH3) and all storages upgrades(categories.MASSSTORAGE * categories.TECH1 * categories.ECONOMIC) and (categories.MASSSTORAGE * categories.TECH2 * categories.ECONOMIC).
                                Or i'm again missing something?
                                Also i can see this in game log, this is upgrade HCT3 to HCExperimental:

                                warning: [platoon.lua, line:2494] *UnitUpgradeAI ERROR: "brb1302":CanBuild( BRMBT1PERI ) failed!
                                

                                Is it anything else wrong what you could spot?
                                From what you've seen, is it ok to list link for corrected version of this mod at this page for troubleshooting?

                                1 Reply Last reply Reply Quote 0
                                • UvesoU
                                  Uveso
                                  last edited by 1 Jun 2021, 20:31

                                  If you upload your mod, then please delete all files with '.dds' and '.scm'

                                  This way no one can use it and i can merge the scripts into my version.

                                  While walking through the scripts i saw you have some upper/lower case mismatch in unit IDs
                                  As example please change all BRMBT1PERI to brmbt1peri
                                  Upper case names don't work.

                                  I used my own formbuilders in my AI, but lowercase IDs like brmbt1peri are working with the upgrade function.
                                  Upper case are not working.

                                  F 1 Reply Last reply 1 Jun 2021, 22:09 Reply Quote 0
                                  • F
                                    foxy_pj @Uveso
                                    last edited by 1 Jun 2021, 22:09

                                    @uveso
                                    Thanks will correct names and remove required files, then upload mod.

                                    1 Reply Last reply Reply Quote 0
                                    • UvesoU
                                      Uveso
                                      last edited by Uveso 6 Jan 2021, 22:43 1 Jun 2021, 22:41

                                      Test it before you upload it. Maybe you don't need to.

                                      Changing the names will do the trick.
                                      As i said i only changed the names and it was working.

                                      But i did not used your Platoonformer.
                                      It has a strange buildcondition:

                                      			{ EBC, 'GreaterThanEconIncome', { 100.0, 4000.0 } },
                                      

                                      its waiting for an base income of 1000 mass and 40000 energy (values are * 10)
                                      (Thats why we write 100.0 to have in mind its 1000)

                                      F 1 Reply Last reply 2 Jun 2021, 16:59 Reply Quote 0
                                      • F
                                        foxy_pj @Uveso
                                        last edited by foxy_pj 2 Jun 2021, 16:59

                                        @uveso
                                        Hi Uveso.
                                        Changes has been done followed by your guide. Done some testing and can see that AI upgrading HC T1->T2->t3->Exp, Power Generator T2->T2+ and T3->T3+, Shields T3->Exp, storages T1->T2->T3.
                                        But on 70min game AI doesn't have any T3+ extractors šŸ˜ž

                                        Platoonformer (buildconditions) has been reviewed too.

                                        Would you be able to check if everything is ok with Extractors upgrade please?
                                        Thank you.

                                        1 Reply Last reply Reply Quote 0
                                        • UvesoU
                                          Uveso
                                          last edited by 2 Jun 2021, 19:48

                                          Extractor upgrade from 1 to 2, 2 to 3 and 4 to experimental are all working.

                                          Maybe you should decrease the eco requirement of the Builder ?

                                          BuilderName = 'EXMEX-Upgrade',
                                          { EBC, 'GreaterThanEconIncome', { 10.0, 500.0 } },
                                          

                                          It's waiting for 100 massincome and 5000 energy. Maybe you should use something like { 10.0, 100.0 }

                                          Also found this warning:

                                          WARNING: *AIExecuteBuildStructure: TECH1 Unit "euebest3" is assigned to build TECH3 buildplatoon! ("EnergyStorage")
                                          

                                          Please check in CustomUnits.lua:

                                          UnitList = {
                                              EnergyStorage = {
                                                  UEF = {'euebest3', 50},
                                              },
                                          },
                                          

                                          EnergyStorage is a Tech1 building and will be assinged to a Tech 1 engineer.
                                          It can't build a tech3 unit euebest3.

                                          There are several other custom entries that have the same problem.

                                          1 Reply Last reply Reply Quote 0
                                          3 out of 44
                                          • First post
                                            3/44
                                            Last post