Guest User

Yami Holders Battler addon

a guest
Jul 26th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.08 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Symphony - Add-on: Holder Battlers
  4. # -- Last Updated: 2013.02.01
  5. # -- Level: Nothing
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["BattleSymphony-HB"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2013.02.01 - Adjust for Symphony v1.13.
  17. # 2012.10.20 - Finished Script.
  18. # 2012.07.01 - Started Script.
  19. #
  20. #==============================================================================
  21. # ¥ Compatibility
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  24. # it will run with RPG Maker VX without adjusting.
  25. # Remember to put this script under Battle Symphony.
  26. #
  27. #==============================================================================
  28.  
  29. $imported = {} if $imported.nil?
  30. $imported["BattleSymphony-HB"] = true
  31.  
  32. #==============================================================================
  33. # ¡ Direction - Advanced Configuration
  34. #==============================================================================
  35.  
  36. module Direction
  37.  
  38. #--------------------------------------------------------------------------
  39. # self.index_hb
  40. #--------------------------------------------------------------------------
  41. def self.index_hb(pose)
  42. case pose
  43. # array = [row, frames]
  44. # frames is optional, default is 15
  45. when :idle
  46. array = [0, 10]
  47. when :struck
  48. array = [3, 10]
  49. when :woozy
  50. array = [2, 10]
  51. #---
  52. when :victory
  53. array = [10]
  54. when :defend
  55. array = [1]
  56. when :dead
  57. array = [12,10]
  58. #---
  59. when :attack
  60. array = [4, 10]
  61. when :skill
  62. array = [6, 10]
  63. when :magic
  64. array = [7, 10]
  65. when :item
  66. array = [5, 10]
  67. #---
  68. when :advance
  69. array = [8, 5]
  70. when :retreat
  71. array = [9, 5]
  72. else; array = [0, 12]
  73. end
  74. return array
  75. end
  76.  
  77. #--------------------------------------------------------------------------
  78. # self.auto_pose_hb
  79. #--------------------------------------------------------------------------
  80. # auto repeatnya disini
  81.  
  82. def self.auto_pose_hb(battler)
  83. return :dead if battler.dead?
  84. return :woozy if battler.hp < battler.mhp / 4
  85. return :defend if battler.guard?
  86. return :idle
  87. end
  88.  
  89. end # Direction
  90.  
  91. #==============================================================================
  92. # ¡ BattleManager
  93. #==============================================================================
  94.  
  95. module BattleManager
  96.  
  97. #--------------------------------------------------------------------------
  98. # alias method: process_victory
  99. #--------------------------------------------------------------------------
  100. class <<self; alias bes_hb_process_victory process_victory; end
  101. def self.process_victory
  102. $game_party.alive_members.each { |battler| battler.force_pose_hb(:victory) }
  103. return bes_hb_process_victory
  104. end
  105.  
  106. #--------------------------------------------------------------------------
  107. # alias method: process_defeat
  108. #--------------------------------------------------------------------------
  109. class <<self; alias bes_hb_process_defeat process_defeat; end
  110. def self.process_defeat
  111. $game_troop.alive_members.each { |battler| battler.force_pose_hb(:victory) }
  112. return bes_hb_process_defeat
  113. end
  114.  
  115. end # BattleManager
  116.  
  117. #==============================================================================
  118. # ¡ Regular Expression
  119. #==============================================================================
  120.  
  121. module REGEXP
  122. module SYMPHONY
  123.  
  124. HOLDERS_BATTLER = /<(?:HOLDERS_BATTLER|holders battler):[ ]*(.*)>/i
  125.  
  126. end
  127. end
  128.  
  129. #==============================================================================
  130. # ¡ DataManager
  131. #==============================================================================
  132.  
  133. module DataManager
  134.  
  135. #--------------------------------------------------------------------------
  136. # alias method: load_database
  137. #--------------------------------------------------------------------------
  138. class <<self; alias load_database_bes_hb load_database; end
  139. def self.load_database
  140. load_database_bes_hb
  141. load_notetags_bes_hb
  142. end
  143.  
  144. #--------------------------------------------------------------------------
  145. # new method: load_notetags_bes_hb
  146. #--------------------------------------------------------------------------
  147. def self.load_notetags_bes_hb
  148. groups = [$data_actors, $data_enemies]
  149. groups.each { |group|
  150. group.each { |obj|
  151. next if obj.nil?
  152. obj.battle_symphony_holders_battler
  153. }
  154. }
  155. end
  156.  
  157. end # DataManager
  158.  
  159. #==============================================================================
  160. # ¡ RPG::BaseItem
  161. #==============================================================================
  162.  
  163. class RPG::BaseItem
  164.  
  165. #--------------------------------------------------------------------------
  166. # * Public Instance Variables
  167. #--------------------------------------------------------------------------
  168. attr_accessor :holders_name
  169.  
  170. #--------------------------------------------------------------------------
  171. # new method: battle_symphony_holders_battler
  172. #--------------------------------------------------------------------------
  173. def battle_symphony_holders_battler
  174. self.note.split(/[\r\n]+/).each { |line|
  175. case line
  176. when REGEXP::SYMPHONY::HOLDERS_BATTLER
  177. @holders_name = $1.to_s
  178. end
  179. }
  180. end
  181.  
  182. end # RPG::BaseItem
  183.  
  184. #==============================================================================
  185. # ¡ Game_Battler
  186. #==============================================================================
  187.  
  188. class Game_Battler < Game_BattlerBase
  189.  
  190. #--------------------------------------------------------------------------
  191. # new method: use_hb?
  192. #--------------------------------------------------------------------------
  193. def use_hb?
  194. self.actor? ? !actor.holders_name.nil? : !enemy.holders_name.nil?
  195. end
  196.  
  197. #--------------------------------------------------------------------------
  198. # new method: holders_name
  199. #--------------------------------------------------------------------------
  200. def holders_name
  201. self.actor? ? actor.holders_name : enemy.holders_name
  202. end
  203.  
  204. #--------------------------------------------------------------------------
  205. # alias method: set_default_position
  206. #--------------------------------------------------------------------------
  207. alias bes_hb_set_default_position set_default_position
  208. def set_default_position
  209. bes_hb_set_default_position
  210. set_hb_default_position if self.use_hb?
  211. end
  212.  
  213. #--------------------------------------------------------------------------
  214. # new method: set_8d_default_position
  215. #--------------------------------------------------------------------------
  216. def set_hb_default_position
  217. self.pose = Direction.auto_pose_hb(self)
  218. end
  219.  
  220. #--------------------------------------------------------------------------
  221. # alias method: break_pose
  222. #--------------------------------------------------------------------------
  223. alias bes_hb_break_pose break_pose
  224. def break_pose
  225. bes_hb_break_pose
  226. break_pose_hb if self.use_hb?
  227. end
  228.  
  229. #--------------------------------------------------------------------------
  230. # new method: break_pose_hb
  231. #--------------------------------------------------------------------------
  232. def break_pose_hb
  233. @pose = Direction.auto_pose_hb(self)
  234. #---
  235. return unless SceneManager.scene.spriteset
  236. return unless self.sprite
  237. @direction = SYMPHONY::View::PARTY_DIRECTION
  238. @direction = Direction.opposite(@direction) if self.enemy?
  239. self.sprite.mirror = [9, 6, 3].include?(@direction)
  240. #@direction = Direction.opposite(@direction) if self.sprite.mirror
  241. end
  242.  
  243. #--------------------------------------------------------------------------
  244. # new method: force_pose_hb
  245. #--------------------------------------------------------------------------
  246. def force_pose_hb(pose)
  247. return unless self.use_hb?
  248. return unless self.exist?
  249. #---
  250. self.break_pose
  251. self.pose = pose
  252. @force_pose = true
  253. end
  254.  
  255. end # Game_Battler
  256.  
  257. #==============================================================================
  258. # ¡ Game_Actor
  259. #==============================================================================
  260.  
  261. class Game_Actor < Game_Battler
  262.  
  263. #--------------------------------------------------------------------------
  264. # alias method: use_charset?
  265. #--------------------------------------------------------------------------
  266. alias bes_hb_use_charset? use_charset?
  267. def use_charset?
  268. return false if use_hb?
  269. return bes_hb_use_charset?
  270. end
  271.  
  272. end # Game_Actor
  273.  
  274. #==============================================================================
  275. # ¡ Game_Enemy
  276. #==============================================================================
  277.  
  278. class Game_Enemy < Game_Battler
  279.  
  280. #--------------------------------------------------------------------------
  281. # alias method: use_charset?
  282. #--------------------------------------------------------------------------
  283. alias bes_hb_use_charset? use_charset?
  284. def use_charset?
  285. return false if use_hb?
  286. return bes_hb_use_charset?
  287. end
  288.  
  289. end # Game_Enemy
  290.  
  291. #==============================================================================
  292. # ¡ Sprite_Battler
  293. #==============================================================================
  294.  
  295. class Sprite_Battler < Sprite_Base
  296.  
  297. #--------------------------------------------------------------------------
  298. # alias method: update_bitmap
  299. #--------------------------------------------------------------------------
  300. alias bes_hb_update_bitmap update_bitmap
  301. def update_bitmap
  302. correct_change_pose if @timer.nil?
  303. @battler.use_hb? ? update_hbset : bes_hb_update_bitmap
  304. end
  305.  
  306. #--------------------------------------------------------------------------
  307. # alias method: update_origin
  308. #--------------------------------------------------------------------------
  309. alias bes_hb_update_origin update_origin
  310. def update_origin
  311. bes_hb_update_origin
  312. update_origin_hb if @battler.use_hb?
  313. end
  314.  
  315. #--------------------------------------------------------------------------
  316. # new method: update_charset
  317. #--------------------------------------------------------------------------
  318. def update_hbset
  319. @battler.set_default_position unless pose
  320. #---
  321. update_hbset_bitmap
  322. update_src_rect
  323. end
  324.  
  325. #--------------------------------------------------------------------------
  326. # alias method: correct_change_pose
  327. #--------------------------------------------------------------------------
  328. alias bes_hb_correct_change_pose correct_change_pose
  329. def correct_change_pose
  330. bes_hb_correct_change_pose unless @battler.use_hb?
  331. correct_change_pose_hb if @battler.use_hb?
  332. end
  333.  
  334. #--------------------------------------------------------------------------
  335. # new method: correct_change_pose_hb
  336. #--------------------------------------------------------------------------
  337. def correct_change_pose_hb
  338. array = Direction.index_hb(pose)
  339. @pattern = @battler.reverse_pose ? 9 : 0
  340. @timer = array[1].nil? ? 15 : array[1]
  341. @last_pose = pose
  342. @back_step = false
  343. end
  344.  
  345. #--------------------------------------------------------------------------
  346. # new method: update_charset_origin
  347. #--------------------------------------------------------------------------
  348. def update_origin_hb
  349. if bitmap
  350. self.ox = @cw / 2
  351. self.oy = @ch
  352. end
  353. end
  354.  
  355. #--------------------------------------------------------------------------
  356. # new method: hb_graphic_changed?
  357. #--------------------------------------------------------------------------
  358. def hb_graphic_changed?
  359. self.bitmap.nil? || @character_name != @battler.holders_name
  360. end
  361.  
  362. #--------------------------------------------------------------------------
  363. # alias method: set_character_bitmap
  364. #--------------------------------------------------------------------------
  365. alias bes_hb_set_character_bitmap set_character_bitmap
  366. def set_character_bitmap
  367. bes_hb_set_character_bitmap unless @battler.use_hb?
  368. return unless @battler.use_hb?
  369. self.bitmap = Cache.character(@character_name)
  370. @cw = bitmap.width / 10
  371. @ch = bitmap.height / 13
  372. end
  373.  
  374. #--------------------------------------------------------------------------
  375. # new method: update_hbset_bitmap
  376. #--------------------------------------------------------------------------
  377. def update_hbset_bitmap
  378. if hb_graphic_changed?
  379. @character_name = @battler.holders_name
  380. set_character_bitmap
  381. end
  382. end
  383.  
  384. #--------------------------------------------------------------------------
  385. # alias method: update_src_rect
  386. #--------------------------------------------------------------------------
  387. alias bes_hb_update_src_rect update_src_rect
  388. def update_src_rect
  389. bes_hb_update_src_rect unless @battler.use_hb?
  390. return unless @battler.use_hb?
  391. @timer -= 1
  392. if @battler.force_pose
  393. if @timer <= 0 && @pattern < 9
  394. array = []
  395. array = Direction.index_hb(pose)
  396. @pattern += 1
  397. @timer = array[1].nil? ? 15 : array[1]
  398. end
  399. else
  400. if @timer <= 0
  401. @pattern += 1
  402. @pattern = 0 if @pattern > 3
  403. @timer = 15
  404. end
  405. end
  406. #---
  407. line_no = Direction.index_hb(pose)[0]
  408. sx = @pattern * @cw
  409. sy = line_no * @ch
  410. self.src_rect.set(sx, sy, @cw, @ch)
  411. end
  412.  
  413. end # Sprite_Battler
  414.  
  415. #===============================================================================
  416. #
  417. # END OF FILE
  418. #
  419. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment