Oct 19, 2014 at 4:15 PM
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Pronouns: he/him
So you mighta saw that I finally added the hackinator to BL
If you haven't, what the heck are you reading this for? Go download the latest version.
Now, the great renaissance of the hackinator is that it lets you write customizable patches that people can load into BL and apply to their game. The hack files are in XML format, and you can edit them with any text editor (although I recommend something with some syntax highlighting like Notepad++)
Specifically there are a few elements that I've defined and I'll try to explain them as best I can because XML is dumb and my implementation is even dumber
So, here's a breakdown of a couple of my sample hacks.
Basic information:
Player Physics:
If you haven't, what the heck are you reading this for? Go download the latest version.
Now, the great renaissance of the hackinator is that it lets you write customizable patches that people can load into BL and apply to their game. The hack files are in XML format, and you can edit them with any text editor (although I recommend something with some syntax highlighting like Notepad++)
Specifically there are a few elements that I've defined and I'll try to explain them as best I can because XML is dumb and my implementation is even dumber
So, here's a breakdown of a couple of my sample hacks.
Basic information:
First off, all XML files start with the XML version on the first line. You just gotta copy-paste this, pretty simple.
Next we have the root node, which is a <hack>. You can only have one per file and in there is where you put all the stuff. It has one optional attribute, "name", which appears at the top of the panel.
Next, is a <panel>. You could in theory place all your fields in the root <hack> node, but it won't look very good. If you're familiar with Swing layout managers, then the hack node uses a BoxLayout and panels use a GridBagLayout. There are a few gridbagconstraints you can use to arrange the elements by setting them as attributes on any child node of <panel>:
'col' sets the column of the grid. Children are parsed in order and anything after it will be placed into the same column until you change it again. However, if you add a new child <panel>, then IT's layout starts at column 0 without affecting the parent's.
'width' and 'height' are not currently implemented but planned to be. This is how many "cells" in the grid subsequently added elements take up.
Currently the gridy attribute (the 'row') is locked at RELATIVE, meaning elements added in a column get put on the bottom.
panels can also have a 'title' attribute, which will generate a titled border around them.
The next most important element is the <field> tag, which lets you define a variety of elements depending on what you have set the 'type' as. Most field elements have an 'offset' attribute, which is where their relevant data gets patched to, and a 'size' indicating how many bytes of data are being changed
[type='label']
This is just a simple text label. Setting the size or offset does nothing, as labels never generate patches. Use this to tell your users what to fill in.
[type='text']
A plain text entry field. It will attempt to load the memory at the offset into the text field. Please keep in mind that if the size is 4, 2 or 1 it will assume that the value is a number and any other sizes are text. There isn't any checking for input validity at the moment, so hope whoever uses it puts the right values in! \o/
Size defaults to 4 so if you are just modifying an int then you don't need to specify it, but it doesn't hurt to either in case I arbitrarily change the specification for no reason.
[type='flags']
Generates a set of checkboxes for selecting various flags. valid sizes for flag fields are 4, 2 and 1 bytes only. Each of the checkboxes have to be defined as <checkbox> elements inside the field element. A flags field may look like this:
The value of each checked checkbox gets OR'd together then applied to the address. Note that you don't have to have your values in order, nor do they have to be only single bit masks but it probably works best if they are.
More field types TBA
Next we have the root node, which is a <hack>. You can only have one per file and in there is where you put all the stuff. It has one optional attribute, "name", which appears at the top of the panel.
Next, is a <panel>. You could in theory place all your fields in the root <hack> node, but it won't look very good. If you're familiar with Swing layout managers, then the hack node uses a BoxLayout and panels use a GridBagLayout. There are a few gridbagconstraints you can use to arrange the elements by setting them as attributes on any child node of <panel>:
'col' sets the column of the grid. Children are parsed in order and anything after it will be placed into the same column until you change it again. However, if you add a new child <panel>, then IT's layout starts at column 0 without affecting the parent's.
'width' and 'height' are not currently implemented but planned to be. This is how many "cells" in the grid subsequently added elements take up.
Currently the gridy attribute (the 'row') is locked at RELATIVE, meaning elements added in a column get put on the bottom.
panels can also have a 'title' attribute, which will generate a titled border around them.
The next most important element is the <field> tag, which lets you define a variety of elements depending on what you have set the 'type' as. Most field elements have an 'offset' attribute, which is where their relevant data gets patched to, and a 'size' indicating how many bytes of data are being changed
[type='label']
This is just a simple text label. Setting the size or offset does nothing, as labels never generate patches. Use this to tell your users what to fill in.
[type='text']
A plain text entry field. It will attempt to load the memory at the offset into the text field. Please keep in mind that if the size is 4, 2 or 1 it will assume that the value is a number and any other sizes are text. There isn't any checking for input validity at the moment, so hope whoever uses it puts the right values in! \o/
Size defaults to 4 so if you are just modifying an int then you don't need to specify it, but it doesn't hurt to either in case I arbitrarily change the specification for no reason.
[type='flags']
Generates a set of checkboxes for selecting various flags. valid sizes for flag fields are 4, 2 and 1 bytes only. Each of the checkboxes have to be defined as <checkbox> elements inside the field element. A flags field may look like this:
Code:
<field type="flags" size="1" offset="0x48f49c">
<checkbox name="0x01" value="0x01" />
<checkbox name="0x02" value="0x02" />
<checkbox name="Ignore solid" value="0x04" />
<checkbox name="Don't break when hit wall" value="0x08" />
<checkbox name="0x10" value="0x10" />
<checkbox name="Break blocks" value ="0x20" />
<checkbox name="Pierce blocks" value="0x40" />
<checkbox name="0x80" value="0x80" />
</field>
More field types TBA
Player Physics:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<hack name="Player Physics">
<panel>
<panel title="water physics">
<field type="label">Max run speed:</field>
<field type="label">Max fall speed:</field>
<field type="label">Gravity</field>
<field type="label">Rising gravity</field>
<field type="label">Jump speed</field>
<field type="label">Walk speed</field>
<field type="label">Air control</field>
<field type="label">Friction</field>
<field type="text" size="4" offset="0x4156E8" col="1"/>
<field type="text" size="4" offset="0x4156EF" />
<field type="text" size="4" offset="0x4156F6" />
<field type="text" size="4" offset="0x4156FD" />
<field type="text" size="4" offset="0x415704" />
<field type="text" size="4" offset="0x41570B" />
<field type="text" size="4" offset="0x415712" />
<field type="text" size="4" offset="0x415719" />
</panel>
<panel title="regular physics" col="1">
<field type="label">Max run speed:</field>
<field type="label">Max fall speed:</field>
<field type="label">Gravity</field>
<field type="label">Rising gravity</field>
<field type="label">Jump speed</field>
<field type="label">Walk speed</field>
<field type="label">Air control</field>
<field type="label">Friction</field>
<field type="text" size="4" offset="0x415712" col="1"/>
<field type="text" size="4" offset="0x415729" />
<field type="text" size="4" offset="0x415730" />
<field type="text" size="4" offset="0x415737" />
<field type="text" size="4" offset="0x41573E" />
<field type="text" size="4" offset="0x415745" />
<field type="text" size="4" offset="0x41574C" />
<field type="text" size="4" offset="0x415753" />
</panel>
</panel>
</hack>