gametechmods

Robot Arena => Modifications => Topic started by: CodeMoose on June 19, 2016, 03:48:40 PM

Title: Modding RA3
Post by: CodeMoose on June 19, 2016, 03:48:40 PM
Since RA3 is built on Unity and I'm pretty familiar with how that works (sort of), I thought I would take a look at how difficult it would be to mod the game. Also considering the second Q&A post by the developers contained the following:

 > I'd also like to ask if any modding tools will be supplied by Octopus Tree
Not at initial release. Between us, Unity games are HIGHLY MODDABLE without any support required on the Dev side. Clever folks can actually hook right into the C# mono code.

I thought they wouldn't mind if I took a look.

So I spent a few days investigating and coming up with a way to modify the C# IL (similar to how other Unity game mods do it - with Mono.Cecil). Then I coded up a few examples of how you could alter the code, by adding a couple of export buttons and a new component.

The code isn't much more than a proof of concept (so expect issues if you try to use it) but I'm hoping it might serve as a useful resource for other people to start modding RA3, or even for fixing issues. I put it up on GitHub over at: https://github.com/CodeMooseUS/ra3-tweaks.

Here is a picture of the example weapon I added to my bot (I call him 'ChopSalad'):
(https://gametechmods.com/uploads/images/98917ra3-tweaks.gif)
Title: Re: Modding RA3
Post by: Badger on June 19, 2016, 03:52:29 PM
looks sweet, wonder how this will interact with online play. I highly doubt that the devs bothered to check that all the components on a bot are stock, or that both players have a modded component installed.
Title: Re: Modding RA3
Post by: CodeMoose on June 19, 2016, 04:03:19 PM
Good question. I imagine if only one person has the component it might crash. If both have the same modded code running though it would probably work. But you are right in that there are no checks (at least as far as I know).
Title: Re: Modding RA3
Post by: Silverfish on June 19, 2016, 04:40:45 PM
Looks nice, man! I can see you going places.
Please have mercy on me when you get admin.
Title: Re: Modding RA3
Post by: RedSawn on June 19, 2016, 05:47:36 PM
I was just wondering if when we'd see something. Excellent.
Title: Re: Modding RA3
Post by: Scrap Daddy on June 19, 2016, 05:51:03 PM
lmao dev team, hire this man.
Title: Re: Modding RA3
Post by: FOTEPX on June 19, 2016, 06:47:09 PM
Now the race is on - will the GTM community patch the game before the actual designers, or will the designers pull their thumbs out of their ass?
Title: Re: Modding RA3
Post by: SharkyPRS on June 19, 2016, 07:02:04 PM
Did you make physics tweaks?  I see the bot bouncing around a bit a doing a bit of wheelie when it moves.  Looks sweet so far.
Title: Re: Modding RA3
Post by: J on June 19, 2016, 07:44:27 PM
So.....

.......

How long until RA3 has a Steam Workshop?
Title: Re: Modding RA3
Post by: Tashic on June 19, 2016, 08:22:03 PM
Very interesting! How did you made that component and how did you import it into the game?
Once I finish these BS exams I might help with this.
Title: Re: Modding RA3
Post by: CodeMoose on June 19, 2016, 11:34:10 PM
My original idea was to design a system where you can just add small tweaks to methods in the original game to fix issues. For instance I just updated the GitHub repo with a small tweak that now draws a line between the last vertex and the mouse cursor when building the chassis baseplate (just like RA2 used to have).

(https://gametechmods.com/uploads/images/52702ra3-tweaks-chassis.gif)

That being said, I also added code to tweak the methods that load up components like seen in the first post. Essentially there are 2 that I changed. The first loads up the list of all components in the game (from a JSON file). I hooked into this function and made it append a second set of json to the end that describes the new components I want to add (just the dagger shown in the first post). That json file has an entry that says what Unity prefab to load when you add the component. So the second method I hooked is the one that loads the prefabs. I check to see if the prefab it is looking for is one I've added and if it is, I load it up from a Unity asset bundle I created (if not I just let it load as normal).

So to create the new components, you have to use Unity (free personal version works fine - its what I have) to create a new gameObject and pack it into an asset bundle.

To do that you basically create a new Unity gameobject that has a child gameobject containing the model mesh, and the physics collider (if you've ever used Unity you'd know this is just a normal sort of thing you would do). You also add a child gameobject called 'AttachPoint' that gets converted into an object where RA3 should attach the component when you add it. Then you put it into an asset bundle using the Unity asset bundle option, and then build the bundle (I included an editor script in the GitHub Unity project that will build it for you from the Assets menu). The components.json file is also included in that asset bundle. That probably all sounds like nonsense, but its actually pretty straight forward once you see it in action.

The system could be improved to use multiple asset bundles or something, and there is no way to specify the type of attach point right now (fixed, motor, wheel, swing, socket, plug, etc). But it is just a proof of concept right now.
Title: Re: Modding RA3
Post by: WeN on June 20, 2016, 01:57:43 AM
interesting. I can create papyrus on RA3.
Title: Re: Modding RA3
Post by: Serge on June 20, 2016, 09:15:03 AM
Great job!
As the game actually works under mono/wine on Linux, I might join in on the fun later on - once I actually learn some more Unity and C# :/. However, doing some RA2/RA3 component conversion might be right up my alley.

I assume the game assembly .dll is not obfuscated, right?
Title: Re: Modding RA3
Post by: CodeMoose on June 20, 2016, 12:30:02 PM
It is not obfuscated, which I am very thankful for. You would need to flesh out the rough component importing system somewhat before attempting to convert any RA2 modded components. Static weapons like blades and spikes might be easy, but it can't do wheels or motors... yet(?)

As an interesting side note, the components.json format that the RA3 game uses, contains entries for RA2 model names, and they have code to convert the metadata from the old format (though I don't see it getting called anywhere). I think they must have manually converted the model meshes though, since I don't see code to read in gmf formats.
Title: Re: Modding RA3
Post by: RedSawn on June 20, 2016, 12:39:35 PM
I can't think of a component that looks like the model has been ripped straight from RA2. Maybe the Power Steering Unit comes close. Curious they even have it, though.
Title: Re: Modding RA3
Post by: CodeMoose on June 20, 2016, 12:42:36 PM
Perhaps it was used for testing before they had new models and left the code in there?
Title: Re: Modding RA3
Post by: toAst on June 25, 2016, 05:11:58 PM
oh this just made my day  :redface: god speed to you all
Title: Re: Modding RA3
Post by: R01 on July 16, 2016, 03:19:34 PM
Perhaps it was used for testing before they had new models and left the code in there?
Code to convert the RA2 components? Now that's something I'd definitely like to have(but I guess that part was already removed?)
Title: Re: Modding RA3
Post by: Sage on July 16, 2016, 05:47:54 PM
Perhaps it was used for testing before they had new models and left the code in there?
Code to convert the RA2 components? Now that's something I'd definitely like to have(but I guess that part was already removed?)

Why would you need to convert RA2 components? RA3 already has them all

/s
Title: Re: Modding RA3
Post by: R01 on July 16, 2016, 06:32:46 PM
Perhaps it was used for testing before they had new models and left the code in there?
Code to convert the RA2 components? Now that's something I'd definitely like to have(but I guess that part was already removed?)

Why would you need to convert RA2 components? RA3 already has them all

/s
Saw the /s. I'm more interested in exporting RA2's components into a format that can be used by 3d model editors so we can go forwards and backwards between the file formats/because I'd like to do a mod for balanced stock and would really love to have the original components as a reference.