Giter Site home page Giter Site logo

pypipboy's Introduction

python_version license_gpl3

PyPipboy

PyPipboy is a Python3 module implementing an event-driven, rich client for the Fallout 4 Companion App protocol.

It connects to a running Fallout 4 game (www.fallout4.com) (using the Companion App interface) and receives data from the game. This data can then be accessed using an event-driven interface. Furthermore it can also send commands to the game.

PyPipboyApp is a GUI application build on top of PyPipboy.

Features

Currently implemented features are:

  • Autodiscovery
  • Connection Handling
  • Receiving Data Updates and Local Map Updates
  • Sending Commands (RPC)

Current Status

PyPipboy is feature complete, but still in alpha state.

Usage

First create an PipboyDataManager object.

from pypipboy.datamanager import PipboyDataManager
pipboy = PipboyDataManager()

Then register a root object listener.

def rootObjectListener(rootObject):
   .... # Do something with the root object

Then connect to the game.

pipboy.connect('localhost')

When the library connects to the game it sends data which is organized in form of a tree. As soon as the root of the tree is known (meaning the tree is fully parsed and there are no tangling references), a root object event is fired. Inside the event handle you can interact with the root object, traverse the tree, register additional listener, ...

For example, navigating to the player's current health and registering a listener for value changes is done like this:

def currHpListener(caller, pipvalue, pathObjs):
    ... # Do something
    
def rootObjectListener(rootObject):
    currHP = rootObject.child('PlayerInfo').child('CurrHP')
    currHP.registerValueUpdatedListener(currHpListener)

To navigate to a specific value inside the tree, start from the top and navigate down on known paths. For example, to fetch an array with all map location markers, start with the root element you got from the root object event and retrieve the child 'Map'. Then, from the map object retrieve the child 'World', and finally 'Locations'. In short: rootObject.child('Map').child('World').child('Locations'). But don't forget to check whether a certain element already exists. For example, if the user stills linger around in the main menu and hasn't loaded a save at all, there is no 'World' object and you would get an exception.

When the user loads a new save, most values get invalidated and don't receive any events anymore. You need to fetch the new elements and re-register the event listeners with them. To know that the user loaded a new save, you need to register listeners with the parents (or their parents) of the values. It is not always easy to say (with the 'Locations' it is the 'Map' object) which parent persists a save load. I have also written another application "PyPipboyApp" (see link above), that allows you to browse the data and see the data updates. Use it to find out which value persists a save load.

API references

Known bugs

It is in alpha state, there might be bugs.

Contribution

Everyone who wants to contribute is welcome.

How did I learn about the protocol?

By re-engineering the official Fallout 4 Companion App (the Android version). The file assets/bin/Data/Managed/Assembly-CSharp.dll contains all code related to the protocol. I just fired up my favorite C#-Disassembler, disassembled that file and read the source code.

License

This software is released under GPL 3.0.

pypipboy's People

Contributors

matzman666 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.