Hello,
Thank you Rhidian for all the info. I am currently working and learning about charscripts, and I found this post to be the most useful regarding the subject.
Charscripts appears to be the most effective way to script NPC state management and routines -like habits, patrols- that can be overrided/suspended by Osiris whenever a Player interact with said NPC. I have found using Osiris alone doesn't give me enough freedom because some Osiris calls (CharacterUseItem, (Proc)CharacterMoveToTrigger...) override everything, including NPC generic behaviors like reactions to stealing and vandalizing. This is the reason why I want to experiment with charscripts.
I actually have a hard time implementing it. I have followed Rhidian's instructions: I created a Package under my Mod in the Resource Manager and imported my created charscript into it... which allows me to add the script in the SideBar properties of the NPC Character.
Unfortunately, with such a configuration, whenever I playtest the game in the editor, I receive a ton of errors non-stop: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt".
So I kind of know where this error comes from. The content of the Main infrastructure is read-only and shouldn't be messed up with... but I don't understand why it throws this error in this specific scenario...?
There are things I should add to better describe the situation:
- In the Resource Manager, I first tried to import my charscript into the Main/Assets/Scripts/Scripts package. Thus I could add the script to the Character, but it throwed the memory error.
- Then I moved the script into a newly created package under the Mod ID -as described here- so that I thought it won't mess up with the Main package. But the error was still throwned whenever I add the charscript to the Character and hit Play.
- I have tried it with and without the patched LSToolFramework.dll in order to remove the main module protection. I used the Steam Verify Cache after deleting the dll to recover the proper one, so I tried with both, to no avail.
At this point I am quite clueless about what to do. I might try to do a backup of my Mod Data and try again on a fresh install of the Divinity Engine.
I'll report my findings, meanwhile if anyone have a clue about what's happening with this error in this context, I'll be very happy :)
Good day