Jump to content
Official BF Editor Forums

Loading an unrestricted python interpreter


Recommended Posts

It's been a while since I posted here... figured I'd share some of the things I've been working on since I started messing with 2142 again.

The python interpreter included with vanilla Battlefield 2142 is lacking a fairly large amount of functionality. Much of this involves restrictions on OS interaction, as well as the removal of threading support and the ability to load C extensions. Due to this, a large chunk of the standard library is broken as it depends on functionality that was removed. The goal here is to replace 2142's python interpreter with an unrestricted one and to include the full standard library. 


^ instructions for doing so


Link to comment
Share on other sites


I'll be posting again soon about using it to dynamically add python callbacks for game events that are currently inaccessible to python.

I want to know more! What else can you access? I've always wanted to be able to alter the momentum of objects in the server, but was limited to position/rotation.

Link to comment
Share on other sites

You can access literally anything the gameserver does, the only thing stopping you is the need to reverse engineer the relevant parts of the server executable and then (if you're hooking stuff) write the code to bootstrap python integration in assembly.  So far, I've got a simple proof of concept working hooking comm rose events and having them call out to python code.  Also have a thing that lets you change the server fps limit on the fly, but that's fairly simple in comparison.

This stuff is all possible through static patching, but it's so much cleaner to do it at runtime using ctypes.

Link to comment
Share on other sites

All things game related are in the server executable, the python library is just python (normal python, nothing game related, and nothing stripped out).  I'm a bit busy with finals this week, but I'll see if I can get the writeup on hooking new events finished when I get a chance.

EDIT: Ah, btw, you're not gonna be able to run it on a Pi.  There aren't any ARM builds afaik.

Edited by amideadyet
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...