Alexander81

Falcao Mana Stones Enchants

Aug 31st, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.56 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # * Caratteristiche
  3. #
  4. # - Armi e Protezioni possono essere incantate adesso.
  5. # - Armi e Protezioni possono avere tutti gli incavi che desideri.
  6. # - Quando incastri un oggetto la caratteristica indicata aumentera di conseguenza.
  7. # - Gli oggetti che incanti possono essere creati con dei sempliti tags.
  8. # - Possibilità di fallimento durante il processo di incantamento.
  9. # - Se l'incantamento fallisce gli oggetti incantati verranno distrutti.
  10. # - Una interfaccia grafica facile da usare.
  11. #
  12. # Nota: le armi e le protezioni sono conciderate uniche, quindi se si dispone di
  13. # più di un arma con lo stesso ID, gli oggetti incastrati rimarrano anche su le altre.
  14. #
  15. #-------------------------------------------------------------------------------
  16. # * Come utilizzarlo
  17. #
  18. # Per incastrare gli oggetti bisogna andare nella schermata di equipaggiamento
  19. # e premere 'A'. Armi e Protezioni devono essere impostate per essere incantate.
  20. #
  21. # Tag da inserire in armi e protezioni
  22. #
  23. # <Incavo: x> - Cambia x per aumentare il numero di incavi a disposizione
  24. #
  25. # Tag da aggiungere all'oggetto che utilizzi per aumentare le caratteristiche.
  26. # (Da notare che ogni oggetto puoi utilizzare uno solo di questi Tags)
  27. #
  28. # <Salute: x> <- Punti Vita Max
  29. # <Mana: x> <- Punti Mana Max
  30. # <Forza: x> <- Attacco Fisico
  31. # <Difesa: x> <- Difesa Fisica
  32. # <Intelletto: x> <- Attacco Magico
  33. # <Stamina: x> <- Difesa Magica
  34. # <Agilità: x>
  35. # <Fortuna: x> => Al posto della x metti il valore da aggiungere
  36. #
  37. # <Probabilità Incastro: x> Cambia x con un valore da 1 a 100 per aumentare la
  38. # percentuale di successo che l'oggetto venga inserito.
  39. #
  40. # (Da notare che se l'oggetto non sarà inserito e verrà distrutto eheh)
  41. # Nota: Se un oggetto incastonato viene rimosso sarà automaticamente distrutto!
  42. #-------------------------------------------------------------------------------
  43.  
  44. module FalMana
  45.  
  46. # Da predefinito per armi e le protezioni, metti 0 se non si desiderano Incavi
  47. DefaultSockets = 4
  48.  
  49. # Percentuale di successo predefinita (dev'essere un valore compreso tra 1 e 100)
  50. DefaultChance = 90
  51.  
  52. # Suono riprodotto quando si incastona un oggetto
  53. SoketingSe = "Heal6"
  54.  
  55. # Suono riprodotto quando l'incastonamento ha successo
  56. SocketSuccessSe = "Decision2"
  57.  
  58. # Suono riprodotto quando l'incastonamento fallisce
  59. SocketFailSe = "Down1"
  60.  
  61. # Suono riprodotto quando si rimuove un oggetto incastonato
  62. ClearSocketSe = "Equip3"
  63.  
  64. #-------------------------------------------------------------------------------
  65. def self.stones(actor)
  66. @actor = actor
  67. SceneManager.call(Scene_ManaStones)
  68. end
  69.  
  70. def self.actor ; @actor ; end
  71.  
  72. def self.socket_manastone(item, index, value, actor)
  73. item.manaslots[index] = value
  74. actor.add_param(value.manastone_param[0], value.manastone_param[1])
  75. end
  76.  
  77. def self.remove_manastone(item, index, value, actor)
  78. item.manaslots[index] = nil
  79. actor.add_param(value.manastone_param[0], - value.manastone_param[1])
  80. end
  81.  
  82. def self.clear_manastones(item, actor)
  83. item.manaslots.each {|m| actor.add_param(m.manastone_param[0],
  84. - m.manastone_param[1]) unless m.nil?}
  85. item.manaslots.size.times {|i| item.manaslots[i] = nil}
  86. end
  87.  
  88. def self.add_param(actor, item, sub=false)
  89. return if item.nil?
  90. return if item.manaslots.nil?
  91. item.manaslots.each {|m| actor.add_param(m.manastone_param[0],
  92. sub ? - m.manastone_param[1] : m.manastone_param[1]) unless m.nil?}
  93. end
  94. end
  95.  
  96. # Game system: Register mana stones values
  97. class Game_System
  98. attr_reader :weapon_slots, :armor_slots
  99. alias falcaomana_slots_ini initialize
  100. def initialize
  101. @weapon_slots = {}
  102. @armor_slots = {}
  103. dataslots_ini(@weapon_slots, $data_weapons)
  104. dataslots_ini(@armor_slots, $data_armors)
  105. falcaomana_slots_ini
  106. end
  107.  
  108. def dataslots_ini(operand, item)
  109. for kind in item
  110. next if kind.nil?
  111. if kind.given_sl != nil
  112. data = []
  113. kind.given_sl.times {|i| data.push(nil)}
  114. operand[kind.id] = data
  115. end
  116. end
  117. end
  118. end
  119.  
  120. # Scene_Equip: main mana stones socketing system
  121. class Scene_Equip < Scene_MenuBase
  122. def update
  123. super
  124. update_manacalling
  125. end
  126.  
  127. def update_manacalling
  128. update_enchant_help
  129. if Input.trigger?(:X)
  130. FalMana.stones(@actor)
  131. Sound.play_ok
  132. end
  133. end
  134.  
  135. def update_enchant_help
  136. @help_window.contents.font.size = Font.default_size
  137. @help_window.refresh
  138. @help_window.contents.font.size = 18
  139. @help_window.draw_text(-22,22,@help_window.width,32, 'Premi A per Incantare.',2)
  140. end
  141. end
  142.  
  143. # RPG::EquipItem: get slots data for each weapon and armor
  144. class RPG::EquipItem < RPG::BaseItem
  145. def given_sl
  146. @note =~ /<Incavo: (.*)>/i ? n = $1.to_i : n = nil
  147. n = FalMana::DefaultSockets if n.nil? and FalMana::DefaultSockets > 0
  148. return n
  149. end
  150.  
  151. def manaslots
  152. self.is_a?(RPG::Weapon) ? i = $game_system.weapon_slots[self.id] :
  153. i = $game_system.armor_slots[self.id]
  154. return i
  155. end
  156. end
  157.  
  158. # RPG::Item: Mana stones item definition
  159. class RPG::Item < RPG::UsableItem
  160. def socket_chance
  161. @note =~ /<Probabilità Incastro: (.*)>/i ? n = $1.to_i : n = FalMana::DefaultChance
  162. return n
  163. end
  164.  
  165. def manastone_param
  166. param = [0, $1.to_i] if @note =~ /<Salute: (.*)>/i
  167. param = [1, $1.to_i] if @note =~ /<Mana: (.*)>/i
  168. param = [2, $1.to_i] if @note =~ /<Forza: (.*)>/i
  169. param = [3, $1.to_i] if @note =~ /<Difesa: (.*)>/i
  170. param = [4, $1.to_i] if @note =~ /<Intelletto: (.*)>/i
  171. param = [5, $1.to_i] if @note =~ /<Stamina: (.*)>/i
  172. param = [6, $1.to_i] if @note =~ /<Agilità: (.*)>/i
  173. param = [7, $1.to_i] if @note =~ /<Fortuna: (.*)>/i
  174. return param
  175. end
  176. end
  177.  
  178. #-------------------------------------------------------------------------------
  179. # Window mana slots
  180. class Window_ItemSlots < Window_Selectable
  181. def initialize(x=0, y=0, w=280, h=124)
  182. super(x, y, w, h)
  183. unselect
  184. end
  185.  
  186. def item() return @data[self.index] end
  187. def line_height() return 24 end
  188. def spacing() return 6 end
  189. def col_max() return 2 end
  190.  
  191. def refresh(object)
  192. self.contents.clear if self.contents != nil
  193. @data = []
  194. return if object.manaslots.nil? rescue return
  195. object.manaslots.each {|i| @data.push(i)}
  196. @item_max = @data.size
  197. if @item_max > 0
  198. self.contents = Bitmap.new(width - 32, row_max * 26)
  199. for i in 0...@item_max
  200. draw_item(i)
  201. end
  202. end
  203. end
  204.  
  205. def draw_item(index)
  206. item = @data[index]
  207. x, y = index % col_max * (129), index / col_max * 24
  208. self.contents.font.size = 18
  209. self.contents.draw_text(x + 2, y - 2, 212, 32, '■', 0)
  210. draw_icon(item.icon_index, x-2, y) rescue nil
  211. param = Vocab.param(item.manastone_param[0]) rescue nil
  212. value = item.manastone_param[1] rescue nil
  213. self.contents.draw_text(x + 26,y,212,32, param + " +#{value}") rescue nil
  214. end
  215.  
  216. def item_max
  217. return @item_max.nil? ? 0 : @item_max
  218. end
  219. end
  220.  
  221. #-------------------------------------------------------------------------------
  222. # Window mana stones
  223. class Window_ManaStones < Window_Selectable
  224. def initialize(x=0, y=124, w=280, h=148)
  225. super(x, y, w, h)
  226. refresh ; unselect
  227. end
  228.  
  229. def item() return @data[self.index] end
  230.  
  231. def refresh
  232. self.contents.clear if self.contents != nil
  233. @data = []
  234. for it in $data_items
  235. next if it.nil?
  236. @data.push(it) if $game_party.has_item?(it) and !it.manastone_param.nil?
  237. end
  238. @item_max = @data.size
  239. if @item_max > 0
  240. self.contents = Bitmap.new(width - 32, row_max * 26)
  241. for i in 0...@item_max
  242. draw_item(i)
  243. end
  244. end
  245. end
  246.  
  247. def draw_item(index)
  248. item = @data[index]
  249. x, y = index % col_max * (90), index / col_max * 24
  250. self.contents.font.size = 18
  251. draw_icon(item.icon_index, x, y)
  252. param = Vocab.param(item.manastone_param[0])
  253. value = item.manastone_param[1]
  254. number = $game_party.item_number(item)
  255. contents.draw_text(x + 24,y,212,32, item.name + " #{param} +#{value}")
  256. contents.draw_text(x -30, y, self.width, 32, ':' + number.to_s, 2)
  257. end
  258.  
  259. def item_max
  260. return @item_max.nil? ? 0 : @item_max
  261. end
  262. end
  263.  
  264. class Game_Actor < Game_Battler
  265. alias falcaomanastones_change change_equip
  266. def change_equip(slot_id, item)
  267. FalMana.add_param(self, @equips[slot_id].object, true)
  268. FalMana.add_param(self, item)
  269. falcaomanastones_change(slot_id, item)
  270. end
  271. end
  272.  
  273.  
  274. #-------------------------------------------------------------------------------
  275. # Window actor equipped
  276. class Window_Equippedwa < Window_Selectable
  277. def initialize(x=0, y=124)
  278. super(x, y, 190, 148)
  279. refresh(FalMana.actor) ; activate ; select(0)
  280. end
  281.  
  282. def item() return @data[self.index] end
  283.  
  284. def refresh(actor)
  285. self.contents.clear if self.contents != nil
  286. @data = []
  287. actor.equips.each {|equips| @data.push(equips) if !equips.nil?}
  288. @item_max = @data.size
  289. if @item_max > 0
  290. self.contents = Bitmap.new(width - 32, row_max * 26)
  291. for i in 0...@item_max
  292. draw_item(i)
  293. end
  294. end
  295. end
  296.  
  297. def draw_item(index)
  298. item = @data[index]
  299. x, y = index % col_max * (90), index / col_max * 24
  300. self.contents.font.size = 18
  301. draw_icon(item.icon_index, x, y)
  302. contents.draw_text(x + 24,y,212,32, item.name)
  303. end
  304.  
  305. def item_max
  306. return @item_max.nil? ? 0 : @item_max
  307. end
  308. end
  309.  
  310. # Scene mana stones
  311. class Scene_ManaStones < Scene_MenuBase
  312. def start
  313. super
  314. w = Graphics.width ; h = Graphics.height ; @actor = FalMana.actor
  315. @slot_window = Window_Equippedwa.new(w/2 - 190/2 - 137, h/2 - 148/2 - 106)
  316. @param_window = Window_Base.new(@slot_window.x,@slot_window.y + 148,190,214)
  317. refresh_param
  318. @socket_window = Window_Base.new(w/2 - 280/2 + 97,h/2 - 90/2 - 136, 280, 90)
  319. @col = [Color.new(180, 225, 245), Color.new(20, 160, 225), Color.new(0,0,0)]
  320. @itemslots = Window_ItemSlots.new(@socket_window.x, @socket_window.y + 90)
  321. @manastones = Window_ManaStones.new(@itemslots.x, @itemslots.y + 124)
  322. @result = '' ; @meter = 0
  323. update_indexes
  324. end
  325.  
  326. def refresh_param
  327. @param_window.contents.clear
  328. @param_window.contents.font.size = 18
  329. @param_window.contents.font.color = @param_window.normal_color
  330. @param_window.contents.fill_rect(0, 0, 190, 44, Color.new(0, 0, 0, 60))
  331. @param_window.draw_character(@actor.character_name,
  332. @actor.character_index, 20, 42)
  333. @param_window.draw_text(50, -6, 190, 32, @actor.name)
  334. @param_window.draw_text(50, 18, 190, 32, 'Parametri')
  335. y = 0
  336. for i in 0...8
  337. y += 17
  338. @param_window.contents.font.color = @param_window.normal_color
  339. @param_window.draw_text(0, y + 28, 190, 32, Vocab.param(i))
  340. @param_window.contents.font.color = @param_window.system_color
  341. @param_window.draw_text(70, y + 28, 190, 32, " => #{@actor.param(i)}")
  342. end
  343. end
  344.  
  345. def refresh_socketing
  346. @socket_window.contents.clear
  347. @socket_window.contents.font.size = 18
  348. if @slot_window.item.nil? || @slot_window.item.manaslots.nil?
  349. @socket_window.draw_text(-16, 0, 280, 32, 'No Incavi', 1)
  350. return
  351. end
  352. @socket_window.draw_icon(@slot_window.item.icon_index, 0, 0)
  353. @socket_window.draw_text(26, 0, @socket_window.width, 32,
  354. @slot_window.item.name + " - Incavi: #{@slot_window.item.manaslots.size}")
  355. @socket_window.draw_text(-20, 44, 280, 32, 'Premi S per rimuovere Gemma.', 2)
  356. if @meter > 0 and @meter < 100
  357. x, y = 78, 34
  358. @socket_window.draw_text(0, 22, 212, 32, 'Incastra:')
  359. @socket_window.contents.fill_rect(x, y, 152, 12, @col[2])
  360. @socket_window.contents.fill_rect(x+1, y+1, 150 *@meter / 100, 5, @col[0])
  361. @socket_window.contents.fill_rect(x+1, y+6, 150 *@meter / 100, 5, @col[1])
  362. elsif @meter > 100
  363. @socket_window.draw_text(0, 22, @socket_window.width, 32, @result)
  364. elsif @meter == 0
  365. @itemslots.item.nil? ? @result = 'Incavo Libero.' : @result = 'Incavo Occupato!'
  366. @socket_window.draw_text(0, 22, @socket_window.width, 32, @result)
  367. end
  368. end
  369.  
  370. def terminate
  371. super
  372. @itemslots.dispose
  373. @manastones.dispose
  374. @socket_window.dispose
  375. @slot_window.dispose
  376. @param_window.dispose
  377. end
  378.  
  379. def update
  380. super
  381. update_selection if Input.trigger?(:C)
  382. update_cancel if Input.trigger?(:B)
  383. update_clear_socket if Input.trigger?(:Y)
  384. start_socketing
  385. update_indexes
  386. end
  387.  
  388. def update_indexes
  389. if @equipp_slot != @slot_window.index
  390. @itemslots.refresh(@slot_window.item)
  391. refresh_socketing
  392. @equipp_slot = @slot_window.index
  393. elsif @slots_index != @itemslots.index and @itemslots.visible
  394. @slots_index = @itemslots.index
  395. refresh_socketing
  396. end
  397. end
  398.  
  399. def start_socketing
  400. return if @soketing.nil?
  401. @meter += 1 ; refresh_socketing
  402. if @meter == 100
  403. r = rand(101)
  404. r <= @manastones.item.socket_chance ? success_socketing : fail_socketing
  405. elsif @meter == 200
  406. @soketing = nil ; @meter = 0 ; @manastones.activate
  407. refresh_socketing
  408. end
  409. end
  410.  
  411. def update_selection
  412. return if @meter > 0 || [email protected]
  413. if [email protected]? || @slot_window.item.nil? ||
  414. @slot_window.item.manaslots.nil?
  415. if !@slot_window.active
  416. Sound.play_buzzer; return
  417. elsif @slot_window.active and @slot_window.item.nil?
  418. Sound.play_buzzer; return
  419. elsif @slot_window.item.manaslots.nil?
  420. Sound.play_buzzer; return
  421. end
  422. end
  423. if @slot_window.active and [email protected]
  424. @itemslots.select(0)
  425. @itemslots.activate
  426. @slot_window.deactivate ; Sound.play_ok
  427. elsif @itemslots.active and [email protected]
  428. @itemslots.deactivate
  429. @manastones.activate ; @manastones.select(0)
  430. Sound.play_ok
  431. elsif @manastones.active and [email protected]?
  432. @manastones.deactivate
  433. RPG::SE.new(FalMana::SoketingSe, 80,).play
  434. @soketing = true
  435. end
  436. end
  437.  
  438. def fail_socketing
  439. FalMana.clear_manastones(@slot_window.item, @actor)
  440. @itemslots.refresh(@slot_window.item)
  441. refresh_param
  442. @result = 'Gemma Distrutta!'
  443. RPG::SE.new(FalMana::SocketFailSe, 80,).play
  444. destroy_manastone
  445. end
  446.  
  447. def success_socketing
  448. FalMana.socket_manastone(@slot_window.item, @itemslots.index,
  449. @manastones.item, @actor)
  450. @itemslots.refresh(@slot_window.item)
  451. refresh_param
  452. @result = 'Gemma Inserita!'
  453. RPG::SE.new(FalMana::SocketSuccessSe, 80,).play
  454. destroy_manastone
  455. end
  456.  
  457. def destroy_manastone
  458. $game_party.lose_item(@manastones.item, 1)
  459. @manastones.refresh
  460. end
  461.  
  462. def update_cancel
  463. return if @meter > 0
  464. Sound.play_cancel
  465. if @slot_window.active
  466. SceneManager.return
  467. elsif @itemslots.active
  468. @slot_window.activate
  469. @itemslots.unselect
  470. @itemslots.deactivate
  471. elsif @manastones.active
  472. @manastones.unselect ; @manastones.deactivate
  473. @itemslots.activate
  474. end
  475. end
  476.  
  477. def update_clear_socket
  478. return if @itemslots.item.nil? || [email protected]
  479. RPG::SE.new(FalMana::ClearSocketSe, 80,).play
  480. FalMana.remove_manastone(@slot_window.item, @itemslots.index,
  481. @itemslots.item, @actor)
  482. @itemslots.refresh(@slot_window.item)
  483. refresh_param
  484. refresh_socketing
  485. end
  486. end
Add Comment
Please, Sign In to add comment