[code]#===============================================================================
#
# Yanfly Engine RD - Actor Item Synthesis
# Last Date Updated: 2009.06.23
# Level: Hard
#
# This item synthesis script is influenced after Gust RPG's famous synthesizing
# systems. To synthesize an item, one would need a recipe and the required actor
# in your party. Different actors can yield different outcomes, but they all
# possess and use the same ingredients.
#
# Another thing this script will provide (for the player) is that any items that
# were synthesized through the shop's recipes can then be bought without need
# to synthesize them again. The need to constantly resynthesize items to get
# more of them becomes rather tedious and that really isn't something we should
# put the player through.
#
# This script also allows playing events after item creation similar to that of
# the Gust RPG's. There you can play out little skits and such or even unlock
# certain parts of the game for synthesizing a particular item.
#
#===============================================================================
# Updates:
# ----------------------------------------------------------------------------
# o 2009.06.23 - Compatibility fix with KGC Help Extension
# o 2009.06.21 - Compatibility update with Display Item Query
# o 2009.06.14 - Bug fix for Synth Listing
# o 2009.06.10 - Added <synth unbuyable>
# o 2009.06.04 - Added <synth block actor x>
# - Common events are played only once per actor now
# - Added <replay event> to replay common events more than once
# - Added <synth exp x> and <synth exp x:y>
# o 2009.06.03 - Finished script
# o 2009.06.02 - Started script
#===============================================================================
# Instructions
#===============================================================================
#
# These go into the recipe's notebox. Recipes can be items, weapons, or armours
# but they must contain the following information before they can be recipes:
# -----------------------------------------------------------------------------
#
# <synth actor a b:c>
# a is the ID of the actor that can use the recipe. If the ID is 0, all actors
# can user the recipe. b has to be either I, W, or A. This will determine what
# type of item will be produced, an item, weapon, or armour. c is the ID of the
# item type to be created. <synth actor 3 I:8> means if actor 3 uses this recipe
# then actor 3 will create Item ID 8.
#
# <synth cost n>
# This is how much synthesizing the recipe will cost. If this isn't included,
# the synthesis is considered to be free.
#
# <ingredients a:b> or <ingredients a:b xc>
# This determines what ingredients are needed. a has to be either I, W, or A to
# determine what type of item is being used. b determines the item ID of the
# item type to be used. Should you decide to use the second tag, c is how many
# of the item is needed for the recipe to be made.
#
# -----------------------------------------------------------------------------
# The following are optional tags you may place in a recipe's notebox.
# -----------------------------------------------------------------------------
#
# <synth block actor x> or <synth block actor x,x>
# This will prevent actors from being able to perform the synthesis at all,
# even if actor 0 is listed for <synth actor>. To block multiple actors, just
# add more of the tags or use the <synth block actor x,x> version.
#
# <synth actor a event:b>
# For those that want to play a common event after a synthesis, set b to the ID
# of the common event desired. a is the actor set to play after that actor makes
# an item. If a is 0, it is set for all actors.
#
# <replay event>
# This will allow the common event to be replayable after viewing once.
#
# <consume recipe> or <not consume recipe>
# This will override the default rules set for consuming recipes. The first will
# always consume the recipe regardless of the rulesetting and the second one
# will prevent the recipe from being consumed.
#
# <synth exp x> or <synth exp x:y>
# This determines how much experience the actor synthesizing the item gains
# from performing the synthesis. The first time through, the actor will gain x
# experience. On follow-up synthesis sessions, the actor will not gain any exp
# unless the second tag is used. Only y exp will be gained on follow up any
# follow-up sessions. But no matter how much experience the actor gains, the
# actor cannot level up from synthesizing items (to prevent bugs from occuring).
#
# <synth unbuyable>
# This makes the item unable to be bought even after synthesizing it. This tag
# can be used in either the item to be bought or the recipe. If it's on the
# item to be bought, then only that item is is disabled from the recipe. If the
# tag is on the recipe, all items created by that recipe cannot be bought.
#
#===============================================================================
#
# Compatibility
# - Works With: KGC's LimitBreak, Help Extension
# - Works With: Yanfly's Variable Controlled Discounts
# - Alias: Scene_Map: call_shop
#
#===============================================================================
$imported = {} if $imported == nil
$imported["ActorItemSynthesis"] = true
module YE
module SYNTH
# This is the switch required to be on before the shop can be called out.
# Remember to turn off your switches beforehand.
SYNTH_SWITCH = 72
# The following determines the various settings for the synthesis shop.
SYNTH_TEXT = "Synth" # Synthesis option for shop commands.
SYNTH_INCOMP = "Incompatible" # Text for incompatible actors.
SYNTH_INCOLR = 10 # Colour for incompatible actors.
SYNTH_INGRED = "Ingredients" # Text used for ingredients.
SYNTH_OUTCOM = "Outcome" # Text used for ingredients.
SYNTH_FSIZE = 16 # Font size for smaller text.
SYNTH_OFFSET = 48 # X offset for text next to actor sprite.
SYNTH_TOTAL = "Recipes Known: %d" # Total recipes done by actor.
SYNTH_COST = "Synth Cost" # Text for synthesis cost.
SYNTH_C_ICON = 205 # Icon for synthesis cost.
SYNTH_T_COST = "%d %s" # Text format used for synth amount.
SYNTH_AMT = "%d/%d" # Ingredients required over possessed.
SYNTH_HIDE_0 = true # This will hide amount needed if zero.
SYNTH_UNICON = 144 # Icon used for unknown items.
SYNTH_UNMASK = "Unknown" # Mask used for unknown items.
# The following determines the rules for recipe consumption. This will
# govern whether or not you would want recipes to be used up after synthing
# an item. If it's set to true, recipes will be included in the ingredients
# listing. The number consumed depends on how many items were synthesized
# from the recipe.
CONSUME_RECIPE_ITEM = false # If recipe is an item, consume item.
CONSUME_RECIPE_WEAPON = true # If recipe is an weapon, consume weapon.
CONSUME_RECIPE_ARMOUR = true # If recipe is an armour, consume armour.
# The following determines the rules governing common events. Note that if
# common events are played outside of the shop, the player will not return
# to the shop after the event is done.
EVENT_IN_SHOP = true # Stay inside the shop for common events.
FADE_TIME = 30 # The amount of frames of fade in between events.
end
end
#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================
module YE
module REGEXP
module SYNTH
ACTOR = /<(?:SYNTH_ACTOR|synth actor)[ ]*(\d+)[ ]\s*([IWA])

\d+)?>/i
EVENT = /<(?:SYNTH_ACTOR|synth actor)[ ]*(\d+)[ ](?:EVENT|event)

\d+)?>/i
BLOCK = /<(?:SYNTH_BLOCK_ACTOR|synth block actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
COST = /<(?:SYNTH_COST|synth cost)[ ]*(\d+)>/i
INGRE = /<(?:INGREDIENT|ingredients)\s*([IWA])

\d+)?>/i
INGRX = /<(?:INGREDIENT|ingredients)\s*([IWA])

\d+)[ ]x(\d+)?>/i
CONSUME = /<(?:CONSUME|consume recipe)>/i
NOTCONSUME = /<(?:NOT_CONSUME|not consume recipe|not consume)>/i
REPLAY = /<(?:REPLAY_EVENT|replay event)>/i
UNBUYABLE = /<(?:SYNTH_UNBUYABLE|synth unbuyable)>/i
EXP1 = /<(?:SYNTH_EXP|synth exp)[ ]*(\d+)>/i
EXP2 = /<(?:SYNTH_EXP|synth exp)[ ]*(\d+)

\d+)>/i
end # BASEITEM
end # REGEXP
end # YE
#===============================================================================
# RPG::BaseItem
#===============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# Yanfly_Cache_BaseItem_AIS
#--------------------------------------------------------------------------
def yanfly_cache_baseitem_ais
@recipe = false; @synth_actor = {}; @ingredients = {}; @synth_cost = 0
@synth_consume = false; @synth_event = {}; @synth_block = []
@replay_event = false; @synth_exp1 = 0; @synth_exp2 = 0
@synth_unbuyable = false
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::SYNTH::ACTOR
case $2.upcase
when "I"
@synth_actor[$1.to_i] = $data_items[$3.to_i]
@synth_consume = YE::SYNTH::CONSUME_RECIPE_ITEM
when "W"
@synth_actor[$1.to_i] = $data_weapons[$3.to_i]
@synth_consume = YE::SYNTH::CONSUME_RECIPE_WEAPON
when "A"
@synth_actor[$1.to_i] = $data_armors[$3.to_i]
@synth_consume = YE::SYNTH::CONSUME_RECIPE_ARMOUR
end
when YE::REGEXP::SYNTH::EVENT
@synth_event[$1.to_i] = $2.to_i
when YE::REGEXP::SYNTH::BLOCK
$1.scan(/\d+/).each { |num|
if num.to_i > 0
@synth_block.push(num.to_i)
end }
when YE::REGEXP::SYNTH::COST
@synth_cost = $1.to_i
when YE::REGEXP::SYNTH::INGRE
case $1.upcase
when "I"
@ingredients[$data_items[$2.to_i]] = 1
when "W"
@ingredients[$data_weapons[$2.to_i]] = 1
when "A"
@ingredients[$data_armors[$2.to_i]] = 1
end
when YE::REGEXP::SYNTH::INGRX
case $1.upcase
when "I"
@ingredients[$data_items[$2.to_i]] = $3.to_i
when "W"
@ingredients[$data_weapons[$2.to_i]] = $3.to_i
when "A"
@ingredients[$data_armors[$2.to_i]] = $3.to_i
end
when YE::REGEXP::SYNTH::REPLAY
@replay_event = true
when YE::REGEXP::SYNTH::EXP1
@synth_exp1 = $1.to_i
when YE::REGEXP::SYNTH::EXP2
@synth_exp1 = $1.to_i
@synth_exp2 = $2.to_i
when YE::REGEXP::SYNTH::UNBUYABLE
@synth_unbuyable = true
end
}
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::SYNTH::CONSUME
@synth_consume = true
when YE::REGEXP::SYNTH::NOTCONSUME
@synth_consume = false
end
}
if @synth_actor != {} and @ingredients != {}
@recipe = true
end
end
#--------------------------------------------------------------------------
# definitions
#--------------------------------------------------------------------------
def recipe?
yanfly_cache_baseitem_ais if @recipe == nil
return @recipe
end
def synth_actor
yanfly_cache_baseitem_ais if @synth_actor == nil
return @synth_actor
end
def synth_event
yanfly_cache_baseitem_ais if @synth_event == nil
return @synth_event
end
def synth_block
yanfly_cache_baseitem_ais if @synth_block == nil
return @synth_block
end
def synth_cost
yanfly_cache_baseitem_ais if @synth_cost == nil
return @synth_cost
end
def synth_consume?
yanfly_cache_baseitem_ais if @synth_consume == nil
return @synth_consume
end
def ingredients
yanfly_cache_baseitem_ais if @ingredients == nil
return @ingredients
end
def replay_event?
yanfly_cache_baseitem_ais if @replay_event == nil
return @replay_event
end
def synth_exp1
yanfly_cache_baseitem_ais if @synth_exp1 == nil
return @synth_exp1
end
def synth_exp2
yanfly_cache_baseitem_ais if @synth_exp2 == nil
return @synth_exp2
end
def synth_unbuyable
yanfly_cache_baseitem_ais if @synth_unbuyable == nil
return @synth_unbuyable
end
end # RPG::BaseItem
#===============================================================================
# Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# Next Exp - The experience needed for the next level.
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
#--------------------------------------------------------------------------
# learn_recipe
#--------------------------------------------------------------------------
def learn_recipe(item)
if item.is_a?(RPG::Item)
unless synth_items.include?(item.id)
synth_items.push(item.id)
exp = [[item.synth_exp1, next_exp - 1].min, 0].max
gain_exp(exp, false)
else
exp = [[item.synth_exp2, next_exp - 1].min, 0].max
gain_exp(exp, false)
end
elsif item.is_a?(RPG::Weapon)
unless synth_weapons.include?(item.id)
synth_weapons.push(item.id)
exp = [[item.synth_exp1, next_exp - 1].min, 0].max
gain_exp(exp, false)
else
exp = [[item.synth_exp2, next_exp - 1].min, 0].max
gain_exp(exp, false)
end
elsif item.is_a?(RPG::Armor)
unless synth_armours.include?(item.id)
synth_armours.push(item.id)
exp = [[item.synth_exp1, next_exp - 1].min, 0].max
gain_exp(exp, false)
else
exp = [[item.synth_exp2, next_exp - 1].min, 0].max
gain_exp(exp, false)
end
end
end
#--------------------------------------------------------------------------
# synth_events
#--------------------------------------------------------------------------
def synth_events
@synth_events = [] if @synth_events == nil
return @synth_events
end
#--------------------------------------------------------------------------
# synth_items
#--------------------------------------------------------------------------
def synth_items
@synth_items = [] if @synth_items == nil
return @synth_items
end
#--------------------------------------------------------------------------
# synth_weapons
#--------------------------------------------------------------------------
def synth_weapons
@synth_weapons = [] if @synth_weapons == nil
return @synth_weapons
end
#--------------------------------------------------------------------------
# synth_armours
#--------------------------------------------------------------------------
def synth_armours
@synth_armours = [] if @synth_armours == nil
return @synth_armours
end
end # Game_Actor
#===============================================================================
# Spriteset_Menu
#===============================================================================
class Spriteset_Menu
unless method_defined?(:create_viewports)
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
create_viewports
create_pictures
update
end
def create_viewports
@viewport1 = Viewport.new(0, 0, 544, 416)
@viewport2 = Viewport.new(0, 0, 544, 416)
@viewport3 = Viewport.new(0, 0, 544, 416)
@viewport2.z = 50
@viewport3.z = 100
end
def create_pictures
@picture_sprites = []
for i in 1..20
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_map.screen.pictures
))
end
end
#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
dispose_pictures
dispose_viewports
end
def dispose_pictures
for sprite in @picture_sprites
sprite.dispose
end
end
def dispose_viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
update_pictures
update_viewports
end
def update_pictures
for sprite in @picture_sprites
sprite.update
end
end
def update_viewports
@viewport1.tone = $game_map.screen.tone
@viewport1.ox = $game_map.screen.shake
@viewport2.color = $game_map.screen.flash_color
@viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
end
end
end # Spriteset_Menu
#===============================================================================
# Scene_Map
#===============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# alias call_shop
#--------------------------------------------------------------------------
alias call_shop_ais call_shop unless $@
def call_shop
if $game_switches[YE::SYNTH::SYNTH_SWITCH]
$game_temp.next_scene = nil
$game_switches[YE::SYNTH::SYNTH_SWITCH] = false
$scene = Scene_Synthesis.new
else
call_shop_ais
end
end
end # Scene_Map
#===============================================================================
# Scene_Synthesis
#===============================================================================
class Scene_Synthesis < Scene_Base
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
def start
super
create_menu_background
@actor_index = 0
@actor_id = $game_party.members[@actor_index].id
@interpreter = Game_Interpreter.new
@common_event = 0
@spriteset = Spriteset_Menu.new
@running = false
@help_window = Window_Help.new
@gold_window = Window_Gold.new(384, @help_window.height)
create_command_window
adjust_window_size
dy = @help_window.height + @gold_window.height
dw = Graphics.width - 304
dh = Graphics.height - dy
@buy_window = Window_SynthBuy.new(0, dy, 304, dh)
@buy_window.help_window = @help_window
@number_window = Window_ShopNumber.new(0, 112)
@number_window.active = false
@number_window.visible = false
@status_window = Window_ShopStatus.new(304, dy)
@status_window.height = dh
@status_window.create_contents
@synth_list = Window_SynthList.new(0, dy, 304, dh)
@synth_list.help_window = @help_window
@ingre_list = Window_Ingredients.new(304, dy, dw, dh)
@synth_number = Window_SynthNumber.new(0, 112)
@synth_number.visible = false
@synth_number.active = false
@message_window = Window_Message.new
@help_window.set_text("")
setup_display_item_query if $imported["DisplayItemQuery"]
end
#--------------------------------------------------------------------------
# adjust_window_size
#--------------------------------------------------------------------------
def adjust_window_size
return unless $imported["HelpExtension"]
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@command_window.y = @help_window.height
@gold_window.y = @help_window.height
dy = @help_window.height + @command_window.height
end
#--------------------------------------------------------------------------
# terminate
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@spriteset.dispose if @spriteset != nil
@help_window.dispose if @help_window != nil
@gold_window.dispose if @gold_window != nil
@buy_window.dispose if @buy_window != nil
@number_window.dispose if @number_window != nil
@status_window.dispose if @status_window != nil
@synth_list.dispose if @synth_list != nil
@ingre_list.dispose if @ingre_list != nil
@command_window.dispose if @command_window != nil
@synth_number.dispose if @synth_number != nil
@message_window.dispose if @message_window != nil
end
#--------------------------------------------------------------------------
# create_command_window
#--------------------------------------------------------------------------
def create_command_window
carray = []
carray.push(Vocab::ShopBuy)
carray.push(YE::SYNTH::SYNTH_TEXT)
carray.push(Vocab::ShopCancel)
@command_window = Window_Command.new(384, carray, 3)
@command_window.y = @help_window.height
end
#--------------------------------------------------------------------------
# setup_display_item_query
#--------------------------------------------------------------------------
def setup_display_item_query
sdx = 0
sdy = @buy_window.y
sdw = 272
sdh = @buy_window.height
@item_data_window = Window_Item_Data.new(0, sdy, 272, sdh)
@item_data_window.visible = false
@item_data_window.active = false
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
update_basic
update_ingredients_window
return if @interpreter.running?
return if $game_message.visible
if $imported["DisplayItemQuery"] and @item_data_window != nil and
@item_data_window.active
update_item_data_window
elsif @command_window.active
update_command_window
elsif @buy_window.active
@last_index = @buy_window.index + 1
update_buy_selection
elsif @synth_list.active
update_synth_list
elsif @number_window.active
update_number_input
elsif @synth_number.active
update_synth_number
end
end
#--------------------------------------------------------------------------
# update_basic
#--------------------------------------------------------------------------
def update_basic
update_menu_background
update_interpreter
$game_map.update
@interpreter.update
@spriteset.update
@message_window.update
end
#--------------------------------------------------------------------------
# update_interpreter
#--------------------------------------------------------------------------
def update_interpreter
if !@interpreter.running? and @running
Graphics.fadeout(YE::SYNTH::FADE_TIME)
@command_window.visible = true
@gold_window.visible = true
@help_window.visible = true
@synth_list.visible = true
@ingre_list.visible = true
@synth_list.update
Graphics.fadein(YE::SYNTH::FADE_TIME)
@running = false
elsif @interpreter.running? and !@running
Graphics.fadeout(YE::SYNTH::FADE_TIME)
@command_window.visible = false
@gold_window.visible = false
@help_window.visible = false
@synth_list.visible = false
@ingre_list.visible = false
Graphics.fadein(YE::SYNTH::FADE_TIME)
@running = true
end
if @common_event > 0
@interpreter.setup($data_common_events[@common_event].list)
@common_event = 0
return
end
end
#--------------------------------------------------------------------------
# update_ingredients_window
#--------------------------------------------------------------------------
def update_ingredients_window
return unless @ingre_list.visible
return if @ingre_list.item == @synth_list.item
@ingre_list.item = @synth_list.item
@ingre_list.refresh(@actor_index)
end
#--------------------------------------------------------------------------
# update_item_data_window
#--------------------------------------------------------------------------
def update_item_data_window
@item_data_window.update
if Input.trigger?(Input::
Sound.play_cancel
@item_data_window.disappear
@buy_window.active = true
elsif Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
@item_data_window.previous_page
elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
@item_data_window.next_page
elsif Input.trigger?(Input::L)
@item_data_window.top_page
elsif Input.trigger?(Input::R)
@item_data_window.bottom_page
end
end
#--------------------------------------------------------------------------
# update_command_window
#--------------------------------------------------------------------------
def update_command_window
@command_window.update
if Input.trigger?(Input::
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0
Sound.play_decision
@command_window.active = false
@buy_window.index = 0 if @buy_window.index < 0
@buy_window.active = true
@buy_window.refresh
@status_window.visible = true
when 1
@synth_list.active = true
@synth_list.visible = true
@ingre_list.visible = true
@synth_list.refresh(@actor_index)
@buy_window.visible = false
@status_window.visible = false
@command_window.active = false
when 2
$scene = Scene_Map.new
end
end
end
#--------------------------------------------------------------------------
# update_buy_selection
#--------------------------------------------------------------------------
def update_buy_selection
if @last_index != @buy_window.index
@last_index = @buy_window.index
@status_window.item = @buy_window.item
end
@buy_window.update
if $imported["DisplayItemQuery"] and
Input.trigger?(YE::MENU::ITEM::ITEM_QUERY_SHOP_BUTTON)
@item = @buy_window.item
if @item == nil
Sound.play_buzzer
else
Sound.play_decision
@item = @buy_window.item
@item_data_window.appear(@item, @buy_window, 2)
@buy_window.active = false
end
elsif Input.trigger?(Input::
Sound.play_cancel
@command_window.active = true
@buy_window.active = false
@status_window.item = nil
@help_window.set_text("")
return
elsif Input.trigger?(Input::C)
@item = @buy_window.item
if @item == nil
Sound.play_buzzer
return
end
number = $game_party.item_number(@item)
limit = $imported["LimitBreak"] ? @item.number_limit : 99
if $imported["VariableControlledDiscounts"]
price = @item.price * $game_variables[YE::EVENT::VARIABLE::PERCENT_BUY]
price /= YE::EVENT::VARIABLE::PERCENT_DIVISOR
else
price = @item.price
end
if @item == nil or price > $game_party.gold or number == limit
Sound.play_buzzer
else
Sound.play_decision
if $imported["LimitBreak"]
max = (price == 0 ? @item.number_limit : $game_party.gold / price)
max = [max, @item.number_limit - number].min
else
max = price == 0 ? 99 : $game_party.gold / price
max = [max, 99 - number].min
end
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# update_synth_list
#--------------------------------------------------------------------------
def update_synth_list
@synth_list.update
@help_window.update
if Input.trigger?(Input::
Sound.play_cancel
@command_window.active = true
@command_window.visible = true
@synth_list.active = false
@synth_list.visible = false
@ingre_list.visible = false
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
@help_window.set_text("")
elsif Input.trigger?(Input::C)
item = @synth_list.item
unless enabled?(item)
Sound.play_buzzer
else
Sound.play_decision
synthesize_item(item)
end
elsif Input.trigger?(Input::LEFT)
Sound.play_cursor
if @actor_index == 0
@actor_index = $game_party.members.size - 1
else
@actor_index -= 1
end
@actor_id = $game_party.members[@actor_index].id
@synth_list.refresh(@actor_index)
@ingre_list.refresh(@actor_index)
elsif Input.trigger?(Input::RIGHT)
Sound.play_cursor
if @actor_index == $game_party.members.size - 1
@actor_index = 0
else
@actor_index += 1
end
@actor_id = $game_party.members[@actor_index].id
@synth_list.refresh(@actor_index)
@ingre_list.refresh(@actor_index)
end
end
#--------------------------------------------------------------------------
# update_number_input
#--------------------------------------------------------------------------
def update_number_input
@number_window.update
if Input.trigger?(Input::
Sound.play_decision
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@number_window.active = false
@number_window.visible = false
elsif Input.trigger?(Input::C)
Sound.play_shop
if $imported["VariableControlledDiscounts"]
price = @item.price * $game_variables[YE::EVENT::VARIABLE::PERCENT_BUY]
price /= YE::EVENT::VARIABLE::PERCENT_DIVISOR
else
price = @item.price
end
$game_party.lose_gold(@number_window.number * price)
$game_party.gain_item(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@number_window.active = false
@number_window.visible = false
end
end
#--------------------------------------------------------------------------
# update_synth_number
#--------------------------------------------------------------------------
def update_synth_number
@synth_number.update
if Input.trigger?(Input::
Sound.play_decision
@synth_list.active = true
@synth_list.visible = true
@synth_number.active = false
@synth_number.visible = false
elsif Input.trigger?(Input::C)
Sound.play_shop
item = @synth_list.item
$game_party.lose_gold(@synth_number.number * item.synth_cost)
if item.synth_actor.include?($game_party.members[@actor_index].id)
synth = item.synth_actor[$game_party.members[@actor_index].id]
else
synth = item.synth_actor[0]
end
$game_party.gain_item(synth, @synth_number.number)
consume_ingredients(item, @synth_number.number)
@gold_window.refresh
$game_actors[@actor_id].learn_recipe(item)
run_common_event(item)
@synth_list.refresh(@actor_index)
@ingre_list.refresh(@actor_index)
@synth_list.active = true
@synth_list.visible = true
@synth_number.active = false
@synth_number.visible = false
end
end
#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(item)
return false if item == nil
return false if @actor_index == -1
return false if item.synth_block.include?(@actor_id)
return false unless (item.synth_actor.include?(@actor_id) or
item.synth_actor.include?(0))
for ingredient in item.ingredients
return false if $game_party.item_number(ingredient[0]) < ingredient[1]
end
return false unless $game_party.gold >= item.synth_cost
return true
end
#--------------------------------------------------------------------------
# synthesize_item
#--------------------------------------------------------------------------
def synthesize_item(item)
if item.synth_cost > 0
max = $game_party.gold / item.synth_cost
else
max = $game_party.gold
end
if item.synth_consume?
max = [max, $game_party.item_number(item)].min
end
for ingredient in item.ingredients
next if ingredient[1] == 0
n = $game_party.item_number(ingredient[0]) / ingredient[1]
max = [max, n].min
end
number = $game_party.item_number(item)
limit = ($imported["LimitBreak"] ? item.number_limit : 99)
max = [max, limit - number].min
synth = synth_number_item(item)
@synth_number.set(synth, max, item.synth_cost, item)
@synth_number.visible = true
@synth_number.active = true
@synth_list.visible = false
@synth_list.active = false
end
#--------------------------------------------------------------------------
# consume_ingredients
#--------------------------------------------------------------------------
def consume_ingredients(item, number)
if item.synth_consume?
$game_party.lose_item(item, number)
end
for ingredient in item.ingredients
$game_party.lose_item(ingredient[0], number * ingredient[1])
end
end
#--------------------------------------------------------------------------
# synth_number_item
#--------------------------------------------------------------------------
def synth_number_item(item)
if item.is_a?(RPG::Item)
if $game_party.members[@actor_index].synth_items.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
item = item.synth_actor[$game_party.members[@actor_index].id]
elsif item.synth_actor.include?(0)
item = item.synth_actor[0]
end
end
elsif item.is_a?(RPG::Weapon)
if $game_party.members[@actor_index].synth_weapons.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
item = item.synth_actor[$game_party.members[@actor_index].id]
elsif item.synth_actor.include?(0)
item = item.synth_actor[0]
end
end
elsif item.is_a?(RPG::Armor)
if $game_party.members[@actor_index].synth_armours.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
item = item.synth_actor[$game_party.members[@actor_index].id]
elsif item.synth_actor.include?(0)
item = item.synth_actor[0]
end
end
end
return item
end
#--------------------------------------------------------------------------
# run_common_event
#--------------------------------------------------------------------------
def run_common_event(item)
event = nil
actor = $game_party.members[@actor_index]
if item.synth_event.include?(actor.id)
@synth_list.update
event = item.synth_event[actor.id]
elsif item.synth_event.include?(0)
@synth_list.update
event = item.synth_event[0]
end
return if event == nil
if !actor.synth_events.include?(event) or item.replay_event?
actor.synth_events.push(event) unless actor.synth_events.include?(event)
if YE::SYNTH::EVENT_IN_SHOP
@common_event = event
else
$game_temp.common_event_id = event
$scene = Scene_Map.new
end
end
end
end # Scene_Synthesis
#==============================================================================
# Window_SynthList
#==============================================================================
class Window_SynthList < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(x, y, w, h)
super(x, y, w, h)
self.visible = false
self.active = false
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(actor_index = -1)
@data = []
for goods_item in $game_temp.shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
next if item == nil
next unless item.recipe?
next unless $game_party.has_item?(item)
@data.push(item)
end
@item_max = @data.size
create_contents
@actor_index = actor_index
@actor_id = $game_party.members[@actor_index].id
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
enable = enabled?(item)
if @actor_index >= 0 and item.synth_actor.include?(@actor_id)
if item.is_a?(RPG::Item)
if $game_actors[@actor_id].synth_items.include?(item.id)
item = item.synth_actor[@actor_id]
end
elsif item.is_a?(RPG::Weapon)
if $game_actors[@actor_id].synth_weapons.include?(item.id)
item = item.synth_actor[@actor_id]
end
elsif item.is_a?(RPG::Armor)
if $game_actors[@actor_id].synth_armours.include?(item.id)
item = item.synth_actor[@actor_id]
end
end
elsif @actor_index >= 0 and item.synth_actor.include?(0)
if item.is_a?(RPG::Item)
if $game_actors[@actor_id].synth_items.include?(item.id)
item = item.synth_actor[0]
end
elsif item.is_a?(RPG::Weapon)
if $game_actors[@actor_id].synth_weapons.include?(item.id)
item = item.synth_actor[0]
end
elsif item.is_a?(RPG::Armor)
if $game_actors[@actor_id].synth_armours.include?(item.id)
item = item.synth_actor[0]
end
end
end
draw_item_name(item, rect.x, rect.y, enable)
end
#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(item)
return false if item == nil
return false if @actor_index == -1
return false if item.synth_block.include?(@actor_id)
return false unless (item.synth_actor.include?(@actor_id) or
item.synth_actor.include?(0))
for ingredient in item.ingredients
return false if $game_party.item_number(ingredient[0]) < ingredient[1]
end
return false unless $game_party.gold >= item.synth_cost
return true
end
#--------------------------------------------------------------------------
# return item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# update_help
#--------------------------------------------------------------------------
def update_help
if item == nil
text = ""
else
text = item.description
end
if item.is_a?(RPG::Item)
if $game_party.members[@actor_index].synth_items.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
text =
item.synth_actor[$game_party.members[@actor_index].id].description
elsif item.synth_actor.include?(0)
text = item.synth_actor[0].description
end
end
elsif item.is_a?(RPG::Weapon)
if $game_party.members[@actor_index].synth_weapons.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
text =
item.synth_actor[$game_party.members[@actor_index].id].description
elsif item.synth_actor.include?(0)
text = item.synth_actor[0].description
end
end
elsif item.is_a?(RPG::Armor)
if $game_party.members[@actor_index].synth_armours.include?(item.id)
if item.synth_actor.include?($game_party.members[@actor_index].id)
text =
item.synth_actor[$game_party.members[@actor_index].id].description
elsif item.synth_actor.include?(0)
text = item.synth_actor[0].description
end
end
end
@help_window.set_text(text)
end
end # Window_SynthList
#==============================================================================
# Window_Ingredients
#==============================================================================
class Window_Ingredients < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(x, y, w, h)
super(x, y, w, h)
self.visible = false
@item = nil
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(actor_index = -1)
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.color.alpha = 255
self.contents.font.size = Font.default_size
@actor_index = actor_index
draw_actor
draw_ingredients
end
#--------------------------------------------------------------------------
# return item
#--------------------------------------------------------------------------
def item
return @item
end
#--------------------------------------------------------------------------
# item=
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
#--------------------------------------------------------------------------
# draw_actor
#--------------------------------------------------------------------------
def draw_actor
return if @actor_index < 0
sw = self.width - 32
actor = $game_party.members[@actor_index]
draw_actor_graphic(actor, 24, WLH*2)
self.contents.draw_text(48, 0, sw-48, WLH, actor.name)
self.contents.font.size = YE::SYNTH::SYNTH_FSIZE
total = actor.synth_items.size + actor.synth_weapons.size +
actor.synth_armours.size
text = sprintf(YE::SYNTH::SYNTH_TOTAL, total)
xoffset = YE::SYNTH::SYNTH_OFFSET
self.contents.draw_text(48, 24, sw-48, WLH, text)
end
#--------------------------------------------------------------------------
# draw_ingredients
#--------------------------------------------------------------------------
def draw_ingredients
return if @item == nil
self.contents.font.size = Font.default_size
sw = self.width - 32
dy = 48
if incompatible? or
@item.synth_block.include?($game_party.members[@actor_index].id)
self.contents.font.color = text_color(YE::SYNTH::SYNTH_INCOLR)
self.contents.draw_text(0, dy, sw, WLH, YE::SYNTH::SYNTH_INCOMP, 1)
return
else
self.contents.font.color = system_color
self.contents.draw_text(0, dy, sw, WLH, @item.name, 1)
end
dy += 24
self.contents.font.color = normal_color
self.contents.font.size = YE::SYNTH::SYNTH_FSIZE
if item.synth_cost > 0
enabled = ($game_party.gold >= item.synth_cost) ? true : false
draw_icon(YE::SYNTH::SYNTH_C_ICON, 0, dy, enabled)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(24, dy, sw-24, WLH, YE::SYNTH::SYNTH_COST)
text = sprintf(YE::SYNTH::SYNTH_T_COST, item.synth_cost, Vocab.gold)
self.contents.draw_text(24, dy, sw-24, WLH, text, 2)
dy += 24
end
if item.synth_consume?
draw_item_name(item, 0, dy)
amount = $game_party.item_number(item)
text = sprintf(YE::SYNTH::SYNTH_AMT, 1, amount)
self.contents.draw_text(0, dy, sw, WLH, text, 2)
dy += 24
end
item_list = @item.ingredients.sort { |a,b| a[0].name <=> b[0].name }
for key in item_list
amount = $game_party.item_number(key[0])
if amount >= key[1]
self.contents.font.color.alpha = 255
enabled = true
else
self.contents.font.color.alpha = 128
enabled = false
end
draw_item_name(key[0], 0, dy, enabled)
text = sprintf(YE::SYNTH::SYNTH_AMT, key[1], amount)
self.contents.draw_tex