Guest User

falco mmrpg alchemy system - rpg maker vx ace

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