Announcement

Collapse
No announcement yet.

ScriptReplacer

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Patch] ScriptReplacer

    The main problem with things like ModManager and ArchiveReplacer is that they don't work for script files. If you want to add or modify script files, you have to use Deflarc.

    Or this.

    Requirements

    ReiPatcher, Cecil.Inject

    Installation

    1. Use CM3DTool to extract all .arc files whose names begin with "script" and tjs.arc.
    2. Copy the contents of the "Managed" directory to CM3D2x[86|64]_Data\Managed, the contents of the ReiPatcher directory to your patches directory, run ReiPatcher.

    Technical Stuff

    Spoiler
    So, what's the difference between how Deflarc works and how the other file loading plugins work?

    Answer: Deflarc changes the file system object to one that works differently, while the others intercept calls to the file system object. Since the former approach worked for scripts and the latter didn't, it was my theory for a while that the script engine had to be doing something at the unmanaged code level. I only noticed recently that ScriptManager has an instance field that gets pointed at GameUty.FileSystem rather than just referring to it directly like pretty much everything else. Put a properly set up FileSystemWindows object there instead, and you get this plugin.

    Well, there's also the matter of making it not crash. Adding a hook to call the dispose method and null the object in ScriptManager's Dispose method seems to have dealt with that.
    Attached Files
    Last edited by hiremi; 07-20-2016, 11:55 PM.

  • #2
    OGG, TJS and KS do use unmanaged code located in cm3d2x(86|64).dll

    Deflarc replaced FileSystemArchive with FileSystemWindows, which is provided by CM3D2 itself, so other managed code can recognize it. ArchiveReplacer, and my plugin which is inspired by it, ModManager, intercepts calls to FileOpen and GetList so its more flexible, but fails to supply native handles of replaced files.
    CM3D2 Editor | CM3D2.ModManager

    Comment


    • #3
      Yep.

      In theory, OGG files could also be overridden by a similar approach to the one I'm using for scripts, but is anyone even interested in changing the sound?

      Comment


      • #4
        I found something strange with TJSScript class. TJSScript class read the object_data from the AFileSystemBase in the ctor, but in its all Eval/ExecScript variants, it takes a string as script or a AFileBase to evaluate the script. After upgrading my Visual Studio, I am going to investigate more whether a mismatch of AFileSystemBase/AFileBase will cause an error.

        EDIT: A detailed lookup in ILSpy suggests that KAG Script are not loaded via managed code, so probably there cannot be a solution with both arc & directory support for scripts.
        EDIT2: It seems that the CM3D2Tool cannot inject script files, so probably directory is the only method to replace scripts
        EDIT3: I am considering of implementing a KAGScript parser in C# so I can replace the managed one. Still not sure how much work will it take
        Last edited by MainVirtualizer; 09-27-2015, 09:53 AM.
        CM3D2 Editor | CM3D2.ModManager

        Comment


        • #5
          Originally posted by Johny96
          I have little problem, where can I get "CM3D2.ArchiveReplacerHelper.Hook.dll"
          What the?

          ... Okay, looks like I screwed up when I changed the name to ScriptReplacer (because it's not dependent on ArchiveReplacer and I didn't want it to sound like it was, especially since ArchiveReplacer never even worked for me).

          Did no one else ever try to install this thing? Because it shouldn't have worked for them either. Anyway, I'll put out a fixed version sometime this evening.

          Edit: New version is up, which has a little refactoring for future-proofing and so forth in addition to fixing the actual problem.

          Also, in the original post I had this line: "When closing the game, there will be an error message about a memory leak."

          I've removed it, because it doesn't seem to happen anymore, but I'm not quite sure why, since when I originally made the addition I made to fix that problem it didn't help. So I'd particularly like to hear if anyone sees that happen again, and under what circumstances.
          Last edited by hiremi; 10-22-2015, 07:13 PM.

          Comment


          • #6
            Will, i just downloaded the "fixed" version, as stated above. And this is what I got when I attempted to install it.
            Spoiler

            I know that it is scriptreplacer because when I remove the two dll files I do not get the error. This looks like one of two things has happen. Either it was not fixed, or the wrong version of the patch was uploaded.

            Comment


            • #7
              probably a stupid question, can this used with deflarc? or is it a replacement for deflarc and you can't/don't need them both. just wanna ask b4 I install it break my game and have to reinstall every thing again. I tired of doing that

              Comment


              • #8
                I don't *think* it will break anything if used with deflarc, but it is completely redundant with deflarc - if you're using it, you gain nothing from having having this installed.

                ScriptManager only replaces one thing that deflarc does. However, put together with ModManager I'm only aware of one thing deflarc can do that they can't - let you modify the music and sound. (Which, as I've said before, I could make a mod to do too, if anyone is interested.) Installed mods are a lot easier to work with using ModManager than deflarc, so I'd recommend using that over deflarc, and then adding this if you want to use modded scripts.

                Comment


                • #9
                  Originally posted by Johny96
                  are you sure, it's working fine for me
                  I had downloaded it three times using the link above. And I have placed CM3D2.ScriptReplacer.Hook.dll in the CM3D2\CM3D2x64_Data\Managed directory. And I have placed CM3D2.ScriptReplacer.Patcher.dll in the CM3D2\ReiPatcher\Patches Directory. And every time I repatch I get the above shown message and ReiPatcher exits.


                  It is now 9:47am my local time. Will re-download with the link above and try one last time. I will edit this post with the result.



                  EDIT 10:09am my local time: I had just downloaded the archive again. And this time the timestamp for the archive is newer than the one I downloaded, multiple of times, yesterday.
                  I then reinstalled the files for ScriptReplacer and patched CM3D2. No errors were given this time. Will test it later on today. But, I believe that I should be working now.
                  Last edited by The WABBIT; 10-24-2015, 09:20 AM.

                  Comment


                  • #10
                    Originally posted by The WABBIT View Post
                    Will, i just downloaded the "fixed" version, as stated above. And this is what I got when I attempted to install it.
                    Spoiler

                    I know that it is scriptreplacer because when I remove the two dll files I do not get the error. This looks like one of two things has happen. Either it was not fixed, or the wrong version of the patch was uploaded.
                    I just double-checked the patcher in JustDecompile, and it makes no references to the old dll names. I think you've still got the old version of the patcher dll. Maybe you didn't overwrite existing files when copying the new ones in?

                    Comment


                    • #11
                      I'm wondering if I should use this patch for the Multiple maids plugin- it comes with some .ks files and I read this is the only patch that can handle these files- (sorry I'm not really good with this stuff)
                      ☆ Virtual Idol & Artist ☆ Kirakishou Lushia Harukajima ♫

                      :: Facebook :: Youtube :: Twitter :: Pixiv :: Deviantart :: Tumblr ::

                      Comment


                      • #12
                        okay, I just noticed... there's no download link ...?
                        ☆ Virtual Idol & Artist ☆ Kirakishou Lushia Harukajima ♫

                        :: Facebook :: Youtube :: Twitter :: Pixiv :: Deviantart :: Tumblr ::

                        Comment


                        • #13
                          You'll find the attached file on first page. (the very first post)

                          Comment


                          • #14
                            Attached is a version of ScriptReplacer that should work with the new Yandere personality, but it's untested since I don't have it yet.

                            Was broken and is removed.
                            Last edited by hiremi; 12-14-2015, 09:12 AM.

                            Comment


                            • #15
                              Tried the new version, for each line that have the Yandere maid's voice gives error

                              Comment

                              Working...
                              X