# Cooking System V0.4.5 - Crazedanimekid 07.28.2010
#
# - Version Log
#
# V0.0.0 -- 07.20.2010 Started script.
# V0.0.5 -- 07.22.2010 Created Scene_Oven, class RPG::BaseItem.
# V0.1.0 -- 07.23.2010 Created class Game_System & Game_Party.
# V0.1.5 -- 07.27.2010 Edits made by Omegas7.
# V0.2.0 -- 07.28.2010 Added Scene_Map, Window_Food_Points, and Window Base.
# V0.2.5 -- 08.03.2010 Added cooked/raw traits
# V0.3.0 -- 08.07.2010 Rewrote/merged IMP's Count up Timer into Cook System.
# V0.3.5 -- 08.09.2010 Added Second Oven functionality
# V0.4.0 -- Added Menu and Recipe functions
# V0.5.0 -- Edited Oven Scenes to make them less verbose.
#==============================================================================
module Vocab
Perfection = "This is cooked to perfection!"
Under = "This is a tad bit undercooked."
Over = "This has been overcooked."
Accept = "This has been cooked nicely."
FoodPoints = "Food Points"
def self.food_points
return Vocab::FoodPoints
end
end # end Module
#==============================================================================
# Define Cooking Times --- Code written by Jet 7.22.10
#==============================================================================
class RPG::BaseItem
def cooked?
return @name.scan(/\(cooked\)/i).size > 0
end
def perfect_time #Read notetag for perfect cooking time.
txt = 0
if @perfect_time.nil?
self.note.split(/[\r\n]+/).each { |notetag|
case notetag
when /<(?:perfect time)[ ]*(\d+)>/i
txt = $1.to_i
end }
@perfect_time = txt.nil? ? :no_perfect_time : txt
end
return @perfect_time
end
def under_time #Read notetag for under cooking time.
txt = 0
if @under_time.nil?
self.note.split(/[\r\n]+/).each { |notetag|
case notetag
when /<(?:under time)[ ]*(\d+)>/i
txt = $1.to_i
end }
@under_time = txt.nil? ? :no_under_time : txt
end
return @under_time
end
def over_time #Read notetag for over cooking time.
txt = 0
if @over_time.nil?
self.note.split(/[\r\n]+/).each { |notetag|
case notetag
when /<(?:over time)[ ]*(\d+)>/i
txt = $1.to_i
end }
@over_time = txt.nil? ? :no_over_time : txt
end
return @over_time
end
end # end Class
#------------------------------------------------------------------------------
# Import
#------------------------------------------------------------------------------
$imported = {} if $imported == nil
$imported["CookSystem"] = true
#------------------------------------------------------------------------------
# class Scene_Oven (New Class)
#------------------------------------------------------------------------------
class Scene_Oven < Scene_Base
def initialize(oven)
@oven = oven
end
def start
super
create_menu_background
@item_window = Window_Item.new(0, 56, 544, 360)
@item_window.active = true
@help_window = Window_Help.new
@help_window.viewport = @viewport
end
def terminate
super
dispose_menu_background
@item_window.dispose
@help_window.dispose
end
def return_scene
$scene = Scene_Map.new
end
def update
super
update_menu_background
@item_window.update
@help_window.update
update_food_selection
end
def update_food_selection
if Input.trigger?(Input::

Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
if @oven == 1
insert_food_to_oven(1)
end
if @oven == 2
insert_food_to_oven(2)
end
else
Sound.play_buzzer
end
end
end
def insert_food_to_oven(num)
@num = num
Sound.play_use_item
$game_party.consume_item(@item)
@item_window.draw_item(@item_window.index)
if @num == 1
$game_switches[3] = true
end
if @num == 2
$game_switches[4] = true
end
return_scene
end
end # end Class
#------------------------------------------------------------------------------
# class Game_System
#------------------------------------------------------------------------------
class Game_System
attr_accessor :oven_timer1
attr_accessor :oven_timer2
alias cak_initialize initialize unless $@
def initialize
@oven_timer1 = 0
@oven_timer2 = 0
cak_initialize
end
alias cak_update update unless $@
def update
cak_update
if $game_switches[3]
@oven_timer1 += 1
end
if $game_switches[4]
@oven_timer2 += 1
end
end
def stop_oven(num)
if num == 1
$game_switches[3] = false
@stop_time = $game_system.oven_timer1 / 60
$game_system.oven_timer1 = 0
$game_party.compare_timer1(@stop_time)
end
if num == 2
$game_switches[4] = false
@stop_time2 = $game_system.oven_timer2 / 60
$game_system.oven_timer2 = 0
$game_party.compare_timer2(@stop_time2)
end
return_food_in_cooked_state(@item_id)
end
def return_food_in_cooked_state(item_id)
@item_id = $game_party.last_item_id
$game_party.gain_item($data_items[@item_id + 1], 1)
end
end # end Class
#=============================================================================
# * class Game_Party
#=============================================================================
class Game_Party
attr_writer :fp
def fp
@fp ||= 0 # accessor initilize, init to 0 if nil or false
end
def item
item = $data_items[$game_party.last_item_id]
end
def compare_timer1(stop_time)
reset_qual(1)
if item.perfect_time == stop_time
@perfection = true
$game_switches[5] = true
self.fp += 8
elsif item.over_time < stop_time
@over = true
$game_switches[6] = true
self.fp += 2
elsif item.under_time > stop_time
@under = true
$game_switches[7] = true
self.fp += 1
elsif item.over_time >= stop_time && item.under_time <= stop_time
@accept = true
$game_switches[8] = true
self.fp += 3
end
end
def compare_timer2(stop_time2)
reset_qual(2)
if item.perfect_time == stop_time2
@perfection = true
$game_switches[11] = true
self.fp += 8
elsif item.over_time < stop_time2
@over = true
$game_switches[12] = true
self.fp += 2
elsif item.under_time > stop_time2
@under = true
$game_switches[13] = true
self.fp += 1
elsif item.over_time >= stop_time2 && item.under_time <= stop_time2
@accept = true
$game_switches[14] = true
self.fp += 3
end
end
def reset_qual(num)
@num = num
if @num == 1
$game_switches[5] = $game_switches[6] = $game_switches[7] = $game_switches[6] = false
@perfection = false
@over = false
@under = false
@accept = false
end
if @num == 2
$game_switches[11] = $game_switches[12] = $game_switches[13] = $game_switches[14] = false
@perfection = false
@over = false
@under = false
@accept = false
end
end
alias disallow_cooked_food item_can_use?
def item_can_use?(item)
return false if item.cooked?
disallow_cooked_food(item)
end
end # end Class
#------------------------------------------------------------------------------
# class Window_Food_Points < Window_Base
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# class Window_Timer < Window_Base
#------------------------------------------------------------------------------
class Window_Timer1 < Window_Base
def initialize(x, y)
super(x, y, 160, WLH + 32)
update
end
def update
super
self.contents.clear
draw_timer1($game_system.oven_timer1, 4, 0, 120)
end
end # end Class
#------------------------------------------------------------------------------
# class Window_Timer2 < Window_Base
#------------------------------------------------------------------------------
class Window_Timer2 < Window_Base
def initialize(x, y)
super(x, y, 160, WLH + 32)
update
end
def update
super
self.contents.clear
draw_timer2($game_system.oven_timer2, 4, 0, 120)
end
end # end Class
#------------------------------------------------------------------------------
# class Window_Base
#------------------------------------------------------------------------------
class Window_Base
def draw_timer1(value, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(0, -4, 120, 32, "Timer 1")
@total_sec = $game_system.oven_timer1 / Graphics.frame_rate
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(8, -4, 120, 32, text, 2)
end
def draw_timer2(value, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(0, -4, 120, 32, "Timer 2")
@total_sec = $game_system.oven_timer2 / Graphics.frame_rate
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(8, -4, 120, 32, text, 2)
end
end # end Class
#------------------------------------------------------------------------------
# class Scene_Map < Scene_Base
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
alias draw_fp start unless $@
def start
@timer_1 = Window_Timer1.new(386, 0)
@timer_1.visible = false
@timer_2 = Window_Timer2.new(386, 65)
@timer_2.visible = false
draw_fp
end
alias close_fp terminate unless $@
def terminate
@timer_1.dispose
@timer_2.dispose
close_fp
end
alias refresh_fp update unless $@
def update
@timer_1.update
@timer_2.update
if $game_switches[3]
@timer_1.visible = true
else
@timer_1.visible = false
end
if $game_switches[4]
@timer_2.visible = true
else
@timer_2.visible = false
end
refresh_fp
end
end # end Class
#==============================================================================
# END
#==============================================================================