Guest User

Yami Engine Symphony - Add-on: Holder Battlers

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