Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

My fix for loading saves

A topic by AleDerXan created Oct 10, 2024 Views: 347 Replies: 2
Viewing posts 1 to 3
(2 edits)

If some mod added states or skills, and then gamer purchased them…

And if gamer deleted this mod, and then trying to load the save file with added skills and states… 

A lot of errors!!!

(4 edits)

If you load 'broken save' with this code as mod, and then create 'new save file' you don't need this code more to load your 'new save file'. This code cleans game, and 'new save file' clean too.

(5 edits)

Updating for items in inventory.

———

class Game_BattlerBase
    def states_save_fix
        @states = @states.reject {|id| $data_states[id] == nil}
    end
end
    
class Game_Actor < Game_Battler
    def skills_save_fix
        @skills = @skills.reject {|id| $data_skills[id] == nil}
    end
end
    
class Game_Party < Game_Unit
    def items_save_fix
        @armors = @armors.reject {|id| $data_armors[id] == nil}
        @weapons = @weapons.reject {|id| $data_weapons[id] == nil}
        @items = @items.reject {|id| $data_items[id] == nil}
    end
end
    
class Game_Player
    def hotkey_save_fix
        $game_player.slot_skill_normal = nil if $game_player.slot_skill_normal != nil && $data_skills[$game_player.slot_skill_normal] == nil
        $game_player.slot_skill_heavy = nil if $game_player.slot_skill_heavy != nil && $data_skills[$game_player.slot_skill_heavy] == nil
        $game_player.slot_skill_control = nil if $game_player.slot_skill_control != nil && $data_skills[$game_player.slot_skill_control] == nil
        $game_player.slot_hotkey_0 = nil if $game_player.slot_hotkey_0 != nil && $data_skills[$game_player.slot_hotkey_0] == nil
        $game_player.slot_hotkey_1 = nil if $game_player.slot_hotkey_1 != nil && $data_skills[$game_player.slot_hotkey_1] == nil
        $game_player.slot_hotkey_2 = nil if $game_player.slot_hotkey_2 != nil && $data_skills[$game_player.slot_hotkey_2] == nil
        $game_player.slot_hotkey_3 = nil if $game_player.slot_hotkey_3 != nil && $data_skills[$game_player.slot_hotkey_3] == nil
        $game_player.slot_hotkey_4 = nil if $game_player.slot_hotkey_4 != nil && $data_skills[$game_player.slot_hotkey_4] == nil
        $game_player.slot_hotkey_other = nil if $game_player.slot_hotkey_other != nil && $data_skills[$game_player.slot_hotkey_other] == nil
    end
end
    
module DataManager
    class << self
        alias_method :extract_save_contents_save_fix, :extract_save_contents
    end
    
    def self.extract_save_contents(contents)
        extract_save_contents_save_fix(contents)
        $game_player.actor.states_save_fix
        $game_player.actor.skills_save_fix
        $game_party.items_save_fix
        $game_player.hotkey_save_fix
    end
end