Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.42 KB | None | 0 0
  1. #==============================================================================
  2. # XaiL System - Core
  3. # Author: Nicke
  4. # Created: 07/01/2012
  5. # Edited: 08/10/2013
  6. # Version: 2.1f
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ? Materials but above ? Main. Remember to save.
  12. #
  13. # Core script for XaiL System.
  14. # Caution! This needs to be located before any other XS scripts.
  15. #
  16. # *** Only for RPG Maker VX Ace. ***
  17. #==============================================================================
  18. ($imported ||= {})["XAIL-XS-CORE"] = true
  19.  
  20. module Colors
  21. #--------------------------------------------------------------------------#
  22. # * Colors
  23. #--------------------------------------------------------------------------#
  24. White = Color.new(255,255,255)
  25. LightRed = Color.new(255,150,150)
  26. LightGreen = Color.new(150,255,150)
  27. LightBlue = Color.new(150,150,255)
  28. DarkYellow = Color.new(225,225,20)
  29. Alpha = Color.new(0,0,0,128)
  30. AlphaMenu = 100
  31. end
  32. module XAIL
  33. module CORE
  34. #--------------------------------------------------------------------------#
  35. # * Settings
  36. #--------------------------------------------------------------------------#
  37. # Graphics.resize_screen(width, height )
  38. Graphics.resize_screen(640,480)
  39.  
  40. # FONT DEFAULTS:
  41. Font.default_name = ["VL Gothic"]
  42. Font.default_size = 20
  43. Font.default_bold = false
  44. Font.default_italic = false
  45. Font.default_shadow = true
  46. Font.default_outline = true
  47. Font.default_color = Colors::White
  48. Font.default_out_color = Colors::Alpha
  49.  
  50. # USE_TONE = true/false:
  51. # Window tone for all windows ingame. Default: true.
  52. USE_TONE = false
  53.  
  54. # SAVE
  55. SAVE_MAX = 20 # Default 16.
  56. SAVE_FILE_VIS = 4 # Default 4.
  57.  
  58. # JAPANESE = true/false
  59. JAPANESE = false
  60.  
  61. end
  62. end
  63. # *** Don't edit below unless you know what you are doing. ***
  64. #==============================================================================#
  65. # ** Game_System
  66. #==============================================================================#
  67. class Game_System
  68.  
  69. # // Method to determine japanese game.
  70. def japanese? ; return XAIL::CORE::JAPANESE ; end
  71.  
  72. end
  73. #==============================================================================#
  74. # ** String
  75. #==============================================================================#
  76. class String
  77.  
  78. def to_class(parent = Kernel)
  79. # // Method to convert string to class.
  80. chain = self.split "::"
  81. klass = parent.const_get chain.shift
  82. return chain.size < 1 ? (klass.is_a?(Class) ? klass : nil) : chain.join("::").to_class(klass)
  83. rescue
  84. nil
  85. end
  86.  
  87. def cap_words
  88. # // Method to capitalize every word.
  89. self.split(' ').map {|w| w.capitalize }.join(' ')
  90. end
  91.  
  92. def slice_char(char)
  93. # // Method to slice char.
  94. self.split(char).map {|w| w.sub(char, " ") }.join(" ")
  95. end
  96.  
  97. end
  98. #==============================================================================#
  99. # ** Vocab
  100. #==============================================================================#
  101. class << Vocab
  102.  
  103. def xparam(id)
  104. # // Method to return xparam name.
  105. case id
  106. when 0 ; "Hit Chance"
  107. when 1 ; "Evasion"
  108. when 2 ; "Critical Chance"
  109. when 3 ; "Critical Evasion"
  110. when 4 ; "Magic Evasion"
  111. when 5 ; "Magic Reflection"
  112. when 6 ; "Counter Attack"
  113. when 7 ; "HP Regeneration"
  114. when 8 ; "MP Regeneration"
  115. when 9 ; "TP Regeneration"
  116. end
  117. end
  118.  
  119. end
  120. #==============================================================================
  121. # ** Sound
  122. #==============================================================================
  123. class << Sound
  124.  
  125. def play(name, volume, pitch, type = :se)
  126. # // Method to play a sound. If specified name isn't valid throw an error.
  127. case type
  128. when :se ; RPG::SE.new(name, volume, pitch).play rescue valid?(name)
  129. when :me ; RPG::ME.new(name, volume, pitch).play rescue valid?(name)
  130. when :bgm ; RPG::BGM.new(name, volume, pitch).play rescue valid?(name)
  131. when :bgs ; RPG::BGS.new(name, volume, pitch).play rescue valid?(name)
  132. end
  133. end
  134.  
  135. def valid?(name)
  136. # // Method to raise error if specified sound name is invalid.
  137. msgbox("Error. Unable to find sound file: " + name)
  138. exit
  139. end
  140.  
  141. end
  142. #==============================================================================
  143. # ** DataManager
  144. #==============================================================================
  145. class << DataManager
  146.  
  147. def savefile_max
  148. # // Method override, save file max.
  149. return XAIL::CORE::SAVE_MAX
  150. end
  151.  
  152. end
  153. #==============================================================================
  154. # ** SceneManager
  155. #==============================================================================
  156. class << SceneManager
  157.  
  158. def call_ext(scene_class, args = nil)
  159. # // Method to call a scene with arguments.
  160. @stack.push(@scene)
  161. @scene = scene_class.new(args)
  162. end
  163.  
  164. end
  165. #==============================================================================
  166. # ** Scene_File
  167. #==============================================================================
  168. class Scene_File < Scene_MenuBase
  169.  
  170. def visible_max
  171. # // Method override, visible_max for save files.
  172. return XAIL::CORE::SAVE_FILE_VIS
  173. end
  174.  
  175. end
  176. #==============================================================================
  177. # ** Window_Base
  178. #------------------------------------------------------------------------------
  179. # Importing font fix that will remove weird characters.
  180. # Adding new methods such as new gauge, actor param, font text, icon drawing,
  181. # big icon drawing and a line with a shadow.
  182. #==============================================================================
  183. class Window_Base < Window
  184.  
  185. # // Importing Custom font fix. (Credit Lone Wolf).
  186. alias :process_normal_character_vxa :process_normal_character
  187. def process_normal_character(c, pos)
  188. return unless c >= ' '
  189. process_normal_character_vxa(c, pos)
  190. end unless method_defined? :process_normal_character
  191.  
  192. def draw_text_ex_no_reset(x, y, text)
  193. # // Method to draw ex text without resetting the font.
  194. text = convert_escape_characters(text)
  195. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  196. process_character(text.slice!(0, 1), text, pos) until text.empty?
  197. end
  198.  
  199. alias xail_core_winbase_upt_tone update_tone
  200. def update_tone(*args, &block)
  201. # // Method to change tone of the window.
  202. return unless XAIL::CORE::USE_TONE
  203. xail_core_winbase_upt_tone(*args, &block)
  204. end
  205.  
  206. def draw_gauge_ex(x, y, width, height, rate, color1, color2)
  207. # // Method to draw a gauge.
  208. fill_w = (width * rate).to_i
  209. gauge_y = y + line_height - 8
  210. contents.fill_rect(x, gauge_y, width + 1, height + 1, Color.new(255,255,255,64))
  211. contents.fill_rect(x, gauge_y, width, height, Color.new(0,0,0,100))
  212. contents.gradient_fill_rect(x, gauge_y, fill_w, height, color1, color2)
  213. end
  214.  
  215. def draw_actor_param_gauge(actor, x, y, width, param_id, font, size, bar_color1, bar_color2, txt_color1, txt_color2)
  216. # // Method to draw actor parameters with a gauge.
  217. case param_id
  218. when 2 ; param_rate = actor.param(2) / actor.param_max(2).to_f
  219. when 3 ; param_rate = actor.param(3) / actor.param_max(3).to_f
  220. when 4 ; param_rate = actor.param(4) / actor.param_max(4).to_f
  221. when 5 ; param_rate = actor.param(5) / actor.param_max(5).to_f
  222. when 6 ; param_rate = actor.param(6) / actor.param_max(6).to_f
  223. when 7 ; param_rate = actor.param(7) / actor.param_max(7).to_f
  224. end
  225. contents.font.name = font
  226. contents.font.size = size
  227. contents.font.bold = true
  228. contents.font.shadow = false
  229. draw_gauge_ex(x, y - 14, width, 20, param_rate, bar_color1, bar_color2)
  230. contents.font.color = txt_color1
  231. draw_text(x + 10, y, 120, line_height, Vocab::param(param_id))
  232. contents.font.color = txt_color2
  233. draw_text(x + width - 38, y, 36, line_height, actor.param(param_id), 2)
  234. reset_font_settings
  235. end
  236.  
  237. def draw_actor_xparam_gauge(actor, x, y, width, xparam_id, font, size, bar_color1, bar_color2, txt_color1, txt_color2)
  238. # // Method to draw actor xparameters with a gauge.
  239. case xparam_id
  240. when 0
  241. xparam_rate = actor.xparam(0) / 100.to_f
  242. xparam_name = Vocab.xparam(0)
  243. when 1
  244. xparam_rate = actor.xparam(1) / 100.to_f
  245. xparam_name = Vocab.xparam(1)
  246. when 2
  247. xparam_rate = actor.xparam(2) / 100.to_f
  248. xparam_name = Vocab.xparam(2)
  249. when 3
  250. xparam_rate = actor.xparam(3) / 100.to_f
  251. xparam_name = Vocab.xparam(3)
  252. when 4
  253. xparam_rate = actor.xparam(4) / 100.to_f
  254. xparam_name = Vocab.xparam(4)
  255. when 5
  256. xparam_rate = actor.xparam(5) / 100.to_f
  257. xparam_name = Vocab.xparam(5)
  258. when 6
  259. xparam_rate = actor.xparam(6) / 100.to_f
  260. xparam_name = Vocab.xparam(6)
  261. when 7
  262. xparam_rate = actor.xparam(7) / 100.to_f
  263. xparam_name = Vocab.xparam(7)
  264. when 8
  265. xparam_rate = actor.xparam(8) / 100.to_f
  266. xparam_name = Vocab.xparam(8)
  267. when 9
  268. xparam_rate = actor.xparam(9) / 100.to_f
  269. xparam_name = Vocab.xparam(9)
  270. end
  271. contents.font.name = font
  272. contents.font.size = size
  273. contents.font.bold = true
  274. contents.font.shadow = false
  275. draw_gauge_ex(x, y - 14, width, 20, xparam_rate, bar_color1, bar_color2)
  276. contents.font.color = txt_color1
  277. draw_text(x + 10, y, 120, line_height, xparam_name)
  278. contents.font.color = txt_color2
  279. draw_text(x + width - 38, y, 36, line_height, "#{actor.xparam(xparam_id)}%", 2)
  280. reset_font_settings
  281. end
  282.  
  283. def draw_line_ex(x, y, color, shadow)
  284. # // Method to draw a horizontal line with a shadow.
  285. line_y = y + line_height / 2 - 1
  286. contents.fill_rect(x, line_y, contents_width, 2, color)
  287. line_y += 1
  288. contents.fill_rect(x, line_y, contents_width, 2, shadow)
  289. end
  290.  
  291. def draw_box(x, y, width, height, color, shadow)
  292. # // Method to draw a box with shadow.
  293. contents.fill_rect(x, y, width, height, color)
  294. x += 1
  295. y += 1
  296. contents.fill_rect(x, y, width, height, shadow)
  297. end
  298.  
  299. def draw_vertical_line_ex(x, y, color, shadow)
  300. # // Method to draw a vertical line with a shadow.
  301. line_x = x + line_height / 2 - 1
  302. contents.fill_rect(line_x, y, 2, contents_height, color)
  303. line_x += 1
  304. contents.fill_rect(line_x, y, 2, contents_height, shadow)
  305. end
  306.  
  307. def draw_icons(icons, alignment, x = 0, y = 0, offset_icon = [])
  308. # // Method to draw icons in a horizonal or vertical alignment.
  309. icons.each {|icon|
  310. next if icon.nil?
  311. # // If included in offset do extra spacing.
  312. offset_icon.each {|offset|
  313. if icon == offset
  314. y += line_height * 1 if alignment == :vertical
  315. x += line_height * 1 if alignment == :horizontal
  316. end
  317. }
  318. draw_icon(icon.nil? ? nil : icon, x.nil? ? 0 : x, y.nil? ? 0 : y) rescue nil
  319. y += line_height if alignment == :vertical
  320. x += line_height if alignment == :horizontal
  321. }
  322. end
  323.  
  324. def draw_big_icon(icon, x, y, width, height, opacity = 255)
  325. # // Method to draw a big icon.
  326. bitmap = Cache.system("Iconset")
  327. rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  328. rect2 = Rect.new(x, y, width, height)
  329. contents.stretch_blt(rect2, bitmap, rect, opacity)
  330. end
  331.  
  332. def draw_font_text(text, x, y, width, alignment, font, size, color, bold = true, shadow = true)
  333. # // Method to draw font text.
  334. contents.font.name = font
  335. contents.font.size = size
  336. contents.font.color = color
  337. contents.font.bold = bold
  338. contents.font.shadow = shadow
  339. contents.font.out_color = Color.new(0,0,0,255)
  340. draw_text(x, y, width, calc_line_height(text), text, alignment)
  341. reset_font_settings
  342. end
  343.  
  344. def draw_font_text_ex(text, x, y, font, size, color, bold = true, shadow = true)
  345. # // Method to draw font text ex.
  346. contents.font.name = font
  347. contents.font.size = size
  348. contents.font.color = color
  349. contents.font.bold = bold
  350. contents.font.shadow = shadow
  351. contents.font.out_color = Color.new(0,0,0,255)
  352. text = convert_escape_characters(text)
  353. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  354. process_character(text.slice!(0, 1), text, pos) until text.empty?
  355. reset_font_settings
  356. end
  357.  
  358. end
  359. #==============================================================================#
  360. # ** Window_Selectable
  361. #------------------------------------------------------------------------------
  362. # Adding support for pageleft and pageright for window selectable.
  363. #==============================================================================#
  364. class Window_Selectable < Window_Base
  365.  
  366. def cursor_pageright ; end
  367. def cursor_pageleft ; end
  368.  
  369. alias xail_core_winselect_process_cursor_move process_cursor_move
  370. def process_cursor_move(*args, &block)
  371. # // Method to process cursor movement.
  372. xail_core_winselect_process_cursor_move(*args, &block)
  373. cursor_pageright if !handle?(:pageright) && Input.trigger?(:RIGHT)
  374. cursor_pageright if !handle?(:pageleft) && Input.trigger?(:LEFT)
  375. end
  376.  
  377. alias xail_core_winselect_process_handling process_handling
  378. def process_handling(*args, &block)
  379. # // Method to process handling.
  380. xail_core_winselect_process_handling(*args, &block)
  381. return process_pageright if handle?(:pageright) && Input.trigger?(:RIGHT)
  382. return process_pageleft if handle?(:pageleft) && Input.trigger?(:LEFT)
  383. end
  384.  
  385. def process_pageright
  386. # // Method to process page right.
  387. Sound.play_cursor
  388. Input.update
  389. deactivate
  390. call_handler(:pageright)
  391. end
  392.  
  393. def process_pageleft
  394. # // Method to process page left.
  395. Sound.play_cursor
  396. Input.update
  397. deactivate
  398. call_handler(:pageleft)
  399. end
  400.  
  401. end
  402. #==============================================================================#
  403. # ** Window_Icon
  404. #------------------------------------------------------------------------------
  405. # New Window :: Window_Icon - A window for drawing icon(s).
  406. #==============================================================================#
  407. class Window_Icon < Window_Base
  408.  
  409. attr_accessor :enabled
  410. attr_accessor :alignment
  411.  
  412. def initialize(x, y, window_width, hsize)
  413. # // Method to initialize the icon window.
  414. super(0, 0, window_width, window_height(hsize))
  415. @icons = []
  416. @index = 0
  417. @enabled = true
  418. @alignment = 0
  419. refresh
  420. end
  421.  
  422. def window_height(hsize)
  423. # // Method to return the height.
  424. fitting_height(hsize)
  425. end
  426.  
  427. def refresh
  428. # // Method to refresh the icon window.
  429. contents.clear
  430. end
  431.  
  432. def draw_cmd_icons(icons, index)
  433. # // Draw all of the icons.
  434. return if !@enabled
  435. count = 0
  436. for i in icons
  437. align = 0
  438. x = 110
  439. next if i[index].nil?
  440. case @alignment
  441. when 1, 2 ; align = -110
  442. end
  443. draw_icon(i[index], x + align, 24 * count)
  444. count += 1
  445. break if (24 * count > height - 24)
  446. end
  447. end
  448.  
  449. end
  450. #==============================================================================
  451. # ** Game_Party
  452. #------------------------------------------------------------------------------
  453. # Adding check item method to return a item based on the type.
  454. #==============================================================================
  455. class Game_Party < Game_Unit
  456.  
  457. def check_item?(item, type)
  458. # // Method to return a item based on the type.
  459. case type
  460. when :items ; $data_items[item]
  461. when :weapons ; $data_weapons[item]
  462. when :armors ; $data_armors[item]
  463. when :gold ; item
  464. when :exp ; item
  465. end
  466. end
  467.  
  468. end
  469. #==============================================================================
  470. # ** Game_Event
  471. #------------------------------------------------------------------------------
  472. # Adding methods to check for comments on events.
  473. #==============================================================================
  474. class Game_Event < Game_Character
  475.  
  476. def comment?(comment)
  477. # // Method to check if comment is included in event.
  478. unless empty? or @list.nil?
  479. for evt in @list
  480. if evt.code == 108 or evt.code == 408
  481. if evt.parameters[0].include?(comment)
  482. return true
  483. end
  484. end
  485. end
  486. end
  487. return false
  488. end
  489.  
  490. def comment_int?(comment)
  491. # // Method to check for a integer in event.
  492. unless empty? or @list.nil?
  493. for evt in @list
  494. if evt.code == 108 or evt.code == 408
  495. if evt.parameters[0] =~ /<#{comment}:[ ]?(\d*)>?/
  496. return ($1.to_i > 0 ? $1.to_i : 0)
  497. end
  498. end
  499. end
  500. end
  501. end
  502.  
  503. def comment_string?(comment)
  504. # // Method to check for a string in event.
  505. unless empty? or @list.nil?
  506. for evt in @list
  507. if evt.code == 108 or evt.code == 408
  508. if evt.parameters[0] =~ /<#{comment}:[ ]?(\w*)>?/
  509. return $1.to_s
  510. end
  511. end
  512. end
  513. end
  514. end
  515.  
  516.  
  517. end # END OF FILE
  518.  
  519. #=*==========================================================================*=#
  520. # ** END OF FILE
  521. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement