[REL] Blueprint Info Framework v1.4.4

Discussion in 'Released Mods' started by Raevn, February 3, 2014.

  1. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    I've noticed a few mods reinventing the wheel so to speak when it comes to reading blueprint data, as well as many requests for being able to easily tell what units build what.

    To that effect, I am making a generalised blueprint info framework. This loads all the unit, tool and ammo data (and caches it in the session, so it doesn't re-load it all per scene), and then provides a large number of utility functions for it (currently 49).

    All blueprints include the non-overridden fields of any inherited blueprints, so you don't need to look up the chain. It does not expand weapons/build arms or ammo into the unit or weapon blueprints respectively, but does give many functions to access these separately.

    This also adds some additional information to the blueprints (added during loading; they are not written to the blueprint files):
    • id - the id of blueprint
    • path - the file path of the blueprint
    • buildIndex (for units) - an integer that determines the order that units appear in the build menu (lowest first)
    • inheritance - an array of blueprints that form the inheritance chain for this blueprint
    • inherited - an array of blueprints that inherit this blueprint
    • unit_types - adds an additional unit type called "UNITTYPE__<unitID>" to all units. Note the extra underscore (to prevent clashes with existing types, such as with bomber). This allows you add or exclude individual units when filtering.
    • buildPicture - The path to the unit's build picture, or null if it's not available.
    • strategicIcon - The path to the unit's strategic icon, or the generic blip icon if a specific one is not available.
    Documentation for each of these functions can be found within the code; additionally, this will be collated into an online reference.

    Current functions include:

    General Functions
    • bif.getBIFReady()
    • bif.registerBIFReadyCallback(functionCallback)
    • bif.sortBlueprintsByAttribute(blueprints, attribute, type, ascending)
    • bif.sortBlueprintAlphabetically(blueprint)
    • bif.getBlueprintIDsFromBlueprints(blueprints)
    • bif.getBlueprintIDFromPath(path)

    Unit Functions
    • bif.unitBlueprintExists(unitID)
    • bif.unitHasType(unitID, type)
    • bif.getUnitBlueprintsFromArray(unitIDArray)
    • bif.getUnitName(unitID)
    • bif.sortBlueprintsByBuildOrder(blueprints)
    • bif.getUnitBlueprint(unitID)
    • bif.getUnitBlueprintInline(unitID)
    • bif.getUnitBlueprints()
    • bif.getUnitIDs()
    • bif.getUnitBlueprintToolIDs(unitID)
    • bif.getUnitBlueprintTools(unitID)
    • bif.getUnitBlueprintWeaponIDs(unitID)
    • bif.getUnitBlueprintWeapons(unitID)
    • bif.getUnitBlueprintBuildArmIDs(unitID)
    • bif.getUnitBlueprintBuildArms(unitID)
    • bif.getFilteredUnitIDs(filter)
    • bif.getFilteredUnitIDsFromArray(unitIDArray, filter)
    • bif.getFilteredUnitBlueprints(filter)
    • bif.getFilteredUnitBlueprintsFromArray (unitIDArray, filter)
    • bif.getUnitBuildableTypeUnitIDs(unitID)
    • bif.getUnitBuildableTypeBlueprints(unitID)
    • bif.getUnitBuiltByUnitIDs(unitID)
    • bif.getUnitBuiltByBlueprints(unitID)
    • bif.getUnitIDIsBuiltBy(unitID, builderUnitID)
    • bif.getUnitIDIsBuildable(unitID, baseBuilderUnitID)
    • bif.getBuildableUnitIDsFromArray(unitIDArray, baseBuilderUnitID)
    • bif.getBuildableUnitIDs(startUnitID)

    Tool Functions
    • bif.toolBlueprintExists(toolID)
    • bif.getToolBlueprintsFromArray(toolIDArray)
    • bif.getToolBlueprint(toolID)
    • bif.getToolBlueprintInline(toolID)
    • bif.getToolBlueprints()
    • bif.getToolIDs()
    • bif.getWeaponBlueprints()
    • bif.getWeaponBlueprintIDs()
    • bif.getBuildArmBlueprints()
    • bif.getBuildArmBlueprintIDs()
    • bif.getWeaponBlueprintAmmoID(weaponID)
    • bif.getWeaponBlueprintAmmo(weaponID)

    Ammo Functions
    • bif.ammoBlueprintExists(ammoID)
    • bif.getAmmoBlueprintsFromArray(ammoIDArray)
    • bif.getAmmoBlueprint(ammoID)
    • bif.getAmmoBlueprints()
    • bif.getAmmoBlueprintIDs()
    Knockout Observables
    • bif.loaded_units()
    • bif.loaded_tools()
    • bif.loaded_ammo()
    • bif.loaded_images()
    Last edited: September 27, 2014
    zgrssd, mishtakashi, trialq and 4 others like this.
  2. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
  3. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    Please add support for figuring out how much build power the fabricators and factories have (i.e. metal and energy usage when fabbing). That would let me remove the current hack that the Build Power mod uses to get that information.

    The build power is not directly in a unit's specs, but in the tools that they use, as shown below. I wonder that should the "spec_id" reference be inlined, the same way that "base_spec" is, to produce the complete runtime presentation of the unit spec.

    \pa\units\land\fabrication_bot\fabrication_bot.json
    Code:
    ...
        "tools": [
            {
                "aim_bone": "bone_root",
                "spec_id": "/pa/units/land/fabrication_bot/fabrication_bot_build_arm.json"
            }
        ],
    ...
    
    \pa\units\land\fabrication_bot\fabrication_bot_build_arm.json
    Code:
    {
        "base_spec": "/pa/tools/engineer_build_arm/engineer_build_arm.json",
        "construction_demand": {
            "energy": 1000,
            "metal": 10
        },
        "pitch_rate": 90,
        "yaw_rate": 90
    }
    
  4. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    Build arms, weapons and ammo blueprints are planned to be included also.

    Added function "getUnitBlueprintsByFilter", plus a few other misc functions.

    I've changed the name to "Blueprint Info Framework", to avoid possible confusion between actual units and unit blueprints.

    Edit: Updated to include functions for Tools (Weapons & Build Arms).
    Last edited: February 4, 2014
  5. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    Lots of work done here. Current method count is 46; this should be it unless people start thinking of more :p.
    I'll hopefully have it up within the next day or two.

    You'd want to do something like:

    Code:
    var theUnitID = "fabrication_bot";
    var buildArms = getUnitBlueprintBuildArms(theUnitID); 
    
    $.each(buildArms, function (key, value) { 
        console.log(value.construction_demand.metal]);
        console.log(value.construction_demand.energy]);
    });
    This will return the metal & energy demands of all build arms (likely to only ever be 1 of these though :p).
  6. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    v1.0.0 Released. Added some additional functions, as well the "inheritance" attribute & added the unit ID to the unit_types array for easier filtering.

    Also moved all functions into the bif object to clear up the namespace.
    Tripax and trialq like this.
  7. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Works fine :) already working in my hotbuild2 version.
    Gonna test some more and then release :)
  8. Tripax

    Tripax Member

    Messages:
    67
    Likes Received:
    62
    hotbuild 2 with blueprint info framework dependency released
    we'll get you some downloads raevn (-:
    Raevn likes this.
  9. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    v1.1.0 released.
    • Added attributes "strategicIcon" and "buildPicture" to all units
    • Added function "getUnitBlueprintInline(unitID)"
    • Added function "getToolBlueprintInline(toolID)"
    LavaSnake likes this.
  10. brianpurkiss

    brianpurkiss Post Master General

    Messages:
    7,879
    Likes Received:
    7,438
    When I boot PA I get the following.

    Screen Shot 2014-02-15 at 2.26.09 PM.png

    It starts off spinning but then stops spinning after a second or two. Waiting for a minute or two changes nothing.

    Disabling the blueprint mod fixes it.

    I'm on OS X with the latest version of PA. Any idea what's going on?
  11. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    Are there any errors shown in the coherent debugger / PA logs?

    Edit: If no errors are found, can you also try and start it up again, and just try and leave it for a bit longer? Maybe the Mac implementation has bad performance in certain circumstances, or isn't multithreaded or something like that (this would increase the loading time by quite a bit). If this is the case, we can work on narrowing down what the problem function is and how to fix it.
    Last edited: February 15, 2014
  12. Alphasite

    Alphasite Active Member

    Messages:
    102
    Likes Received:
    26
    I'm having the same issue (see gist: Alphasite/bc22a31c6448855482b7 for the log). It doesn't look like theres anything related to the mod in there.
  13. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    Can you copy the log from within the coherent debugger? It includes additional console output from the mod.
  14. Alphasite

    Alphasite Active Member

    Messages:
    102
    Likes Received:
    26
    Here it is: Alphasite/1fdf8802b66057787461 The game locks up after the spinner spins for a few seconds.
    Last edited: February 17, 2014
  15. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    So I can see that it finishes loading the unit blueprints, but doesn't finish the tool/ammo blueprints, and only checks 1 strategic icon.

    At this stage my hunch is that it's with the strat icon/build pic loading. I *think* the next blueprint that it would attempt to find the icon for would be base_structure,which as a base blueprint wouldn't have an icon. For me, that simply doesn't return a 200 success code, so i mark it as having the blip icon and move on. Maybe something there doesn't work the same way on other OSs.
  16. Tripax

    Tripax Member

    Messages:
    67
    Likes Received:
    62
    well, since they're on mac, you could test with an iatkos release in a vm as we try to do for hotbuild2...
  17. Alphasite

    Alphasite Active Member

    Messages:
    102
    Likes Received:
    26
    This may be handy for you? Alphasite/657737aa3277372029ff
  18. brianpurkiss

    brianpurkiss Post Master General

    Messages:
    7,879
    Likes Received:
    7,438
    Where's the debugger?

    Still doing it with the new build.
  19. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    Not sure on a mac. Somewhere in the PA directory is a coherent debugger application. You might just have to dig for it.
  20. brianpurkiss

    brianpurkiss Post Master General

    Messages:
    7,879
    Likes Received:
    7,438
    From what I've seen, all the game files are located in the same places from PC to Mac.

    I'm looking in the PA folder and I only see unit/building/etc files. There's a "debug" folder, but it has a few .papa files, and that's it.

    I'm looking elsewhere and I don't see much.

Share This Page