[REL] TransformPA: A tool to generate balance mods

Discussion in 'Released Mods' started by cola_colin, October 25, 2014.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    REL!
    Github: https://github.com/pamods/TransformPA
    see the readme to use this tool to generate balance mods.

    What does it do?
    It accepts a json file like this:
    Code:
    [
      {
        "affects":[
          "/pa/units/land/land_barrier/land_barrier.json"
        ],
        "ops":[
          {
            "cmd":"=",
            "keys":[
              [
                "wreckage_health_frac"
              ]
            ],
            "value":0
          }
        ]
      },
      {
        "affects":[
          "/pa/units/air/base_flyer/base_flyer.json",
          "/pa/units/land/base_bot/base_bot.json",
          "/pa/units/land/base_unit/base_unit.json",
          "/pa/units/land/base_vehicle/base_vehicle.json",
          "/pa/units/sea/base_ship/base_ship.json"
        ],
        "ops":[
          {
            "cmd":"=",
            "keys":[
              [
                "wreckage_health_frac"
              ]
            ],
            "value":10
          }
        ]
      },
      {
        "affects":[
          "/pa/units/air/air_factory/air_factory.json",
          "/pa/units/sea/naval_factory/naval_factory.json",
          "/pa/units/land/energy_storage/energy_storage.json",
          "/pa/units/land/land_barrier/land_barrier.json",
          "/pa/units/land/energy_plant/energy_plant.json",
          "/pa/units/land/vehicle_factory/vehicle_factory.json",
          "/pa/units/land/radar/radar.json",
          "/pa/units/land/metal_extractor/metal_extractor.json",
          "/pa/units/land/bot_factory/bot_factory.json",
          "/pa/units/land/metal_storage/metal_storage.json"
        ],
        "ops":[
          {
            "cmd":"*",
            "keys":[
              [
                "build_metal_cost"
              ]
            ],
            "value":0.75
          }
        ]
      },
      {
        "affects":[
          "/pa/units/land/teleporter/teleporter.json"
        ],
        "ops":[
          {
            "cmd":"*",
            "keys":[
              [
                "build_metal_cost"
              ]
            ],
            "value":1.5
          }
        ]
      },
      {
        "affects":[
          "/pa/units/air/fabrication_aircraft/fabrication_aircraft.json",
          "/pa/units/land/fabrication_vehicle/fabrication_vehicle.json",
          "/pa/units/land/fabrication_bot/fabrication_bot.json",
          "/pa/units/sea/fabrication_ship/fabrication_ship.json"
        ],
        "ops":[
          {
            "cmd":"*",
            "keys":[
              [
                "build_metal_cost"
              ]
            ],
            "value":0.75
          },
          {
            "cmd":"=",
            "keys":[
              [
                "max_health"
              ]
            ],
            "value":150
          }
        ]
      },
      {
        "affects":[
          "/pa/units/land/fabrication_bot/fabrication_bot_build_arm.json",
          "/pa/units/land/fabrication_vehicle/fabrication_vehicle_build_arm.json",
          "/pa/units/sea/fabrication_ship/fabrication_ship_build_arm.json",
          "/pa/units/air/fabrication_aircraft/fabrication_aircraft_build_arm.json"
        ],
        "ops":[
          {
            "cmd":"*",
            "keys":[
              [
                "construction_demand",
                "metal"
              ]
            ],
            "value":0.75
          },
          {
            "cmd":"*",
            "keys":[
              [
                "construction_demand",
                "energy"
              ]
            ],
            "value":0.50
          }
        ]
      },
      {
        "affects":[
          "/pa/units/land/metal_extractor/metal_extractor.json"
        ],
        "ops":[
          {
            "cmd":"=",
            "keys":[
              [
                "production",
                "metal"
              ]
            ],
            "value":5
          }
        ]
      },
      {
        "affects":[
          "/pa/units/land/fabrication_bot_combat/fabrication_bot_combat.json"
        ],
        "ops":[
          {
            "cmd":"=",
            "keys":[
              [
                "build_metal_cost"
              ]
            ],
            "value":100
          },
          {
            "cmd":"=",
            "keys":[
              [
                "max_health"
              ]
            ],
            "value":150
          }
        ]
      },
      {
        "affects":[
          "/pa/units/land/fabrication_bot_combat/fabrication_bot_combat_build_arm.json"
        ],
        "ops":[
          {
            "cmd":"=",
            "keys":[
              [
                "construction_demand",
                "metal"
              ]
            ],
            "value":20
          }
        ]
      }
    ]
    And produces a mod that applies the changes. It supports +-/*= as a operators.

    So with this file I can i.e. generate my expansionist balance mods for a current version of PA by just running the program. That way I can get a new copy of my mod even after PA has updates and I can easily generate a mod that i.e. "reduces all structure metal prices to 75%" without having to edit all those files by hand.

    How to use:
    Modifes conf.json and transform.json, read the program output for how to use it. After the mod is created edit the modinfo.json of the mod

    A little extra thing, some quick and dirty JS, to be run in the live_game console:

    Code:
    var _unitSpecMapping = undefined;
                unitInfoParser.loadUnitTypeMapping(function(mapping) {
                    _unitSpecMapping = mapping;
                });
    
    for (var x in _unitSpecMapping) {if (_unitSpecMapping[x].indexOf('Basic') != -1 && _unitSpecMapping[x].indexOf('Structure') != -1) {console.log("\""+x+"\",");}}
    
    First make it define the _unitSpecMapping via my unitInfoParser. That object will exist if you have PA Stats active.
    Then you can go through the spec mapping, which is a map of unit-ids to arrays with their unit types and i.e. get all basic structures printed, so you can use them in a transform.json file for TransformPA
    Last edited: October 28, 2014
  2. philoscience

    philoscience Post Master General

    Messages:
    1,022
    Likes Received:
    1,048
    I'd say Uber should just go ahead and hire you, but then that would probably reduce your output. Great work Colin.
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    REL, now on github with pre-packaged jar
  4. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Added a quick and dirty js example of how to use the unitInfoParser, which is part of PA Stats, to get a list of all units in the game that fulfill certain types.
    mered4 and Clopse like this.
  5. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    So this tool could also re-create the cheats mod I made for both Galactic War and AI Skirmish modes pretty quickly? Example:

    "build_metal_cost": 1, or reduce 99% for quicker/instant build
    "max_health": 60000, or increase 100% for higher health
    "production": {"energy": 600000}, or increase 100% for higher energy production
    "production": {"metal": 70000}, or increase 100% for higher metal production
    "storage": {"metal": 200000}, or increase 100% for higher metal storage
    "storage": {"energy": 200000}, or increase 100% for higher energy storage

    Do the work that took me a weekend in minutes, lol. Only trouble at that point is that it would also affect AI units, but if I copy the unit JSON and put em in my hackedunit directory and revert the originals, I get updated cheat units and the AI doesn't. STAMP OF APPROVAL!~

    EDIT: Bahh, thought it was a python script, but even if it's an in-game mod, the theory is still sound. Lovin this!
  6. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    in game mod? As you can see on github it is a java program.
    Also I am not sure of the setup of galactic war mods. This generator creates mods that are active for all players, even the AI.

    EDIT: Ah I missed your text about that somehow, so it's fine I guess.
  7. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Yeah, don't mind me, I kinda mis-read your post too, lol. Awesome job yo!~
  8. nixtempestas

    nixtempestas Post Master General

    Messages:
    1,216
    Likes Received:
    746
    Raevn and cola_colin like this.
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
  10. nixtempestas

    nixtempestas Post Master General

    Messages:
    1,216
    Likes Received:
    746
    Great minds :)

    Yours is a bit more sophisticated than mine, though a bit more verbose as a result. Having both isn't a bad thing.

    Maybe tonight ill go poke at the source and see if I can combine the input file types. Will be a nice distraction from my compiler homework at least
  11. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Alrighty cola,
    I'm back and I remembered your script here. I'm at the in-game console trying to figure out how to produce a unit list though and I'm stuck. I copy/paste your code and get undefined; however, I've also tried changing this line

    Code:
    var _unitSpecMapping = undefined;
    to UNITTYPE_Fabber, Fabber, Tank, Construction, etc. I know I'm doing something wrong, but not sure what. Just looking to make as complete of a unit list as possible.

    EDIT: Got the unit list, now trying to run the TransformPA.jar file. I've tried from the command screen and explorer, but neither attempts to run it. I have updated the conf.json and transform.json file, but nothing else.
    Last edited: May 14, 2015
  12. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Don't mind me, apparently I'm just dumb in my old age. Totally worked, now to see if this cheat mod actually works, LOL!~
  13. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Not sure who all might see this, but it's worth a shot:

    I'm updating my AI Skirmish cheat mod for PA:Titans and I'm having a few issues. I'm not sure if I need to run this on the PA\Units folder, the PA_EX1\Units folder, or both. I've got my transform.json configured to pull all unit file JSON's from both currently and it outputs both folders separately; however, I'm also having an issue with it not being able to convert the JSON's, which I believe is due to the fact I'm trying to update multiple JSON files for multiple ops, some of which have 1 or the other and some have all ops available. My reasoning for this assumption is the fact that the Advanced Radar has all of the operations available (build_metal_cost, max_health, consumption energy, energy, energy_demand, and metal) and it does build me an advanced radar json.

    If my assumption is correct, I think I need to run Transform.PA a couple times so I can update JSON's that have just one or the other operations available, but that would be a huge headache. I used to be able to run it just once and Transform.PA would update all JSON's with whatever operations were actually available. Any suggestions?
  14. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    The mod needs to output PA\Units, but if you want to use Titans stuff, you'll need to pull the data from PA_EX1\Units where available.
    mysticalfists likes this.
  15. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Finally got over it the long way. I listed all units (PA and PA_EX1) and modified each of my categories one by one, first max health, which affected everything. Copied all modified PA_EX1 files to PA. Then repulled all units modifying the next attribute from the directory I'd just created, rinse and repeat until all required attributes were modified. I think my problem might be from the fact I just realized there's now a "Production" attribute similar to "Consumption", but I haven't tested it.

Share This Page