Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Pillars of Eternity Coding/Hacking Thread

Rumsteak

Literate
Joined
Nov 15, 2014
Messages
8
Nice work! It's been ages since I tinkered in C# (I don't use Windows any more). Good luck
 

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
Two new things.

1. Figured out how to make a custom options page and fill it with custom options (and they're saved between plays and can affect the game as per their description). This should be useful when people start making mods.

2014-12-09_00002.jpg


2. Made an in-game GameObject hierarchy browser and components inspector. This is very useful for figuring out what goes where, has what components, has what values, etc. Used to take hours to properly inspect certain things through debug. Now it's instantaneous. Can toggle gameobjects on/off to see if you're on the gameobject that you think you are. Will probably make components' fields editable in the future.

2014-12-09_00003.jpg


I think I'll polish it up a little and release the sources for everything in a few days.
 

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
I've been taking a break since that last post and I still am. I'd like however to share this thing, in case anyone needs it some day.

I'm only an amateur programmer, so the "tool" is in a chaotic and unfinished state, uses shortcuts it shouldn't, etc, so don't be surprised when you see some horrible things inside.

Link (framework + examples): https://dl.dropboxusercontent.com/u/62420848/PEModdingTool.zip

How to set it up:
- Compile Mono.Cecil https://github.com/jbevain/cecil and add other necessary references from PillarsOfEternity_Data\Managed
- The Assembly-Csharp you use in references must have all methods and fields public. In order to do that, use an unpatched assembly first and then run this code once. Replace the Assembly-Csharp in your references with the one this code should produce:

Code:
//int types = 0;
//int nestedTypes = 0;
//int fields = 0;
//int methods = 0;
//foreach (TypeDefinition td in mainMod.Types)
//{
//   types++;
//   foreach (TypeDefinition ntd in td.NestedTypes)
//   {
//     nestedTypes++;
//     foreach (FieldDefinition fd in ntd.Fields)
//     {
//       fields++;
//       if (fd.IsPrivate)
//         fd.IsPublic = true;
//     }
//
//     foreach (MethodDefinition md in ntd.Methods)
//     {
//       if (md.IsPrivate)
//         md.IsPublic = true;
//       methods++;
//     }
//     if (ntd.IsNestedPrivate)
//       ntd.IsNestedPublic = true;
//   }
//   foreach (FieldDefinition fd in td.Fields)
//   {
//     fields++;
//     if (fd.IsPrivate)
//       fd.IsPublic = true;
//   }
//
//   foreach (MethodDefinition md in td.Methods)
//   {
//     if (md.IsPrivate)
//       md.IsPublic = true;
//     methods++;
//   }
//}
//Log ("Types: " + types + ", nested types:" + nestedTypes+", methods: "+ methods+ ", fields: "+fields);

Now you're all set.

Usage:
- All your classes must be named "Mod", followed by any digits, i.e.: Mod01
- Your Mod-something classes must inherit from the class that you're going to modify (you can see this in examples). Unless you want to inject some code that uses the "base" keyword, in which case you must inherit from its base class. Because of this, in certain rare cases it might cause problems when you use both "base" and "this" keywords, you can see why. Never encountered it though.
- The order matters, kind of like in c++. You can't inject a method that references a variable before injecting that variable into the target assembly first.

What works:
- PatchExistingMethod //clears all instructions in the target method and injects instructions from your custom method
- PatchExistingProperty //patches the get-set methods of an existing property... i don't remember if I tested it at all, sorry
- PatchExistingNestedType // patches an existing enum
- InjectMethodIntoType //injects an empty method into a class, only attributes currently supported are: public static or private
- InjectFieldIntoType //injects a field. It copies the type, attributes and name from the field that it receives as a paramater.
- MakeFieldPublic
- MakeMethodPublic
- RemoveMethodFromType
- RemoveFieldFromType

What doesn't work yet:
- delegates ("delegate" creates and adds a new method to its type... this method has to be found and copied to the corresponding type in the target assembly before it can be refereced in the target assembly)
- lambda expressions (probably for a similar reason)
- The following expression wouldn't work: new int[] { 0, 3, 1, 4, 5, 2 }... The reason being, it creates a field and a type in <PrivateImplementationDetails> and we need to copy them and rename them. For now, simply code it differently instead: new int[7], then myint[0] = 0;, etc...

Limitations:
- Sometimes you're going to have a field and an event of the same name inside a type. There is no way to programmatically distinguish between them that I'm aware of when referencing them in your own code. For Mod4, I had to manually rename in .Net Reflector UIOptionsManager:OnWindowHidden to OnWindowHiddenField in the referenced assembly and in the unpatched assembly that is loaded when the program starts. I don't know if any other workaround for this exists. I only stumbled upon this problem once though.
For this reason, the example mod Mod4 will not compile and execute correctly (unless you perform the same manipulations as the ones I've carried out).

Regarding GameObject browser:
- it can't show all parentless gameobjects yet (when you reach the root of the gameobject hierarchy).
- it can't change components' numerical values yet, although it should be easy to implement.

Licence:
If you make a mod or an improved framework based on this project, please share the sources. I believe this type of license is called CC BY-SA.
I'll make a repository for it when things start moving. Right now I'm taking a break from it.

Regarding modding PoE in general:
- The UI system it uses is NGUI 2.6.5
It's an asset that in theory can be bought on Unity AssetStore for $95, but you won't be able to get this particular version, because it's very old, somewhere from spring 2013. And the new NGUI 3.7 is nothing like that old one, sadly - the syntax and a ton of things changed, it would be completely useless to you. However, it is possible to buy 2.6.4 on torrents. If you can't find it, PM me, I might be able to help you out :roll:. This is very useful because it allows you to try your code in your own Unity project. It'll save you tens of hours.
The documentation for 2.5 can be found on webarchive: http://web.archive.org/web/20130322004347/http://www.tasharen.com/?page_id=197 I didn't check if there was a way to get documentation exactly for 2.6.5, but it's quite similar.
- If you're unfamiliar with Unity, you *need* to watch some tutorials in order to understand its components system, gameobject hierarchy, etc. You'll probably need to make a few simple projects of your own, too.

About Unity's UI systems in general if you're just starting to mod. People often seem to be confused about it, so:
- Unity has a legacy UI system, which used to be its main UI system before 4.6 came out. It's the code you see in OnGUI(){...}. You can use it to make interface for debugging purposes, it's the UI you see in GameObject browser. It's ugly by default... it can be made beautiful, but it's complicated. The mouse clicks will go through the buttons created this way - the button will be pressed, and your character will also go where you clicked. To avoid this, you need to create a collider and place it under the buttons. You can find it in the project's examples.
- There's NGUI, a custom UI system, which is what PoE uses.
- There's the new 4.6 UI, which you will be able to use once they upgrade to 4.6. They promised to do that in a few weeks. This UI is probably the easiest to code and resembles NGUI in many ways.
 

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
Interesting thing.
Somebody from Obsidian asked me if I could share the sources for this tool with them a few days ago (only noticed the PM today). I suppose they could use such a tool to sometimes avoid waiting for 5 hours for the game to compile in order for the QA to test a small bug fix, because patching the dll directly is instantaneous.

That makes sense in theory, except this "tool" is so horribly coded :lol: that they could probably make a better one in less than an hour. So I lol'd, but still sent it to them, asking if they could maybe share their improved version of it in case they actually decide to work with it. If that happens and they do decide to release their improved version, this will be really really good. The chances are low, though.
 
Last edited:

Abu Antar

Turn-based Poster
Patron
Joined
Jan 19, 2014
Messages
13,582
Enjoy the Revolution! Another revolution around the sun that is. Shadorwun: Hong Kong Divinity: Original Sin 2 Pillars of Eternity 2: Deadfire Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
Interesting thing.
Somebody from Obsidian asked me if I could share the sources for this tool with them a few days ago (only noticed the PM today). I suppose they could use such a tool to sometimes avoid waiting for 5 hours for the game to compile in order for the QA to test a small bug fix, because patching the dll directly is instantaneous.

That makes sense in theory, except this "tool" is so horribly coded :lol: that they could probably make a better one in less than an hour. So I lol'd, but still sent it to them, asking if they could maybe share their improved version of it in case they actually decide to work with it. If that happens and they do decide to release their improved version, this will be really really good. The chances are low, though.
You fool. You should have asked for a job or compensation. In due time, you would have overtaken the position of lead programmer.
 

Johannes

Arcane
Joined
Nov 20, 2010
Messages
10,521
Location
casting coach
Interesting thing.
Somebody from Obsidian asked me if I could share the sources for this tool with them a few days ago (only noticed the PM today). I suppose they could use such a tool to sometimes avoid waiting for 5 hours for the game to compile in order for the QA to test a small bug fix, because patching the dll directly is instantaneous.

That makes sense in theory, except this "tool" is so horribly coded :lol: that they could probably make a better one in less than an hour. So I lol'd, but still sent it to them, asking if they could maybe share their improved version of it in case they actually decide to work with it. If that happens and they do decide to release their improved version, this will be really really good. The chances are low, though.
You fool. You should have asked for a job or compensation. In due time, you would have overtaken the position of lead programmer.
You're assuming he doesn't have a better job then lead programmer of Obsidian already.
 

Abu Antar

Turn-based Poster
Patron
Joined
Jan 19, 2014
Messages
13,582
Enjoy the Revolution! Another revolution around the sun that is. Shadorwun: Hong Kong Divinity: Original Sin 2 Pillars of Eternity 2: Deadfire Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
Interesting thing.
Somebody from Obsidian asked me if I could share the sources for this tool with them a few days ago (only noticed the PM today). I suppose they could use such a tool to sometimes avoid waiting for 5 hours for the game to compile in order for the QA to test a small bug fix, because patching the dll directly is instantaneous.

That makes sense in theory, except this "tool" is so horribly coded :lol: that they could probably make a better one in less than an hour. So I lol'd, but still sent it to them, asking if they could maybe share their improved version of it in case they actually decide to work with it. If that happens and they do decide to release their improved version, this will be really really good. The chances are low, though.
You fool. You should have asked for a job or compensation. In due time, you would have overtaken the position of lead programmer.
You're assuming he doesn't have a better job then lead programmer of Obsidian already.
He wouldn't spend his time with us if he had. :troll:
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
I was a bit curious and checkout out the unity new gui thing that took so many years to do

:lol:

no svg support for a new, multiple target systems gui library, really? I had svg support in java looks and feels from 2005! Not to mention the pathetic layout code. Doomed to reinvent badly indeed. Also no notion of separation of looks from GUI elements (CSS). Is there even a docking framework in there? I know there is a sorta clumsy animation editor.i
 
Last edited:

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
Adapted the code for the new version and added a few really tiny things. Download here.

What's new:
- Custom options will now allow you to test what Sensuki's been talking about - combat without engagement.
- If you're a hardcore nostalgia fag, you can have IE-like cyan blue circles instead of TOEE-like blue. Also blue circles themselves are now optional.
- You can turn off highlights for things that basically don't require it.

I play like this:

modv392.jpg


In case anyone has any suggestions for what to add next, post them. I might implement them.

Edit: found a little bug - the highlight will also be disabled for AOE abilities that require you to approach in order to cast them. Will fix in next version.
 
Last edited:

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Will this stuff work on a hypothetical linux build or does it depend on a microsoft specific api?
 
Last edited:

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
Will this stuff work on a hypothetical linux build?
The patcher itself might, but I'm only releasing a patched assembly right now and it's for a windows version. Same goes for mac.

Uhm, is there a simple way to apply it? I am pretty dumb.
Yeah, put the Assembly-CSharp.dll into steamapps\common\Pillars of Eternity - Public Beta\PillarsOfEternity_Data\Managed replacing the old one.
 

Athelas

Arcane
Joined
Jun 24, 2013
Messages
4,502
Well, that feels much better. Not a surprise though. Animations will need some adjustment, since in lieu of engagement the enemies have the habit of gliding around.
 

Sensuki

Arcane
Joined
Oct 26, 2012
Messages
9,800
Location
New North Korea
Codex 2014 Serpent in the Staglands Shadorwun: Hong Kong A Beautifully Desolate Campaign
Yeah that's basically the only problem with it. I can reproduce those issues with Engagement in, I think. Once I do, I'll report them.
 

Athelas

Arcane
Joined
Jun 24, 2013
Messages
4,502
Next up on the modding agenda should be the removal of the strict separation between the combat state and non-combat state, if not fully, at least for certain abilities/status ailments/buffs.
 

Sensuki

Arcane
Joined
Oct 26, 2012
Messages
9,800
Location
New North Korea
Codex 2014 Serpent in the Staglands Shadorwun: Hong Kong A Beautifully Desolate Campaign
Well I don't think that's possible to remove, but it's easy to make spells work in the non-combat state. Mutonizer did it way back in v278 I think.
 

Athelas

Arcane
Joined
Jun 24, 2013
Messages
4,502
But can you drag the separate portrait icons and align them vertically on the right side of the screen? :P
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
if you could resize the console that would be useful
 

J_C

One Bit Studio
Patron
Developer
Joined
Dec 28, 2010
Messages
16,947
Location
Pannonia
Project: Eternity Wasteland 2 Shadorwun: Hong Kong Divinity: Original Sin 2 Steve gets a Kidney but I don't even get a tag. Pathfinder: Wrath
Adapted the code for the new version and added a few really tiny things. Download here.

What's new:
- Custom options will now allow you to test what Sensuki's been talking about - combat without engagement.
- If you're a hardcore nostalgia fag, you can have IE-like cyan blue circles instead of TOEE-like blue. Also blue circles themselves are now optional.
- You can turn off highlights for things that basically don't require it.

I play like this:

modv392.jpg


In case anyone has any suggestions for what to add next, post them. I might implement them.

Edit: found a little bug - the highlight will also be disabled for AOE abilities that require you to approach in order to cast them. Will fix in next version.
Disabling engagement completely strips this mechanic out of the game? Does this have any downside?
 

Athelas

Arcane
Joined
Jun 24, 2013
Messages
4,502
Disabling engagement completely strips this mechanic out of the game? Does this have any downside?
None, unless you're a sadomasochist.

Though I'm noticing some issues with enemies jogging in place or standing completely still in combat, not doing anything. Of course this could be a bug of the beta proper rather than the removal of engagement.
 

Bester

⚰️☠️⚱️
Patron
Vatnik
Joined
Sep 28, 2014
Messages
11,122
Location
USSR
Disabling engagement completely strips this mechanic out of the game? Does this have any downside?
The mod simply adds a condition that for an engagement to happen, this checkbox needs to be unchecked. Otherwise, nothing else is touched or changed, so whatever you see happening in combat would also happen if you were playing an unmodded version.

But can you drag the separate portrait icons and align them vertically on the right side of the screen? :P
Yeah, vertical alignment will be possible, hopefully. (without the need to drag them individually)

Here's the repository btw and here's the mod's readme and the latest version.
 
Last edited:

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom