Â
# Addon - Combination of WazaBrew 4.0 and Lockpick Minigame
# Author: EOG
#
# This is only and addon so base scripts are still needed!
#
module Brew
RECIPES = [
  {'NAME' => 'Silver Potion',
   'DIFFICULTY' => 0, # 0-very easy, 4-insane
   'TYPE' => 'Brew',
   'RESULT' => [ITEM, 3, 1],
   'COMPONENTS' => [
    [ITEM, 2, 1, CONSUMED],
    [ITEM, 1, 1, CONSUMED]
   ]
  },
  {'NAME' => 'Golden Potion',
   'DIFFICULTY' => 1, # 0-very easy, 4-insane
   'TYPE' => 'Brew',
   'RESULT' => [ITEM, 6, 1],
   'COMPONENTS' => [
    [ITEM, 4, 1, CONSUMED],
    [ITEM, 5, 1, CONSUMED]
   ]
  }
 ]
end
Â
class Scene_Brew
 def brew(recipe)
  return false unless Brew.can_make?(recipe)
  recipe = Brew.get_recipe(@recipe_list.data)
   if Brew::SHOW_RESULT
    if @result_window
     @result_window.dispose
     @result_window = nil
    end
    pass = minigame(recipe['DIFFICULTY'])
    @result_window = Window_Base.new(0, 0, 256, 64)
    @result_window.contents = Bitmap.new(224, 32)
    @result_window.x = 320 - @result_window.width / 2
    @result_window.y = 240 - @result_window.height / 2
    @result_window.z = 9998
    if pass
     @result_window.contents.draw_text(4, 0, 224, 32,
     "#{$data_items[recipe['RESULT'][1]].name} made!", 1)
    else
     @result_window.contents.draw_text(4, 0, 224, 32,
     "#{$data_items[recipe['RESULT'][1]].name} fail to made!", 1)
    end
   end
  for component in recipe['COMPONENTS']
   case component[0]
   when 0
    $game_party.lose_item(component[1], component[2]) if component[3]
   end
  end
  case recipe['RESULT'][0]
  when 0
   if pass
    $game_party.gain_item(recipe['RESULT'][1], recipe['RESULT'][2])
   end
  end
  return true
 end
 def minigame(difficulty)
  @recipe_list.visible = false
  @result_info.visible = false
  @result_comp.visible = false
  @result_window_sprite.visible = false
  @recipe_list_sprite.visible = false
  @result_info_sprite.visible = false
  @result_comp_sprite.visible = false
  $game_temp.lock_difficulty = difficulty
  minigame_init = Scene_LockpickMinigame.new
  minigame_init.main_variable
  minigame_init.main_sprite
  minigame_init.main_window
  minigame_init.main_audio
  minigame_init.main_transition
  loop do
   Graphics.update
   Input.update
   minigame_init.main_update
   @@temp = minigame_init.update
   if @@temp == "DONE" or @@temp == "NOTDONE"
    break
   end
   @@temp = nil
  end
  minigame_init.main_end
  minigame_init.main_dispose
  @recipe_list.visible = true
  @result_info.visible = true
  @result_comp.visible = true
  @result_window_sprite.visible = true
  @recipe_list_sprite.visible = true
  @result_info_sprite.visible = true
  @result_comp_sprite.visible = true
  minigame_init = nil
  return true if @@temp == "DONE" else false
 end
end
Â
Â
Â
class Scene_LockpickMinigame < SDK::Scene_Base
 def update
  # game cancelled
  if Input.trigger?( Input::B )
   return "NOTDONE"
  end
 Â
  # Don't allow other input if animating
  if @lockpick_sprite.move?
   return
  end
  for i in 0...@pins.size
   if @pins[ i ].move?
    return
   end
  end
 Â
  # move the lockpick left or right
  if Input.trigger?( Input::RIGHT )
   @lockpick_sprite.move_right
   if not @lockpick_sprite.move?
    $game_system.se_play( $data_system.buzzer_se )
   end
  end
  if Input.trigger?( Input::LEFT )
   @lockpick_sprite.move_left
   if not @lockpick_sprite.move?
    $game_system.se_play( $data_system.buzzer_se )
   end
  end
 Â
  # knock a tumbler up - cascades
  if Input.trigger?( Input::UP )
   @pins[ @lockpick_sprite.position ].raise
   if @pins[ @lockpick_sprite.position ].move?
    $game_system.se_play( Tumbler::TUMBLER_AUDIO_UP )
    @lockpick_sprite.tap_up
    if @lockpick_sprite.position > 0 # first pin guaranteed no cascades
     @pins[ ( @lock_number * @lockpick_sprite.position ) %
      @pins.size ].raise
    end
    if $game_temp.lock_difficulty == LOCK_INSANE
     @pins[ ( @lock_number + @lockpick_sprite.position ) %
      @pins.size ].lower
    end
   else
    $game_system.se_play($data_system.buzzer_se)
   end
  end
 Â
  # knock a tumbler down - cascades
  if Input.trigger?( Input::DOWN )
   @pins[ @lockpick_sprite.position ].lower
   if @pins[ @lockpick_sprite.position ].move?
    $game_system.se_play( Tumbler::TUMBLER_AUDIO_DOWN )
    @lockpick_sprite.tap_down
    if @lockpick_sprite.position > 0 # first pin guaranteed no cascades
     @pins[ ( @lock_number * @lockpick_sprite.position ) %
      @pins.size ].lower
    end
    if $game_temp.lock_difficulty == LOCK_INSANE
     @pins[ ( @lock_number + @lockpick_sprite.position ) %
      @pins.size ].raise
    end
   else
    $game_system.se_play( $data_system.buzzer_se )
   end
  end
Â
  # game finished, maybe
  if Input.trigger?( Input::C )
   unlockable = true
   for i in 0...@pins.size
    if not @pins[ i ].open?
     unlockable = false
     break
    end
   end
   if unlockable
   Â
    $game_system.se_play( LOCK_AUDIO_UNLOCK )
    return "DONE"    Â
   else
    $game_system.se_play( $data_system.buzzer_se )
   end
  end
 end
end
Â