Unlockables
Authors: Wecoc
Version: 1.0
Type: Game Utility
Key Term: Game Utility
IntroductionWith this script you will be able to add an unlockables in the game.
Imagine for example the player arrived to the last save point on your game (ie practically we can say that the player has spent the entire game at least once), then you can do that if the player re-start the game again he will have some options he had not before.
That's what this script does.
Features
- Use multiple unlockables (as many as you want)
- "New Game" versus "New Game +" (read instructions)
ScreenshotsNot for this type of script.
DemoNo demo available. You can ask for one.
ScriptXP version:
#==============================================================================
# ** [XP] Unlockables v 1.0
# by: Wecoc
#==============================================================================
module Wep
DES_SW = [1] # switch ID
NEW_PLUS = true # New Game +
end
class Window_Command < Window_Selectable
def size
return @item_max
end
end
class Scene_Title
include Wep
def main
if $BTEST
battle_test
return
end
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
draw_commands
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
if @continue_enabled
@command_window.index = @command_window.size - 2
else
@command_window.disable_item(@command_window.size - 2)
end
$game_system.bgm_play($data_system.title_bgm)
Audio.me_stop
Audio.bgs_stop
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@command_window.dispose
@sprite.bitmap.dispose
@sprite.dispose
end
def draw_commands
s1 = "New Game"
s2 = "New Game +"
s3 = "Load"
s4 = "Exit"
if NEW_PLUS
result = []
for i in 0...DES_SW.size
result.push(false)
end
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
file = File.open("Save#{i+1}.rxdata", "rb")
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
for i in 0...DES_SW.size
result[i] = true if $game_switches[DES_SW[i]] == true
end
file.close
end
end
result.delete(false)
array = result.size > 0 ? [s1, s2, s3, s4] : [s1, s3, s4]
else
array = [s1, s3, s4]
end
@command_window = Window_Command.new(192, array)
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
end
def update
@command_window.update
if Input.trigger?(Input::C)
if @command_window.size == 4
case @command_window.index
when 0 # New game
command_new_game
when 1 # New game plus
command_new_game_plus
when 2 # Continue
command_continue
when 3 # Shutdown
command_shutdown
end
else
case @command_window.index
when 0 # New game plus
command_new_game_plus
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
end
def command_new_game_plus
if DES_SW == nil or DES_SW.size == 0
command_new_game
return
end
result = []
for i in 0...DES_SW.size
result.push(false)
end
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
file = File.open("Save#{i+1}.rxdata", "rb")
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
for i in 0...DES_SW.size
result[i] = true if $game_switches[DES_SW[i]] == true
end
file.close
end
end
command_new_game
for i in 0...result.size
$game_switches[DES_SW[i]] = true if result[i] == true
end
end
end
VX version:
#==============================================================================
# ** [VX] Unlockables v 1.0
# by: Wecoc
#==============================================================================
module Wep
DES_SW = [1] # switch ID
NEW_PLUS = true # New Game +
end
class Window_Command < Window_Selectable
def size
return @item_max
end
end
class Scene_Title
include Wep
def create_command_window
s1 = Vocab::new_game
s2 = Vocab::new_game + " +"
s3 = Vocab::continue
s4 = Vocab::shutdown
if NEW_PLUS
result = []
for i in 0...DES_SW.size
result.push(false)
end
for i in 0..3
if FileTest.exist?("Save#{i+1}.rvdata") and (Wep::DES_SW).size > 0
file = File.open("Save#{i+1}.rvdata", "rb")
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
for i in 0...DES_SW.size
result[i] = true if $game_switches[DES_SW[i]] == true
end
file.close
end
end
result.delete(false)
array = result.size > 0 ? [s1, s2, s3, s4] : [s1, s3, s4]
else
array = [s1, s3, s4]
end
@command_window = Window_Command.new(192, array)
@command_window.back_opacity = 160
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = @command_window.size == 3 ? 288 : 262
if @continue_enabled
@command_window.index = @command_window.size - 2
else
@command_window.draw_item(@command_window.size - 2, false)
end
@command_window.openness = 0
@command_window.open
end
def update
@command_window.update
if Input.trigger?(Input::C)
if @command_window.size == 4
case @command_window.index
when 0 # New game
command_new_game
when 1 # New game plus
command_new_game_plus
when 2 # Continue
command_continue
when 3 # Shutdown
command_shutdown
end
else
case @command_window.index
when 0 # New game plus
command_new_game_plus
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
end
def command_new_game_plus
if DES_SW == nil or DES_SW.size == 0
command_new_game
return
end
result = []
for i in 0...DES_SW.size
result.push(false)
end
for i in 0..3
if FileTest.exist?("Save#{i+1}.rvdata") and (Wep::DES_SW).size > 0
file = File.open("Save#{i+1}.rvdata", "rb")
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
for i in 0...DES_SW.size
result[i] = true if $game_switches[DES_SW[i]] == true
end
file.close
end
end
command_new_game
for i in 0...result.size
$game_switches[DES_SW[i]] = true if result[i] == true
end
end
end
InstructionsTo use it, at that point where the unlockable has to be activated, you have to activate a game switch. Then in the first line of this script you put the ID switch, where it says DES_SW = [1] (so changing the 1 for the ID). You can use more than one, por example DES_SW = [1, 2] for multiple unlockables, the mechanism is the same.
As long as that file of the completed game exists, the new games will contain automatically that switch/es already activated, so after that the rest is simple.
The script contains a global called NEW_PLUS, you can see it in the very start of the code. When activated, on the screen will appear a new command "New Game +", so you can start the game as always without the unlock features OR with the unlockables using the new command. When deactivated, the default "New Game" will gain the new feature.
CompatibilityProbably you will need to do some changes if you use a non-default title screen.
Credits and Thanks
Author's NotesI know that Moonpearl did a very similar script some time ago called "Moonpearl's New Game Plus", the differences are which I said in Features; DES_SW is an array and you can deactivate the New Game + command.