Advertisement
khanhdu

Fabrication System ( Falcao + RPGMAKERVN

Jul 20th, 2017
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 32.56 KB | None | 0 0
  1. #==============================================================================#
  2. #  #*********************************#                                         #
  3. #  #*** By RPG MAKER VN Vs Falcao ***#          *Trang RPG Maker Vn            #
  4. #  #*********************************#          Thank You Falcao               #
  5. #                               Hệ Thống Chế Tạo Đồ Vật Và Vật Phẩm            #
  6. #       RMVXACE                Script Này Được Dùng Free. Ngày : 7/20/2017      #
  7. #                                                                              #
  8. # Falcao RGSS site:  http://falcaorgss.wordpress.com                           #
  9. # RPG Maker VN site: https://rpgmakervn.blogspot.com                              #
  10. #==============================================================================#
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Cách Sử Dụng ?
  14. #
  15. # - Một Vài Hướng Dẫn Bên Dưới Hoặc Bạn Vào Blogger Để Coi Bài Hướng Dẫn
  16. # Cái Này Ko dành cho người tập mới vào.
  17. # - Hãy Like Và Share Trang Mình Nhé
  18. # Thank You .
  19. #
  20. # It is called Crafting
  21. #-------------------------------------------------------------------------------
  22.  
  23. #-------------------------------------------------------------------------------
  24. # * Cập Nhật Có Gì Mới
  25. #
  26. # - Hệ thống kỹ năng Đầy đủ
  27. # - Hệ thống kỹ năng khai thác
  28. # - Sự kỳ diệu và khai thác Hệ thống san lấp mặt bằng
  29. # - Hệ thống giải thuật giả kim và chiết xuất toàn bộ
  30. # - Hệ Thống có thể tạo Weapons, Armors and Items
  31. # - Trong game tối đa hóa phép thuật và mức độ khai thác được kích hoạt
  32. # - Alchemy Hỗ trợ tối đa 20 thành phần
  33. # - Sự kỳ diệu và trích xuất, tốc độ, số lượng, cơ hội được kích hoạt
  34. # - Có Chức Năng công thức nấu ăn
  35. # - Cấp nhà máy trích xuất được kích hoạt
  36. # - Khôi phục cây cối được kích hoạt
  37. # - Bàn Chế Tạo
  38. # - Sáng tạo công thức linh hoạt và dễ dàng
  39. # - Dễ dàng sử dụng
  40. #-------------------------------------------------------------------------------
  41.  
  42. # * Điều Khoản Và giấy phép
  43.  
  44. # - Nhớ credit Falcao và credit RPG MAKER VN
  45. # - Bạn Có Thể sửa bất cứ thứ j bạn mún
  46. # - Bạn Được Chia sẻ
  47. # -  Không loại bỏ tiêu đề của bất kỳ tập lệnh kịch bản nào
  48. # -  Bạn được tự do sử dụng tập lệnh này trong các dự án phi thương mại,
  49. # cho mục đích thương mại
  50. #  Gmail Liên Hệ : Khanhsunguj@gmail hoặc Falcao : falmc99@gmail.com
  51.  
  52. =begin
  53. ===============================================================================
  54.  * Script Manual
  55.  
  56.  *************************
  57.  * Alchemy skill set up  *
  58.  
  59.  Use the following script call to display the alchemy GUI
  60.  SceneManager.call(Scene_Alchemy)
  61.  
  62.  You will see an empty GUI, the first thing you have to do is create a recipe
  63.  in the database item section using the following notetags
  64.  
  65.  - Here a normal recipe set up
  66.  
  67.  <Output Item Type: Item>
  68.  <Output Item Id: 2>
  69.  <Output Item Chance: 50>
  70.  <Output Item Quantity: 2>
  71.  <Recipe Speed: 1.5>
  72.  <Recipe Level: 1>
  73.  <Recipe Item Mixs: 17, 18, 19>
  74.  <Recipe Item Cost: 3, 2, 2>
  75.  
  76.  - Tags explanation
  77.  
  78.  <Output Item Type: Item>
  79.  recipe output item type, it can be Item, Weapon or Armor
  80.  
  81.  <Output Item Id: 2>
  82.  Item Type id you choose
  83.  
  84.  <Output Item Chance: 50>
  85.  Chance to produce the item, it can be a number form 1 to 100 percent of chance
  86.  
  87.  <Output Item Quantity: 2>
  88.  How many items you want to get when succes producing?
  89.  
  90.  <Recipe Speed: 1.5>
  91.  production speed, it display a hud. it support decimals
  92.  
  93.  <Recipe Level: 1>
  94.  Level of the recipe (if the player alchemy level is below he cant learn it)
  95.  
  96.  <Recipe Item Mixs: 17, 18, 19>
  97.  Ingredients items ids required to produce the output item
  98.  
  99.  <Recipe Item Cost: 3, 2, 2>
  100.  Quantity of item Mixs required to produce the Ouput item, MUST be in the same
  101.  order of Item Mixs. In this case item id 17 require 3 or more, item id 18
  102.  require 2 and item id 19 require 2.
  103.  
  104.  * IMPORTANT
  105.  Once the game party gets the Item recipe, the game player has to learn the
  106.  recipe from the inventory menu in order to be displayed in the alchemy GUI
  107.  
  108.  -------------------------------------
  109.  * Extraction skill set up  *
  110.  
  111.  In order to extract items plants, rocks or whatever you need, create an event
  112.  with the following comment tags.
  113.  
  114.  Here a regular plant creation
  115.  
  116.  <extract_item: 19>
  117.  <extract_quantity: 3>
  118.  <extract_chance: 70>
  119.  <extract_speed: 1.0>
  120.  <extract_level: 1>
  121.  <extract_times: 3>
  122.  <extract_respawn: 10>
  123.  
  124.  Tags explanation
  125.  
  126.  <extract_item: 19>
  127.  Which item id do you want to extract?
  128.  
  129.  <extract_quantity: 3>
  130.  How many items will be extracted?
  131.  
  132.  <extract_chance: 70>
  133.  Extraction success chance, it can be a number between 1 to 100 percent
  134.  
  135.  <extract_speed: 1.0>
  136.  Extraction speed, it support decimals
  137.  
  138.  <extract_level: 1>
  139.  item extraction level, if player extraction skill is below this level it cannot
  140.  be extracted
  141.  
  142.  <extract_times: 3>
  143.  How many times you want this plant to be extracted before dissapear?
  144.  
  145.  <extract_respawn: 10>
  146.  Time in seconds this plant takes to respawn
  147.  
  148.  IMPORTANT NOTE!
  149.  I strongly recomend to see this script demo examples for the correct usage of
  150.  this complex system
  151.  
  152. =end
  153.  
  154. #===============================================================================
  155. # * Alchemy skill settings
  156. #===============================================================================
  157. module FalcaoAlchemy
  158.  
  159.   # After how many production times get a chance to level up
  160.   ProductionTimesLevelUp = 3
  161.  
  162.   # Chance to level up when the production times match
  163.   AlchemyLevelUpChance = 70
  164.  
  165.   # After how many party alchemy skill level above of Recipe level have a chance
  166.   # to level up the alchemy skill. Example: Alchemy level = 20
  167.   # Recipe level = 9, there are 11 levels above so party can not level up skill
  168.   SeparateLevel = 10
  169.  
  170.   # Default alchemy maximun level (can be changed in game)
  171.   DefaultMaxLevel = 100
  172.  
  173.   # Sound played when succes produce an item
  174.   SuccesProduceSe = "Decision2"
  175.  
  176.   # Sound played when fail producing an item
  177.   FailProduceSe = "Stare"
  178.  
  179.   # Sound played when succes level up the alchemy skill
  180.   AlchemyLevelUpSe = "Raise1"
  181. end
  182.  
  183.  
  184. #===============================================================================
  185. # * Extraction skill settings
  186. #===============================================================================
  187. module FalExtract
  188.  
  189.   # After how many extraction times get a chance to level up
  190.   ExtracTimesLevelUp = 4
  191.  
  192.   # Chance to level up when the production times match
  193.   ExtracLevelUpChance = 80
  194.  
  195.   # After how many party extraction skill level above of Plant level have a
  196.   # chance to level up the extraction skill. Example: Extraction level = 20
  197.   # Plant level = 9, there are 11 levels above so party can not level up skill
  198.   SeparateLevell = 5
  199.  
  200.   # Cấp Độ Tối Đa (can be changed in game)
  201.   DefaultMaxLevel = 100
  202.  
  203.   # Animation id played while extracting
  204.   ExAnimation = 111
  205.  
  206.   # Sound played when succes extrac an item
  207.   SuccesExtractSe = "Item3"
  208.  
  209.   # Sound played when fail extract an item
  210.   FailExtractSe = "Down1"
  211.  
  212.   # Sound played when level up extraction skill
  213.   AlchemyLevelUpSe = "Raise1"
  214.  
  215.   #-----------------------------------------------
  216.   def self.check_extracted_ones
  217.     $game_map.events.values.each do |event|
  218.       break if $game_party.ev_extdata[$game_map.map_id].nil?
  219.       if !$game_party.ev_extdata[$game_map.map_id][event.id].nil?
  220.         event.erase if $game_party.ev_extdata[$game_map.map_id][event.id][2]
  221.       end
  222.     end
  223.   end
  224. end
  225.  
  226. #Do you want to add the alchemy scene to the game menu? true / false
  227. FalcaoRGSS_AddAlchemy_to_menu = true
  228.  
  229. #-----------------------------------------------------------------------------
  230. # * Script calls
  231. #
  232. # Use this script call only if you want to change the extraction and alchemy
  233. # levels manually
  234. #
  235. # $game_party.alchemy_maxlv(x)   If you want to change the alchemy maximun level
  236. #                                in game change x for the new maximun level
  237. # $game_party.alchemy_lv = x     if you want to change the current alchemy level
  238. #                                change x for the new level
  239.  
  240. # $game_party.extraction_maxlv(x) Extraction max level, change x for the new
  241. #                                 maximun level
  242. # $game_party.extract_lv = x      Extraction current level, change x for any
  243. #                                 integer
  244. #-------------------------------------------------------------------------------
  245.  
  246. ($imported ||= {})['Falcao Mmorpg Alchemy And Extraction'] = 1.0
  247.  
  248. #===============================================================================
  249. # * Falcao Alchemy skill END OF SETINGS
  250. #===============================================================================
  251. class RecipeData
  252.   attr_accessor :recipes
  253.   def initialize
  254.     @recipes = {}
  255.     @ingredients = {}
  256.     register_values
  257.   end
  258.  
  259.   def register_values
  260.     for item in $data_items
  261.       next if item.nil?
  262.       id = item.recipedata("<Output Item Id: ")
  263.       next if id.nil?
  264.       type   = item.recipedata("<Output Item Type: ", false)
  265.       chance = item.recipedata("<Output Item Chance: ")
  266.       quanti = item.recipedata("<Output Item Quantity: ")
  267.       sp     = item.recipedata("<Recipe Speed: ", true, true)
  268.       lv     = item.recipedata("<Recipe Level: ")
  269.       mix    =  item.recipedata("<Recipe Item Mixs: ", false)
  270.       @recipes[item.id] = [item.name, type, id, chance, quanti, sp, lv, item.id]
  271.       @ingredients[item.id] = mix.split(",").map { |s| s.to_i }
  272.     end
  273.   end
  274.  
  275.   def recipes
  276.     @recipes
  277.   end
  278.  
  279.   def ingredients
  280.     @ingredients
  281.   end
  282. end
  283.  
  284. class RPG::BaseItem
  285.   def recipedata(comment, s=true, f=false)
  286.     if @note =~ /#{comment}(.*)>/i
  287.       return $1.to_f if f
  288.       return s ? $1.to_i : $1.to_s.sub("\r","")
  289.     end
  290.   end
  291.  
  292.   def costitem
  293.     if @costitemm.nil?
  294.       @costitemm = {}
  295.       if @note =~ /<Recipe Item Mixs: (.*)>/i
  296.         key = $1.to_s.sub("\r","").split(",").map { |s| s.to_i }
  297.       end
  298.       if @note =~ /<Recipe Item Cost: (.*)>/i
  299.         value = $1.to_s.sub("\r","").split(",").map { |s| s.to_i }
  300.       end
  301.       if key != nil
  302.         index = 0
  303.         key.each {|k|
  304.         @costitemm[k] = value[index]
  305.         index += 1}
  306.       end
  307.       return @costitemm
  308.     else
  309.       return @costitemm
  310.     end
  311.   end
  312. end
  313.  
  314. class Game_Party < Game_Unit
  315.   attr_reader   :recipes
  316.   attr_accessor   :extract_data, :extract_lv, :extrat_count, :ev_extdata
  317.   attr_accessor   :alchemy_lv, :alchemy_count, :pop_windowdata
  318.   attr_accessor   :al_maxlv, :ex_maxlv
  319.   alias falcaoalchemy_ini initialize
  320.   def initialize
  321.     @recipes = []
  322.     @extract_lv = 1
  323.     @extrat_count = 0
  324.     @ev_extdata = {}
  325.     @alchemy_lv = 1
  326.     @alchemy_count = 0
  327.     @al_maxlv = FalcaoAlchemy::DefaultMaxLevel
  328.     @ex_maxlv = FalExtract::DefaultMaxLevel
  329.     falcaoalchemy_ini
  330.   end
  331.  
  332.   def alchemy_maxlv(lv)
  333.     @al_maxlv = lv if lv >= @al_maxlv
  334.   end
  335.  
  336.   def extraction_maxlv(lv)
  337.     @ex_maxlv = lv if lv >= @ex_maxlv
  338.   end
  339.  
  340.   def add_recipe(id)
  341.     @recipes.push(id) unless @recipes.include?(id)
  342.   end
  343.  
  344.   def pop_w(time, name, text)
  345.     return unless @pop_windowdata.nil?
  346.     @pop_windowdata = [time, text, name]
  347.   end
  348. end
  349.  
  350. class Game_Battler < Game_BattlerBase
  351.   alias falcaoalchemy_mm_item consume_item
  352.   def consume_item(item)
  353.     if item.is_a?(RPG::Item) and !item.recipedata("<Output Item Id: ").nil?
  354.       level = item.recipedata("<Recipe Level: ")
  355.       if $game_party.alchemy_lv >= level
  356.         $game_party.add_recipe(item.id)
  357.         $game_party.pop_w(
  358.         180, 'Thông Báo', "Công Thức : #{item.name} Đã Học Xong!")
  359.       else
  360.         $game_party.gain_item(item, 1)
  361.         $game_party.pop_w(
  362.         180,'Chú Ý',"Chế Tạo Cấp #{level} Để Học Cách Chế Tạo")
  363.         Sound.play_buzzer
  364.       end
  365.     end
  366.     falcaoalchemy_mm_item(item)
  367.   end
  368. end
  369.  
  370. #-------------------------------------------------------------------------------
  371. class Window_AlRecipes < Window_Selectable
  372.   def initialize(x, y, w, h, rdata)
  373.     super(x, y,  w, h)
  374.     @rdata = rdata
  375.     refresh ; select(0)
  376.   end
  377.  
  378.   def item() return @data[self.index] end
  379.    
  380.   def refresh
  381.     self.contents.clear if self.contents != nil
  382.     @data = []
  383.     @rdata.recipes.each {|id, recipe| @data.push(recipe) if
  384.     $game_party.recipes.include?(id)}
  385.     @item_max = @data.size
  386.     if @item_max > 0
  387.       self.contents = Bitmap.new(width - 32, row_max * 26)
  388.       for i in 0...@item_max
  389.         draw_item(i)
  390.       end
  391.     end
  392.   end
  393.  
  394.   def draw_item(index)
  395.     item = @data[index]
  396.     x, y = index % col_max * (90), index / col_max  * 24
  397.     self.contents.font.size = 18
  398.     draw_icon($data_items[item[7]].icon_index, x, y)
  399.     contents.draw_text(x + 25, y, self.width, 32, item[0])
  400.   end
  401.  
  402.   def item_max
  403.     return @item_max.nil? ? 0 : @item_max
  404.   end
  405. end
  406.  
  407. class Window_StartProducing < Window_HorzCommand
  408.   def initialize(dark)
  409.     @darked = dark
  410.     super(200, 0)
  411.   end
  412.   def window_width()  return 344  end
  413.   def window_height() return 60   end  
  414.    
  415.   def col_max
  416.     return 2
  417.   end
  418.  
  419.   def make_command_list
  420.     add_command("Chế Tạo ",  :start, @darked.items_ready?)
  421.     add_command("Dừng",   :stop)
  422.   end
  423.  
  424.   def process_cancel
  425.     @darked.meter > 0 ? return : super
  426.   end
  427. end
  428.  
  429.  
  430. class FalcaoExtraction
  431.   include FalExtract
  432.   def initialize
  433.     @col = [Color.new(180, 225, 245), Color.new(20, 160, 225), Color.new(0,0,0)]
  434.     @running = false
  435.     @anitimer = 0
  436.   end
  437.  
  438.   def update
  439.     update_extraction_trigger if Input.trigger?(:C)
  440.     update_display_window if $game_party.extract_data != nil
  441.     update_respawn
  442.   end
  443.  
  444.   def update_respawn
  445.     return if $game_party.ev_extdata[$game_map.map_id].nil?
  446.     $game_map.events.values.each do |event|
  447.       break if $game_party.ev_extdata[$game_map.map_id].nil?
  448.       if !$game_party.ev_extdata[$game_map.map_id][event.id].nil?
  449.         if $game_party.ev_extdata[$game_map.map_id][event.id][2]
  450.           $game_party.ev_extdata[$game_map.map_id][event.id][1] -= 1 if
  451.           $game_party.ev_extdata[$game_map.map_id][event.id][1] > 0
  452.           if $game_party.ev_extdata[$game_map.map_id][event.id][1] == 0
  453.             event.fading = [:fade_out, 60]
  454.             $game_party.ev_extdata[$game_map.map_id].delete(event.id)
  455.             if $game_party.ev_extdata[$game_map.map_id].empty?
  456.               $game_party.ev_extdata.delete($game_map.map_id)
  457.             end
  458.             next
  459.           end
  460.         end
  461.       end
  462.     end
  463.   end
  464.  
  465.   def update_display_window
  466.     create_window
  467.     if $game_party.extract_data[5] > 0
  468.       $game_party.extract_data[5] -= 1
  469.       if $game_party.extract_data[5] == 0
  470.         $game_party.extract_data = nil
  471.         dispose_window
  472.         @running = false
  473.         return
  474.       end
  475.     end
  476.    
  477.     return if $game_party.extract_data[5] > 0
  478.     if @running
  479.       if $game_party.extract_data[5] == 0
  480.         refresh_contents
  481.         $game_party.extract_data[4] += 1
  482.       end
  483.       if $game_party.extract_data[4] >= $game_party.extract_data[3] * 60
  484.         $game_party.extract_data[5] = 60
  485.         refresh_contents
  486.       end
  487.    end
  488.   end
  489.  
  490.   def create_window
  491.     return if !@ext_window.nil?
  492.     @ext_window = Window_Base.new(544 / 2 - 200 / 2, 0, 260, 66)
  493.     if $game_party.extract_lv >= $game_party.extract_data[6]
  494.       @running = true
  495.     end
  496.     refresh_contents
  497.   end
  498.  
  499.   def refresh_contents
  500.     @ext_window.contents.clear
  501.     @ext_window.contents.fill_rect(0, 10, 26, 38, Color.new(0, 0, 0, 68))
  502.     item = $game_party.extract_data[0]
  503.     @ext_window.draw_icon(item.icon_index, 1, 11)
  504.     @ext_window.contents.font.size = 20
  505.     @ext_window.contents.font.color = @ext_window.normal_color
  506.     @ext_window.contents.font.shadow = true
  507.     string = "Bạn Đang Nhặt " + item.name
  508.     @ext_window.draw_text(-4, -6, @ext_window.width, 32, string, 1)
  509.     @ext_window.contents.font.size = 15
  510.     @ext_window.draw_text(0, 222, 26, 32, $game_party.extract_data[1].to_s, 1)
  511.     @ext_window.contents.font.size = 15
  512.     if @running
  513.       if $game_party.extract_data[5] == 60
  514.         r = rand(101)
  515.         @ext_window.contents.font.color = Color.new(-255,225,-225, 255)
  516.         if r <= $game_party.extract_data[2]
  517.           $game_party.gain_item($game_party.extract_data[0],
  518.           $game_party.extract_data[1])
  519.           RPG::SE.new(SuccesExtractSe, 80,).play
  520.           @ext_window.draw_text(-30, 20, @ext_window.width, 32, 'Nhặt Thành Công', 2)
  521.           if $game_party.extrat_count == ExtracTimesLevelUp - 1
  522.             r2 = rand(101)
  523.             if r2 <= ExtracLevelUpChance
  524.               leveling = true unless stop_growing?
  525.               apply_extraction_growing
  526.             end
  527.           else
  528.             $game_party.extrat_count += 1
  529.           end
  530.           @anitimer = 0
  531.         else
  532.           RPG::SE.new(FailExtractSe, 80,).play
  533.           @ext_window.draw_text(-30, 20, @ext_window.width, 32, 'Nhặt Thất Bại', 2)
  534.         end
  535.         apply_variance
  536.         @running = false
  537.       end
  538.       run_extractor if leveling.nil?
  539.     else
  540.       @ext_window.draw_text(0, 16, @ext_window.width, 32,
  541.       "Phải Lên Cấp #{$game_party.extract_data[6]} Bắt Buộc", 1)
  542.       Sound.play_buzzer
  543.       s = "Yêu Cầu Nhặt Cấp #{$game_party.extract_data[6]} Cần Thiết "
  544.       $game_party.pop_w(180, 'Nhắc Nhở', s)
  545.       $game_party.extract_data[5] = 120
  546.     end
  547.   end
  548.  
  549.   def stop_growing?
  550.     lv = $game_party.extract_data[6]
  551.     return true if $game_party.extract_lv == $game_party.ex_maxlv
  552.     return true unless $game_party.extract_lv <= lv + SeparateLevell - 1
  553.     return false
  554.   end
  555.  
  556.   # growing
  557.   def apply_extraction_growing
  558.     return if stop_growing?
  559.     RPG::SE.new(AlchemyLevelUpSe, 80,).play
  560.     $game_party.extract_lv += 1
  561.     $game_party.extrat_count = 0
  562.     @ext_window.draw_text(30, 20, @ext_window.width, 32,
  563.     "Lên Cấp #{$game_party.extract_lv}!")
  564.   end
  565.  
  566.   def apply_variance
  567.     $game_party.ev_extdata[$game_map.map_id] = {} if
  568.     $game_party.ev_extdata[$game_map.map_id].nil?
  569.     event = $game_party.extract_data[7]
  570.     times = event.check_ext("<extract_times: ")
  571.     res   = event.check_ext("<extract_respawn: ") * 60
  572.     if $game_party.ev_extdata[$game_map.map_id][event.id].nil?
  573.       $game_party.ev_extdata[$game_map.map_id][event.id] = [times, res, false]
  574.     end
  575.     $game_party.ev_extdata[$game_map.map_id][event.id][0] -= 1
  576.     if $game_party.ev_extdata[$game_map.map_id][event.id][0] == 0
  577.       event.fading = [:fade_in, 60]
  578.       $game_party.ev_extdata[$game_map.map_id][event.id][2] = true
  579.     end
  580.   end
  581.  
  582.   def run_extractor
  583.     x, y = 30, 30
  584.     @ext_window.contents.fill_rect(x, y, 102, 12, @col[2])
  585.     max = $game_party.extract_data[3] * 60
  586.     meter = $game_party.extract_data[4]
  587.     @ext_window.contents.fill_rect(x+1, y+1, 100 *meter / max, 5, @col[0])
  588.     @ext_window.contents.fill_rect(x+1, y+6, 100 *meter / max, 5, @col[1])
  589.     @anitimer += 1
  590.     @anitimer = 0 if @anitimer == 6
  591.     $game_party.extract_data[7].animation_id = ExAnimation if @anitimer == 2
  592.     $game_player.pattern = 2
  593.   end
  594.  
  595.   def dispose_window
  596.     return if @ext_window.nil?
  597.     @ext_window.dispose
  598.     @ext_window = nil
  599.   end
  600.  
  601.   def update_extraction_trigger
  602.     return if $game_party.extract_data != nil
  603.     $game_map.events.values.each do |event|
  604.       next if event.fading[1] > 0
  605.       next unless $game_player.in_front_ext?(event)
  606.       item   = event.check_ext("<extract_item: ")
  607.       weapon = event.check_ext("<extract_weapon: ")
  608.       armor  = event.check_ext("<extract_weapon: ")
  609.       if item != 0      then kind = $data_items[item]
  610.       elsif weapon != 0 then kind = $data_weapons[weapon]
  611.       elsif armor != 0  then kind = $data_armor[armor]
  612.       end
  613.       if kind != nil
  614.         quantity = event.check_ext("<extract_quantity: ")
  615.         chance   = event.check_ext("<extract_chance: ")
  616.         speed    = event.check_ext("<extract_speed: ", false)
  617.         lv       = event.check_ext("<extract_level: ")
  618.         $game_party.extract_data = [kind,quantity,chance,speed,meter=0, t=0,
  619.         lv, event]
  620.         break
  621.       end
  622.     end
  623.   end
  624.  
  625.   def dispose
  626.     dispose_window
  627.   end
  628. end
  629.  
  630. class Spriteset_Map
  631.   alias falcaoextraction_create_p create_pictures
  632.   def create_pictures
  633.     falcaoextraction_create_p
  634.     @falextraction = FalcaoExtraction.new
  635.   end
  636.  
  637.   alias falcaoextraction_update update
  638.   def update
  639.     falcaoextraction_update
  640.     @falextraction.update
  641.   end
  642.  
  643.   alias falcaoextraction_dispose dispose
  644.   def dispose
  645.     falcaoextraction_dispose
  646.     @falextraction.dispose
  647.   end
  648. end
  649.  
  650. class Game_Event < Game_Character
  651.   attr_accessor :opacity, :erased, :fading
  652.   def check_ext(comment, f=true)
  653.     return 0 if @list.nil? or @list.size <= 0
  654.     for item in @list
  655.       if item.code == 108 or item.code == 408
  656.         return f ? $1.to_i : $1.to_f if item.parameters[0] =~ /#{comment}(.*)>/i
  657.       end
  658.     end
  659.     return 0
  660.   end
  661.  
  662.   alias falcaoexts_ini initialize
  663.   def initialize(map_id, event)
  664.     @fading = [:fade_in, time=0]
  665.     falcaoexts_ini(map_id, event)
  666.   end
  667.  
  668.   alias falcaoexts_up update
  669.   def update
  670.     if @fading[1] > 0
  671.       @fading[1] -= 1
  672.       if @fading[0] == :fade_in
  673.         @opacity -= 4 if @opacity >= 0
  674.         erase if @fading[1] == 0
  675.       elsif @fading[0] == :fade_out
  676.         if @erased
  677.           @erased = false
  678.           refresh ; @opacity = 0
  679.         end
  680.         @opacity += 4 if @opacity <= 255
  681.       end
  682.     end
  683.     falcaoexts_up
  684.   end
  685. end
  686.  
  687. class Game_Player < Game_Character
  688.   attr_accessor :pattern
  689.   def in_front_ext?(target)
  690.     return true if @direction == 2 and @x == target.x and (@y+1) == target.y
  691.     return true if @direction == 4 and (@x-1) == target.x and @y == target.y
  692.     return true if @direction == 6 and (@x+1) == target.x and @y == target.y
  693.     return true if @direction == 8 and @x == target.x and (@y-1) == target.y
  694.     return false
  695.   end
  696.  
  697.   def update_anime_pattern
  698.     return if !$game_party.extract_data.nil?
  699.     super
  700.   end
  701.  
  702.   alias falcaoextraction_mov movable?
  703.   def movable?
  704.     return false if $game_party.extract_data != nil
  705.     falcaoextraction_mov
  706.   end
  707.  
  708.   alias falcaoext_perform_transfer perform_transfer
  709.   def perform_transfer
  710.     falcaoext_perform_transfer
  711.     FalExtract.check_extracted_ones if $game_map.map_id !=  @new_map_id
  712.   end
  713. end
  714.  
  715. class << DataManager
  716.   alias falcaoalchemy_mmo_load load_normal_database
  717.   def DataManager.load_normal_database
  718.     falcaoalchemy_mmo_load
  719.     for item in $data_items
  720.       next if item.nil?
  721.       if item.recipedata("<Output Item Id: ") != nil
  722.         item.name = item.name + " L#{item.recipedata("<Recipe Level: ")}"
  723.         item.consumable = true
  724.         item.scope = 0
  725.       end
  726.     end
  727.   end
  728.  
  729.   alias falcaoalchemy_reloadmap reload_map_if_updated
  730.   def DataManager.reload_map_if_updated
  731.     falcaoalchemy_reloadmap
  732.     FalExtract.check_extracted_ones if
  733.     $game_system.version_id != $data_system.version_id
  734.   end
  735. end
  736.  
  737. # ingrediebnts
  738. class AlIngredients
  739.   attr_accessor :meter
  740.   def initialize(rdata)
  741.     @ingredients = Window_Base.new(200, 60, 344, 266)
  742.     @recipe = []
  743.     @meter = 0
  744.     @rdata = rdata
  745.   end
  746.  
  747.   def refresh(recipe)
  748.     @recipe = recipe
  749.     @ingredients.contents.clear
  750.     @ingredients.contents.font.size = 18 ; w = @ingredients.width
  751.     @ingredients.contents.fill_rect(0, 24, w, 220, Color.new(0, 0, 0, 60))
  752.     apply_color(1)
  753.     @ingredients.draw_text(-16, -6, w, 32, 'Nguyên Liệu Cần Thiết', 1)
  754.     draw_ingredients
  755.   end
  756.  
  757.   def draw_ingredients
  758.     manager = y = 0
  759.     for i in ingredients
  760.       item = $data_items[i]
  761.       manager += 1
  762.       (manager%2 == 0) ? x = 156 : y += 24
  763.       x = 0 unless (manager%2 == 0)
  764.       enable = $game_party.item_number(item) >= cost[item.id]
  765.       enable ? apply_color(1) : apply_color(2)
  766.       @ingredients.draw_icon(item.icon_index, x, y, enable)
  767.       @ingredients.contents.font.size = 15
  768.       number = $game_party.item_number(item)
  769.       @ingredients.draw_text(x - 2, y + 6, 32, 32, number.to_s, 1)
  770.       @ingredients.contents.font.size = 18
  771.       @ingredients.draw_text(x + 24, y,212,32, item.name + " X#{cost[item.id]}")
  772.     end
  773.   end
  774.  
  775.   def items_ready?
  776.     return false if @meter > 0
  777.     combi = ingredients ; item = [] ; combi = [] if combi.nil?
  778.     combi.each {|i|
  779.     it =$data_items[i]; item << i if $game_party.item_number(it) >= cost[it.id]}
  780.     item.size == combi.size
  781.   end
  782.  
  783.   def apply_color(c)
  784.     @ingredients.contents.font.color = @ingredients.normal_color if c == 1
  785.     @ingredients.contents.font.color = Color.new(255,255,255,128)  if c == 2
  786.   end
  787.  
  788.   def ingredients
  789.     return @rdata.ingredients[@recipe.last]
  790.   end
  791.  
  792.   def dispose
  793.     @ingredients.dispose
  794.   end
  795.  
  796.  
  797.   def update_index(recipe_index)
  798.     @recipe_index = recipe_index
  799.   end
  800.  
  801.   def cost
  802.     return $data_items[@recipe_index].costitem
  803.   end
  804. end
  805.  
  806. #----------
  807. class Scene_Alchemy < Scene_MenuBase
  808.   include FalcaoAlchemy
  809.   def start
  810.     super
  811.     recipedata = RecipeData.new
  812.     @col = [Color.new(180, 225, 245), Color.new(20, 160, 225), Color.new(0,0,0)]
  813.     @meter = 0
  814.     @infow = Window_Base.new(0, 0, 200, 60)
  815.     @alstatus = Window_Base.new(0, 326, 200, 90)
  816.     refresh_alstatus
  817.     @infow.contents.font.size = 20
  818.     @infow.draw_text(-16, 0, @infow.width, 32, 'Công Thức', 1)
  819.     @recipes = Window_AlRecipes.new(0, 60, 200, 266, recipedata)
  820.     @ngrewindow = AlIngredients.new(recipedata)
  821.     update_rindex
  822.     @oven = Window_Base.new(200, 326, 344, 90)
  823.     @pop_timer = 0
  824.     update_recipe
  825.     @start_window = Window_StartProducing.new(@ngrewindow)
  826.     update_cancel
  827.     @start_window.set_handler(:start,     method(:update_start))
  828.     @start_window.set_handler(:stop,      method(:update_stop))
  829.     @start_window.set_handler(:cancel,    method(:update_cancel))
  830.   end
  831.  
  832.   def refresh_alstatus
  833.     @alstatus.contents.clear
  834.     @alstatus.contents.font.size = 18; w = @alstatus.width ; g = $game_party
  835.     @alstatus.draw_icon(218, 0, 16)  ; arr = [g.al_maxlv.to_s, g.ex_maxlv.to_s]
  836.     @alstatus.draw_icon(482, 0, 40)
  837.     @alstatus.draw_text(-16, -8, w, 32, 'Bản Thành Thạo ', 1)
  838.     @alstatus.draw_text(26, 16, w, 32,"Chế Tạo Cấp : #{g.alchemy_lv}/" + arr[0])
  839.     @alstatus.draw_text(26, 40, w, 32,"Nhặt Cấp : #{g.extract_lv}/" + arr[1])
  840.   end
  841.  
  842.   def update_start
  843.     @ngrewindow.meter = 1
  844.   end
  845.  
  846.   def update_stop
  847.     @ngrewindow.meter = 0
  848.     @start_window.refresh
  849.     @start_window.activate
  850.     refresh_oven
  851.   end
  852.  
  853.   def output_item
  854.     item = @recipes.item
  855.     kind = $data_items[item[2]]   if item[1]=='Item'   || item[1]=='item'
  856.     kind = $data_weapons[item[2]] if item[1]=='Weapon' || item[1]=='weapon'
  857.     kind = $data_armors[item[2]]  if item[1]=='Armor'  || item[1]=='armor'
  858.     kind
  859.   end
  860.  
  861.   def update_cancel
  862.     @start_window.unselect
  863.     @start_window.deactivate
  864.     @recipes.activate
  865.   end
  866.  
  867.   def refresh_ingredients
  868.     @ngrewindow.refresh(@recipes.item)
  869.   end
  870.  
  871.   def refresh_oven
  872.     @oven.contents.clear
  873.     @oven.contents.font.size = 18
  874.     @oven.contents.fill_rect(0, 31, 31, 36, Color.new(0, 0, 0, 60))
  875.     @oven.draw_text(-16, -6,  @oven.width, 32, 'Thông Tin Chế Tạo', 1)
  876.     if @pop_timer > 0
  877.       @oven.contents.font.color = Color.new(255, 120, 0, 255)
  878.       @oven.draw_text(0, -6,  @oven.width, 32, @type)
  879.     end
  880.     @oven.contents.font.color = @oven.normal_color
  881.     @oven.draw_icon(output_item.icon_index, 4, 34)
  882.     @oven.contents.font.size = 15
  883.     @oven.draw_text(0, 45, 33, 32, @recipes.item[4], 1)
  884.     @oven.contents.font.size = 18
  885.     @oven.draw_text(34, 23, 250, 32, output_item.name)
  886.     @oven.draw_text(-26, 23,  @oven.width, 32, 'Tỷ Lệ Thành Công ', 2)
  887.     @oven.draw_text(-26, 40,  @oven.width, 32,  @recipes.item[3].to_s + '%', 2)
  888.     x, y = 33, 52
  889.     @oven.contents.fill_rect(x, y, 150, 12, @col[2])
  890.     max = @recipes.item[5] * 60
  891.     @oven.contents.fill_rect(x+1, y+1, 152 *@ngrewindow.meter / max, 5, @col[0])
  892.     @oven.contents.fill_rect(x+1, y+6, 152 *@ngrewindow.meter / max, 5, @col[1])
  893.   end
  894.  
  895.   def update_rindex
  896.     @ngrewindow.update_index(@recipes.item[7]) unless @recipes.item.nil?
  897.   end
  898.  
  899.   def update
  900.     super
  901.     update_rindex
  902.     update_recipe
  903.     SceneManager.return if Input.trigger?(:B) and @recipes.active
  904.     update_selection if Input.trigger?(:C) and @recipes.active and
  905.     !@recipes.item.nil?
  906.     update_meter
  907.   end
  908.  
  909.   def update_meter
  910.     if @pop_timer > 0
  911.       @pop_timer -= 1
  912.       refresh_oven if @pop_timer == 0
  913.     end
  914.    
  915.     if @ngrewindow.meter != 0
  916.       @start_window.refresh if @ngrewindow.meter == 1
  917.       @start_window.activate if @ngrewindow.meter == 1
  918.       @ngrewindow.meter += 1
  919.       refresh_oven
  920.       if @ngrewindow.meter >= @recipes.item[5] * 60
  921.         @ngrewindow.meter = 0
  922.         random = rand(101)
  923.         random <= @recipes.item[3] ? success_producing : fail_producing
  924.       end
  925.     end
  926.   end
  927.  
  928.   def success_producing
  929.     RPG::SE.new(SuccesProduceSe, 80,).play
  930.     $game_party.gain_item(output_item, @recipes.item[4])
  931.     @type = 'Thành Công!' ; @pop_timer = 50
  932.     destroy_items
  933.     apply_alchemy_growing
  934.   end
  935.  
  936.   def apply_alchemy_growing
  937.     return if $game_party.alchemy_lv == $game_party.al_maxlv
  938.     return unless $game_party.alchemy_lv <= @recipes.item[6] + SeparateLevel - 1
  939.     if $game_party.alchemy_count == ProductionTimesLevelUp - 1
  940.       r2 = rand(101)
  941.       if r2 <= AlchemyLevelUpChance
  942.         $game_party.alchemy_lv += 1
  943.         RPG::SE.new(AlchemyLevelUpSe, 80,).play
  944.         $game_party.alchemy_count = 0
  945.         refresh_alstatus
  946.       end
  947.       else
  948.       $game_party.alchemy_count += 1
  949.     end
  950.   end
  951.  
  952.   def fail_producing
  953.     RPG::SE.new(FailProduceSe, 80,).play
  954.     @type = 'Thất Bại!' ; @pop_timer = 50
  955.     destroy_items
  956.   end
  957.  
  958.   def destroy_items
  959.     c = $data_items[@recipes.item[7]].costitem
  960.     @ngrewindow.ingredients.each {|i|$game_party.lose_item($data_items[i],c[i])}
  961.     refresh_ingredients
  962.     refresh_oven
  963.     @ngrewindow.items_ready? ? update_start : @start_window.refresh
  964.   end
  965.  
  966.   def update_selection
  967.     Sound.play_ok
  968.     @start_window.select(0)
  969.     @start_window.activate
  970.     @recipes.deactivate
  971.   end
  972.  
  973.   def update_recipe
  974.     return if @recipes.item.nil?
  975.     if @recipe_index != @recipes.index
  976.       @recipe_index = @recipes.index
  977.       refresh_ingredients
  978.       @start_window.refresh if !@start_window.nil?
  979.       refresh_oven
  980.     end
  981.   end
  982.  
  983.   def terminate
  984.     super
  985.     @recipes.dispose
  986.     @infow.dispose
  987.     @ngrewindow.dispose
  988.     @start_window.dispose
  989.     @oven.dispose
  990.     @alstatus.dispose
  991.   end
  992. end
  993.  
  994. # Input module update engine
  995. class << Input
  996.   alias falcaoalchemy_mmo_update update
  997.   def Input.update
  998.     update_popwindow2 if !$game_party.nil? and !$game_party.pop_windowdata.nil?
  999.     falcaoalchemy_mmo_update
  1000.   end
  1001.  
  1002.   # pop window global
  1003.   def update_popwindow2
  1004.     $game_party.pop_windowdata[0] -= 1 if $game_party.pop_windowdata[0] > 0
  1005.     if @temp_window.nil?
  1006.       tag = $game_party.pop_windowdata[2]
  1007.       string = $game_party.pop_windowdata[1] + tag
  1008.       width = (string.length * 9) - 10
  1009.       x, y = Graphics.width / 2 - width / 2,  Graphics.height / 2 - 64 / 2
  1010.       @temp_window = Window_Base.new(x, y, width, 64)
  1011.       @temp_window.contents.font.size = 20
  1012.       @temp_window.z = 9999
  1013.       @temp_window.draw_text(-10, -6, width, 32, tag, 1)
  1014.       @temp_window.draw_text(-10,14, width, 32, $game_party.pop_windowdata[1],1)
  1015.       @current_scene = SceneManager.scene.class
  1016.     end
  1017.     if $game_party.pop_windowdata[0] == 0 ||
  1018.       @current_scene != SceneManager.scene.class
  1019.       @temp_window.dispose
  1020.       @temp_window = nil
  1021.       $game_party.pop_windowdata = nil
  1022.     end
  1023.   end
  1024. end
  1025.  
  1026. if FalcaoRGSS_AddAlchemy_to_menu
  1027. class Window_MenuCommand < Window_Command
  1028.   alias falcaoadd_alchemy add_original_commands
  1029.   def add_original_commands
  1030.     add_command('Bản Chế Tạo',   :alchemy, main_commands_enabled)
  1031.     falcaoadd_alchemy
  1032.   end
  1033. end
  1034.  
  1035. class Scene_Menu < Scene_MenuBase
  1036.   alias falcao_alchemy_command create_command_window
  1037.   def create_command_window
  1038.     falcao_alchemy_command
  1039.     @command_window.set_handler(:alchemy,   method(:call_alchemy_scene))
  1040.   end
  1041.   def call_alchemy_scene
  1042.     SceneManager.call(Scene_Alchemy)
  1043.   end
  1044. end
  1045. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement