Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.97 KB | None | 0 0
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  2. #_/ ◆ Synthesize Items - KGC_ComposeItem ◆ VX ◆
  3. #_/ ◇ Last Update: 2008/08/01 ◇
  4. #_/ ◆ Translation by Mr. Anonymous ◆
  5. #_/ ◆ Special credit to Moon for Testing ◆
  6. #_/-----------------------------------------------------------------------------
  7. #_/ This script opens the ability for the designer to allow items, weapons, &
  8. #_/ armor to be created by the player through specified "recipies". It also
  9. #_/ extends the normal shop event into becoming a Synthesize Shop, controlled
  10. #_/ by a simple ON/OFF switch.
  11. #_/=============================================================================
  12. #_/ Install: Insert below KGC_UsableEquipment
  13. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  14.  
  15. #==============================================================================#
  16. # ★ Customization ★ #
  17. #==============================================================================#
  18.  
  19. module KGC
  20. module ComposeItem
  21. # ◆ Compose Shop Switch ◆
  22. # This allows you to assign which SwitchID (Event Commands, Page 1 "Game
  23. # Progression", Control Switch) you wish to control the Synthesis Shop.
  24. # When that switch is turned ON, the Synthesis Shop replaces the normal
  25. # shop screen. When OFF, the shop is normal.
  26. COMPOSE_CALL_SWITCH = 2
  27.  
  28. # ◆ Recipe Tables ◆
  29. # The following lines allow you to create recipe tables of synthesizable
  30. # items, weapons, and other equipment. Please do note overwrite:
  31. # RECIPE_ITEM = [] # Item
  32. # RECIPE_WEAPON = [] # Weapon
  33. # RECIPE_ARMOR = [] # Armor
  34. # Instead, add your custom recipes tables after those lines.
  35. #
  36. # ◆ Format
  37. # RECIPE_TYPE[ItemID] = [Cost, "Type:ID",Quantity]
  38. #
  39. # ◆ Key
  40. # Cost: Amount of money charged.
  41. # Type: (I.Items W.Weapons A.Armor)
  42. # ID: The ID number for the above specified material type.
  43. # Quantity: The required amount of materials used.
  44. #
  45. # "Type:ID,Quantity" can be used multiple times for multiple items with their
  46. # corresponding quantity. Also, the must be no space between the comma and
  47. # the given quantity.
  48. # The required quantity of an item is treated as 1 if quantity is omitted.
  49. # Untested: It seems if you set Quantity to 0, the item is still required,
  50. # but not 'consumed' or used.
  51. # Also note that the item to be synthesized can be written as an array,
  52. # allowing you to create multiple items of the same type that can be
  53. # synthesized from the same recipe.
  54. # Note: Do not alter or remove the next three lines, that is done below them.
  55. RECIPE_ITEM = [] # Item
  56. RECIPE_WEAPON = [] # Weapon
  57. RECIPE_ARMOR = [] # Armor
  58.  
  59. # ◆ Custom Recipe Tables Inserted Below ◆
  60. # Examples:
  61. # *Note: I use the default database items for these examples.
  62. # Recipe for ItemID:8 (Elixer)
  63. # Requirements: ItemID 2 (High potion), 4 (Magic water), 7 (Dispel herb)
  64. # with a quantity of 1 for each(because it's omitted), at a cost of 0.
  65. RECIPE_ITEM[8] = [0, "I:2", "I:4", "I:7"] # This can be replaced/removed.
  66. # Recipe for WeaponID:16 (Flamberge)
  67. # Requirements: WeaponID:10 (Bastard Sword)x1, ItemID:16 (Flame scroll)x2
  68. # at a cost of 800 gold.
  69. RECIPE_WEAPON[16] = [800, "W:10", "I:16,2"] # This can be replaced/removed.
  70. # Recipe for ArmorID:29 (Life Ring) AND ArmorID:30 (Sage's Ring)
  71. # Requirements: ArmorID:23 (Fire Ring)x1, ItemID:9 (Life up)x1,
  72. # ItemID:10 (Mana up)x1, ItemID:4 (Magic water)x5
  73. # at a cost of 1,000 gold.
  74. RECIPE_ARMOR[29, 30] = [1000, "A:23", "I:09", "I:10", "I:4,5"] # Removable
  75. # ◆ Recipes For the Demo Only ◆
  76. # The following recipes are for items used in the demo. You may remove or
  77. # alter these to your liking.
  78. RECIPE_ITEM[17] = [25, "I:6,2", "I:3","I:14"]
  79. RECIPE_ITEM[18] = [50, "I:6,4", "I:3,2","I:14"]
  80. RECIPE_ITEM[19] = [75, "I:6,6", "I:3,3","I:14"]
  81. RECIPE_ITEM[20] = [50, "I:7,3", "I:3","I:14"]
  82. RECIPE_ITEM[21] = [75, "I:7,4", "I:3,2","I:14"]
  83. RECIPE_ITEM[22] = [100, "I:7,5", "I:3,3","I:14"]
  84. RECIPE_ITEM[23] = [30, "I:9,2", "I:5","I:14"]
  85. RECIPE_ITEM[24] = [60, "I:9,3", "I:5,2","I:14"]
  86. RECIPE_ITEM[25] = [90, "I:9,4", "I:5,3","I:14"]
  87. RECIPE_ITEM[26] = [75, "I:8,2", "I:4","I:14"]
  88. RECIPE_ITEM[27] = [100, "I:8,3", "I:4,2","I:14"]
  89. RECIPE_ITEM[28] = [125, "I:8,4", "I:4,3","I:14"]
  90. RECIPE_ITEM[29] = [50, "I:11,2", "I:13","I:14"]
  91. RECIPE_ITEM[30] = [100, "I:11,3", "I:13,2","I:14"]
  92. RECIPE_ITEM[31] = [200, "I:11,6", "I:13,4","I:14"]
  93.  
  94. # ◆ Compose Item Command Name ◆
  95. # This is displayed at the position of the "Buy" command.
  96. VOCAB_COMPOSE_ITEM = "Comenzar"
  97.  
  98. # ◆ Parameter Changes Button ◆
  99. # Button that switches the required materials list with the parameter changes
  100. # list. (The changes only show for equipment, obviously)
  101. # SWITCH_INFO_BUTTON = Input::nil disables this.
  102. SWITCH_INFO_BUTTON = Input::X
  103.  
  104. # ◆ Compact Material List ◆
  105. # This toggle allows you to compact(shrink) the recipe list when true.
  106. COMPACT_MATERIAL_LIST = false
  107.  
  108. # ◆ Hide Command Window Toggle ◆
  109. # This toggle hides the command window (Synthesize, Sell, Cancel, Gold) after
  110. # the synthesize option has been selected. The gold window is moved to the
  111. # lower right corner.
  112. # true = command window is hidden
  113. # false = command window is shown
  114. HIDE_COMMAND_WINDOW = false
  115.  
  116. # ◆ Hide Gold Window Toggle ◆
  117. # This toggle is to be used in conjunction with HIDE_COMMAND_WINDOW = true
  118. # true = Hides the Gold/Money window.
  119. # false = Disply the Gold/Money window.
  120. # *Note: If HIDE_COMMAND_WINDOW = false, The gold window is always displayed.
  121. HIDE_GOLD_WINDOW = false
  122.  
  123. # ◆ Hide Zero Cost Toggle ◆
  124. # true = When a synthesis recipe has a cost of 0, the cost is not displayed.
  125. # false = When a synthesis recipe has a cost of 0, the cost is displayed.
  126. HIDE_ZERO_COST = true
  127.  
  128. # ◆ 合成済みのレシピは常に表示する
  129. # true : 一度でも合成したことがあれば常にリストに表示
  130. # false : 合成したことがあっても↓の条件に従う
  131. # Not sure what this is supposed to do at the moment.
  132. SHOW_COMPOSED_RECIPE = false
  133.  
  134. # ◆ Hide Recipe Requirements Toggle ◆
  135. # This toggle allows you to hide recipe and materials required when you lack
  136. # the items needed to create an item.
  137. # true = Hide recipe and items required when you lack the items needed
  138. # false = Show recipe requirements when you lack the items needed.
  139. HIDE_SHORTAGE_COST = true
  140.  
  141. # ◆ Unknown Recipe Toggle ◆
  142. # true = Hides the names of recipes that cannot be synthesized.
  143. # false = All recipe names are visible.
  144. HIDE_SHORTAGE_MATERIAL = false
  145.  
  146. # ◆ 判明 or 解禁していないレシピは合成不可
  147. # true : 判明 or 解禁するまで合成不可
  148. # false : 素材さえあれば合成可能
  149. # Not sure what this is supposed to do at the moment.
  150. NEED_RECIPE_OPEN_OR_CLEAR = false
  151.  
  152. # ◆ Unknown Recipe Toggle ◆
  153. # true = Hides the names of recipes that cannot be synthesized.
  154. # false = All recipe names are visible.
  155. MASK_UNKNOWN_RECIPE_NAME = false
  156.  
  157. # ◆ Text Displayed on Masked Recipes ◆
  158. # If only one character is specified, it extends the length of the recipe
  159. # name. Example: If UNKNOWN_NAME_MASK = "?", and let's say the recipe is
  160. # for a Long Sword, then the displayed text would be "??????????"
  161. UNKNOWN_NAME_MASK = "?"
  162.  
  163. # ◆ Hide Recipe Information Text ◆
  164. # This toggle allows you to mask the text displayed in the "Help" (topmost)
  165. # window of a recipe that the player doesn't meet the requirements to make.
  166. # true = mask the recipe's help text
  167. # false = display the text normally
  168. HIDE_UNKNOWN_RECIPE_HELP = false
  169.  
  170. # ◆ Information Text Displayed on Masked Recipes ◆
  171. # This allows you to change the text displayed in the "Help" (topmost) window
  172. # of an unknown recipe. (When HIDE_UNKNOWN_RECIPE_HELP = true)
  173. UNKNOWN_RECIPE_HELP = "What does this recipe create? Who knows!"
  174.  
  175. # ◆ Sell and Cancel Options in Command Window ◆
  176. # Added by Mr. Anonymous.
  177. # This toggle allows you to remove the sell and cancel selections on the
  178. # synthesize shop when set to true.
  179. HIDE_SELL_CANCEL = false
  180.  
  181. end
  182. end
  183.  
  184. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  185.  
  186. $imported = {} if $imported == nil
  187. $imported["ComposeItem"] = true
  188.  
  189. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  190. # Unless you know what you're doing, it's best not to alter anything beyond #
  191. # this point, as this only affects the tags used for "Notes" in database. #
  192. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  193. # Whatever word(s) are after the separator ( | ) in the following lines are
  194. # what are used to determine what is searched for in the "Notes" section.
  195.  
  196. module KGC::ComposeItem
  197. module Regexp
  198. # Recipe Tag
  199. RECIPE = /([IWA])\s*:\s*(\d+)(\s*,\s*\d+)?/i
  200. end
  201. end
  202.  
  203. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  204.  
  205. #==============================================================================
  206. # □ KGC::Commands
  207. #==============================================================================
  208.  
  209. module KGC::Commands
  210. module_function
  211. #--------------------------------------------------------------------------
  212. # ○ レシピ判明フラグを設定
  213. # type : レシピのタイプ (0..アイテム 1..武器 2..防具)
  214. # id : アイテムの ID
  215. # enabled : true..判明 false..未判明
  216. #--------------------------------------------------------------------------
  217. def set_recipe_cleared(type, id, enabled = true)
  218. item = nil
  219. case type
  220. when 0, :item # アイテム
  221. item = $data_items[id]
  222. when 1, :weapon # 武器
  223. item = $data_weapons[id]
  224. when 2, :armor # 防具
  225. item = $data_armors[id]
  226. end
  227.  
  228. $game_party.set_recipe_cleared(item, enabled) if item != nil
  229. end
  230. #--------------------------------------------------------------------------
  231. # ○ レシピ解禁フラグを設定
  232. # type : レシピのタイプ (0..アイテム 1..武器 2..防具)
  233. # id : アイテムの ID
  234. # enabled : true..解禁 false..未解禁
  235. #--------------------------------------------------------------------------
  236. def set_recipe_opened(type, id, enabled = true)
  237. item = nil
  238. case type
  239. when 0, :item # アイテム
  240. item = $data_items[id]
  241. when 1, :weapon # 武器
  242. item = $data_weapons[id]
  243. when 2, :armor # 防具
  244. item = $data_armors[id]
  245. end
  246.  
  247. $game_party.set_recipe_opened(item, enabled) if item != nil
  248. end
  249. end
  250.  
  251. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  252.  
  253. #==============================================================================
  254. # ■ Vocab
  255. #==============================================================================
  256.  
  257. module Vocab
  258. # 合成画面
  259. ComposeItem = KGC::ComposeItem::VOCAB_COMPOSE_ITEM
  260. end
  261.  
  262. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  263.  
  264. #==============================================================================
  265. # ■ RPG::BaseItem
  266. #==============================================================================
  267.  
  268. class RPG::BaseItem
  269. #--------------------------------------------------------------------------
  270. # ○ クラス変数
  271. #--------------------------------------------------------------------------
  272. @@__masked_name =
  273. KGC::ComposeItem::UNKNOWN_NAME_MASK # マスク名
  274. @@__expand_masked_name = false # マスク名拡張表示フラグ
  275.  
  276. if @@__masked_name != nil
  277. @@__expand_masked_name = (@@__masked_name.scan(/./).size == 1)
  278. end
  279. #--------------------------------------------------------------------------
  280. # ○ アイテム合成のキャッシュ生成
  281. #--------------------------------------------------------------------------
  282. def create_compose_item_cache
  283. @__compose_cost = 0
  284. @__compose_materials = []
  285.  
  286. # レシピ取得
  287. recipe = nil
  288. case self
  289. when RPG::Item # アイテム
  290. recipe = KGC::ComposeItem::RECIPE_ITEM[self.id]
  291. when RPG::Weapon # 武器
  292. recipe = KGC::ComposeItem::RECIPE_WEAPON[self.id]
  293. when RPG::Armor # 防具
  294. recipe = KGC::ComposeItem::RECIPE_ARMOR[self.id]
  295. end
  296. return if recipe == nil
  297. recipe = recipe.dup
  298.  
  299. @__compose_cost = recipe.shift
  300. # 素材リストを作成
  301. recipe.each { |r|
  302. if r =~ KGC::ComposeItem::Regexp::RECIPE
  303. material = Game_ComposeMaterial.new
  304. material.kind = $1.upcase # 素材の種類を取得
  305. material.id = $2.to_i # 素材の ID を取得
  306. if $3 != nil
  307. material.number = [$3[/\d+/].to_i, 0].max # 必要数を取得
  308. end
  309. @__compose_materials << material
  310. end
  311. }
  312. end
  313. #--------------------------------------------------------------------------
  314. # ○ マスク名
  315. #--------------------------------------------------------------------------
  316. def masked_name
  317. if KGC::ComposeItem::MASK_UNKNOWN_RECIPE_NAME
  318. if @@__expand_masked_name
  319. # マスク名を拡張して表示
  320. return @@__masked_name * self.name.scan(/./).size
  321. else
  322. return @@__masked_name
  323. end
  324. else
  325. return self.name
  326. end
  327. end
  328. #--------------------------------------------------------------------------
  329. # ○ 合成用費用
  330. #--------------------------------------------------------------------------
  331. def compose_cost
  332. create_compose_item_cache if @__compose_cost == nil
  333. return @__compose_cost
  334. end
  335. #--------------------------------------------------------------------------
  336. # ○ 合成用素材リスト
  337. #--------------------------------------------------------------------------
  338. def compose_materials
  339. create_compose_item_cache if @__compose_materials == nil
  340. return @__compose_materials
  341. end
  342. #--------------------------------------------------------------------------
  343. # ○ 合成アイテムか
  344. #--------------------------------------------------------------------------
  345. def is_compose?
  346. return !compose_materials.empty?
  347. end
  348. end
  349.  
  350. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  351.  
  352. #==============================================================================
  353. # ■ Game_Party
  354. #==============================================================================
  355.  
  356. class Game_Party < Game_Unit
  357. #--------------------------------------------------------------------------
  358. # ○ 合成済みフラグをクリア
  359. #--------------------------------------------------------------------------
  360. def clear_composed_flag
  361. @item_composed = {}
  362. @weapon_composed = {}
  363. @armor_composed = {}
  364. end
  365. #--------------------------------------------------------------------------
  366. # ○ レシピ判明フラグをクリア
  367. #--------------------------------------------------------------------------
  368. def clear_recipe_cleared_flag
  369. @item_recipe_cleared = {}
  370. @weapon_recipe_cleared = {}
  371. @armor_recipe_cleared = {}
  372. end
  373. #--------------------------------------------------------------------------
  374. # ○ レシピ解禁フラグをクリア
  375. #--------------------------------------------------------------------------
  376. def clear_recipe_opened_flag
  377. @item_recipe_opened = {}
  378. @weapon_recipe_opened = {}
  379. @armor_recipe_opened = {}
  380. end
  381. #--------------------------------------------------------------------------
  382. # ○ アイテムの合成済みフラグを設定
  383. # item : アイテム
  384. # flag : true..合成済み false..未合成
  385. #--------------------------------------------------------------------------
  386. def set_item_composed(item, flag = true)
  387. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  388. return false unless item.is_compose? # 合成アイテム以外
  389.  
  390. # 合成済みフラグを格納するハッシュを作成
  391. clear_composed_flag if @item_composed == nil
  392.  
  393. # 合成済みフラグをセット
  394. case item
  395. when RPG::Item # アイテム
  396. @item_composed[item.id] = flag
  397. when RPG::Weapon # 武器
  398. @weapon_composed[item.id] = flag
  399. when RPG::Armor # 防具
  400. @armor_composed[item.id] = flag
  401. end
  402. end
  403. #--------------------------------------------------------------------------
  404. # ○ アイテムの合成済み判定
  405. # item : アイテム
  406. #--------------------------------------------------------------------------
  407. def item_composed?(item)
  408. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  409. return false unless item.is_compose? # 合成アイテム以外
  410.  
  411. # 合成済みフラグを格納するハッシュを作成
  412. clear_composed_flag if @item_composed == nil
  413.  
  414. # 合成済み判定
  415. case item
  416. when RPG::Item # アイテム
  417. return @item_composed[item.id]
  418. when RPG::Weapon # 武器
  419. return @weapon_composed[item.id]
  420. when RPG::Armor # 防具
  421. return @armor_composed[item.id]
  422. end
  423. return false
  424. end
  425. #--------------------------------------------------------------------------
  426. # ○ アイテムの合成済みフラグを設定
  427. # item : アイテム
  428. # flag : true..合成済み false..未合成
  429. #--------------------------------------------------------------------------
  430. def set_item_composed(item, flag = true)
  431. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  432. return false unless item.is_compose? # 合成アイテム以外
  433.  
  434. # 合成済みフラグを格納するハッシュを作成
  435. clear_composed_flag if @item_composed == nil
  436.  
  437. # 合成済みフラグをセット
  438. case item
  439. when RPG::Item # アイテム
  440. @item_composed[item.id] = flag
  441. when RPG::Weapon # 武器
  442. @weapon_composed[item.id] = flag
  443. when RPG::Armor # 防具
  444. @armor_composed[item.id] = flag
  445. end
  446. end
  447. #--------------------------------------------------------------------------
  448. # ○ レシピ判明判定
  449. # item : アイテム
  450. #--------------------------------------------------------------------------
  451. def recipe_cleared?(item)
  452. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  453. return false unless item.is_compose? # 合成アイテム以外
  454.  
  455. # 判明フラグを格納するハッシュを作成
  456. clear_recipe_cleared_flag if @item_recipe_cleared == nil
  457.  
  458. # 判定
  459. case item
  460. when RPG::Item # アイテム
  461. return @item_recipe_cleared[item.id]
  462. when RPG::Weapon # 武器
  463. return @weapon_recipe_cleared[item.id]
  464. when RPG::Armor # 防具
  465. return @armor_recipe_cleared[item.id]
  466. end
  467. return false
  468. end
  469. #--------------------------------------------------------------------------
  470. # ○ アイテムの判明フラグを設定
  471. # item : アイテム
  472. # flag : true..判明 false..未判明
  473. #--------------------------------------------------------------------------
  474. def set_recipe_cleared(item, flag = true)
  475. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  476. return false unless item.is_compose? # 合成アイテム以外
  477.  
  478. # 判明フラグを格納するハッシュを作成
  479. clear_recipe_cleared_flag if @item_recipe_cleared == nil
  480.  
  481. # 判明フラグをセット
  482. case item
  483. when RPG::Item # アイテム
  484. @item_recipe_cleared[item.id] = flag
  485. when RPG::Weapon # 武器
  486. @weapon_recipe_cleared[item.id] = flag
  487. when RPG::Armor # 防具
  488. @armor_recipe_cleared[item.id] = flag
  489. end
  490. end
  491. #--------------------------------------------------------------------------
  492. # ○ レシピ解禁判定
  493. # item : アイテム
  494. #--------------------------------------------------------------------------
  495. def recipe_opened?(item)
  496. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  497. return false unless item.is_compose? # 合成アイテム以外
  498.  
  499. # 解禁フラグを格納するハッシュを作成
  500. clear_recipe_opened_flag if @item_recipe_opened == nil
  501.  
  502. # 判定
  503. case item
  504. when RPG::Item # アイテム
  505. return @item_recipe_opened[item.id]
  506. when RPG::Weapon # 武器
  507. return @weapon_recipe_opened[item.id]
  508. when RPG::Armor # 防具
  509. return @armor_recipe_opened[item.id]
  510. end
  511. return false
  512. end
  513. #--------------------------------------------------------------------------
  514. # ○ アイテムの解禁フラグを設定
  515. # item : アイテム
  516. # flag : true..解禁 false..未解禁
  517. #--------------------------------------------------------------------------
  518. def set_recipe_opened(item, flag = true)
  519. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  520. return false unless item.is_compose? # 合成アイテム以外
  521.  
  522. # 解禁フラグを格納するハッシュを作成
  523. clear_recipe_opened_flag if @item_recipe_opened == nil
  524.  
  525. # 解禁フラグをセット
  526. case item
  527. when RPG::Item # アイテム
  528. @item_recipe_opened[item.id] = flag
  529. when RPG::Weapon # 武器
  530. @weapon_recipe_opened[item.id] = flag
  531. when RPG::Armor # 防具
  532. @armor_recipe_opened[item.id] = flag
  533. end
  534. end
  535. #--------------------------------------------------------------------------
  536. # ○ アイテムの合成可能判定
  537. # item : アイテム
  538. #--------------------------------------------------------------------------
  539. def item_can_compose?(item)
  540. return false unless item_compose_cost_satisfy?(item)
  541. return false unless item_compose_material_satisfy?(item)
  542.  
  543. return true
  544. end
  545. #--------------------------------------------------------------------------
  546. # ○ 合成アイテムの資金充足判定
  547. # item : アイテム
  548. #--------------------------------------------------------------------------
  549. def item_compose_cost_satisfy?(item)
  550. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  551. return false unless item.is_compose? # 合成アイテム以外
  552.  
  553. return (gold >= item.compose_cost)
  554. end
  555. #--------------------------------------------------------------------------
  556. # ○ 合成アイテムの素材充足判定
  557. # item : アイテム
  558. #--------------------------------------------------------------------------
  559. def item_compose_material_satisfy?(item)
  560. return false unless item.is_a?(RPG::BaseItem) # アイテム以外
  561. return false unless item.is_compose? # 合成アイテム以外
  562.  
  563. item.compose_materials.each { |material|
  564. num = item_number(material.item)
  565. return false if num < material.number || num == 0 # 素材不足
  566. }
  567. return true
  568. end
  569. #--------------------------------------------------------------------------
  570. # ○ アイテムの合成可能数を取得
  571. # item : アイテム
  572. #--------------------------------------------------------------------------
  573. def number_of_composable(item)
  574. return 0 unless item.is_a?(RPG::BaseItem) # アイテム以外
  575. return 0 unless item.is_compose? # 合成アイテム以外
  576.  
  577. number = ($imported["LimitBreak"] ? item.number_limit : 99)
  578. if item.compose_cost > 0
  579. number = [number, gold / item.compose_cost].min
  580. end
  581. # 素材数判定
  582. item.compose_materials.each { |material|
  583. next if material.number == 0 # 必要数 0 は無視
  584. n = item_number(material.item) / material.number
  585. number = [number, n].min
  586. }
  587. return number
  588. end
  589. end
  590.  
  591. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  592.  
  593. #==============================================================================
  594. # □ Game_ComposeMaterial
  595. #------------------------------------------------------------------------------
  596. # 合成素材の情報を格納するクラスです。
  597. #==============================================================================
  598.  
  599. class Game_ComposeMaterial
  600. #--------------------------------------------------------------------------
  601. # ○ 公開インスタンス変数
  602. #--------------------------------------------------------------------------
  603. attr_accessor :kind # アイテムの種類 (/[IWA]/)
  604. attr_accessor :id # アイテムの ID
  605. attr_accessor :number # 必要数
  606. #--------------------------------------------------------------------------
  607. # ○ オブジェクト初期化
  608. #--------------------------------------------------------------------------
  609. def initialize
  610. @kind = "I"
  611. @id = 0
  612. @number = 1
  613. end
  614. #--------------------------------------------------------------------------
  615. # ○ アイテム取得
  616. #--------------------------------------------------------------------------
  617. def item
  618. case @kind
  619. when "I" # アイテム
  620. return $data_items[@id]
  621. when "W" # 武器
  622. return $data_weapons[@id]
  623. when "A" # 防具
  624. return $data_armors[@id]
  625. else
  626. return nil
  627. end
  628. end
  629. end
  630.  
  631. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  632.  
  633. #==============================================================================
  634. # ■ Window_Base
  635. #==============================================================================
  636.  
  637. class Window_Base < Window
  638. #--------------------------------------------------------------------------
  639. # ○ 合成アイテム名の描画
  640. # item : アイテム (スキル、武器、防具でも可)
  641. # x : 描画先 X 座標
  642. # y : 描画先 Y 座標
  643. # enabled : 有効フラグ。false のとき半透明で描画
  644. #--------------------------------------------------------------------------
  645. def draw_compose_item_name(item, x, y, enabled = true)
  646. return if item == nil
  647.  
  648. draw_icon(item.icon_index, x, y, enabled)
  649. self.contents.font.color = normal_color
  650. self.contents.font.color.alpha = enabled ? 255 : 128
  651. masked = !$game_party.item_composed?(item) &&
  652. !$game_party.recipe_cleared?(item)
  653. self.contents.draw_text(x + 24, y , 172, WLH,
  654. masked ? item.masked_name : item.name)
  655. end
  656. end
  657.  
  658. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  659.  
  660. #==============================================================================
  661. # □ Window_ComposeNumber
  662. #------------------------------------------------------------------------------
  663. # 合成画面で、合成するアイテムの個数を入力するウィンドウです。
  664. #==============================================================================
  665.  
  666. class Window_ComposeNumber < Window_ShopNumber
  667. #--------------------------------------------------------------------------
  668. # ○ 公開インスタンス変数
  669. #--------------------------------------------------------------------------
  670. attr_accessor :sell_flag # 売却フラグ
  671. #--------------------------------------------------------------------------
  672. # ● オブジェクト初期化
  673. # x : ウィンドウの X 座標
  674. # y : ウィンドウの Y 座標
  675. #--------------------------------------------------------------------------
  676. alias initialize_KGC_ComposeItem initialize unless $@
  677. def initialize(x, y)
  678. @sell_flag = false
  679.  
  680. initialize_KGC_ComposeItem(x, y)
  681. end
  682. #--------------------------------------------------------------------------
  683. # ● リフレッシュ
  684. #--------------------------------------------------------------------------
  685. def refresh
  686. y = 96
  687. self.contents.clear
  688. if @sell_flag
  689. draw_item_name(@item, 0, y)
  690. else
  691. draw_compose_item_name(@item, 0, y)
  692. end
  693. self.contents.font.color = normal_color
  694. self.contents.draw_text(212, y, 20, WLH, "x")
  695. self.contents.draw_text(248, y, 20, WLH, @number, 2)
  696. self.cursor_rect.set(244, y, 28, WLH)
  697. if !KGC::ComposeItem::HIDE_ZERO_COST || @price > 0
  698. draw_currency_value(@price * @number, 4, y + WLH * 2, 264)
  699. end
  700. end
  701. end
  702.  
  703. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  704.  
  705. #==============================================================================
  706. # □ Window_ComposeItem
  707. #------------------------------------------------------------------------------
  708. # 合成画面で、合成できる商品の一覧を表示するウィンドウです。
  709. #==============================================================================
  710.  
  711. class Window_ComposeItem < Window_ShopBuy
  712. #--------------------------------------------------------------------------
  713. # ● リフレッシュ
  714. #--------------------------------------------------------------------------
  715. def refresh
  716. @data = []
  717. for goods_item in @shop_goods
  718. case goods_item[0]
  719. when 0
  720. item = $data_items[goods_item[1]]
  721. when 1
  722. item = $data_weapons[goods_item[1]]
  723. when 2
  724. item = $data_armors[goods_item[1]]
  725. end
  726. # 合成アイテムのみ追加
  727. @data.push(item) if include?(item)
  728. end
  729. @item_max = @data.size
  730. create_contents
  731. for i in 0...@item_max
  732. draw_item(i)
  733. end
  734. end
  735. #--------------------------------------------------------------------------
  736. # ○ アイテムをリストに含めるかどうか
  737. # item : アイテム
  738. #--------------------------------------------------------------------------
  739. def include?(item)
  740. return false if item == nil # アイテムが nil なら含めない
  741. return false unless item.is_compose? # 合成アイテム以外は含めない
  742.  
  743. # 合成済みなら表示
  744. if KGC::ComposeItem::SHOW_COMPOSED_RECIPE
  745. return true if $game_party.item_composed?(item)
  746. end
  747. # 判明 or 解禁済みなら表示
  748. if $game_party.recipe_cleared?(item) || $game_party.recipe_opened?(item)
  749. return true
  750. end
  751. # 費用不足なら隠す
  752. if KGC::ComposeItem::HIDE_SHORTAGE_COST
  753. return false unless $game_party.item_compose_cost_satisfy?(item)
  754. end
  755. # 素材不足なら隠す
  756. if KGC::ComposeItem::HIDE_SHORTAGE_MATERIAL
  757. return false unless $game_party.item_compose_material_satisfy?(item)
  758. end
  759.  
  760. if KGC::ComposeItem::NEED_RECIPE_OPEN_OR_CLEAR
  761. # 判明 or 解禁していない
  762. unless $game_party.recipe_cleared?(item) ||
  763. $game_party.recipe_opened?(item)
  764. return false
  765. end
  766. end
  767.  
  768. return true
  769. end
  770. #--------------------------------------------------------------------------
  771. # ○ アイテムを許可状態で表示するかどうか
  772. # item : アイテム
  773. #--------------------------------------------------------------------------
  774. def enable?(item)
  775. return $game_party.item_can_compose?(item)
  776. end
  777. #--------------------------------------------------------------------------
  778. # ● 項目の描画
  779. # index : 項目番号
  780. #--------------------------------------------------------------------------
  781. def draw_item(index)
  782. item = @data[index]
  783. number = $game_party.item_number(item)
  784. limit = ($imported["LimitBreak"] ? item.number_limit : 99)
  785. rect = item_rect(index)
  786. self.contents.clear_rect(rect)
  787. draw_compose_item_name(item, rect.x, rect.y, enable?(item))
  788. # 費用を描画
  789. if !KGC::ComposeItem::HIDE_ZERO_COST || item.compose_cost > 0
  790. rect.width -= 4
  791. self.contents.draw_text(rect, item.compose_cost, 2)
  792. end
  793. end
  794.  
  795. if KGC::ComposeItem::HIDE_UNKNOWN_RECIPE_HELP
  796. #--------------------------------------------------------------------------
  797. # ● ヘルプテキスト更新
  798. #--------------------------------------------------------------------------
  799. def update_help
  800. item = (index >= 0 ? @data[index] : nil)
  801. if item == nil || $game_party.item_composed?(item) ||
  802. $game_party.recipe_cleared?(item)
  803. # アイテムが nil or 合成済み or 判明済みなら [Window_ShopBuy] に任せる
  804. super
  805. else
  806. @help_window.set_text(KGC::ComposeItem::UNKNOWN_RECIPE_HELP)
  807. end
  808. end
  809. end
  810. end
  811.  
  812. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  813.  
  814. #==============================================================================
  815. # □ Window_ComposeStatus
  816. #------------------------------------------------------------------------------
  817. #  合成画面で、素材の所持数や必要数を表示するウィンドウです。
  818. #==============================================================================
  819.  
  820. class Window_ComposeStatus < Window_ShopStatus
  821. #--------------------------------------------------------------------------
  822. # ○ 表示モード
  823. #--------------------------------------------------------------------------
  824. MODE_MATERIAL = 0 # 素材リスト
  825. MODE_STATUS = 1 # パーティのステータス
  826. #--------------------------------------------------------------------------
  827. # ● オブジェクト初期化
  828. # x : ウィンドウの X 座標
  829. # y : ウィンドウの Y 座標
  830. #--------------------------------------------------------------------------
  831. def initialize(x, y)
  832. @mode = MODE_MATERIAL
  833. super(x, y)
  834. end
  835. #--------------------------------------------------------------------------
  836. # ○ モード変更
  837. #--------------------------------------------------------------------------
  838. def change_mode
  839. case @mode
  840. when MODE_MATERIAL
  841. @mode = MODE_STATUS
  842. when MODE_STATUS
  843. @mode = MODE_MATERIAL
  844. end
  845. self.oy = 0
  846. refresh
  847. end
  848. #--------------------------------------------------------------------------
  849. # ● ウィンドウ内容の作成
  850. #--------------------------------------------------------------------------
  851. def create_contents
  852. if @mode == MODE_STATUS
  853. super
  854. return
  855. end
  856.  
  857. self.contents.dispose
  858. ch = height - 32
  859. if @item != nil
  860. mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  861. ch = [ch, WLH * (mag + @item.compose_materials.size * mag)].max
  862. end
  863. self.contents = Bitmap.new(width - 32, ch)
  864. end
  865. #--------------------------------------------------------------------------
  866. # ● リフレッシュ
  867. #--------------------------------------------------------------------------
  868. def refresh
  869. create_contents
  870. self.contents.font.size = Font.default_size
  871. case @mode
  872. when MODE_MATERIAL
  873. draw_material_list
  874. when MODE_STATUS
  875. super
  876. end
  877. end
  878. #--------------------------------------------------------------------------
  879. # ○ 素材リストを描画
  880. #--------------------------------------------------------------------------
  881. def draw_material_list
  882. return if @item == nil
  883. number = $game_party.item_number(@item)
  884. self.contents.font.color = system_color
  885. self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
  886. self.contents.font.color = normal_color
  887. self.contents.draw_text(4, 0, 200, WLH, number, 2)
  888. self.contents.font.size = 16 if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  889. mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  890. @item.compose_materials.each_with_index { |material, i|
  891. y = WLH * (mag + i * mag)
  892. draw_material_info(0, y, material)
  893. }
  894. end
  895. #--------------------------------------------------------------------------
  896. # ○ 素材情報を描画
  897. #--------------------------------------------------------------------------
  898. def draw_material_info(x, y, material)
  899. m_item = material.item
  900. return if m_item == nil
  901. number = $game_party.item_number(m_item)
  902. enabled = (number > 0 && number >= material.number)
  903. draw_item_name(m_item, x, y, enabled)
  904. if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  905. m_number = (material.number == 0 ? "-" : sprintf("%d", material.number))
  906. self.contents.draw_text(x, y, width - 32, WLH,
  907. sprintf("%s/%d", m_number, number), 2)
  908. else
  909. m_number = (material.number == 0 ? "-" : sprintf("%2d", material.number))
  910. self.contents.draw_text(x, y + WLH, width - 32, WLH,
  911. sprintf("%2s/%2d", m_number, number), 2)
  912. end
  913. end
  914. end
  915.  
  916. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  917.  
  918. #==============================================================================
  919. # ■ Scene_Map
  920. #==============================================================================
  921.  
  922. class Scene_Map < Scene_Base
  923. #--------------------------------------------------------------------------
  924. # ● ショップ画面への切り替え
  925. #--------------------------------------------------------------------------
  926. alias call_shop_KGC_ComposeItem call_shop
  927. def call_shop
  928. # 合成画面を呼び出した場合
  929. if $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH]
  930. # 合成画面に移行
  931. $game_temp.next_scene = nil
  932. $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH] = false
  933. $scene = Scene_ComposeItem.new
  934. else
  935. call_shop_KGC_ComposeItem
  936. end
  937. end
  938. end
  939.  
  940. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  941.  
  942. #==============================================================================
  943. # □ Scene_ComposeItem
  944. #------------------------------------------------------------------------------
  945. #  合成画面の処理を行うクラスです。
  946. #==============================================================================
  947.  
  948. class Scene_ComposeItem < Scene_Shop
  949. #--------------------------------------------------------------------------
  950. # ● 開始処理
  951. #--------------------------------------------------------------------------
  952. def start
  953. super
  954. # コマンドウィンドウ非表示
  955. if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  956. @command_window.visible = false
  957. @gold_window.y = Graphics.height - @gold_window.height
  958. @gold_window.z = @status_window.z + 100
  959. @gold_window.visible = !KGC::ComposeItem::HIDE_GOLD_WINDOW
  960.  
  961. @dummy_window.y = @command_window.y
  962. @dummy_window.height += @command_window.height
  963. end
  964.  
  965. # [Scene_Shop] 再利用のため、合成リストに @buy_window を使用
  966. @buy_window.dispose
  967. @buy_window = Window_ComposeItem.new(0, @dummy_window.y)
  968. @buy_window.height = @dummy_window.height
  969. @buy_window.active = false
  970. @buy_window.visible = false
  971. @buy_window.help_window = @help_window
  972.  
  973. # その他のウィンドウを再構成
  974. @number_window.dispose
  975. @number_window = Window_ComposeNumber.new(0, @buy_window.y)
  976. @number_window.height = @buy_window.height
  977. @number_window.create_contents
  978. @number_window.active = false
  979. @number_window.visible = false
  980.  
  981. @status_window.dispose
  982. @status_window = Window_ComposeStatus.new(@buy_window.width, @buy_window.y)
  983. @status_window.height = @buy_window.height
  984. @status_window.create_contents
  985. @status_window.visible = false
  986.  
  987. # コマンドウィンドウ非表示の場合、合成ウィンドウに切り替え
  988. if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  989. @command_window.active = false
  990. @dummy_window.visible = false
  991. @buy_window.active = true
  992. @buy_window.visible = true
  993. @buy_window.update_help
  994. @status_window.visible = true
  995. @status_window.item = @buy_window.item
  996. end
  997. end
  998. #--------------------------------------------------------------------------
  999. # ● コマンドウィンドウの作成
  1000. #--------------------------------------------------------------------------
  1001. def create_command_window
  1002. s1 = Vocab::ComposeItem
  1003. s2 = Vocab::ShopSell
  1004. s3 = Vocab::ShopCancel
  1005. # Added 4/11 [Mr. Anonymous]
  1006. if KGC::ComposeItem::HIDE_SELL_CANCEL
  1007. @command_window = Window_Command.new(150, [s1], 1)
  1008. else
  1009. @command_window = Window_Command.new(384, [s1, s2, s3], 3)
  1010. end
  1011. #@command_window = Window_Command.new(384, [s1, s2, s3], 3)
  1012. @command_window.y = 56
  1013. if $game_temp.shop_purchase_only
  1014. @command_window.draw_item(1, false)
  1015. end
  1016. end
  1017. #--------------------------------------------------------------------------
  1018. # ● フレーム更新
  1019. #--------------------------------------------------------------------------
  1020. def update
  1021. super
  1022. if KGC::ComposeItem::SWITCH_INFO_BUTTON != nil &&
  1023. Input.trigger?(KGC::ComposeItem::SWITCH_INFO_BUTTON)
  1024. Sound.play_cursor
  1025. @status_window.change_mode
  1026. end
  1027. end
  1028. #--------------------------------------------------------------------------
  1029. # ● 購入アイテム選択の更新
  1030. #--------------------------------------------------------------------------
  1031. def update_buy_selection
  1032. @number_window.sell_flag = false
  1033.  
  1034. # コマンドウィンドウ非表示で B ボタンが押された場合
  1035. if KGC::ComposeItem::HIDE_COMMAND_WINDOW && Input.trigger?(Input::B)
  1036. Sound.play_cancel
  1037. $scene = Scene_Map.new
  1038. return
  1039. end
  1040.  
  1041. @status_window.item = @buy_window.item
  1042. if Input.trigger?(Input::C)
  1043. @item = @buy_window.item
  1044. # アイテムが無効なら選択不可
  1045. if @item == nil
  1046. Sound.play_buzzer
  1047. return
  1048. end
  1049.  
  1050. # 合成不可能 or 限界数まで所持している場合は選択不可
  1051. number = $game_party.item_number(@item)
  1052. limit = ($imported["LimitBreak"] ? @item.number_limit : 99)
  1053. if !$game_party.item_can_compose?(@item) || number == limit
  1054. Sound.play_buzzer
  1055. return
  1056. end
  1057.  
  1058. # 個数入力に切り替え
  1059. Sound.play_decision
  1060. max = $game_party.number_of_composable(@item)
  1061. max = [max, limit - number].min
  1062. @buy_window.active = false
  1063. @buy_window.visible = false
  1064. @number_window.set(@item, max, @item.compose_cost)
  1065. @number_window.active = true
  1066. @number_window.visible = true
  1067. return
  1068. end
  1069.  
  1070. super
  1071. end
  1072. #--------------------------------------------------------------------------
  1073. # ● 売却アイテム選択の更新
  1074. #--------------------------------------------------------------------------
  1075. def update_sell_selection
  1076. @number_window.sell_flag = true
  1077. super
  1078. end
  1079. #--------------------------------------------------------------------------
  1080. # ● 個数入力の決定
  1081. #--------------------------------------------------------------------------
  1082. def decide_number_input
  1083. if @command_window.index != 0 # 「合成する」以外
  1084. super
  1085. return
  1086. end
  1087.  
  1088. Sound.play_shop
  1089. @number_window.active = false
  1090. @number_window.visible = false
  1091. # 合成処理
  1092. operation_compose
  1093. @gold_window.refresh
  1094. @buy_window.refresh
  1095. @status_window.refresh
  1096. @buy_window.active = true
  1097. @buy_window.visible = true
  1098. end
  1099. #--------------------------------------------------------------------------
  1100. # ○ 合成の処理
  1101. #--------------------------------------------------------------------------
  1102. def operation_compose
  1103. $game_party.lose_gold(@number_window.number * @item.compose_cost)
  1104. $game_party.gain_item(@item, @number_window.number)
  1105. # 素材を減らす
  1106. @item.compose_materials.each { |material|
  1107. $game_party.lose_item(material.item,
  1108. material.number * @number_window.number)
  1109. }
  1110. # 合成済みにする
  1111. $game_party.set_item_composed(@item)
  1112. end
  1113. end
  1114. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  1115. #_/ The original untranslated version of this script can be found here:
  1116. # http://f44.aaa.livedoor.jp/~ytomy/tkool/rpgtech/php/tech.php?tool=VX&cat=tech_vx/item&tech=compose_item
  1117. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement