Hacking Unit JSON Loading

Discussion in 'Mod Discussions' started by wondible, March 11, 2014.

  1. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Forking discussion from https://forums.uberent.com/threads/pa-client-api-requests.57785/

    Recap:


  2. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Thanks, let's get this party started! I sure hope we can figure this out; it would improve and allow so many mods.

    Basically my end goal is to make a framework mod like one of raevn's that would allow other mods to edit JSON at runtime. From there I could use it to improve my custom unit names mod and probably turn it into a framework too.

    Also, @raevn we could really use your PA backend js knowledge here. :D
  3. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    My guess is that the loading of unit json files is done inside the application, not via the UI.
  4. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    I sure hope that's not the case but I guess it makes sense based on what I saw in the js code I was looking at.
  5. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    I am looking through right now for an engine call that might reload the json.
  6. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    This is a little far fetched but maybe we could make a native tool that runs a localhost server that you can ping with js and then it will edit the JSON files through a shadowing mod.
  7. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    That was my impression as well, which is I posted it in the API requests.

    It was mostly guesswork before but "unit_info.json" appears in the PA executable, not in the moddable UI. So unless there's some sort of callback we've missed, the UI doesn't do it.
  8. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Not that far fetched. You could write a python script(Easily compiled on all platforms) and open a websocket. The only problem is your would probably have to reload the game for the new files to update.
  9. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Most game files are automatically reloaded on the fly if they are edited (this is really cool & useful). It won't pick up newly added files though.
  10. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I just tried replacing a URL in a shadowed unit_list.json with a localhost address and PA outright crashed immediately on start.
  11. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    So in theory we could shadow all unit json files in a mod and then have the python script edit them on command to do our bidding...
    Raevn and someonewhoisnobody like this.
  12. Dementiurge

    Dementiurge Post Master General

    Messages:
    1,094
    Likes Received:
    693
    I'd simply like to be able to make supplementary changes to one or more attributes of an existing unit.
    E.g. Setting the line build settings of a unit without changing the other settings, so that I can make an area build mod that doesn't break every time unit stats are changed.
    LavaSnake likes this.
  13. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    Ahh... why do you need to edit the JSON files at runtime?

    It's JS. You can just go object.property = value all day long.
  14. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    In short, we don't have access to object.
  15. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    In hindsight, that doesn't surprise me in the slightest.

    There's no point screwing with JSON for unit data unless we can screw with it on the server as well.
  16. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    In general true, but there are some values which are client-side only, and you can also change models etc.
  17. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
  18. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Technically, a note though. The only things that would really make a difference in the game json files would be unit names, models, and effects(Off the top of my head)
  19. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    There's a few more (such as sounds, line/area build settings etc), but those are the main ones. In general, if it affects gameplay, it can't be changed client-side.
  20. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    Would we be able to dynamically change strategic icons too?

Share This Page