Jump to content

Help Adding New Journal Entries


Laokia

Recommended Posts

Hello,

 

First off, thank you for taking the time to read this. Really, it is greatly appreciated.

 

I have just finished putting together a private mod for this game, just for playing the game with my sister. The mod uses various bits and bobs from other mods, so I will in no way be making it public. Unfortunately, my computer can barely run the base game, let alone the large and amazing looking mods people have made. I've tried them, but... While I am used to frames dipping into the single digits, when they remain that low for too long playing becomes unbearable.

 


 

My mod includes custom quests with tooltips. However, when calling these tips normally the log is overrun with errors trying to actually read/write the journal entries. After digging around I did find the section in the AssemblyC-Sharp.dll file that has the journal entries. Editing that is where I ran into a wall. My knowledge of C# is extremely basic. While it is something I am interested in learning, at the moment I am... Well, not in the best place emotionally and mentally. Oddly enough, while working itself helps keep my mind off things, for some reason trying to learn does the opposite.

 

I hate to ask this, but I have searched around for a while and could not find any answers. Could someone help me with possibly creating a patchscript/script in SDX that will add custom journal entries to the list present in the assembly file? Alternatively I could use a tool to manually edit the file, but re-compiling the de-obfuscated code requires me to do more than just adding the entries to the list, and that is where I am at a bit of a loss.

 

If someone could help me with this, I would be extremely grateful. I would also love if the code could be explained because as stated this is something that I do want to learn. In the meantime I have used existing tips/journal entries for my quests and just removed those tips from the items/blocks that gave them. It works, but I would prefer just being able to add new entries.

 

Again, thanks so much!

Link to comment
Share on other sites

Sure, at least I will try. I'm not sure exactly what examples to post, I'll start with the section in the C-Sharp file I'm talking about I suppose? I know that Starvation Mod has added new entries onto the list. I'm not 100% sure that adding the tips to the list will actually enable those tips to be read/written to the journal properly or if there are other steps.

 

Er, is it allowed to show Starvation Mod's edit of the file I'm referencing? I don't want to be stepping on toes or anything... I'll add it for now but if I need to remove it please let me know and I will do so.

 

The first image is of the public class 'Player Journal' in the un-modified Assembly-CSharp DLL. The second is of the same class within the Starvation Mod. Vanilla tips end at 'passthroughTriggeringTip', starvation has added a few custom tips to the end of the list. Sorry about the size, I don't have a high resolution and making the text smaller was having a big impact on readability.

 

ScreenShotJournalCSharpStarvation.jpg.d548d5ba67a8bd3f58dbccd0a2ebfdd0.jpg

 

EDIT: Okay, so... I didn't realize that the images would be shrunk like that. I'm trying to upload them and get direct links off-site, but my internet is barely chugging along today.

 

Here-

Vanilla C-Sharp

 

Starvation C-Sharp

ScreenShotJournalCSharp.jpg.1126479e80374f56cdd476bf7caebdb5.jpg

Link to comment
Share on other sites

Yeah, I figured, but wasn't sure, so thank you. I was asking for help with the code for the patch script because I have very little knowledge of C#. Eventually I will be able to actually focus on learning more, but I can't envision that happening for a few months at least, which is why I'm even asking...

 

Sorry I'm exhausted and lost my train of thought. ^^'

Link to comment
Share on other sites

Here you go. Just fill in the tips you want to add in the Patch method. The number at the end has to be unique and not already used by the enum. I can't remember why I used a byte and not an integer but if you have a lot of tips to add (total 127+) you may need to change the variable type. Int32 should work fine.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Mono.Cecil;
using Mono.Cecil.Cil;
using SDX.Compiler;

public class EnumPatcher : IPatcherMod
{

   public bool Patch(ModuleDefinition module)
   {

       AddEnumOption(module, "PlayerJournal", "JournalTipEntry", "myNewTip", 55);
       AddEnumOption(module, "PlayerJournal", "JournalTipEntry", "myOtherTip", 56);

       return true;
   }

   private void AddEnumOption(ModuleDefinition gameModule, string className, string enumName, string enumFieldName, byte enumValue)
   {
       var enumType = gameModule.Types.First(d=> d.Name == className).NestedTypes.First(d => d.Name == enumName);
       FieldDefinition literal = new FieldDefinition(enumFieldName, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault, enumType);
       enumType.Fields.Add(literal);
       literal.Constant = enumValue;
   }

   public bool Link(ModuleDefinition gameModule, ModuleDefinition modModule)
   {
       return true;
   }

}

Link to comment
Share on other sites

Thank you so much! I doubt I will have very many tips to add, but I understand enough to change the variable if needed. I can read a code and see what it is doing most of the time. Having this as an example when I am able to learn C# will be super helpful as well- I find it easier to learn when I have practical examples to review.

 

Sorry that my reply is kinda lame. I haven't been sleeping lately. Actually, I wrote out one reply and accidentally pressed the 'Reply to Thread' button again rather than pressing the button to post the reply. Definitely not at my brightest...

 

Thank you!

Link to comment
Share on other sites

  • 7 months later...
Here you go. Just fill in the tips you want to add in the Patch method. The number at the end has to be unique and not already used by the enum. I can't remember why I used a byte and not an integer but if you have a lot of tips to add (total 127+) you may need to change the variable type. Int32 should work fine.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Mono.Cecil;
using Mono.Cecil.Cil;
using SDX.Compiler;

public class EnumPatcher : IPatcherMod
{

   public bool Patch(ModuleDefinition module)
   {

       AddEnumOption(module, "PlayerJournal", "JournalTipEntry", "myNewTip", 55);
       AddEnumOption(module, "PlayerJournal", "JournalTipEntry", "myOtherTip", 56);

       return true;
   }

   private void AddEnumOption(ModuleDefinition gameModule, string className, string enumName, string enumFieldName, byte enumValue)
   {
       var enumType = gameModule.Types.First(d=> d.Name == className).NestedTypes.First(d => d.Name == enumName);
       FieldDefinition literal = new FieldDefinition(enumFieldName, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault, enumType);
       enumType.Fields.Add(literal);
       literal.Constant = enumValue;
   }

   public bool Link(ModuleDefinition gameModule, ModuleDefinition modModule)
   {
       return true;
   }

}

files now in a17

Are there any ways to do this without modding the dll files now in a17. I want to continue to use the quest pop up window but get a constant error in the f1 log. Doesn't seem to mess up gameplay so far but it can't be good

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...