Thanks for the help FromHolland, I think I finally have a fix on how to overwrite the Main Campaign charScripts successfully (even if it throws a few errors).
Here's the method (if I got it correct)-
1. Create a charScript in your mod's Public/(Mod Name)/Scripts/ folder that has the same name and contents as the charScript you're trying to overwrite (ie DefaultCharacter.charScript if you're overwriting DefaultCharacter, copy/pasting the contents as well)
2. In the Editor in the Resources Manager, create a Package for your mod
3. In the Resources Manager, click the Main folder and find the script you're trying to overwrite. Right click that and click "Copy to my mod". In the window that pops up, select the package created in Step 2 (should be auto-filled)
4. In the Resources Manager, click your Package and the script that is now there. With the Sidebar (from View), change the SourceFile path from Public/Main/Scripts/(original script file) to Public/(Mod Name)/Scripts/(your script file)
5. You can now edit your mod's file and have it overwrite successfully (although a lot of errors may still be thrown when saving changes)
I'm pretty close to where I want this mod to be, but there's still one big issue that I'm hoping to resolve (more of an annoyance really, not a CTD error). Here's what I have:
Modified parts of DefaultCharacter
INIT
INT:%canRespawn=0
CHARACTER:%spawn=null
FLOAT3:%spawnPos=null
EVENTS
EVENT RespawnCharacter
VARS
CHARACTERTEMPLATE:_root
FLOAT3:_myPos
ON
OnInit()
ACTIONS
IF "c1&c2&c3&c4"
IsEqual(%canRespawn, 1)
CharacterIsDead(__Me)
CharacterGetTemplate(__Me, _root)
GetPosition(__Me, _myPos)
THEN
IF "c1"
IsEqual(%spawnPos, null)
THEN
Set(%spawnPos, _myPos)
ENDIF
SpawnCharacter(%spawn, _root, %spawnPos, 0)
ENDIF
EVENT ProgenyDeath
ON
OnDie(%spawn,_,_,_)
ACTIONS
GetPosition(%spawn, %spawnPos)
Set(%spawn,null)
Set(%canRespawn, 0)
CharacterEvent(__Me, "CheckForRespawn")
Story code:
IF
CharacterEvent(_Char, "CheckForRespawn")
THEN
CharacterSetVarInteger(_Char, "canRespawn", 1);
The way it works is that when the original character dies the first time, they set the %spawnPos to _myPos (where they died) so that the next progeny will respawn where they died.
...I just realized, in the middle of writing this post, that this code shouldn't work. canRespawn starts at 0, and theoretically the it shouldn't be spawning any other characters until canRespawn is set to 1. The only thing that sets it to 1 though is the OnDie event which should only be triggering when the spawned characters die.
In anycase, the way it works in-game from my testing is that the characters die, and on reload spawn characters where they died. If the spawned characters move and then die, the next time that they are respawned they are where they died last.
The biggest issue is that there is a huge lag spike when any character dies. I am thinking that it is due to the game processing the OnDie event. The problem, though, is that it seems to be doing this when the original characters die as well. With what I noted above, it seems as if it's doing the OnDie event whenever the character dies, regardless of whether it's the original or the spawned character.
@Vortaka- Whenever I get this to work correctly, the time between respawns can be changed. I am hooking the canRespawn variable to a Story event so that I can check all of the additional conditions as well when a character dies to see if they can respawn. Right now in my test builds it's set to respawn all of the time, but later on it should incorporate both a time delay and the skill toggle.
Edit:
After more testing, it seems that the OnDie command triggers whenever the character with the charScript dies, even if %spawn is a different character. Either that or a character of null defaults to __Me instead.