pigu_6

VE Basic Module

Nov 20th, 2012
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.72 KB | None | 0 0
  1. #==============================================================================
  2. # ** Victor Engine - Basic Module
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. # v 1.00 - 2011.12.19 > First relase
  8. # v 1.01 - 2011.12.21 > Added Event Troop notes
  9. # v 1.02 - 2011.12.22 > Added character frames value
  10. # v 1.03 - 2011.12.30 > Added Actor and Enemy notes
  11. # v 1.04 - 2012.01.01 > Added party average level and map actors
  12. # v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
  13. # v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
  14. # > Added new Sprite Character functions
  15. # v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
  16. # v 1.08 - 2012.01.13 > Compatibility with Trait Control
  17. # v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
  18. # v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
  19. # v 1.11 - 2012.01.26 > Compatibility with Followers Options
  20. # Compatibility with Animated Battle beta
  21. # v 1.12 - 2012.02.08 > Compatibility with Animated Battle
  22. # v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
  23. # v 1.14 - 2012.03.11 > Better version handling and required messages
  24. # v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
  25. # v 1.16 - 2012.03.21 > Compatibility with Follower Control
  26. # v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
  27. # v 1.18 - 2012.03.22 > Added Battler Types tag support
  28. # v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
  29. # v 1.20 - 2012.05.21 > Fix for older RMVXa versions
  30. # v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
  31. # v 1.22 - 2012.07.02 > Compatibility with Terrain States
  32. # v 1.23 - 2012.07.03 > Fix for Pixel Movement
  33. # v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
  34. # v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
  35. # v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
  36. # v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
  37. # v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
  38. #------------------------------------------------------------------------------
  39. # This is the basic script for the system from Victory Engine and is
  40. # required to use the scripts from the engine. This script offer some new
  41. # functions to be used within many scripts of the engine.
  42. #------------------------------------------------------------------------------
  43. # Compatibility
  44. # Required for the Victor Engine
  45. #
  46. # * Overwrite methods
  47. # class << Cache
  48. # def self.character(filename)
  49. #
  50. # class Sprite_Character < Sprite_Base
  51. # def set_character_bitmap
  52. #
  53. # * Alias methods
  54. # class Game_Interpreter
  55. # def command_108
  56. #
  57. # class Window_Base < Window
  58. # def convert_escape_characters(text)
  59. #
  60. #------------------------------------------------------------------------------
  61. # Instructions:
  62. # To instal the script, open you script editor and paste this script on
  63. # a new section bellow the Materials section.
  64. #
  65. #------------------------------------------------------------------------------
  66. # New functions
  67. #
  68. # * Random number between two vales
  69. # rand_between(min, max)
  70. # min : min value
  71. # max : max value
  72. # Can be called from any class, this method return an random value between
  73. # two specific numbers
  74. #
  75. # * Random array value
  76. # <Array>.random
  77. # <Array>.random!
  78. # Returns a random object from the array, the method .random! is destructive,
  79. # removing the value returned from the array.
  80. #
  81. # * Sum of the numeric values of a array
  82. # <Array>.sum
  83. # Returns the sum of all numeric values
  84. #
  85. # * Average of all numeric values from the array
  86. # <Array>.average(float = false)
  87. # float : float flag
  88. # Returns the average of all numeric values, if floa is true, the value
  89. # returned is a float, otherwise it's a integer.
  90. #
  91. # * Note for events
  92. # <Event>.note
  93. # By default, events doesn't have note boxes. This command allows to use
  94. # comments as note boxes, following the same format as the ones on the
  95. # database. Returns all comments on the active page of the event.
  96. #
  97. # * Comment calls
  98. # <Event>.comment_call
  99. # Another function for comment boxes, by default, they have absolutely no
  100. # effect in game when called. But this method allows to make the comment
  101. # box to behave like an script call, but with the versatility of the
  102. # note boxes. Remember that the commands will only take effect if there
  103. # is scripts to respond to the comment code.
  104. #
  105. #==============================================================================
  106.  
  107. #==============================================================================
  108. # ** Victor Engine
  109. #------------------------------------------------------------------------------
  110. # Setting module for the Victor Engine
  111. #==============================================================================
  112.  
  113. module Victor_Engine
  114. #--------------------------------------------------------------------------
  115. # * New method: required_script
  116. #--------------------------------------------------------------------------
  117. def self.required_script(name, req, version, type = 0)
  118. if type != :bellow && (!$imported[req] || $imported[req] < version)
  119. msg = "The script '%s' requires the script\n"
  120. case type
  121. when :above
  122. msg += "'%s' v%s or higher above it to work properly\n"
  123. else
  124. msg += "'%s' v%s or higher to work properly\n"
  125. end
  126. msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  127. self.exit_message(msg, name, req, version)
  128. elsif type == :bellow && $imported[req]
  129. msg = "The script '%s' requires the script\n"
  130. msg += "'%s' to be put bellow it\n"
  131. msg += "move the scripts to the proper position"
  132. self.exit_message(msg, name, req, version)
  133. end
  134. end
  135. #--------------------------------------------------------------------------
  136. # * New method: exit_message
  137. #--------------------------------------------------------------------------
  138. def self.exit_message(message, name, req, version)
  139. name = self.script_name(name)
  140. req = self.script_name(req)
  141. msgbox(sprintf(message, name, req, version))
  142. exit
  143. end
  144. #--------------------------------------------------------------------------
  145. # * New method: script_name
  146. #--------------------------------------------------------------------------
  147. def self.script_name(name, ext = "VE")
  148. name = name.to_s.gsub("_", " ").upcase.split
  149. name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  150. name.join(" ")
  151. end
  152. end
  153.  
  154. $imported ||= {}
  155. $imported[:ve_basic_module] = 1.28
  156.  
  157. #==============================================================================
  158. # ** Object
  159. #------------------------------------------------------------------------------
  160. # This class is the superclass of all other classes.
  161. #==============================================================================
  162.  
  163. class Object
  164. #--------------------------------------------------------------------------
  165. # * Include setting module
  166. #--------------------------------------------------------------------------
  167. include Victor_Engine
  168. #-------------------------------------------------------------------------
  169. # * New method: rand_between
  170. #-------------------------------------------------------------------------
  171. def rand_between(min, max)
  172. min + rand(max - min + 1)
  173. end
  174. #--------------------------------------------------------------------------
  175. # * New method: numeric?
  176. #--------------------------------------------------------------------------
  177. def numeric?
  178. return false
  179. end
  180. #--------------------------------------------------------------------------
  181. # * New method: string?
  182. #--------------------------------------------------------------------------
  183. def string?
  184. return false
  185. end
  186. #--------------------------------------------------------------------------
  187. # * New method: array?
  188. #--------------------------------------------------------------------------
  189. def array?
  190. return false
  191. end
  192. #--------------------------------------------------------------------------
  193. # * New method: float?
  194. #--------------------------------------------------------------------------
  195. def float?
  196. return false
  197. end
  198. #--------------------------------------------------------------------------
  199. # * New method: item?
  200. #--------------------------------------------------------------------------
  201. def item?
  202. return false
  203. end
  204. #--------------------------------------------------------------------------
  205. # * New method: skill?
  206. #--------------------------------------------------------------------------
  207. def skill?
  208. return false
  209. end
  210. #--------------------------------------------------------------------------
  211. # * New method: file_exist?
  212. #--------------------------------------------------------------------------
  213. def file_exist?(path, filename)
  214. $file_list ||= {}
  215. $file_list[path + filename] ||= file_test(path, filename)
  216. $file_list[path + filename]
  217. end
  218. #--------------------------------------------------------------------------
  219. # * New method: get_file_list
  220. #--------------------------------------------------------------------------
  221. def file_test(path, filename)
  222. bitmap = Cache.load_bitmap(path, filename) rescue nil
  223. bitmap ? true : false
  224. end
  225. #--------------------------------------------------------------------------
  226. # * New method: character_exist?
  227. #--------------------------------------------------------------------------
  228. def character_exist?(filename)
  229. file_exist?("Graphics/Characters/", filename)
  230. end
  231. #--------------------------------------------------------------------------
  232. # * New method: battler_exist?
  233. #--------------------------------------------------------------------------
  234. def battler_exist?(filename)
  235. file_exist?("Graphics/Battlers/", filename)
  236. end
  237. #--------------------------------------------------------------------------
  238. # * New method: get_filename
  239. #--------------------------------------------------------------------------
  240. def get_filename
  241. "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
  242. end
  243. #--------------------------------------------------------------------------
  244. # * New method: get_all_values
  245. #--------------------------------------------------------------------------
  246. def get_all_values(value1, value2 = nil)
  247. value2 = value1 unless value2
  248. /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
  249. end
  250. #--------------------------------------------------------------------------
  251. # * New method: make_symbol
  252. #--------------------------------------------------------------------------
  253. def make_symbol(string)
  254. string.downcase.gsub(" ", "_").to_sym
  255. end
  256. #--------------------------------------------------------------------------
  257. # * New method: make_string
  258. #--------------------------------------------------------------------------
  259. def make_string(symbol)
  260. symbol.to_s.gsub("_", " ").upcase
  261. end
  262. #--------------------------------------------------------------------------
  263. # * New method: returing_value
  264. #--------------------------------------------------------------------------
  265. def returing_value(i, x)
  266. i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
  267. end
  268. #--------------------------------------------------------------------------
  269. # New method: in_rect?
  270. #--------------------------------------------------------------------------
  271. def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
  272. aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  273. bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
  274. end
  275. #--------------------------------------------------------------------------
  276. # New method: in_radius?
  277. #--------------------------------------------------------------------------
  278. def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
  279. aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  280. ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
  281. end
  282. #--------------------------------------------------------------------------
  283. # New method: setup_area
  284. #--------------------------------------------------------------------------
  285. def setup_area(w, h, x1, y1, x2, y2, fx)
  286. aw = w
  287. ah = h * aw
  288. ax = x1
  289. ay = y1
  290. bx = x2
  291. by = y2
  292. bx += fx / 4 if ax > bx
  293. bx -= fx / 4 if ax < bx
  294. [aw, ah, ax, ay, bx, by]
  295. end
  296. end
  297.  
  298. #==============================================================================
  299. # ** String
  300. #------------------------------------------------------------------------------
  301. # The string class. Can handle character sequences of arbitrary lengths.
  302. #==============================================================================
  303.  
  304. class String
  305. #--------------------------------------------------------------------------
  306. # * New method: string?
  307. #--------------------------------------------------------------------------
  308. def string?
  309. return true
  310. end
  311. end
  312.  
  313. #==============================================================================
  314. # ** Numeric
  315. #------------------------------------------------------------------------------
  316. # This is the abstract class for numbers.
  317. #==============================================================================
  318.  
  319. class Numeric
  320. #--------------------------------------------------------------------------
  321. # * New method: numeric?
  322. #--------------------------------------------------------------------------
  323. def numeric?
  324. return true
  325. end
  326. #--------------------------------------------------------------------------
  327. # * New method: ceil?
  328. #--------------------------------------------------------------------------
  329. def ceil?
  330. return false
  331. end
  332. end
  333.  
  334. #==============================================================================
  335. # ** Float
  336. #------------------------------------------------------------------------------
  337. # This is the abstract class for the floating point values.
  338. #==============================================================================
  339.  
  340. class Float
  341. #--------------------------------------------------------------------------
  342. # * New method: float?
  343. #--------------------------------------------------------------------------
  344. def float?
  345. return true
  346. end
  347. #--------------------------------------------------------------------------
  348. # * New method: ceil?
  349. #--------------------------------------------------------------------------
  350. def ceil?
  351. self != self.ceil
  352. end
  353. end
  354.  
  355. #==============================================================================
  356. # ** Array
  357. #------------------------------------------------------------------------------
  358. # This class store arbitrary Ruby objects.
  359. #==============================================================================
  360.  
  361. class Array
  362. #--------------------------------------------------------------------------
  363. # * New method: array?
  364. #--------------------------------------------------------------------------
  365. def array?
  366. return true
  367. end
  368. #-------------------------------------------------------------------------
  369. # * New method: random
  370. #-------------------------------------------------------------------------
  371. def random
  372. self[rand(size)]
  373. end
  374. #-------------------------------------------------------------------------
  375. # * New method: random!
  376. #-------------------------------------------------------------------------
  377. def random!
  378. self.delete_at(rand(size))
  379. end
  380. #---------------------------------------------------------------------------
  381. # * New method: sum
  382. #---------------------------------------------------------------------------
  383. def sum
  384. self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
  385. end
  386. #---------------------------------------------------------------------------
  387. # * New method: average
  388. #---------------------------------------------------------------------------
  389. def average(float = false)
  390. self.sum / [(float ? size.to_f : size.to_i), 1].max
  391. end
  392. #---------------------------------------------------------------------------
  393. # * New method: next_item
  394. #---------------------------------------------------------------------------
  395. def next_item
  396. item = self.shift
  397. self.push(item)
  398. item
  399. end
  400. #---------------------------------------------------------------------------
  401. # * New method: previous_item
  402. #---------------------------------------------------------------------------
  403. def previous_item
  404. item = self.pop
  405. self.unshift(item)
  406. item
  407. end
  408. end
  409.  
  410. #==============================================================================
  411. # ** RPG::Troop::Page
  412. #------------------------------------------------------------------------------
  413. # This is the data class for battle events (pages).
  414. #==============================================================================
  415.  
  416. class RPG::Troop::Page
  417. #--------------------------------------------------------------------------
  418. # * New method: note
  419. #--------------------------------------------------------------------------
  420. def note
  421. return "" if !@list || @list.size <= 0
  422. comment_list = []
  423. @list.each do |item|
  424. next unless item && (item.code == 108 || item.code == 408)
  425. comment_list.push(item.parameters[0])
  426. end
  427. comment_list.join("\r\n")
  428. end
  429. end
  430.  
  431. #==============================================================================
  432. # ** RPG::UsableItem
  433. #------------------------------------------------------------------------------
  434. # This is the superclass for skills and items.
  435. #==============================================================================
  436.  
  437. class RPG::UsableItem < RPG::BaseItem
  438. #--------------------------------------------------------------------------
  439. # * New method: for_all_targets?
  440. #--------------------------------------------------------------------------
  441. def for_all_targets?
  442. return false
  443. end
  444. end
  445.  
  446. #==============================================================================
  447. # ** RPG::Skill
  448. #------------------------------------------------------------------------------
  449. # This is the data class for skills.
  450. #==============================================================================
  451.  
  452. class RPG::Skill < RPG::UsableItem
  453. #--------------------------------------------------------------------------
  454. # * New method: item?
  455. #--------------------------------------------------------------------------
  456. def item?
  457. return false
  458. end
  459. #--------------------------------------------------------------------------
  460. # * New method: skill?
  461. #--------------------------------------------------------------------------
  462. def skill?
  463. return true
  464. end
  465. #--------------------------------------------------------------------------
  466. # * New method: type_set
  467. #--------------------------------------------------------------------------
  468. def type_set
  469. [stype_id]
  470. end
  471. end
  472.  
  473. #==============================================================================
  474. # ** RPG::Item
  475. #------------------------------------------------------------------------------
  476. # This is the data class for items.
  477. #==============================================================================
  478.  
  479. class RPG::Item < RPG::UsableItem
  480. #--------------------------------------------------------------------------
  481. # * New method: item?
  482. #--------------------------------------------------------------------------
  483. def item?
  484. return true
  485. end
  486. #--------------------------------------------------------------------------
  487. # * New method: skill?
  488. #--------------------------------------------------------------------------
  489. def skill?
  490. return false
  491. end
  492. #--------------------------------------------------------------------------
  493. # * New method: type_set
  494. #--------------------------------------------------------------------------
  495. def type_set
  496. [itype_id]
  497. end
  498. end
  499.  
  500. #==============================================================================
  501. # ** Cache
  502. #------------------------------------------------------------------------------
  503. # This module loads each of graphics, creates a Bitmap object, and retains it.
  504. # To speed up load times and conserve memory, this module holds the created
  505. # Bitmap object in the internal hash, allowing the program to return
  506. # preexisting objects when the same bitmap is requested again.
  507. #==============================================================================
  508.  
  509. class << Cache
  510. #--------------------------------------------------------------------------
  511. # * Overwrite method: character
  512. #--------------------------------------------------------------------------
  513. def character(filename, hue = 0)
  514. load_bitmap("Graphics/Characters/", filename, hue)
  515. end
  516. #--------------------------------------------------------------------------
  517. # * New method: cache
  518. #--------------------------------------------------------------------------
  519. def cache
  520. @cache
  521. end
  522. end
  523.  
  524. #==============================================================================
  525. # ** Game_BattlerBase
  526. #------------------------------------------------------------------------------
  527. # This class handles battlers. It's used as a superclass of the Game_Battler
  528. # classes.
  529. #==============================================================================
  530.  
  531. class Game_BattlerBase
  532. #--------------------------------------------------------------------------
  533. # * Public Instance Variables
  534. #--------------------------------------------------------------------------
  535. attr_reader :buffs
  536. #--------------------------------------------------------------------------
  537. # * New method: get_cond
  538. #--------------------------------------------------------------------------
  539. def get_cond(text)
  540. case text.upcase
  541. when "HIGHER" then ">"
  542. when "LOWER" then "<"
  543. when "EQUAL" then "=="
  544. when "DIFFERENT" then "!="
  545. else "!="
  546. end
  547. end
  548. #--------------------------------------------------------------------------
  549. # * New method: get_param
  550. #--------------------------------------------------------------------------
  551. def get_param(text)
  552. case text.upcase
  553. when "MAXHP" then self.mhp
  554. when "MAXMP" then self.mmp
  555. when "MAXTP" then self.max_tp
  556. else eval("self.#{text.downcase}")
  557. end
  558. end
  559. #--------------------------------------------------------------------------
  560. # * New method: get_param_id
  561. #--------------------------------------------------------------------------
  562. def get_param_id(text)
  563. case text.upcase
  564. when "MAXHP", "HP" then 0
  565. when "MAXMP", "MP" then 1
  566. when "ATK" then 2
  567. when "DEF" then 3
  568. when "MAT" then 4
  569. when "MDF" then 5
  570. when "AGI" then 6
  571. when "LUK" then 7
  572. end
  573. end
  574. #--------------------------------------------------------------------------
  575. # * New method: type
  576. #--------------------------------------------------------------------------
  577. def type
  578. list = []
  579. get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
  580. $1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
  581. end
  582. list.uniq
  583. end
  584. #--------------------------------------------------------------------------
  585. # * New method: danger?
  586. #--------------------------------------------------------------------------
  587. def danger?
  588. hp < mhp * 25 / 100
  589. end
  590. #--------------------------------------------------------------------------
  591. # * New method: sprite
  592. #--------------------------------------------------------------------------
  593. def sprite
  594. valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
  595. valid ? SceneManager.scene.spriteset.sprite(self) : nil
  596. end
  597. #--------------------------------------------------------------------------
  598. # * New method:
  599. #--------------------------------------------------------------------------
  600. def element_set(item)
  601. element_set = [item.damage.element_id]
  602. element_set += atk_elements if item.damage.element_id < 0
  603. element_set.compact
  604. end
  605. #--------------------------------------------------------------------------
  606. # * New method: add_state_normal
  607. #--------------------------------------------------------------------------
  608. def add_state_normal(state_id, rate = 1, user = self)
  609. chance = rate
  610. chance *= state_rate(state_id)
  611. chance *= luk_effect_rate(user)
  612. add_state(state_id) if rand < state_rate(state_id)
  613. end
  614. #--------------------------------------------------------------------------
  615. # * New method: damaged?
  616. #--------------------------------------------------------------------------
  617. def damaged?
  618. @result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
  619. end
  620. #--------------------------------------------------------------------------
  621. # * New method: mtp
  622. #--------------------------------------------------------------------------
  623. def mtp
  624. return 100
  625. end
  626. end
  627.  
  628. #==============================================================================
  629. # ** Game_Battler
  630. #------------------------------------------------------------------------------
  631. # This class deals with battlers. It's used as a superclass of the Game_Actor
  632. # and Game_Enemy classes.
  633. #==============================================================================
  634.  
  635. class Game_Battler < Game_BattlerBase
  636. #--------------------------------------------------------------------------
  637. # * New method: cri_rate
  638. #--------------------------------------------------------------------------
  639. def cri_rate(user, item)
  640. user.cri
  641. end
  642. #--------------------------------------------------------------------------
  643. # * New method: cri_eva
  644. #--------------------------------------------------------------------------
  645. def cri_eva(user, item)
  646. cev
  647. end
  648. #--------------------------------------------------------------------------
  649. # * New method: setup_critical
  650. #--------------------------------------------------------------------------
  651. def setup_critical(user, item)
  652. cri_rate(user, item) * (1 - cri_eva(user, item))
  653. end
  654. end
  655.  
  656. #==============================================================================
  657. # ** Game_Enemy
  658. #------------------------------------------------------------------------------
  659. # This class handles enemy characters. It's used within the Game_Troop class
  660. # ($game_troop).
  661. #==============================================================================
  662.  
  663. class Game_Enemy < Game_Battler
  664. #--------------------------------------------------------------------------
  665. # * New method: note
  666. #--------------------------------------------------------------------------
  667. def note
  668. enemy ? enemy.note : ""
  669. end
  670. #--------------------------------------------------------------------------
  671. # * New method: get_all_notes
  672. #--------------------------------------------------------------------------
  673. def get_all_notes(*args)
  674. notes = ""
  675. notes += note if !args.include?(:self)
  676. states.compact.each {|state| notes += state.note } if !args.include?(:state)
  677. notes
  678. end
  679. #--------------------------------------------------------------------------
  680. # * New method: get_all_objects
  681. #--------------------------------------------------------------------------
  682. def get_all_objects(*args)
  683. result = []
  684. result += [self] if !args.include?(:self)
  685. result += states.compact if !args.include?(:state)
  686. result
  687. end
  688. #--------------------------------------------------------------------------
  689. # * New method: level
  690. #--------------------------------------------------------------------------
  691. def level
  692. return 1
  693. end
  694. #--------------------------------------------------------------------------
  695. # * New method: skill_learn?
  696. #--------------------------------------------------------------------------
  697. def skill_learn?(skill)
  698. skill.skill? && skills.include?(skill)
  699. end
  700. #--------------------------------------------------------------------------
  701. # * New method: skills
  702. #--------------------------------------------------------------------------
  703. def skills
  704. enemy.actions.collect {|action| $data_skills[action.skill_id] }
  705. end
  706. end
  707.  
  708. #==============================================================================
  709. # ** Game_Actor
  710. #------------------------------------------------------------------------------
  711. # This class handles actors. It's used within the Game_Actors class
  712. # ($game_actors) and referenced by the Game_Party class ($game_party).
  713. #==============================================================================
  714.  
  715. class Game_Actor < Game_Battler
  716. #--------------------------------------------------------------------------
  717. # * New method: note
  718. #--------------------------------------------------------------------------
  719. def note
  720. actor ? actor.note : ""
  721. end
  722. #--------------------------------------------------------------------------
  723. # * New method: hue
  724. #--------------------------------------------------------------------------
  725. def hue
  726. @hue ? @hue : 0
  727. end
  728. #--------------------------------------------------------------------------
  729. # * New method: get_all_notes
  730. #--------------------------------------------------------------------------
  731. def get_all_notes(*args)
  732. notes = ""
  733. notes += note if !args.include?(:self)
  734. notes += self.class.note if !args.include?(:class)
  735. equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
  736. states.compact.each {|state| notes += state.note } if !args.include?(:state)
  737. notes
  738. end
  739. #--------------------------------------------------------------------------
  740. # * New method: get_all_objects
  741. #--------------------------------------------------------------------------
  742. def get_all_objects(*args)
  743. result = []
  744. result += [self] if !args.include?(:self)
  745. result += [self.class] if !args.include?(:self)
  746. result += equips.compact if !args.include?(:equip)
  747. result += states.compact if !args.include?(:state)
  748. result
  749. end
  750. #--------------------------------------------------------------------------
  751. # * New method: in_active_party?
  752. #--------------------------------------------------------------------------
  753. def in_active_party?
  754. $game_party.battle_members.include?(self)
  755. end
  756. #--------------------------------------------------------------------------
  757. # * New method: in_reserve_party?
  758. #--------------------------------------------------------------------------
  759. def in_reserve_party?
  760. $game_party.reserve_members.include?(self)
  761. end
  762. #--------------------------------------------------------------------------
  763. # * New method: in_party?
  764. #--------------------------------------------------------------------------
  765. def in_party?
  766. $game_party.all_members.include?(self)
  767. end
  768. #--------------------------------------------------------------------------
  769. # * New method: map_animation
  770. #--------------------------------------------------------------------------
  771. def map_animation(id)
  772. $game_map.actors.each do |member|
  773. member.animation_id = id if member.actor == self
  774. end
  775. end
  776. #--------------------------------------------------------------------------
  777. # * New method: on_damage_floor
  778. #--------------------------------------------------------------------------
  779. def on_damage_floor?
  780. $game_player.on_damage_floor?
  781. end
  782. end
  783.  
  784. #==============================================================================
  785. # ** Game_Unit
  786. #------------------------------------------------------------------------------
  787. # This class handles units. It's used as a superclass of the Game_Party and
  788. # Game_Troop classes.
  789. #==============================================================================
  790.  
  791. class Game_Unit
  792. #--------------------------------------------------------------------------
  793. # * New method: refresh
  794. #--------------------------------------------------------------------------
  795. def refresh
  796. members.each {|member| member.refresh }
  797. end
  798. end
  799.  
  800. #==============================================================================
  801. # ** Game_Party
  802. #------------------------------------------------------------------------------
  803. # This class handles the party. It includes information on amount of gold
  804. # and items. The instance of this class is referenced by $game_party.
  805. #==============================================================================
  806.  
  807. class Game_Party < Game_Unit
  808. #--------------------------------------------------------------------------
  809. # * New method: average_level
  810. #--------------------------------------------------------------------------
  811. def average_level
  812. battle_members.collect {|actor| actor.level }.average
  813. end
  814. #--------------------------------------------------------------------------
  815. # * New method: reserve_members
  816. #--------------------------------------------------------------------------
  817. def reserve_members
  818. all_members - battle_members
  819. end
  820. end
  821.  
  822. #==============================================================================
  823. # ** Game_Map
  824. #------------------------------------------------------------------------------
  825. # This class handles maps. It includes scrolling and passage determination
  826. # functions. The instance of this class is referenced by $game_map.
  827. #==============================================================================
  828.  
  829. class Game_Map
  830. #--------------------------------------------------------------------------
  831. # * New method: event_list
  832. #--------------------------------------------------------------------------
  833. def event_list
  834. events.values
  835. end
  836. #--------------------------------------------------------------------------
  837. # * New method: note
  838. #--------------------------------------------------------------------------
  839. def note
  840. @map ? @map.note : ""
  841. end
  842. #--------------------------------------------------------------------------
  843. # * New method: vehicles
  844. #--------------------------------------------------------------------------
  845. def vehicles
  846. @vehicles
  847. end
  848. #--------------------------------------------------------------------------
  849. # * New method: map_events
  850. #--------------------------------------------------------------------------
  851. def map_events
  852. @map.events
  853. end
  854. #--------------------------------------------------------------------------
  855. # * New method: actors
  856. #--------------------------------------------------------------------------
  857. def actors
  858. [$game_player] + $game_player.followers.visible_followers
  859. end
  860. end
  861.  
  862. #==============================================================================
  863. # ** Game_CharacterBase
  864. #------------------------------------------------------------------------------
  865. # This class deals with characters. Common to all characters, stores basic
  866. # data, such as coordinates and graphics. It's used as a superclass of the
  867. # Game_Character class.
  868. #==============================================================================
  869.  
  870. class Game_CharacterBase
  871. #--------------------------------------------------------------------------
  872. # * Public Instance Variables
  873. #--------------------------------------------------------------------------
  874. attr_accessor :move_speed
  875. attr_accessor :move_frequency
  876. #--------------------------------------------------------------------------
  877. # * New method: player?
  878. #--------------------------------------------------------------------------
  879. def player?
  880. return false
  881. end
  882. #--------------------------------------------------------------------------
  883. # * New method: event?
  884. #--------------------------------------------------------------------------
  885. def event?
  886. return false
  887. end
  888. #--------------------------------------------------------------------------
  889. # * New method: follower?
  890. #--------------------------------------------------------------------------
  891. def follower?
  892. return false
  893. end
  894. #--------------------------------------------------------------------------
  895. # * New method: vehicle?
  896. #--------------------------------------------------------------------------
  897. def vehicle?
  898. return false
  899. end
  900. #--------------------------------------------------------------------------
  901. # * New method: frames
  902. #--------------------------------------------------------------------------
  903. def frames
  904. return 3
  905. end
  906. #--------------------------------------------------------------------------
  907. # * New method: hue
  908. #--------------------------------------------------------------------------
  909. def hue
  910. @hue ? @hue : 0
  911. end
  912. end
  913.  
  914. #==============================================================================
  915. # ** Game_Character
  916. #------------------------------------------------------------------------------
  917. # This class deals with characters. It's used as a superclass of the
  918. # Game_Player and Game_Event classes.
  919. #==============================================================================
  920.  
  921. class Game_Character < Game_CharacterBase
  922. #--------------------------------------------------------------------------
  923. # * New method: move_toward_position
  924. #--------------------------------------------------------------------------
  925. def move_toward_position(x, y)
  926. sx = distance_x_from(x)
  927. sy = distance_y_from(y)
  928. if sx.abs > sy.abs
  929. move_straight(sx > 0 ? 4 : 6)
  930. move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  931. elsif sy != 0
  932. move_straight(sy > 0 ? 8 : 2)
  933. move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  934. end
  935. end
  936. #--------------------------------------------------------------------------
  937. # * New method: move_toward_position
  938. #--------------------------------------------------------------------------
  939. def turn_toward_position(x, y)
  940. sx = distance_x_from(x)
  941. sy = distance_y_from(y)
  942. if sx.abs > sy.abs
  943. set_direction(sx > 0 ? 4 : 6)
  944. elsif sy != 0
  945. set_direction(sy > 0 ? 8 : 2)
  946. end
  947. end
  948. end
  949.  
  950. #==============================================================================
  951. # ** Game_Player
  952. #------------------------------------------------------------------------------
  953. # This class handles the player.
  954. # The instance of this class is referenced by $game_map.
  955. #==============================================================================
  956.  
  957. class Game_Player < Game_Character
  958. #--------------------------------------------------------------------------
  959. # * New method: player?
  960. #--------------------------------------------------------------------------
  961. def player?
  962. return true
  963. end
  964. #--------------------------------------------------------------------------
  965. # * New method: perform_transfer
  966. #--------------------------------------------------------------------------
  967. def new_map_id
  968. @new_map_id
  969. end
  970. #--------------------------------------------------------------------------
  971. # * New method: hue
  972. #--------------------------------------------------------------------------
  973. def hue
  974. actor ? actor.hue : 0
  975. end
  976. end
  977.  
  978. #==============================================================================
  979. # ** Game_Follower
  980. #------------------------------------------------------------------------------
  981. # This class handles the followers. Followers are the actors of the party
  982. # that follows the leader in a line. It's used within the Game_Followers class.
  983. #==============================================================================
  984.  
  985. class Game_Follower < Game_Character
  986. #--------------------------------------------------------------------------
  987. # * New method: follower?
  988. #--------------------------------------------------------------------------
  989. def follower?
  990. return true
  991. end
  992. #--------------------------------------------------------------------------
  993. # * New method: index
  994. #--------------------------------------------------------------------------
  995. def index
  996. @member_index
  997. end
  998. #--------------------------------------------------------------------------
  999. # * New method: gathering?
  1000. #--------------------------------------------------------------------------
  1001. def gathering?
  1002. $game_player.followers.gathering? && !gather?
  1003. end
  1004. end
  1005.  
  1006. #==============================================================================
  1007. # ** Game_Followers
  1008. #------------------------------------------------------------------------------
  1009. # This class handles the followers. It's a wrapper for the built-in class
  1010. # "Array." It's used within the Game_Player class.
  1011. #==============================================================================
  1012.  
  1013. class Game_Followers
  1014. #--------------------------------------------------------------------------
  1015. # * New method: get_actor
  1016. #--------------------------------------------------------------------------
  1017. def get_actor(id)
  1018. list = [$game_player] + visible_followers
  1019. list.select {|follower| follower.actor && follower.actor.id == id }.first
  1020. end
  1021. #--------------------------------------------------------------------------
  1022. # * Method fix: visble_folloers
  1023. #--------------------------------------------------------------------------
  1024. unless method_defined?(:visible_followers)
  1025. def visible_followers; visible_folloers; end
  1026. end
  1027. end
  1028.  
  1029. #==============================================================================
  1030. # ** Game_Vehicle
  1031. #------------------------------------------------------------------------------
  1032. # This class handles vehicles. It's used within the Game_Map class. If there
  1033. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  1034. #==============================================================================
  1035.  
  1036. class Game_Vehicle < Game_Character
  1037. #--------------------------------------------------------------------------
  1038. # * New method: vehicle?
  1039. #--------------------------------------------------------------------------
  1040. def vehicle?
  1041. return true
  1042. end
  1043. #--------------------------------------------------------------------------
  1044. # * New method: map_id
  1045. #--------------------------------------------------------------------------
  1046. def map_id
  1047. @map_id
  1048. end
  1049. #--------------------------------------------------------------------------
  1050. # * New method: type
  1051. #--------------------------------------------------------------------------
  1052. def type
  1053. @type
  1054. end
  1055. #--------------------------------------------------------------------------
  1056. # * New method: aerial?
  1057. #--------------------------------------------------------------------------
  1058. def aerial?
  1059. type == :airship
  1060. end
  1061. #--------------------------------------------------------------------------
  1062. # * New method: above?
  1063. #--------------------------------------------------------------------------
  1064. def above?
  1065. aerial?
  1066. end
  1067. end
  1068.  
  1069. #==============================================================================
  1070. # ** Game_Event
  1071. #------------------------------------------------------------------------------
  1072. # This class deals with events. It handles functions including event page
  1073. # switching via condition determinants, and running parallel process events.
  1074. # It's used within the Game_Map class.
  1075. #==============================================================================
  1076.  
  1077. class Game_Event < Game_Character
  1078. #--------------------------------------------------------------------------
  1079. # * New method: name
  1080. #--------------------------------------------------------------------------
  1081. def name
  1082. @event.name
  1083. end
  1084. #--------------------------------------------------------------------------
  1085. # * New method: event?
  1086. #--------------------------------------------------------------------------
  1087. def event?
  1088. return true
  1089. end
  1090. #--------------------------------------------------------------------------
  1091. # * New method: erased?
  1092. #--------------------------------------------------------------------------
  1093. def erased?
  1094. @erased
  1095. end
  1096. #--------------------------------------------------------------------------
  1097. # * New method: note
  1098. #--------------------------------------------------------------------------
  1099. def note
  1100. return "" if !@page || [email protected] || @page.list.size <= 0
  1101. return @notes if @notes && @page.list == @note_page
  1102. @note_page = @page.list.dup
  1103. comment_list = []
  1104. @page.list.each do |item|
  1105. next unless item && (item.code == 108 || item.code == 408)
  1106. comment_list.push(item.parameters[0])
  1107. end
  1108. @notes = comment_list.join("\r\n")
  1109. @notes
  1110. end
  1111. end
  1112.  
  1113. #==============================================================================
  1114. # ** Game_Interpreter
  1115. #------------------------------------------------------------------------------
  1116. # An interpreter for executing event commands. This class is used within the
  1117. # Game_Map, Game_Troop, and Game_Event classes.
  1118. #==============================================================================
  1119.  
  1120. class Game_Interpreter
  1121. #--------------------------------------------------------------------------
  1122. # * Alias method: command_108
  1123. #--------------------------------------------------------------------------
  1124. alias :command_108_ve_basic_module :command_108
  1125. def command_108
  1126. command_108_ve_basic_module
  1127. comment_call
  1128. end
  1129. #--------------------------------------------------------------------------
  1130. # * New method: comment_call
  1131. #--------------------------------------------------------------------------
  1132. def comment_call
  1133. end
  1134. #--------------------------------------------------------------------------
  1135. # * New method: note
  1136. #--------------------------------------------------------------------------
  1137. def note
  1138. @comments ? @comments.join("\r\n") : ""
  1139. end
  1140. end
  1141.  
  1142. #==============================================================================
  1143. # ** Sprite_Character
  1144. #------------------------------------------------------------------------------
  1145. # This sprite is used to display characters. It observes a instance of the
  1146. # Game_Character class and automatically changes sprite conditions.
  1147. #==============================================================================
  1148.  
  1149. class Sprite_Character < Sprite_Base
  1150. #--------------------------------------------------------------------------
  1151. # * Overwrite method: set_character_bitmap
  1152. #--------------------------------------------------------------------------
  1153. def set_character_bitmap
  1154. update_character_info
  1155. set_bitmap
  1156. set_bitmap_position
  1157. end
  1158. #--------------------------------------------------------------------------
  1159. # * New method: center_y
  1160. #--------------------------------------------------------------------------
  1161. def actor?
  1162. @character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
  1163. end
  1164. #--------------------------------------------------------------------------
  1165. # * New method: center_y
  1166. #--------------------------------------------------------------------------
  1167. def actor
  1168. actor? ? @character.actor : nil
  1169. end
  1170. #--------------------------------------------------------------------------
  1171. # * New method: update_character_info
  1172. #--------------------------------------------------------------------------
  1173. def update_character_info
  1174. end
  1175. #--------------------------------------------------------------------------
  1176. # * New method: hue
  1177. #--------------------------------------------------------------------------
  1178. def hue
  1179. @character.hue
  1180. end
  1181. #--------------------------------------------------------------------------
  1182. # * New method: set_bitmap
  1183. #--------------------------------------------------------------------------
  1184. def set_bitmap
  1185. self.bitmap = Cache.character(set_bitmap_name, hue)
  1186. end
  1187. #--------------------------------------------------------------------------
  1188. # * New method: set_bitmap_name
  1189. #--------------------------------------------------------------------------
  1190. def set_bitmap_name
  1191. @character_name
  1192. end
  1193. #--------------------------------------------------------------------------
  1194. # * New method: set_bitmap_position
  1195. #--------------------------------------------------------------------------
  1196. def set_bitmap_position
  1197. sign = get_sign
  1198. if sign && sign.include?('$')
  1199. @cw = bitmap.width / @character.frames
  1200. @ch = bitmap.height / 4
  1201. else
  1202. @cw = bitmap.width / (@character.frames * 4)
  1203. @ch = bitmap.height / 8
  1204. end
  1205. self.ox = @cw / 2
  1206. self.oy = @ch
  1207. end
  1208. #--------------------------------------------------------------------------
  1209. # * New method: get_sign
  1210. #--------------------------------------------------------------------------
  1211. def get_sign
  1212. @character_name[/^[\!\$]./]
  1213. end
  1214. end
  1215.  
  1216. #==============================================================================
  1217. # ** Sprite_Battler
  1218. #------------------------------------------------------------------------------
  1219. # This sprite is used to display battlers. It observes a instance of the
  1220. # Game_Battler class and automatically changes sprite conditions.
  1221. #==============================================================================
  1222.  
  1223. class Sprite_Battler < Sprite_Base
  1224. #--------------------------------------------------------------------------
  1225. # * Public Instance Variables
  1226. #--------------------------------------------------------------------------
  1227. attr_accessor :dmg_mirror
  1228. #--------------------------------------------------------------------------
  1229. # * New method: center_x
  1230. #--------------------------------------------------------------------------
  1231. def center_x
  1232. self.ox
  1233. end
  1234. #--------------------------------------------------------------------------
  1235. # * New method: center_y
  1236. #--------------------------------------------------------------------------
  1237. def center_y
  1238. self.oy / 2
  1239. end
  1240. end
  1241.  
  1242. #==============================================================================
  1243. # ** Spriteset_Battle
  1244. #------------------------------------------------------------------------------
  1245. # This class brings together battle screen sprites. It's used within the
  1246. # Scene_Battle class.
  1247. #==============================================================================
  1248.  
  1249. class Spriteset_Battle
  1250. #--------------------------------------------------------------------------
  1251. # * Public Instance Variables
  1252. #--------------------------------------------------------------------------
  1253. attr_reader :viewport1
  1254. #--------------------------------------------------------------------------
  1255. # * New method: sprite
  1256. #--------------------------------------------------------------------------
  1257. def sprite(subject)
  1258. battler_sprites.compact.select {|sprite| sprite.battler == subject }.first
  1259. end
  1260. end
  1261.  
  1262. #==============================================================================
  1263. # ** Window_Base
  1264. #------------------------------------------------------------------------------
  1265. # This is a superclass of all windows in the game.
  1266. #==============================================================================
  1267.  
  1268. class Window_Base < Window
  1269. #--------------------------------------------------------------------------
  1270. # * Alias method: convert_escape_characters
  1271. #--------------------------------------------------------------------------
  1272. alias :convert_escape_ve_basic_module :convert_escape_characters
  1273. def convert_escape_characters(text)
  1274. result = text.to_s.clone
  1275. result = text_replace(result)
  1276. result = convert_escape_ve_basic_module(text)
  1277. result
  1278. end
  1279. #--------------------------------------------------------------------------
  1280. # * New method: text_replace
  1281. #--------------------------------------------------------------------------
  1282. def text_replace(result)
  1283. result.gsub!(/\r/) { "" }
  1284. result.gsub!(/\\/) { "\e" }
  1285. result
  1286. end
  1287. end
  1288.  
  1289. #==============================================================================
  1290. # ** Scene_Battle
  1291. #------------------------------------------------------------------------------
  1292. # This class performs battle screen processing.
  1293. #==============================================================================
  1294.  
  1295. class Scene_Battle < Scene_Base
  1296. #--------------------------------------------------------------------------
  1297. # * Public Instance Variables
  1298. #--------------------------------------------------------------------------
  1299. attr_reader :subject
  1300. attr_reader :spriteset
  1301. end
  1302.  
  1303. #==============================================================================
  1304. # ** Scene_Battle
  1305. #------------------------------------------------------------------------------
  1306. # This class performs map screen processing.
  1307. #==============================================================================
  1308.  
  1309. class Scene_Map < Scene_Base
  1310. #--------------------------------------------------------------------------
  1311. # * Public Instance Variables
  1312. #--------------------------------------------------------------------------
  1313. attr_reader :spriteset
  1314. end
Advertisement
Add Comment
Please, Sign In to add comment