Advertisement
Raizen

Untitled

Dec 28th, 2013
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.67 KB | None | 0 0
  1. #=======================================================
  2. # Lune Item Craft
  3. # Author: Raizen
  4. # Comunity: centrorpg.com
  5. # Made for: RMVXAce
  6.  
  7. # Adds a function of Item combining in the menu,
  8. # similar to other games like Diablo II.
  9. #=======================================================
  10.  
  11. module Lune_Combine
  12. #===========================================================================
  13. # In case you use the recipe window , otherwise you can jump to Lose Items?
  14. # Help Text
  15. Text_comb1 = "See the combined items and its results!"
  16. Text_comb2 = "To combine items go to the menu"
  17. # Name that appears on the menu.
  18. Craft = "Craft"
  19. # Add to Menu?
  20. Craft_Menu = true
  21.  
  22. # To activate the Craft window, SceneManager.call(Scene_LuneCraft)
  23. # by Call Script.
  24. #===========================================================================
  25. # Lose Items?
  26. # When Items are combined, in case it is a wrong combinations,
  27. # They disappear or continue on the actors items?
  28. # true = lose, false = don't lose
  29. Lose_Itens = true
  30. # Sound played in case of success
  31. # To bem in SE folder of the project
  32. Sound = "Item3"
  33.  
  34. # Vocabulary on menu
  35. # Use
  36. Use = 'Use'
  37. # Combine
  38. Combine = 'Combine'
  39. # Release Items from combination
  40. Throw = 'Release'
  41. # Help text in item window.
  42. TextComb = "Combination - Press Shift to combine."
  43. # To create new combinations copy and paste the following, changing the
  44. # value inside the [] on Combination[n].
  45. # Key to be pressed to confirm the combination,
  46. # Remembering it is the same keys from events.
  47. # A = SHIFT, X = A, Y = S, Z = D, L = Q, R = W.
  48. # In this way, :A for exemple.
  49. Tecla = :A
  50. Combination = []
  51. #=========================================================================
  52. # Combination 0 => 5 large potions
  53. #=========================================================================
  54. Combination[0] = {
  55. # ID of the combined items
  56. "Itens ID" => [1, 2],
  57. # Tupe of items that are being combined, in the same order as above.
  58. # 1 = item, 2 = weapons, 3 = armors
  59. "Itens Types" => [1, 1],
  60. # Quantidade needed of each item.
  61. "Quantity" => [5, 5],
  62. # Final Result of the item , ID do item.
  63. "Result Item" => 3,
  64. # Type of item obtained.
  65. # 1 = item, 2 = weapons, 3 = armors
  66. "Res Type" => 1,
  67. # Quantity of item obtained
  68. "ResQuantity" => 5 }
  69. #=========================================================================
  70. # Combination 1 => 1 War Axe
  71. #=========================================================================
  72. Combination[1] = {
  73. # ID of the combined items
  74. "Itens ID" => [1],
  75. # Tupe of items that are being combined, in the same order as above.
  76. # 1 = item, 2 = weapons, 3 = armors
  77. "Itens Types" => [2],
  78. # Quantidade needed of each item.
  79. "Quantity" => [10],
  80. # Final Result of the item , ID do item.
  81. "Result Item" => 2,
  82. # Type of item obtained.
  83. # 1 = item, 2 = weapons, 3 = armors
  84. "Res Type" => 2,
  85. # Quantity of item obtained
  86. "ResQuantity" => 1 }
  87. #=========================================================================
  88. # Combination 2 => 5 Mana Potions
  89. #=========================================================================
  90. Combination[2] = {
  91. # ID of the combined items
  92. "Itens ID" => [1, 2, 3],
  93. # Tupe of items that are being combined, in the same order as above.
  94. # 1 = item, 2 = weapons, 3 = armors
  95. "Itens Types" => [1, 1, 1],
  96. # Quantidade needed of each item.
  97. "Quantity" => [5, 5, 5],
  98. # Final Result of the item , ID do item.
  99. "Result Item" => 4,
  100. # Type of item obtained.
  101. # 1 = item, 2 = weapons, 3 = armors
  102. "Res Type" => 1,
  103. # Quantity of item obtained
  104. "ResQuantity" => 5 }
  105.  
  106.  
  107. #===========================================================================
  108. # Inicio do script
  109. #===========================================================================
  110. end
  111.  
  112. class Scene_Item < Scene_ItemBase
  113. alias raizen_combine_start start
  114. alias lune_terminate terminate
  115. def start
  116. raizen_combine_start
  117. $combine_itemicon = []
  118. $combine_itemcheck = []
  119. @combine_item = Window_Item_Combine.new
  120. @combine_item.viewport = @viewport
  121. @combine_window = Window_Combine.new
  122. @combine_window.viewport = @viewport
  123. @combine_item.set_handler(:new_game, method(:command_use))
  124. @combine_item.set_handler(:continue, method(:command_combine))
  125. @combine_item.set_handler(:shutdown, method(:command_release))
  126. end
  127. def create_item_window
  128. wy = @category_window.y + @category_window.height
  129. wh = Graphics.height - wy
  130. @item_window = Window_ItemList.new(0, wy, Graphics.width, wh - 80)
  131. @item_window.viewport = @viewport
  132. @item_window.help_window = @help_window
  133. @item_window.set_handler(:ok, method(:on_item_ok))
  134. @item_window.set_handler(:cancel, method(:on_item_cancel))
  135. @category_window.item_window = @item_window
  136. end
  137. def on_item_ok
  138. if item == nil
  139. @item_window.activate
  140. return
  141. end
  142. if @combine_item.close?
  143. @combine_item.open
  144. @combine_item.activate
  145. else
  146. determine_item
  147. end
  148. end
  149. def return_itens
  150. return if $combine_itemicon == []
  151. for n in 0...$combine_itemicon.size
  152. $game_party.gain_item($combine_itemicon[n], $combine_itens[n])
  153. end
  154. $combine_itemicon = []
  155. end
  156. def update
  157. super
  158. if Input.trigger?(Lune_Combine::Tecla)
  159. @noreturn = false
  160. for n in 0...Lune_Combine::Combination.size
  161. @types = true
  162. @lune_combination = []
  163. for i in 0...Lune_Combine::Combination[n]['Itens Types'].size
  164. case Lune_Combine::Combination[n]['Itens Types'][i]
  165. when 1
  166. @lune_combination.push($data_items[Lune_Combine::Combination[n]['Itens ID'][i]])
  167. when 2
  168. @lune_combination.push($data_weapons[Lune_Combine::Combination[n]['Itens ID'][i]])
  169. when 3
  170. @lune_combination.push($data_armors[Lune_Combine::Combination[n]['Itens ID'][i]])
  171. end
  172. end
  173. for inc in 0...$combine_itemicon.size
  174. @types = false unless @lune_combination.include?($combine_itemicon[inc])
  175. get_pos = $combine_itemicon.index(@lune_combination[inc])
  176. if get_pos != nil
  177. @types = false if Lune_Combine::Combination[n]['Quantity'][inc] != $combine_itens[get_pos]
  178. end
  179. end
  180. @types = false unless @lune_combination.size == $combine_itemicon.size
  181. if @types
  182. @noreturn = true
  183. gotoforge(n)
  184. end
  185. end
  186. return if @noreturn
  187. @number_window.close if @number_window
  188. command_release(Lune_Combine::Lose_Itens)
  189. Sound.play_buzzer
  190. end
  191. @combine_window.refresh
  192. if @number_window and @number_window.nitens == true
  193. @number_window.nitens = false
  194. @combine_item.close
  195. @item_window.refresh
  196. @item_window.activate
  197. end
  198. if Input.trigger?(:B) and !@combine_item.close?
  199. Sound.play_cancel
  200. if @number_window and !@number_window.close?
  201. @number_window.close
  202. @combine_item.activate
  203. else
  204. @combine_item.close
  205. @item_window.activate
  206. end
  207. end
  208. end
  209. def command_use
  210. determine_item
  211. end
  212. def command_combine
  213. p @index
  214. if @number_window and !@number_window.close?
  215. @combine_item.activate
  216. return
  217. end
  218. @number_window = Window_NumberInputInner.new(Window_Base.new(0,0,0,0), item, @item_window.index)
  219. @number_window.viewport = @viewport
  220. @number_window.start
  221. end
  222. def command_release(n = false)
  223. return_itens unless n
  224. $combine_itens = []
  225. $combine_itemicon = []
  226. @item_window.refresh
  227. @combine_item.close
  228. @item_window.activate
  229. end
  230. def terminate
  231. return_itens
  232. lune_terminate
  233. end
  234. def gotoforge(n)
  235. $combine_itens = []
  236. $combine_itemicon = []
  237. case Lune_Combine::Combination[n]['Res Type']
  238. when 1
  239. get_item = $data_items[Lune_Combine::Combination[n]['Result Item']]
  240. when 2
  241. get_item = $data_weapons[Lune_Combine::Combination[n]['Result Item']]
  242. when 3
  243. get_item = $data_armors[Lune_Combine::Combination[n]['Result Item']]
  244. end
  245. RPG::SE.new(Lune_Combine::Sound).play
  246. $game_party.gain_item(get_item, Lune_Combine::Combination[n]['ResQuantity'])
  247. @item_window.refresh
  248. end
  249. end
  250. #==============================================================================
  251. # ** Window_Combine
  252. #------------------------------------------------------------------------------
  253. # Esta janela exibe os itens a serem fundidos.
  254. #==============================================================================
  255.  
  256. class Window_Combine < Window_Base
  257. include Lune_Combine
  258. #--------------------------------------------------------------------------
  259. # * Inicialização do objeto
  260. #--------------------------------------------------------------------------
  261. def initialize
  262. super(0, window_height, Graphics.width, 80)
  263. $combine_itens = []
  264. refresh
  265. end
  266. #--------------------------------------------------------------------------
  267. # * Aquisição da largura da janela
  268. #--------------------------------------------------------------------------
  269. def window_width
  270. return 160
  271. end
  272. def window_height
  273. Graphics.height - 80
  274. end
  275.  
  276. #--------------------------------------------------------------------------
  277. # * Renovação
  278. #--------------------------------------------------------------------------
  279. def refresh
  280. contents.clear
  281.  
  282. draw_text(0, -5, Graphics.width, 30, TextComb, 0)
  283. unless $combine_itens.nil?
  284. for i in 0...$combine_itens.size
  285. draw_combine_icons(i)
  286. end
  287. end
  288. end
  289. #--------------------------------------------------------------------------
  290. # * Aquisição do valor em dinheiro
  291. #--------------------------------------------------------------------------
  292. def value
  293. $game_party.gold
  294. end
  295. def draw_combine_icons(i)
  296. item_icon = $combine_itemicon[i].icon_index
  297. item_number = $combine_itens[i]
  298. draw_icon(item_icon, 0 + i*50, 30)
  299. draw_text(i*50 + 5, 30, 20, 30, "x", 0)
  300. draw_text(i*50 + 20, 30, 20, 30, item_number, 0)
  301. end
  302. #--------------------------------------------------------------------------
  303. # * Aquisição da unidade monetária
  304. #--------------------------------------------------------------------------
  305. def currency_unit
  306. Vocab::currency_unit
  307. end
  308. #--------------------------------------------------------------------------
  309. # * Abertura da janela
  310. #--------------------------------------------------------------------------
  311. def open
  312. refresh
  313. super
  314. end
  315. end
  316.  
  317. #==============================================================================
  318. # ** Window_MenuStatus
  319. #------------------------------------------------------------------------------
  320. # Esta janela exibe os parâmetros dos membros do grupo na tela de menu.
  321. #==============================================================================
  322.  
  323. class Window_Item_Combine < Window_Command
  324. include Lune_Combine
  325. #--------------------------------------------------------------------------
  326. # * Inicialização do objeto
  327. #--------------------------------------------------------------------------
  328. def initialize
  329. super(0, 0)
  330. self.z = 9999
  331. self.x = (Graphics.width / 2) - (window_width / 2)
  332. self.y = Graphics.height / 2
  333. self.openness = 0
  334. end
  335. #--------------------------------------------------------------------------
  336. # * Aquisição da largura da janela
  337. #--------------------------------------------------------------------------
  338. def window_width
  339. return 160
  340. end
  341. #--------------------------------------------------------------------------
  342. # * Criação da lista de comandos
  343. #--------------------------------------------------------------------------
  344. def make_command_list
  345. add_main_commands
  346.  
  347. end
  348. #--------------------------------------------------------------------------
  349. # * Adição dos comandos principais
  350. #--------------------------------------------------------------------------
  351. def add_main_commands
  352. add_command(Use, :new_game, true)
  353. add_command(Combine, :continue, true)
  354. add_command(Throw, :shutdown, true)
  355. end
  356.  
  357. end
  358.  
  359.  
  360.  
  361.  
  362. #==============================================================================
  363. # ** Scene_ItemBase
  364. #------------------------------------------------------------------------------
  365. # Esta é a superclasse das classes que executam as telas de itens e
  366. # habilidades.
  367. #==============================================================================
  368.  
  369. class Scene_ItemBase < Scene_MenuBase
  370. def determine_item
  371. @combine_item.close
  372. if item.is_a?(RPG::Item) and item.for_friend?
  373. show_sub_window(@actor_window)
  374. @actor_window.select_for_item(item)
  375. else
  376. item.is_a?(RPG::Item) ? use_item : Sound.play_buzzer
  377. activate_item_window
  378. end
  379. end
  380. end
  381.  
  382. #==============================================================================
  383. # ** Window_NumberInputInner
  384. #------------------------------------------------------------------------------
  385. # Esta janela é utilizada para o comando de eventos [Armazenar Número]
  386. #==============================================================================
  387.  
  388. class Window_NumberInputInner < Window_NumberInput
  389. attr_accessor :nitens
  390. def initialize(message_window, item, index_2)
  391. @index_2 = index_2
  392. @item = item
  393. @get_lost_itens = 0
  394. super(message_window)
  395. end
  396. #--------------------------------------------------------------------------
  397. # * Inicialização do processo
  398. #--------------------------------------------------------------------------
  399. def start
  400. @digits_max = 2
  401. @number = @get_lost_itens
  402. @number = [[@number, 0].max, 10 ** @digits_max - 1].min
  403. @index = 0
  404. update_placement
  405. create_contents
  406. refresh
  407. open
  408. activate
  409. end
  410. #--------------------------------------------------------------------------
  411. # * Atualização da posição da janela
  412. #--------------------------------------------------------------------------
  413. def update_placement
  414. self.width = @digits_max * 20 + padding * 2
  415. self.height = fitting_height(1)
  416. self.x = (Graphics.width - width) / 2
  417. self.y = Graphics.height/2 - height
  418. self.z = 150
  419. end
  420.  
  421. #--------------------------------------------------------------------------
  422. # * Definição de resultado ao pressionar o botão de confirmação
  423. #--------------------------------------------------------------------------
  424. def process_ok
  425. Sound.play_ok
  426. number = $game_party.item_number(@item)
  427. if @number <= number && @number != 0
  428. make_icon
  429. end
  430. deactivate
  431. @nitens = true
  432. close
  433. end
  434. def make_icon
  435. @nitens = true
  436. $combine_itemicon.push(@item)
  437. $combine_itemcheck.push(@item.id)
  438. $combine_itens.push(@number)
  439. $game_party.lose_item(@item, @number)
  440. end
  441. end
  442.  
  443.  
  444. #==============================================================================
  445. # ** Window_ItemList
  446. #------------------------------------------------------------------------------
  447. # Esta janela exibe a lista de itens possuidos na tela de itens.
  448. #==============================================================================
  449.  
  450. class Window_ItemList < Window_Selectable
  451. #--------------------------------------------------------------------------
  452. # * Definição de habilitação de seleção
  453. #--------------------------------------------------------------------------
  454. def current_item_enabled?
  455. true
  456. end
  457. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement