class Scene_Title
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_alchemy = Game_Alchemy.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
end
class Alchemy_Database
def initialize
#item = [item_id, element_id, size]
a1 = [1, 17, 1]
a2 = [2, 17, 2]
a3 = [3, 17, 3]
a4 = [26, 21, 6]
a5 = [29, 19, 7]
$data_alchemy = [a1, a2, a3, a4, a5]
end
end
class Game_Alchemy < Alchemy_Database
def initialize
super()
@alchemy = $data_alchemy
@elements = $data_system.elements
check_matter_existance(@alchemy)
end
def check_matter_existance(array)
a = []
#element_id = []
for i in 0..array.length - 1
element_id = array[i][1]
if !array[i].empty? and @elements[element_id] != nil
a << 1
else
a << 0
end
end
for i in 0..array.length - 1
if a[i] == 0
array.delete_at(i)
end
end
return array
end
def replace_material?(new_matter, old_matter)
matter1 = @alchemy[new_matter][0]
matter2 = @alchemy[old_matter][0]
type1 = @alchemy[new_matter][1]
type2 = @alchemy[old_matter][1]
size1 = @alchemy[new_matter][2]
size2 = @alchemy[old_matter][2]
if matter1 != matter2 && type1 == type2 && size1 == size2
return true
else
return false
end
end
end
#==============================================================================
# ** Scene_Transmute
#------------------------------------------------------------------------------
# This class performs Transmute screen processing.
#==============================================================================
class Scene_Transmute
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
# Make command window
s1 = "Transmute"
s2 = "Exit"
@command_window = Window_Command.new(160, [s1, s2])
@command_window.index = @menu_index
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
@spriteset.dispose
# Dispose of windows
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@spriteset.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # Transmute
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Scene_Alchemy
$scene = Scene_Alchemy.new
when 1 # Exit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch back to the Map
$scene = Scene_Map.new
end
return
end
end
end
#==============================================================================
# ** Scene_Alchemy
#------------------------------------------------------------------------------
# This class performs Alchemy screen processing.
#==============================================================================
class Scene_Alchemy
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
@help_window = Window_Help.new
@item_window = Window_Item.new
@item_list = Window_Item_List.new
@item_list.active = false
@item_list.visible = false
@item = nil
@item2 = nil #Used in Transmutation
@item_chosen = false
# Associate help window
@item_window.help_window = @help_window
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@item_window.dispose
@item_list.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@item_window.update
@item_list.update
# If item window is active: call update_item
if @item_window.active && @item_chosen == false
update_item1
return
end
if @item_window.active && @item_chosen == true
@item_window.visible = false
@item_window.active = false
@item_list.visible = true
@item_list.active = true
update_item2
return
end
if @item_list.active == true && @item2 != nil
transmute(@item, @item2)
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item1
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Transmute.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @item_window.item
# If not a use item
unless @item.is_a?(RPG::Item)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If it can't be used
unless $game_party.item_can_use?(@item.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
@item_chosen = true
# Play decision SE
$game_system.se_play($data_system.decision_se)
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item2
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Transmute.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item2 = @item_list.item
# Play decision SE
$game_system.se_play($data_system.decision_se)
return
end
end
#--------------------------------------------------------------------------
# * Transmute
#--------------------------------------------------------------------------
def transmute(start, product) #add Transmute:type later.
@item_list.active = false
@item_list.visible = false
allowed = $game_alchemy.replace_material?(start, product)
if allowed == true
$game_system.play_se($data_system.decision_se)
$game_party.lose_item(start, 1)
$game_party.gain_item(product, 1)
$scene = Scene_Transmute.new
else
$game_system.se_play($data_system.buzzer_se)
$game_party.lose_item(start, 1)
$scene = Scene_Transmute.new
end
end
end