Save File gets corrupted after certain script

Hello. I've been using a script called "Pets and Summons" which allows my character to temporarily transform into another one for a limited amount of turns.

However, I run into an issue. When the transformed character wins a battle, everything works as intended. They transform back into the original actor, not the summoned actor. Everything actually works perfectly, except that when the summoned character wins a battle, the save file gets corrupted and deletes itself. This doesn't even happen 100% of the time too. It happens about 90% of the time or so.

I'm so confused, what about this script could cause it to corrupt the save file? I'll post the script in question too. Not sure what causes this, especially since it is not 100% of the time, but most of the time.

EDIT: After further testing it seems like only a select number of troops cause this issue? Certain troops don't corrupt the file but then on the other hand, some do. This is honestly the weirdest error I've ever encountered.
saving doesn't work that way - you are missing at least one additional component here.

either the actual destroying of the file happens from a third program (antivirus getting false-positive, cloudsync removing file after a bad sync, harddrive short of failure or a few other options), or a few other possibilities.
It might be a problem with constructing the save data? For example, maybe there are unhandled circular references. I know MV/MZ avoid this by making temporary backups of any existing file before attempting to overwrite, but I'm not familiar with VXAce's scripts/structure.
saving doesn't work that way - you are missing at least one additional component here.

either the actual destroying of the file happens from a third program (antivirus getting false-positive, cloudsync removing file after a bad sync, harddrive short of failure or a few other options), or a few other possibilities.
So you're saying that this is an external issue? Not as a result of the script?
I think I had the same error before (corruption on save) but not with this script.
from what I gathered from the post, it seems like he's spawning a battler out of thin air for the purposes of the battle alone, and then (maybe?) trying to save that battler back into the file as part of the party.

the script itself has no ties to the data manager, that I could see.
maybe that's the problem?
I just can't put myself to test it in detail.

So you're saying that this is an external issue? Not as a result of the script?
yes, most definitely.
I think I had the same error before (corruption on save) but not with this script.
from what I gathered from the post, it seems like he's spawning a battler out of thin air for the purposes of the battle alone, and then (maybe?) trying to save that battler back into the file as part of the party.

the script itself has no ties to the data manager, that I could see.
maybe that's the problem?
I just can't put myself to test it in detail.


yes, most definitely.
That's strange, though. It only happens when I activate this specific script. Nothing else. The battler spawns out of thin air and replaces the main actor. Also after some more testing, the corruption still happens even when the actor transforms back and the battle has ended. Again, this only happens with certain troops, not all of them.

It doesn't have ties to the data manager, but the database yes. Would it be beneficial if I sent the game on here?
Maybe there is a script incompatibility.
If it was just this script and only with the actors transformed, then resetting the actors before the victory might fix it. But only for that.
Ruby:
class Scene_Battle
    alias r2_update_pets_victory    update
    def update
      $game_party.restore_party if $game_troop.all_dead?
      $game_party.restore_party_end if $game_troop.all_dead?
      r2_update_pets_victory
    end
end
I’ve been trying to see if anything else causes the issue but it seems to be just this script. I’ll give it a go, and I’ll provide an update if this works or not

EDIT: Tried this, still no dice. I put that line underneath the script. Maybe I put it wrong?
It doesn't have ties to the data manager, but the database yes
maybe that's the problem.

the data manager is there for a reason.
maybe that's the problem.

the data manager is there for a reason.
Well, what would I have to do then?
Okay, have done some more testing. I think it corresponds to certain rooms. I don't have this issue in certain rooms but in other rooms the save file gets corrupted.

Is there something that could potentially conflict with the script in a room that corrupts the save file?
Maybe one of your events are doing something, setting a switch or variable on, changing data.
does your map notes have anything written in it for scripts. Are there parallel processes running?
There aren't any parallel processes running. Also, I don't think it is by room anymore. I tried one room and one encounter worked fine, while another corrupted the save file.

It's definitely by troop.
So then are there any commands in your troop?
There are not. They're all blank.
Update: Now it seems to be happening randomly. It doesn't matter the troop I fight, it will start to save in the beginning, but then afterwards the save file will corrupt.
I know of one script that tries to put a sprite into the Game_Character or Game_Event class (don't remember the name, just know there was one). This would cause errors with saving games, which would then cause the save file to be deleted.

Edit - yep, this is not the script I'm thinking of, but this script adds a sprite to the Game_Pet class, and adds pets to Game_Actor. So that's exactly what its doing - trying to add a sprite to the game data. Because that's in the Game_Actor class (or $game_actors by this stage), its automatically covered by the Data Manager.

The sprite should be completely separate, not a part of the Game_Pet class. This will need someone to do a bit of a rewrite, but ideally you'd go back to the developer and ask them to create a separate Sprite_Pet class as needed. Their contact details are in the script.

btw - please don't put other people's scripts into your post. Give a link to them instead.
I know of one script that tries to put a sprite into the Game_Character or Game_Event class (don't remember the name, just know there was one). This would cause errors with saving games, which would then cause the save file to be deleted.

Edit - yep, this is not the script I'm thinking of, but this script adds a sprite to the Game_Pet class, and adds pets to Game_Actor. So that's exactly what its doing - trying to add a sprite to the game data. Because that's in the Game_Actor class (or $game_actors by this stage), its automatically covered by the Data Manager.

The sprite should be completely separate, not a part of the Game_Pet class. This will need someone to do a bit of a rewrite, but ideally you'd go back to the developer and ask them to create a separate Sprite_Pet class as needed. Their contact details are in the script.

btw - please don't put other people's scripts into your post. Give a link to them instead.
Oh, my bad about posting the script.

Although the person who made this script hasn't been active in 6 years, so I doubt I could ask for a rewrite. I will probably just use a different script or just try to do an actor transformation without a script to begin with.
I know of one script that tries to put a sprite into the Game_Character or Game_Event class (don't remember the name, just know there was one). This would cause errors with saving games, which would then cause the save file to be deleted.

Edit - yep, this is not the script I'm thinking of, but this script adds a sprite to the Game_Pet class, and adds pets to Game_Actor. So that's exactly what its doing - trying to add a sprite to the game data. Because that's in the Game_Actor class (or $game_actors by this stage), its automatically covered by the Data Manager.

The sprite should be completely separate, not a part of the Game_Pet class. This will need someone to do a bit of a rewrite, but ideally you'd go back to the developer and ask them to create a separate Sprite_Pet class as needed. Their contact details are in the script.

btw - please don't put other people's scripts into your post. Give a link to them instead.
On second thought, it seems like it would be easier to rewrite and edit some things myself. Do you have any tips on what lines should be reworked and all?
I may have it working for you. Sent you a message with the fix.
Fortunately a small change seems to work.
adding in a few lines before Game_Pet and changing one line in Game_Pet

no luck yet. Shaz was right it's the data in game_actors.
Changing this works but the summon is not returned when the timer runs out or the battle ends, leaving you with the summon permently.
working on it.

Original thread: https://forums.rpgmakerweb.com/threads/save-file-gets-corrupted-after-certain-script.148364/