Writing custom code

Started by Mark, March 17, 2014, 10:48:22 AM

Previous topic - Next topic

Mark

Hello! I would like to write some custom code for the AI of the rimworld inhabitants. I've read through the manual ludeon posted, but it holds little information of how to actually go about it. For example I wanted to implement that an inhabitant who is searching for materials in a certain radius, does not only check the air-distance to the material, but also the walking distance to it. An inhabitant would compare at most 10 different materials in his or her searching radius, and head towards the resource closest in walking distance. I have a list in my head of things that id like to try out with the AI engine, but I lack some sort of starting point. (I have over 6 years of programming experience in multiple languages).
to space,

Mark

JackQW

Hey Mark,
In Alpha 2 there are problems with compiled code mods.
With quite a bit of effort, you may be able to use the approach used in the RWSandboxMod sample I posted to modify the AIKing and related AI namespaced components.
I suggest using ILSpy or Reflector to examine the dlls in the Managed directory, and get familiar with the 'analyze' function to examine inheritance of the various components.
I tried to generate a class diagram and failed... but you can start at the 'Find' class.
Might be easier to wait for Alpha 3.

Architect

I think most people at the moment are using ILSpy :) If it's advice you're looking for, you can do no better than JackQW from what I've seen XD Well, apart from maybe Tynan. Darker also seems to have a pretty good mind for it all, so it might be worth following anything he pops up with :P
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Cala13er

Darker uses .Net reflector and ILSpy. I believe, And ILSpy is the best for me. As there is a way to read the compiler generated code.

Mark

#4
Thanks for the replies. Modding seems to be limited to adding new game objects, and not really for changing the game logic. I think its best for me to wait for the Alpha 3 release before I delve into AI modding. I'm hoping that there will be some sort of documentation to the relevant dll's and official software tool recommendations for all the types of modding, as in what software to use to make new game objects, for modifying AI, for modding the Storyteller, etc. and possibly some example code. I'm a (hobby) programmer, no resource hacker, as I assume most of you guys are as well and I find these demands to be quite basic for a community to actually produce useful content. (My curiosity got the better of me I just downloaded ILSpy)
-Mark

[edit] actually, it seems Ive found what Ive been looking for.

Ive found something interesting: int the Dll Assembly, the class ReachabilityRegions in its function Reset() are three For loops, they iterate through three dimensions specified es x,y and z. Possibly this third dimension is not fully implemented yet and is a feature yet to come (Gnomoria style)

Rokiyo

#5
At this stage it's looking like we'll need to develop that documentation as we go, as a community project (hopefully on a wiki or something similar).

There's no need to feel bad about using ILSpy: Tynan has given us his blessing to decompile, read through and discuss the dlls, and none of the mod testing that has been done so far for Alpha 3 would have been possible without doing that. We have not been given source files or API documentation or anything like that (which is understandable, considering the development team of one that is building this game!).

In short: Go for it, and keep some notes so that you can share your learnings with us later. :)

Mark

How do you guys recompile the DLL's ? I use eclipse for Java/C/C++ but its not working too well for DLL recompilation. Over at Stackoverflow stackoverflow.com/questions/7388985/dotnet-dll-decompile-and-change-the-code THEY suggest the following:
"I've had limited success in recompiling DLLs. A better way of going about it is to using Reflector and the Reflexil plugin. You need to have a bit better knowledge of the IL code that makes up .NET assemblies but Reflexil does a great job of describing the OP codes [...]"
I'd be happy to hear from anyone whos attempted to recompile a DLL..

Architect

Quote from: Mark on April 05, 2014, 08:18:59 AM
How do you guys recompile the DLL's ? I use eclipse for Java/C/C++ but its not working too well for DLL recompilation. Over at Stackoverflow stackoverflow.com/questions/7388985/dotnet-dll-decompile-and-change-the-code THEY suggest the following:
"I've had limited success in recompiling DLLs. A better way of going about it is to using Reflector and the Reflexil plugin. You need to have a bit better knowledge of the IL code that makes up .NET assemblies but Reflexil does a great job of describing the OP codes [...]"
I'd be happy to hear from anyone whos attempted to recompile a DLL..

Sorry dude, I'm not the right person to answer these questions, but I'm interested to learn. Can I just ask what you mean by recompile a DLL as opposed to just compiling one?
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Cala13er


Architect

Quote from: Cala13er on April 05, 2014, 08:25:40 AM
Visual Studio Ultimate.

For compiling maybe, but I use the free express version, ultimate is really not necessary for those of us who don't have a spare £11,000 to fling at a modding community. This guy said recompiling though, in which case he either means compiling, or I don't understand. One way or another, an answer would be nice if you can provide one?
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


mrofa

Hello mate i got a question for the dll.
How do you extract data from it and how do you make new one ?
All i do is clutter all around.

Architect

Quote from: mrofa on April 05, 2014, 10:54:09 AM
Hello mate i got a question for the dll.
How do you extract data from it and how do you make new one ?

I think most of us use ILSpy to decompile the DLLs. It's literally just a case of opening up the file using ILSpy for that. As for making them, most people either use Microsoft Visual Studio, or MonoDevelop, both of which are very good at their jobs, and both of which are free for what we need. I can give you further instruction for Visual Studios if you wish, but I have never used MonoDevelop, so I dont know much about it.
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Mark

By 'recompiling' I simply compiling the decompiled code. Anyways, I'm using Reflector with the Reflexil add-in and it seems to work. I did some researching on the DLLs and this is what I've figured till now:
mscorlib - .net base class library
Vectrosity - fast and easy Line drawing for the Unity engine
Boo.Lang  - "a established object oriented statically typed programming language for .NET and Mono.
Mono. is a software platform designed to allow developers to easily create cross platform applications.

It seems to me that the only DLL that can be changed is Assembly, or am I mistaken? As I understand it the complementary DLLs are only libraries? Architect, which DLLs have you modified?