While the corpses of spawned characters aren't persistent, the corpse of the original character *is* persistent, and it should be possible to get it to spawn multiple times.
I'm thinking that there needs to be an unholy alliance between the CharacterScripts and Story Scripts to make this happen.
I just tried this and it didn't work-
Character Script-
INIT
INT:%canRespawn=0
CHARACTER:%parentCharacter=null
EVENTS
EVENT Respawn
VARS
CHARACTERTEMPLATE:_myTemplate
FLOAT3:_myPos
CHARACTER:_spawned
ON
OnInit()
ACTIONS
IF "c1&c2&c3&c4"
IsEqual(%canRespawn, 1)
CharacterIsDead(__Me)
GetPosition(__Me, _myPos)
CharacterGetTemplate(__Me, _myTemplate)
THEN
SpawnCharacter(_spawned, _myTemplate, _myPos, 1)
Set(%canRespawn, 0)
CharacterVisible(__Me, 0)
CharacterEvent(__Me, "PrepRespawnTarget")
CharacterEvent(_spawned, "PrepRespawnSource")
ENDIF
EVENT PrepRespawn
ON
OnDie(__Me,_,_,_)
ACTIONS
IF "!c1"
IsEqual(%parentCharacter, null)
THEN
CharacterEvent(__Me, "SetRespawnChild")
CharacterEvent(%parentCharacter, "SetRespawnParent")
ENDIF
Story-
IF
CharacterDied(_Char)
THEN
CharacterSetVarInteger(_Char, "canRespawn", 1);
IF
CharacterEvent(_Char, "PrepRespawnTarget")
THEN
DB_TempRespawnParent(_Char);
IF
CharacterEvent(_Char, "PrepRespawnSource")
AND
DB_TempRespawnParent(_parent)
THEN
CharacterSetVarCharacter(_Char, "parentCharacter", _parent);
NOT DB_TempRespawnParent(_parent);
IF
CharacterEvent(_child, "SetRespawnChild")
AND
CharacterGetPosition(_child, _x, _y, _z)
THEN
DB_TempPos(_x, _y, _z);
IF
CharacterEvent(_parent, "SetRespawnParent")
AND
DB_TempPos(_x, _y, _z)
THEN
CharacterTeleportToPosition(_parent, _x, _y, _z, "NinjaTeleportRespawn");
CharacterSetVarInteger(_parent, "canRespawn", 1);
NOT DB_TempPos(_x, _y, _z);
The problem I think is that the spawned stuff doesn't trigger the OnDie event either, meaning that none of the other stuff happens (SetVisible to 0 didn't appear to work on corpses either).
Now that I think about it a bit more, I think the solution would need to be the following:
1. If the original character is dead, it should always spawn a character at it's current position OnInit(). This is because the spawned characters will go away upon reload/map changes
2. Should a spawned character die, somehow it needs to teleport the original character to its position so that when it next spawns another character, it's where the character 'died' last
The problem is number 2 I think, since spawned characters can't trigger anything upon death. Maybe I could do something with OnDamage?
Edit:
By the way, what is the proper way to overwrite a Main campaign script (like DefaultCharacter)? I think I'm doing it somewhat wrong, because while my changes work the game editor throws a ton of errors and I can only Build the Story once per Editor load.