Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Enchant System - Main Script
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.5
- # * Updated: 22/02/2015
- # * Requires: Vlue's W/A Randomizer script
- # Sixth's Custom Feature Extension for Vlue's Randomizer
- #-------------------------------------------------------------------------------
- # * This part contains the code for the enchant system.
- # Do not edit anything in it, unless you know what you are doing!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthEnchantSystem"] = true
- class Game_Interpreter
- def enchant_scene(info1=Sixth_Enchant_Scene::Prefixes,
- info2=Sixth_Enchant_Scene::Suffixes,
- random=Sixth_Enchant_Scene::Default_Random_Command,
- phide=Sixth_Enchant_Scene::Hidden_Prefs,
- shide=Sixth_Enchant_Scene::Hidden_Suffs)
- SceneManager.call(Scene_SixthEnchant)
- SceneManager.scene.prepare(info1,info2,random,phide,shide)
- end
- def edit_enc_bonus(categ,value)
- $game_system.enchant_bonus[categ] = value
- end
- def exclude_enc(t,excl)
- l = t == :pref ? Sixth_Enchant_Scene::Prefixes : Sixth_Enchant_Scene::Suffixes
- excl.each do |id|
- l.delete(id)
- end
- return l
- end
- def enc_categ(categ)
- $game_system.enchant_categories = categ
- end
- end
- class Window_Base
- def draw_affix_info(id,x,y,width,enabled=true)
- color = id[:color] ? id[:color] : normal_color
- icon = id[:enc_info][:icon]
- text = Sixth_Enchant_Scene::BeforeTxt+id[:enc_info][:name]+Sixth_Enchant_Scene::AfterTxt
- draw_icon(icon, x, y, enabled)
- change_color(color, enabled)
- draw_text(x + 26, y, width, line_height, text)
- change_color(normal_color)
- end
- def draw_random_enc_info(aff,x,y,width,enabled=true)
- if aff == 0
- affix = Sixth_Enchant_Scene::Rand_Enc_Pref
- else
- affix = Sixth_Enchant_Scene::Rand_Enc_Suff
- end
- color = Color.new(*affix[:color])
- icon = affix[:icon]
- text = affix[:name]
- draw_icon(icon, x, y, enabled)
- change_color(color, enabled)
- draw_text(x + 26, y, width, line_height, text)
- change_color(normal_color)
- end
- end
- class RPG::BaseItem
- def enchant_price
- @note =~ /<enc price: (\d+)>/i ? $1.to_i : Sixth_Enchant_Scene::Default_Enchant_Fee
- end
- def hide_from_enchant?
- @note =~ /<enchant hide>/i
- end
- def enchant_chance
- @note =~ /<enc chance: (\d+)>/i ? $1.to_i : Sixth_Enchant_Scene::Default_Enchant_Chance
- end
- def pref_id # Not used yet!
- @pref_id ? @pref_id : nil
- end
- def suff_id # Not used yet!
- @suff_id ? @suff_id : nil
- end
- def set_aff_id(new_id,pref=false) # Not used yet!
- if pref == true
- @pref_id = new_id
- else
- @suff_id = new_id
- end
- end
- end
- class Game_System
- attr_accessor :enchant_bonus
- attr_accessor :enchant_categories
- alias sixth_enc_ini12213 initialize
- def initialize
- sixth_enc_ini12213
- @enchant_bonus = [0,0,0]
- @enchant_categories = [:item,:weapon,:armor]
- end
- end
- class Scene_SixthEnchant < Scene_Base
- include Sixth_Enchant_Scene
- def start
- super
- create_all_windows
- end
- def prepare(info1,info2,random,phide,shide)
- @pref_list = info1
- @suff_list = info2
- @random = random
- @phide = phide
- @shide = shide
- end
- def create_all_windows
- @help_window = Window_Help.new
- @help_window.y = Window_Setup[:help][:y_pos]
- create_command_window
- create_item_window
- create_prefix_window
- create_suffix_window
- create_detail_window
- create_gold_window
- create_ending_window
- @help_window.clear
- end
- def create_command_window
- @commands = Enchy_Commands.new
- @commands.set_handler(:ok, method(:on_category_ok))
- @commands.set_handler(:cancel, method(:on_category_cancel))
- end
- def create_item_window
- x = Window_Setup[:item][:pos][0]; y = Window_Setup[:item][:pos][1]
- w = Window_Setup[:item][:size][0]; h = Window_Setup[:item][:size][1]
- @items = Enchy_Items.new(x,y,w,h)
- @items.set_handler(:ok, method(:on_items_ok))
- @items.set_handler(:cancel, method(:on_items_cancel))
- @items.help_window = @help_window
- @commands.item_list = @items
- end
- def create_prefix_window
- @prefixes = Enchy_Prefixes.new(@pref_list,@random)
- @prefixes.set_handler(:prefix, method(:on_prefixes))
- @prefixes.set_handler(:cancel, method(:on_prefix_cancel))
- @prefixes.help_window = @help_window
- @prefixes.hide.close
- end
- def create_suffix_window
- @suffixes = Enchy_Suffixes.new(@suff_list,@random)
- @suffixes.set_handler(:suffix, method(:on_suffixes))
- @suffixes.set_handler(:cancel, method(:on_suffix_cancel))
- @suffixes.help_window = @help_window
- @suffixes.hide.close
- end
- def create_detail_window
- @details = Enchy_Details.new
- end
- def create_gold_window
- @goldy = Enchy_Gold.new
- end
- def create_ending_window
- @finish = Enchy_Finish.new
- @finish.set_handler(:finish, method(:on_finish))
- @finish.set_handler(:cancel, method(:on_finish_cancel))
- @finish.hide.close
- end
- def on_category_ok
- Sound.play_ok
- case @commands.current_symbol
- when :item
- @prefixes.enc_item[0] = @suffixes.enc_item[0] = 0
- @item_sound = Item_OK
- @bonus = $game_system.enchant_bonus[0]
- when :weapon
- @prefixes.enc_item[0] = @suffixes.enc_item[0] = 1
- @item_sound = Weap_OK
- @bonus = $game_system.enchant_bonus[1]
- when :armor
- @prefixes.enc_item[0] = @suffixes.enc_item[0] = 2
- @item_sound = Armr_OK
- @bonus = $game_system.enchant_bonus[2]
- end
- @prefixes.make_command_list
- @suffixes.make_command_list
- @items.select_last
- @details.refresh(1)
- @items.activate
- end
- def on_category_cancel
- Sound.play_cancel
- $game_system.enchant_bonus = [0,0,0] if Reset_Bonus == true
- $game_system.enchant_categories = Reset_Categories if !Reset_Categories.nil?
- return_scene
- end
- def on_items_ok
- @item_sound.play
- @item = @items.item
- @gold = $game_party.gold
- @gold -= @item.enchant_price
- if Rand_Enc_Pref[:price] == :average
- @r_price1 = get_random_price(@prefixes.pref_list,true)
- else
- @r_price1 = Rand_Enc_Pref[:price]
- end
- @prefixes.enc_item[2] = @r_price1
- @prefixes.enc_item[1] = @gold
- @prefixes.refresh
- @details.refresh(2,@item)
- @prefixes.select(0)
- @prefixes.show.open
- @prefixes.activate
- @items.deactivate
- @items.hide.close
- end
- def on_items_cancel
- Sound.play_cancel
- @items.unselect
- @details.refresh
- @help_window.clear
- @commands.activate
- end
- def get_random_price(affixes,pref=false)
- @rand_fee = 0
- no_enc = pref == true ? No_Enchant[0] : No_Enchant[1]
- affixes.each do |affix|
- next if affix == no_enc && AFFIXES[no_enc][:enc_info][:price] == 0
- @rand_fee += AFFIXES[affix][:enc_info][:price]
- end
- pdiv = affixes.size
- pdiv -= 1 if affixes.include?(no_enc) && AFFIXES[no_enc][:enc_info][:price] == 0
- pdiv = 1 if pdiv == 0
- frand_fee = (@rand_fee/pdiv).to_i
- return frand_fee
- end
- def on_prefixes
- Pref_OK.play
- @prefixes.deactivate
- @prefixes.hide.close
- if @prefixes.current_ext == -10
- @gold -= @r_price1
- else
- @gold -= AFFIXES[@prefixes.current_ext][:enc_info][:price]
- end
- if Rand_Enc_Suff[:price] == :average
- @r_price2 = get_random_price(@suffixes.suff_list)
- else
- @r_price2 = Rand_Enc_Suff[:price]
- end
- @suffixes.enc_item[3] = @r_price2
- @suffixes.enc_item[1] = @gold
- if Allow_Clear == false
- @suffixes.enc_item[2] = false if @prefixes.current_ext == No_Enchant[0]
- end
- @suffixes.refresh
- @details.refresh(3,@item,@prefixes.current_ext,nil,[@r_price1,nil])
- @suffixes.select(0)
- @suffixes.show.open
- @suffixes.activate
- end
- def on_prefix_cancel
- Sound.play_cancel
- @prefixes.deactivate
- @prefixes.hide.close
- @details.refresh(1)
- @items.show.open
- @items.help_window.refresh
- @items.activate
- end
- def on_suffixes
- Suff_OK.play
- @suffixes.deactivate
- @details.refresh(0,@item,@prefixes.current_ext,@suffixes.current_ext,[@r_price1,@r_price2])
- @finish.show.open
- @finish.activate
- end
- def on_suffix_cancel
- Sound.play_cancel
- @suffixes.deactivate
- @suffixes.hide.close
- if @prefixes.current_ext == -10
- @gold += @r_price1
- else
- @gold += AFFIXES[@prefixes.current_ext][:enc_info][:price]
- end
- @prefixes.enc_item[1] = @gold
- @prefixes.refresh
- @suffixes.enc_item[2] = true
- @details.refresh(2,@item)
- @prefixes.show.open
- @prefixes.activate
- end
- def get_extra_random_affix(list,categ)
- @hide_mod = []
- list.each do |id|
- next if AFFIXES[id].nil? || AFFIXES[id][:enc_info].nil?
- next if !AFFIXES[id][:enc_info][:category].include?(categ)
- @hide_mod.push(id)
- end
- end
- def do_random_enchant_prefix
- if @phide.size > 0
- get_extra_random_affix(@phide,@prefixes.enc_item[0])
- end
- pl = @prefixes.pref_list.size
- pl += @hide_mod.size if @phide.size > 0 && @hide_mod.size > 0
- pp = rand(pl)
- pfl = @prefixes.pref_list
- pfl += @hide_mod if @phide.size > 0 && @hide_mod != []
- prefix = pfl[pp]
- if Rand_Enc_Pref[:bonus] == false
- chance1 = Rand_Enc_Pref[:chance]
- else
- chance1 = [[0,Rand_Enc_Pref[:chance]*((@item.enchant_chance+@bonus)*0.01)].max,100].min
- end
- return "<PREFIX#{prefix} #{chance1.round}>"
- end
- def do_random_enchant_suffix
- if @shide.size > 0
- get_extra_random_affix(@shide,@suffixes.enc_item[0])
- end
- sl = @suffixes.suff_list.size
- sl += @hide_mod.size if @shide.size > 0 && @hide_mod.size > 0
- ss = rand(sl)
- sfl = @suffixes.suff_list
- sfl += @hide_mod if @shide.size > 0 && @hide_mod != []
- suffix = sfl[ss]
- if Rand_Enc_Suff[:bonus] == false
- chance2 = Rand_Enc_Suff[:chance]
- else
- chance2 = [[0,Rand_Enc_Suff[:chance]*((@item.enchant_chance+@bonus)*0.01)].max,100].min
- end
- return "<SUFFIX#{suffix} #{chance2.round}>"
- end
- def on_finish
- Fnsh_OK.play
- @finish.deactivate
- @finish.hide.close
- if @prefixes.current_ext == -10
- subnote1 = do_random_enchant_prefix
- pprice = @r_price1
- item_pre = $data_items[Rand_Enc_Pref[:item]] if Item_Req == true && !Rand_Enc_Pref[:item].nil?
- else
- prefix = AFFIXES[@prefixes.current_ext]
- if prefix[:enc_info][:bonus] == false
- chance1 = prefix[:enc_info][:chance]
- else
- chance1 = [[0,prefix[:enc_info][:chance]*((@item.enchant_chance+@bonus)*0.01)].max,100].min
- end
- subnote1 = "<PREFIX#{@prefixes.current_ext} #{chance1.round}>"
- pprice = prefix[:enc_info][:price]
- item_pre = $data_items[prefix[:enc_info][:item]] if Item_Req == true && !prefix[:enc_info][:item].nil?
- end
- if @suffixes.current_ext == -10
- subnote2 = do_random_enchant_suffix
- sprice = @r_price2
- item_suf = $data_items[Rand_Enc_Suff[:item]] if Item_Req == true && !Rand_Enc_Suff[:item].nil?
- else
- suffix = AFFIXES[@suffixes.current_ext]
- if suffix[:enc_info][:bonus] == false
- chance2 = suffix[:enc_info][:chance]
- else
- chance2 = [[0,suffix[:enc_info][:chance]*((@item.enchant_chance+@bonus)*0.01)].max,100].min
- end
- subnote2 = "<SUFFIX#{@suffixes.current_ext} #{chance2.round}>"
- sprice = suffix[:enc_info][:price]
- item_suf = $data_items[suffix[:enc_info][:item]] if Item_Req == true && !suffix[:enc_info][:item].nil?
- end
- subnote = subnote1 + subnote2
- iprice = @item.enchant_price
- total = pprice + sprice + iprice
- if @item.is_a?(RPG::Item)
- $game_party.add_item(@item.original_id,1,false,subnote)
- elsif @item.is_a?(RPG::Weapon)
- $game_party.add_weapon(@item.original_id,1,false,subnote)
- elsif @item.is_a?(RPG::Armor)
- $game_party.add_armor(@item.original_id,1,false,subnote)
- end
- $game_party.lose_item(@item,1)
- if Item_Req == true
- $game_party.lose_item(item_pre,1)
- $game_party.lose_item(item_suf,1)
- end
- $game_party.lose_gold(total)
- @suffixes.hide.close
- @suffixes.enc_item[2] = true
- @items.refresh
- @details.refresh(1)
- @goldy.refresh
- @items.select(0)
- @items.show.open
- @items.help_window.refresh
- @items.activate
- end
- def on_finish_cancel
- Sound.play_cancel
- @finish.deactivate
- @finish.hide.close
- @details.refresh(3,@item,@prefixes.current_ext,nil,[@r_price1,nil])
- @suffixes.activate
- end
- end
- class Enchy_Commands < Window_Command
- include Sixth_Enchant_Scene
- def initialize
- x = Window_Setup[:category][:pos][0]; y = Window_Setup[:category][:pos][1]
- super(x,y)
- self.windowskin = Cache.system(Window_Setup[:category][:skin])
- end
- def window_width
- Window_Setup[:category][:size][0]
- end
- def window_height
- Window_Setup[:category][:size][1]
- end
- def alignment
- return Window_Setup[:category][:align]
- end
- def spacing
- Window_Setup[:category][:spacing]
- end
- def col_max
- return Window_Setup[:category][:columns]
- end
- def update
- super
- @item_list.category = current_symbol if @item_list
- end
- def make_command_list
- add_command(Weaps_Cmd,:weapon) if $game_system.enchant_categories.include?(:weapon)
- add_command(Armrs_Cmd,:armor) if $game_system.enchant_categories.include?(:armor)
- add_command(Items_Cmd,:item) if $game_system.enchant_categories.include?(:item)
- add_command(Exxit_Cmd,:cancel)
- end
- def draw_item(index)
- contents.font.name = Text_Options[:cmnd_win][0]
- contents.font.size = Text_Options[:cmnd_win][1]
- super
- end
- def item_list=(item_window)
- @item_list = item_window
- update
- end
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- end
- class Enchy_Items < Window_ItemList
- include Sixth_Enchant_Scene
- def initialize(x,y,width,height)
- super
- self.windowskin = Cache.system(Window_Setup[:item][:skin])
- refresh
- end
- def col_max
- 1
- end
- def update_padding_bottom
- self.padding_bottom = padding
- end
- def enable?(item)
- return false unless item && item.enchant_price <= $game_party.gold
- return false if !item.nil? && Enable_ReEnchant == false && item.original_id != item.id
- true
- end
- def current_item
- @data[index]
- end
- def select_last
- select(@data.index($game_party.last_item.object) || 0)
- end
- def make_item_list
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.push(nil) if include?(nil)
- end
- def item_height
- line_height*2
- end
- def include?(item)
- return false if !item.nil? && item.hide_from_enchant?
- super
- end
- def draw_item_number(rect, item, enable)
- change_color(system_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,IOwned_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,$game_party.item_number(item),2)
- end
- def draw_item_enc_price(rect, item, enable)
- change_color(system_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,IPrice_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,item.enchant_price,2)
- end
- def draw_item(index)
- contents.font.name = Text_Options[:item_win][0]
- contents.font.size = Text_Options[:item_win][1]
- item = @data[index]
- if item
- rect = item_rect(index)
- contents.fill_rect(rect.x,rect.y+1,contents.width,rect.height-2,Color.new(*BackGrdColor))
- draw_item_name(item, rect.x, rect.y, enable?(item),contents.width)
- rect.y += line_height
- draw_item_number(rect, item, enable?(item))
- draw_item_enc_price(rect, item, enable?(item))
- end
- end
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- end
- class Enchy_Prefixes < Window_Command
- include Sixth_Enchant_Scene
- attr_accessor :enc_item
- attr_reader :pref_list
- def initialize(enc_list,random)
- x = Window_Setup[:item][:pos][0]; y = Window_Setup[:item][:pos][1]
- @random = random
- @pref_list = []
- @enc_list = enc_list
- @enc_item = [-1,0,0] #,nil]
- super(x,y)
- self.windowskin = Cache.system(Window_Setup[:item][:skin])
- end
- def window_width
- Window_Setup[:item][:size][0]
- end
- def window_height
- Window_Setup[:item][:size][1]
- end
- def item_height
- Item_Req == true ? line_height*2 : line_height
- end
- def update_padding_bottom
- self.padding_bottom = padding
- end
- def make_command_list
- @pref_list.clear
- @enc_list.each do |id|
- next if AFFIXES[id].nil? || AFFIXES[id][:enc_info].nil?
- @pref_list.push(id) if !@pref_list.include?(id) && current_item_for_enc(id)
- add_command(AFFIXES[id][:enc_info][:name],:prefix,can_add(id),id) if current_item_for_enc(id)
- end
- add_command(Rand_Enc_Pref[:name],:prefix,can_add_random,-10) if random_enchant_enabled
- end
- def can_add(id)
- if Item_Req == true && !AFFIXES[id][:enc_info][:item].nil?
- return false if $game_party.item_number($data_items[AFFIXES[id][:enc_info][:item]]) <= 0
- end
- return true if AFFIXES[id][:enc_info][:price] <= @enc_item[1]
- return false
- end
- def current_item_for_enc(id)
- if Item_Req == true && Show_All == false && !AFFIXES[id][:enc_info][:item].nil?
- return false if $game_party.item_number($data_items[AFFIXES[id][:enc_info][:item]]) <= 0
- end
- return true if AFFIXES[id][:enc_info][:category].include?(@enc_item[0])
- return false
- end
- def can_add_random
- return false if !Rand_Enc_Pref[:item].nil? && $game_party.item_number($data_items[Rand_Enc_Pref[:item]]) <= 0 && Item_Req == true
- return true if @enc_item[2] <= @enc_item[1]
- return false
- end
- def random_enchant_enabled
- if Item_Req == true && Show_All == false && !Rand_Enc_Pref[:item].nil?
- return false if $game_party.item_number($data_items[Rand_Enc_Pref[:item]]) <= 0
- end
- return true if @random == true
- return false
- end
- def update_help
- @help_window.contents.clear
- return if current_ext.nil?
- return if self.active == false
- if current_ext == -10
- @help_window.draw_random_enc_info(0,0,0,contents.width)
- @help_window.draw_text_ex(0,line_height,Rand_Enc_Pref[:description])
- else
- id = AFFIXES[current_ext]
- @help_window.draw_affix_info(id,0,0,contents.width)
- @help_window.draw_text_ex(0,line_height,id[:enc_info][:description]) if !id[:enc_info][:description].nil?
- end
- end
- def draw_item_number(rect, item, enable)
- return if item.nil?
- change_color(system_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,IOwned_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,$game_party.item_number(item),2)
- end
- def draw_item_enc_price(rect, price, enable)
- change_color(system_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,IPrice_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,price,2)
- end
- def draw_item(index)
- contents.font.name = Text_Options[:item_win][0]
- contents.font.size = Text_Options[:item_win][1]
- rect = item_rect(index)
- contents.fill_rect(rect.x,rect.y+1,contents.width,rect.height-2,Color.new(*BackGrdColor))
- if Item_Req == true
- if @list[index][:ext] == -10
- price = @enc_item[2]
- enabled = can_add_random
- draw_random_enc_info(0,rect.x,rect.y,contents.width,enabled)
- rect.y += line_height
- item = $data_items[Rand_Enc_Pref[:item]] if !Rand_Enc_Pref[:item].nil?
- draw_item_number(rect, item, enabled)
- draw_item_enc_price(rect, price, enabled)
- else
- id = AFFIXES[@list[index][:ext]]
- price = id[:enc_info][:price]
- enabled = can_add(@list[index][:ext])
- draw_affix_info(id,rect.x,rect.y,rect.width,enabled)
- rect.y += line_height
- if !id[:enc_info][:item].nil?
- item = $data_items[id[:enc_info][:item]]
- draw_item_number(rect, item, enabled)
- end
- draw_item_enc_price(rect, price, enabled)
- end
- else
- if @list[index][:ext] == -10
- price = @enc_item[2]
- enabled = can_add_random
- draw_random_enc_info(0,rect.x,rect.y,contents.width,enabled)
- else
- id = AFFIXES[@list[index][:ext]]
- price = id[:enc_info][:price]
- enabled = can_add(@list[index][:ext])
- draw_affix_info(id,rect.x,rect.y,rect.width,enabled)
- end
- contents.font.color.alpha = translucent_alpha unless enabled
- draw_text(rect.x,rect.y,rect.width,rect.height,price,2)
- end
- end
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- end
- class Enchy_Suffixes < Window_Command
- include Sixth_Enchant_Scene
- attr_accessor :enc_item
- attr_reader :suff_list
- def initialize(enc_list,random)
- x = Window_Setup[:item][:pos][0]; y = Window_Setup[:item][:pos][1]
- @random = random
- @suff_list = []
- @enc_list = enc_list
- @enc_item = [-1,0,true,0]
- super(x,y)
- self.windowskin = Cache.system(Window_Setup[:item][:skin])
- end
- def window_width
- Window_Setup[:item][:size][0]
- end
- def window_height
- Window_Setup[:item][:size][1]
- end
- def item_height
- Item_Req == true ? line_height*2 : line_height
- end
- def update_padding_bottom
- self.padding_bottom = padding
- end
- def make_command_list
- @suff_list.clear
- @enc_list.each do |id|
- next if AFFIXES[id].nil? || AFFIXES[id][:enc_info].nil?
- @suff_list.push(id) if !@suff_list.include?(id) && current_item_for_enc(id)
- add_command(AFFIXES[id][:enc_info][:name],:suffix,can_add(id),id) if current_item_for_enc(id)
- end
- add_command(Rand_Enc_Suff[:name],:suffix,can_add_random,-10) if random_enchant_enabled
- end
- def can_add(id)
- return false if id == No_Enchant[1] && @enc_item[2] == false
- if Item_Req == true && !AFFIXES[id][:enc_info][:item].nil?
- return false if $game_party.item_number($data_items[AFFIXES[id][:enc_info][:item]]) <= 0
- end
- return true if AFFIXES[id][:enc_info][:price] <= @enc_item[1]
- return false
- end
- def current_item_for_enc(id)
- if Item_Req == true && Show_All == false && !AFFIXES[id][:enc_info][:item].nil?
- return false if $game_party.item_number($data_items[AFFIXES[id][:enc_info][:item]]) <= 0
- end
- return true if AFFIXES[id][:enc_info][:category].include?(@enc_item[0])
- return false
- end
- def can_add_random
- return false if !Rand_Enc_Suff[:item].nil? && $game_party.item_number($data_items[Rand_Enc_Suff[:item]]) <= 0 && Item_Req == true
- return true if @enc_item[3] <= @enc_item[1]
- return false
- end
- def random_enchant_enabled
- if Item_Req == true && Show_All == false && !Rand_Enc_Suff[:item].nil?
- return false if $game_party.item_number($data_items[Rand_Enc_Suff[:item]]) <= 0
- end
- return true if @random == true
- return false
- end
- def update_help
- @help_window.contents.clear
- return if current_ext.nil?
- return if self.active == false
- if current_ext == -10
- @help_window.draw_random_enc_info(1,0,0,contents.width)
- @help_window.draw_text_ex(0,line_height,Rand_Enc_Suff[:description])
- else
- id = AFFIXES[current_ext]
- @help_window.draw_affix_info(id,0,0,contents.width)
- @help_window.draw_text_ex(0,line_height,id[:enc_info][:description]) if !id[:enc_info][:description].nil?
- end
- end
- def draw_item_number(rect, item, enable)
- return if item.nil?
- change_color(system_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,IOwned_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+contents.width/2+4,rect.y,contents.width/2-8,line_height,$game_party.item_number(item),2)
- end
- def draw_item_enc_price(rect, price, enable)
- change_color(system_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,IPrice_Text)
- change_color(normal_color, enable)
- draw_text(rect.x+4,rect.y,contents.width/2-8,line_height,price,2)
- end
- def draw_item(index)
- contents.font.name = Text_Options[:item_win][0]
- contents.font.size = Text_Options[:item_win][1]
- rect = item_rect(index)
- contents.fill_rect(rect.x,rect.y+1,contents.width,rect.height-2,Color.new(*BackGrdColor))
- if Item_Req == true
- if @list[index][:ext] == -10
- price = @enc_item[3]
- enabled = can_add_random
- draw_random_enc_info(1,rect.x,rect.y,contents.width,enabled)
- rect.y += line_height
- item = $data_items[Rand_Enc_Suff[:item]] if !Rand_Enc_Suff[:item].nil?
- draw_item_number(rect, item, enabled)
- draw_item_enc_price(rect, price, enabled)
- else
- id = AFFIXES[@list[index][:ext]]
- price = id[:enc_info][:price]
- enabled = can_add(@list[index][:ext])
- draw_affix_info(id,rect.x,rect.y,rect.width,enabled)
- rect.y += line_height
- if !id[:enc_info][:item].nil?
- item = $data_items[id[:enc_info][:item]]
- draw_item_number(rect, item, enabled)
- end
- draw_item_enc_price(rect, price, enabled)
- end
- else
- if @list[index][:ext] == -10
- price = @enc_item[2]
- enabled = can_add_random
- draw_random_enc_info(1,rect.x,rect.y,contents.width,enabled)
- else
- id = AFFIXES[@list[index][:ext]]
- price = id[:enc_info][:price]
- enabled = can_add(@list[index][:ext])
- draw_affix_info(id,rect.x,rect.y,rect.width,enabled)
- end
- contents.font.color.alpha = translucent_alpha unless enabled
- draw_text(rect.x,rect.y,rect.width,rect.height,price,2)
- end
- end
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- end
- class Enchy_Details < Window_Base
- include Sixth_Enchant_Scene
- def initialize
- x = Window_Setup[:detail][:pos][0]; y = Window_Setup[:detail][:pos][1]
- w = Window_Setup[:detail][:size][0]; h = Window_Setup[:detail][:size][1]
- super(x,y,w,h)
- self.windowskin = Cache.system(Window_Setup[:detail][:skin])
- refresh
- end
- def refresh(decision=0,item=nil,prefix=nil,suffix=nil,random=nil)
- contents.clear
- @fillc = Color.new(*TextBoxColor)
- 3.times do |i|
- contents.fill_rect(Detail_Info_X,Detail_Info_Y-1+i*(line_height*2+4),contents.width,line_height*2+2,@fillc)
- end
- if item.is_a?(RPG::Item)
- bonus = $game_system.enchant_bonus[0]
- elsif item.is_a?(RPG::Weapon)
- bonus = $game_system.enchant_bonus[1]
- elsif item.is_a?(RPG::Armor)
- bonus = $game_system.enchant_bonus[2]
- end
- contents.fill_rect(Total_Price_X,Total_Price_Y-1,contents.width,line_height+2,@fillc)
- color1 = Color.new(*Line_Colors[:item_up])
- color2 = Color.new(*Line_Colors[:item_dw])
- color3 = Color.new(*Line_Colors[:pref_up])
- color4 = Color.new(*Line_Colors[:pref_dw])
- color5 = Color.new(*Line_Colors[:suff_up])
- color6 = Color.new(*Line_Colors[:suff_dw])
- color7 = Color.new(*Line_Colors[:titl_up])
- color8 = Color.new(*Line_Colors[:titl_dw])
- contents.font.name = Text_Options[:titl_opt][0]
- contents.font.size = Text_Options[:titl_opt][1]
- tlw = text_size(Title_Text).width
- tlx = (contents.width-tlw)/2
- contents.fill_rect(tlx-8,TitleLine_Y,tlw+16,2,color7)
- contents.fill_rect(tlx-8,TitleLine_Y+2,tlw+16,1,color8)
- offy = -6 + Line_Offset_Y
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height+offy,contents.width-8,2,color1)
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height+2+offy,contents.width-8,1,color2)
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height*3+offy+4,contents.width-8,2,color3)
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height*3+2+offy+4,contents.width-8,1,color4)
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height*5+offy+8,contents.width-8,2,color5)
- contents.fill_rect(Detail_Info_X+4,Detail_Info_Y+line_height*5+2+offy+8,contents.width-8,1,color6)
- change_color(Color.new(*TitleColor))
- draw_text(0,0,contents.width,[contents.font.size, 24].max,Title_Text,1)
- contents.font.name = Text_Options[:dtls_win][0]
- contents.font.size = Text_Options[:dtls_win][1]
- change_color(system_color)
- py = text_size("000%").width
- draw_text(Detail_Info_X+4,Detail_Info_Y,contents.width-8,line_height,Sel_Item)
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*2+4,contents.width-8,line_height,Sel_Pref)
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*4+8,contents.width-8,line_height,Sel_Suff)
- draw_text(Total_Price_X+4,Total_Price_Y,contents.width-8,line_height,Total_Price)
- if Show_Chance == true
- draw_text(Detail_Info_X+4,Detail_Info_Y,contents.width-8-py,line_height,SuccessChanceTxt,2) if Show_Item_Chance == true
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*2+4,contents.width-8-py,line_height,SuccessChanceTxt,2)
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*4+8,contents.width-8-py,line_height,SuccessChanceTxt,2)
- end
- change_color(normal_color)
- if decision == 0
- no_text1 = no_text2 = no_text3 = Not_Selected
- elsif decision == 1
- no_text1 = Current_Sele
- no_text2 = no_text3 = Not_Selected
- elsif decision == 2
- no_text2 = Current_Sele
- no_text3 = Not_Selected
- elsif decision == 3
- no_text3 = Current_Sele
- end
- if item.nil?
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height,contents.width-8,line_height,no_text1)
- draw_text(Detail_Info_X+4,Detail_Info_Y,contents.width-8,line_height,No_ChanceTxt,2) if Show_Chance == true && Show_Item_Chance == true
- else
- chancei = [[0,item.enchant_chance+bonus].max,100].min
- draw_text(Detail_Info_X+4,Detail_Info_Y,contents.width-8,line_height,chancei.round.to_s+"%",2) if Show_Chance == true && Show_Item_Chance == true
- draw_item_name(item,Detail_Info_X+4,Detail_Info_Y+line_height,true,contents.width-8)
- end
- if prefix.nil?
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*3+4,contents.width-8,line_height,no_text2)
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*2+4,contents.width-8,line_height,No_ChanceTxt,2) if Show_Chance == true
- else
- if prefix == -10
- draw_random_enc_info(0,Detail_Info_X+4,Detail_Info_Y+line_height*3+4,contents.width-8)
- price1 = random[0]
- if Rand_Enc_Pref[:bonus] == false
- chance1 = Rand_Enc_Pref[:chance]
- else
- chance1 = [[0,Rand_Enc_Pref[:chance]*((item.enchant_chance+bonus)*0.01)].max,100].min
- end
- else
- id1 = AFFIXES[prefix]
- price1 = id1[:enc_info][:price]
- if id1[:enc_info][:bonus] == false
- chance1 = id1[:enc_info][:chance]
- else
- chance1 = [[0,id1[:enc_info][:chance]*((item.enchant_chance+bonus)*0.01)].max,100].min
- end
- draw_affix_info(id1,Detail_Info_X+4,Detail_Info_Y+line_height*3+4,contents.width-8)
- end
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*2+4,contents.width-8,line_height,chance1.round.to_s+"%",2) if Show_Chance == true
- end
- if suffix.nil?
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*5+8,contents.width-8,line_height,no_text3)
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*4+8,contents.width-8,line_height,No_ChanceTxt,2) if Show_Chance == true
- else
- if suffix == -10
- draw_random_enc_info(1,Detail_Info_X+4,Detail_Info_Y+line_height*5+8,contents.width-8)
- price2 = random[1]
- if Rand_Enc_Suff[:bonus] == false
- chance2 = Rand_Enc_Suff[:chance]
- else
- chance2 = [[0,Rand_Enc_Suff[:chance]*((item.enchant_chance+bonus)*0.01)].max,100].min
- end
- else
- id2 = AFFIXES[suffix]
- price2 = id2[:enc_info][:price]
- if id2[:enc_info][:bonus] == false
- chance2 = id2[:enc_info][:chance]
- else
- chance2 = [[0,id2[:enc_info][:chance]*((item.enchant_chance+bonus)*0.01)].max,100].min
- end
- draw_affix_info(id2,Detail_Info_X+4,Detail_Info_Y+line_height*5+8,contents.width-8)
- end
- draw_text(Detail_Info_X+4,Detail_Info_Y+line_height*4+8,contents.width-8,line_height,chance2.round.to_s+"%",2) if Show_Chance == true
- end
- price = 0
- price += item.enchant_price if !item.nil?
- price += price1 if !price1.nil?
- price += price2 if !price2.nil?
- draw_text(Total_Price_X+4,Total_Price_Y,contents.width-8,line_height,price,2)
- end
- end
- class Enchy_Gold < Window_Base
- include Sixth_Enchant_Scene
- def initialize
- x = Window_Setup[:gold][:pos][0]; y = Window_Setup[:gold][:pos][1]
- w = Window_Setup[:gold][:size][0]; h = Window_Setup[:gold][:size][1]
- super(x,y,w,h)
- self.windowskin = Cache.system(Window_Setup[:gold][:skin])
- contents.font.name = Text_Options[:gold_win][0]
- contents.font.size = Text_Options[:gold_win][1]
- refresh
- end
- def refresh
- contents.clear
- change_color(system_color)
- draw_text(0,0,contents.width,line_height,Gold_Text)
- change_color(normal_color)
- draw_text(0,0,contents.width,line_height,$game_party.gold,2)
- end
- end
- class Enchy_Finish < Window_Command
- include Sixth_Enchant_Scene
- def initialize
- x = Window_Setup[:finish][:pos][0]; y = Window_Setup[:finish][:pos][1]
- super(x,y)
- self.windowskin = Cache.system(Window_Setup[:finish][:skin])
- end
- def window_width
- return 100
- end
- def window_height
- return 96
- end
- def alignment
- return 1
- end
- def make_command_list
- add_command(Start_Cmd,:finish)
- add_command(Cancl_Cmd,:cancel)
- end
- def item_rect(index)
- rect = Rect.new
- rect.width = item_width
- rect.height = item_height
- rect.x = index % col_max * (item_width + spacing)
- rect.y = (index / col_max * item_height) + 24
- rect
- end
- def draw_finish_text
- draw_text(0,0,contents.width,line_height,Finsh_Txt,1)
- end
- def draw_item(index)
- contents.font.name = Text_Options[:fnsh_win][0]
- contents.font.size = Text_Options[:fnsh_win][1]
- super
- end
- def refresh
- textw = text_size(Finsh_Txt).width + 30 + Window_Setup[:finish][:add_width]
- self.width = textw
- self.x = self.x+((Graphics.width-self.x)-self.width)/2
- super
- draw_finish_text
- end
- def process_ok
- if current_item_enabled?
- Input.update
- deactivate
- call_ok_handler
- else
- Sound.play_buzzer
- end
- end
- end
- #==============================================================================
- # !!END OF SCRIPT!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement