BrewLAN is a mod for Supreme Commander: Forged Alliance that has been in on and off development by a team of one for almost a decade. It adds a wide variety of new units for all factions, as well as offering several new game modes and features. The core design goals for the mod are simple; to add new, interesting, and visually aesthetic units which complement those already in existence and to maximise technical compatibility with other mods.

Forum Thread
  Posts  
EXP Factory Bug or Intended Feature? (Games : Supreme Commander: Forged Alliance : Mods : BrewLAN : Forum : Bugs & requests : EXP Factory Bug or Intended Feature?) Locked
Thread Options
Jun 16 2019 Anchor

I've encountered a behavior with the experimental factories and I'm not sure if it is a bug or if its designed to work this way.

My friend and I enjoy the longer "slug fest" style game from time to time so we occasionally disable air units to make the game last longer. I recently started making a custom mod which would disable all air units except for scouts and transports. This works fine for normal air factories and direct build units (Soul Ripper, CZAR, etc). The issue that I am running into is that the BrewLAN experimental factories (AEON & UEF) can still build the flying experimentals despite my mod disabling them.

In a human vs. human game, this wouldn't be a problem since we could just say "OK, don't build those...". Since we play against AI opponents, it becomes an issue since they will still build the flying EXPs (from the factories), but we can't build anything to counter them. Is this how the factories are designed to operate or is this a bug where they should be honoring the build restrictions?

After looking through the various code files for the factories I think this would be a part of the BuildModeChange and/or the ChooseExperimental functions.

Thanks,

RoboticSith


BrewLAN: V0.79

Blueprints file from my mod below:

(I took several key parts from the "Build_Restrictions_Modpack" by MagicPower and changed them to my needs)

--base logic copied from the "Build Restriction Mod Pack"
do
  --local UnitDisabled = false
  
  local function DisableUnitBuild(unit)
    -- Array contains all buildable categories
    local builders = { ["BUILTBYCOMMANDER"]      = 1, ["BUILTBYTIER1ENGINEER"] = 1, ["BUILTBYTIER1FACTORY"] = 1,
                       ["BUILTBYTIER2COMMANDER"] = 1, ["BUILTBYTIER2ENGINEER"] = 1, ["BUILTBYTIER2FACTORY"] = 1,
                       ["BUILTBYTIER3COMMANDER"] = 1, ["BUILTBYTIER3ENGINEER"] = 1, ["BUILTBYTIER3FACTORY"] = 1,
                       ["BUILTBYEXPERIMENTALSUB"] = 1, ["BUILTBYQUANTUMGATE"] = 1, ["TRANSPORTBUILTBYTIER1FACTORY"] = 1,
                       ["TRANSPORTBUILTBYTIER2FACTORY"] = 1, ["TRANSPORTBUILTBYTIER3FACTORY"] = 1, }
  
    local i = 1
    while unit.Categories[i]do
      -- The array 'builders' is used to search for buildable categories
      if builders[unit.Categories[i]] then
        table.remove(unit.Categories,i)
      else
        i = i + 1
      end
    end
  end --end DisableUnitBuild
  
  --Looks for a keyword in an array and returns ture if found
  local function FoundInArray(list,keyword)
    local i = 1
    while list[i]do
      if (list[i]== keyword) then
        return true
      end --end if
      i = i + 1
    end --end while
    return false
  end --end FoundInArray
  
  --modifies the build categories of units so they can or cannot be built
  local oldModBlueprints = ModBlueprints
  function ModBlueprints(all_bps)
    --status vars
    local isAIRUnit = false
    local isGroundFactory = false
    local isPureTransport = false
    local isSpyPlane = false
    local UnitDisabled = false
    oldModBlueprints(all_bps)
    --local oldModBlueprints = nil
    for id,bp in all_bps.Unit do
      --reset control vars
      isAIRUnit = false
      isGroundFactory = false
      isPureTransport = false
      isSpyPlane = false
      UnitDisabled = false
      
      --check if its an air unit
      if FoundInArray(bp.Categories,"AIR") then
        --AIR unit found...Disable UNLESS any of the following are TRUE...
        isAIRUnit = true
        --Factory?
        if FoundInArray(bp.Categories,"FACTORY") then
          --Unit is a factory
          --Structure?
          if FoundInArray(bp.Categories,"STRUCTURE") then
            --Ground Factory Detected -> DO NOT DISABLE
            isGroundFactory = true
          end --end Structure Check
        end --end Factory Check
        
        --Transport?
        if FoundInArray(bp.Categories,"TRANSPORTATION") then
          --Unit is a Transport
          --special logic to cover UEF T1 & T2 gunships
          if FoundInArray(bp.Categories,"GROUNDATTACK") then
            --Unit is NOT a pure transport -> DISABLE
            isPureTransport = false
          else
            --Unit is a pure transport -> DO NOT DISABLE
            isPureTransport = true
          end --end GROUNDATTACK
        end --end Transport Check
        
        --Spy Plane
        if FoundInArray(bp.Categories,"INTELLIGENCE") then
          --Unit is a spy plane -> DO NOT DISABLE
          isSpyPlane = true
        else
          --Unit is NOT a spy plane -> DISABLE
          isSpyPlane = false
        end --end INTELLIGENCE check 
      end --end AIR Check
      
      --Disable the unit UNLESS the control flags indicate otherwise
      if isAIRUnit == true and
         isGroundFactory == false and
         isPureTransport == false and
         isSpyPlane == false 
      then
         DisableUnitBuild(bp)
         UnitDisabled = true
      end
      
      
      --secondary logic for torpedo bombers since they get missed by the above logic (can't figure out why)
      --only runs this logic if the general logic above failed to disable the unit
      if UnitDisabled == false then
        if FoundInArray(bp.Categories,"AIR") then
          if FoundInArray(bp.Categories,"ANTINAVY") then
            --Disable torpedo bombers
            DisableUnitBuild(bp)
            UnitDisabled = true
          end --end ANTINAVY
        end --end redundant AIR check
      end --end secondary logic

      --tertiary logic for flying experimentals.
      --above logic prevents direct building, but BrewLAN super factories ignore this...
      --ALWAYS run this logic
      if FoundInArray(bp.Categories,"AIR") then
        if FoundInArray(bp.Categories,"EXPERIMENTAL") then
          --Disable flying EXPs
          DisableUnitBuild(bp)
        end --end EXPERIMENTAL
      end --end redundant AIR check
      
    end --end main for
  end --end ModBlueprints
end --end main do
Jun 17 2019 Anchor

You're not actually restricting units with that script, you're removing build categories and you're not removing the Gantry build categories. I'm fairly sure you would also be able to build those units from those factories, well from the Aeon and UEF ones anyway.

Edited by: Balthassar

Jun 22 2019 Anchor

Thanks for the feedback. I completely missed that the Gantries had their own build categories. Adding those tags to my list gives me the result I was looking for. When I was testing this, I was actually seeing if I could build them since the AI would also be able to build them in that case.

Jun 22 2019 Anchor

The AI can build stuff from the non-UEF gantries that players can't; while the UEF Gantry can toggle between air/land/naval freely, the Arthrolab is land only for players, the Independence Engine is air only for players, and the Seraphim one is naval only for players, but when used by the AI they lose their layer only restrictions, so you actually wouldn't necessarily have the same build list as the AI. On the ALT-F2 cheatspawn menu though, if you double click on an AI name, you take control of that AI and can see what they can see.

I should also mention, one side effect of doing it that way; if there are any wreckage's on the map of units you don't want enabled, the Seraphim reconstruction engineer will be able to learn it's blueprint still. Only map I can think of where that'd be an issue is Ian's Cross with the CZAR wreckage.

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.