TheoAllen

TSBS Patch3

Feb 28th, 2015
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.01 KB | None | 0 0
  1. #===============================================================================
  2. # TSBS v1.4 Bugfixes
  3. #-------------------------------------------------------------------------------
  4. # Change Logs :
  5. # 2015.02.28 - Fixed change attack / guard id in states bug
  6. # 2015.02.04 - Fixed Smooth return typo that cause fatal crash
  7. #            - Fixed Show icon index
  8. # 2015.01.09 - Added compatibility with YEA Steal Item
  9. # 2015.01.08 - Added compatibility with YEA Party Command
  10. # 2015.01.06 - Added fix for default flip
  11. #            - Change how update key work in battler icon
  12. #            - Added move to target fix
  13. # 2015.01.01 - Added YEA skill steal compatibility
  14. # 2014.12.25 - Release date
  15. #
  16. #-------------------------------------------------------------------------------
  17. # Known issues :
  18. #-------------------------------------------------------------------------------
  19. # - When you set an event in Troop that target all enemies (like change enemy
  20. #   HP / MP, hidden enemies will be revealed, but can not be targeted) (FIXED!)
  21. #
  22. # - When using custom collapse sequence, if you change the graphics like
  23. #   changing filename from battler_1.png to battler_2.png, your battler will
  24. #   suddenly disappear (FIXED!)
  25. #
  26. # - Multiple Animations addon breaks the game if it's played over the animation
  27. #   guard. An animation that played over the target when it took damage.(FIXED!)
  28. #
  29. # - Heavy lag issue if you set Looping_Background in config 1 to true and you
  30. #   haven't set any background for battleback in map. (FIXED!)
  31. #
  32. # - Revived enemy won't collapsed twice (FIXED!)
  33. #
  34. # - Double resume error when using substitute not followed by yanfly script
  35. #   (FIXED!)
  36. #
  37. # - Trying to show weapon icon for enemy causes crash (FIXED!)
  38. #
  39. # - System sound (recovery) played when using item in map/menu (FIXED!)
  40. #
  41. # - small issues on :sm_target and :end_action (FIXED!)
  42. #
  43. # - Enemy Default flip doesn't work (FIXED!)
  44. #
  45. # - Move to target + area tag + flipped battler cause the battler go off screen
  46. #   (FIXED!)
  47. #
  48. # - When you're using :sm_return, it will cause crash due to typo (FIXED!)
  49. #
  50. # - When you're using index -3 in icon settings. Unless you give the notetag
  51. #   <iconfile: name> you cant show icon. It should display default icon instead
  52. #   of displaying nothing. No wonder some people keep asking me "how to show
  53. #   weapon icon?"
  54. #
  55. # - Change attack skill ID and guard skill ID when influenced by states wont
  56. #   work properly (FIXED)
  57. #
  58. #-------------------------------------------------------------------------------
  59. # Known incompatibilities :
  60. #-------------------------------------------------------------------------------
  61. # - Incompatibility with YEA Active Chain Skill (FIXED!)
  62. #
  63. # - Incompatibility with YEA Skill Steal (FIXED!)
  64. #
  65. # - Incompatibility with AEA Charge turn battle(?)
  66. #
  67. # - Incompatibility with YEA Party Command (FIXED!)
  68. #
  69. # - Incompatibility with YEA Steal Item (FIXED!)
  70. #
  71. #-------------------------------------------------------------------------------
  72. # To use this patch, simply put this script below implementation
  73. #===============================================================================
  74.  
  75. #===============================================================================
  76. # ** Game_Battler
  77. #===============================================================================
  78.  
  79. class Game_Battler
  80.   #----------------------------------
  81.   # Weapon icon fix
  82.   #----------------------------------
  83.   def icon_file(index = 0)
  84.     return @icon_file unless @icon_file.empty?
  85.     return weapons[index].icon_file if actor? && weapons[index]
  86.     return ''
  87.   end
  88.  
  89.   #----------------------------------
  90.   # System sound fix
  91.   #----------------------------------
  92.   def make_base_result(user, item)
  93.     tsbs_make_base_result(user, item)
  94.     Sound.tsbs_play_recovery if item.damage.recover? && play_sound?
  95.     return if user == self
  96.     return if busy?
  97.     if item.damage.recover? || item.damage.type == 0
  98.       self.battle_phase = :idle
  99.       # Refresh idle key. In case if there is any state change or
  100.       # HP rate change
  101.       return
  102.     end
  103.     self.battle_phase = :hurt if @result.hit?
  104.     # Automatically switch to hurt phase
  105.     if @result.missed && play_sound?
  106.       Sound.tsbs_play_miss
  107.     end
  108.     if @result.evaded
  109.       Sound.tsbs_play_eva if item.physical? && play_sound?
  110.       Sound.tsbs_play_magic_eva if item.magical? && play_sound?
  111.       self.battle_phase = :evade
  112.       # Automatically switch to evade phase
  113.     end
  114.   end
  115.  
  116.   def play_sound?
  117.     SceneManager.in_battle? && PlaySystemSound
  118.   end
  119.  
  120.   #----------------------------------
  121.   # End action fix
  122.   #----------------------------------
  123.   def setup_end_action
  124.     @break_action = true
  125.     @finish = true
  126.     method_wait
  127.   end
  128.  
  129.   #----------------------------------
  130.   # Smooth move to target fix
  131.   #----------------------------------
  132.   def setup_smooth_move_target
  133.     if area_flag
  134.       size = target_array.size
  135.       xpos = target_array.inject(0) {|r,battler| r + battler.x}/size
  136.       ypos = target_array.inject(0) {|r,battler| r + battler.y}/size
  137.       xpos += @acts[1] * (flip && !@ignore_flip_point ? -1 : 1)
  138.       dur = @acts[3] || 25
  139.       rev = @acts[4]
  140.       rev = true if rev.nil?
  141.       smooth_move(xpos, ypos + @acts[2], dur, rev)
  142.       return
  143.     end
  144.     return unless target
  145.     tx = @acts[1] + target.x || 0
  146.     ty = @acts[2] + target.y || 0
  147.     tx *= -1 if flip && !@ignore_flip_point
  148.     dur = @acts[3] || 25
  149.     rev = @acts[4]
  150.     rev = true if rev.nil?
  151.     smooth_move(tx,ty,dur,rev)
  152.   end
  153.  
  154.   #----------------------------------
  155.   # Move to target flip fix
  156.   #----------------------------------
  157.   def setup_move_to_target
  158.     return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5
  159.     stop_all_movements
  160.     if area_flag
  161.       size = target_array.size
  162.       xpos = target_array.inject(0) {|r,battler| r + battler.x}/size
  163.       ypos = target_array.inject(0) {|r,battler| r + battler.y}/size
  164.       xpos += @acts[1] * (flip && !@ignore_flip_point ? -1 : 1)
  165.       # Get the center coordinate of enemies
  166.       goto(xpos, ypos + @acts[2], @acts[3], @acts[4])
  167.       return
  168.     end
  169.     xpos = target.x + (flip ? -@acts[1] : @acts[1])
  170.     ypos = target.y + @acts[2]
  171.     goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)
  172.   end
  173.  
  174.   #-----------------------------------
  175.   # Smooth return patch
  176.   #-----------------------------------
  177.   def setup_smooth_return
  178.     tx = @ori_x
  179.     ty = @ori_y
  180.     dur = @acts[1] || 25
  181.     rev = @acts[2]
  182.     rev = true if rev.nil?
  183.     smooth_move(tx,ty,dur,rev)
  184.   end
  185.  
  186. end
  187.  
  188. #===============================================================================
  189. # ** Game_Actor
  190. #===============================================================================
  191.  
  192. class Game_Actor
  193.   # --------------------------------------------------------------------------
  194.   # Attack Fix
  195.   # --------------------------------------------------------------------------
  196.   def attack_skill_id
  197.     return $data_states[sort_states.first].attack_id if
  198.       sort_states.any?{ |state| $data_states[state].attack_id > 0}
  199.     return weapons[0].attack_id if weapons[0] ? weapons[0].attack_id > 0 :
  200.       false
  201.     return $data_classes[class_id].attack_id if
  202.       $data_classes[class_id].attack_id > 0
  203.     return $data_actors[id].attack_id if $data_actors[id].attack_id > 0
  204.     return tsbs_atk_id
  205.   end
  206.  
  207.   # --------------------------------------------------------------------------
  208.   # Guard Fix
  209.   # --------------------------------------------------------------------------
  210.   alias tsbs_grd_id guard_skill_id
  211.   def guard_skill_id
  212.     return $data_states[sort_states.first].guard_id if
  213.       sort_states.any? { |state| $data_states[state].guard_id > 0}
  214.     return $data_classes[class_id].guard_id if
  215.       $data_classes[class_id].guard_id > 0
  216.     return $data_actors[id].guard_id if $data_actors[id].guard_id > 0
  217.     return tsbs_grd_id
  218.   end
  219.  
  220. end
  221.  
  222. #===============================================================================
  223. # ** Game_Enemy
  224. #===============================================================================
  225.  
  226. class Game_Enemy
  227.   #-------------------
  228.   # Enemy revival fix
  229.   #-------------------
  230.   def hp=(hp)
  231.     super
  232.     @collapsed = false if hp > 0
  233.   end
  234.  
  235.   #-------------------
  236.   # Default flip fix
  237.   #-------------------
  238.   def default_flip
  239.     result = TSBS::Enemy_Default_Flip
  240.     toggler = (!data_battler.note[DefaultFlip].nil? rescue false)
  241.     result = !result if toggler
  242.     return result
  243.   end
  244.  
  245. end
  246.  
  247. #===============================================================================
  248. # ** Sprite_Battler
  249. #===============================================================================
  250.  
  251. class Sprite_Battler
  252.   #----------------------------
  253.   # Battler visibility fix
  254.   #----------------------------
  255.   def init_visibility
  256.     return if actor? && !@battler.data_battler.dead_key.empty?
  257.     not_hidden = !@battler.hidden?
  258.     not_collapsed = (@battler.enemy? && @battler.battle_phase != :collapse ?
  259.       !@battler.collapsed : true)
  260.     @battler_visible = not_hidden && not_collapsed
  261.     self.opacity = 0 unless @battler_visible
  262.   end
  263.  
  264.   #----------------------------
  265.   # Opacity refresh fix
  266.   #----------------------------
  267.   def update_opacity
  268.     self.opacity = [opacity,@battler.max_opac].min
  269.     @battler.refresh_opacity = false
  270.   end
  271.  
  272. end
  273.  
  274. #===============================================================================
  275. # ** Sprite_AnimGuard
  276. #===============================================================================
  277.  
  278. class Sprite_AnimGuard
  279.   #----------------------------
  280.   # Get battler (Multiple animation fix)
  281.   #----------------------------
  282.   def battler
  283.     @spr_battler.battler
  284.   end
  285.  
  286. end
  287.  
  288. #===============================================================================
  289. # ** Sprite_BattlerIcon
  290. #===============================================================================
  291.  
  292. class Sprite_BattlerIcon
  293.   #--------------------------------------
  294.   # Iconfix
  295.   #--------------------------------------
  296.   def icon_index=(index)
  297.     @icon_index = index
  298.     if index < 0
  299.       battler = @spr_battler.battler
  300.       name = battler.icon_file(index + 1)
  301.       if name.empty?
  302.         index = index.abs - 3
  303.         self.icon_index = (battler.weapons[index].icon_index rescue (
  304.           battler.weapons[index + 1].icon_index) rescue 0)
  305.         return
  306.       else
  307.         bmp = Cache.system(name)
  308.         self.bitmap = bmp
  309.         return
  310.       end
  311.     end
  312.     icon_bitmap = Cache.system("Iconset")
  313.     rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
  314.     bmp = Bitmap.new(24,24)
  315.     bmp.blt(0, 0, icon_bitmap, rect, 255)
  316.     self.bitmap = bmp
  317.   end
  318.  
  319.   #----------------------------------
  320.   # Change update key for icon
  321.   #----------------------------------
  322.   def update_key
  323.     actor = battler # Just make alias
  324.     @used_key = battler.icon_key
  325.     array = Icons[@used_key]
  326.     return icon_error unless array
  327.     self.anchor = array[0]
  328.     @dummy.x = (battler.flip ? -array[1] : array[1])
  329.     @dummy.y = array[2]
  330.     @above_char = array[3]
  331.     update_placement
  332.     self.angle = array[4]
  333.     target = array[5]
  334.     duration = array[6]
  335.     icon_index = (eval(array[7]) rescue 0) if array[7].is_a?(String)
  336.     if array[7] >= 0
  337.       icon_index = array[7]
  338.     elsif !array[7].nil?
  339.       if array[7] == -1 # First weapon ~
  340.         icon_index = (battler.weapons[0].icon_index rescue 0)
  341.       elsif array[7] == -2 # Second weapon ~
  342.         icon_index = (battler.weapons[1].icon_index rescue
  343.           (battler.weapons[0].icon_index rescue 0))
  344.       elsif array[7] <= -3 # Custom icon graphic
  345.         icon_index = array[7] + 2
  346.       end
  347.     end
  348.     self.mirror = (array[8].nil? ? false : array[8])
  349.     if array[9] && array[10] && array[11]
  350.       @dummy.slide(array[9], array[10], array[11])
  351.     end
  352.     icon_index = icon_index || 0
  353.     self.icon_index = icon_index
  354.     change_angle(target, duration)
  355.     battler.icon_key = ""
  356.   end
  357. end
  358.  
  359. #===============================================================================
  360. # ** Spriteset_Battle
  361. #===============================================================================
  362.  
  363. class Spriteset_Battle
  364.   #----------------------------
  365.   # Looping background fix
  366.   #----------------------------
  367.   def battleback2_bitmap
  368.     if battleback2_name
  369.       Cache.battleback2(battleback2_name)
  370.     elsif TSBS::Looping_Background
  371.       Bitmap.new(Graphics.width, Graphics.height)
  372.     else
  373.       Bitmap.new(1, 1)
  374.     end
  375.   end
  376.  
  377. end
  378.  
  379. #===============================================================================
  380. # ** Window_BattleLog
  381. #===============================================================================
  382.  
  383. class Window_BattleLog
  384.   #-----------------------------------------
  385.   # Double resume fix in substitute
  386.   #-----------------------------------------
  387.   def display_substitute(sub, targ)
  388.     return unless $imported["YEA-BattleEngine"] &&
  389.       YEA::BATTLE::MSG_SUBSTITUTE_HIT
  390.     add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
  391.   end
  392.  
  393. end
  394.  
  395. #===============================================================================
  396. # ** Scene_Battle
  397. #===============================================================================
  398.  
  399. class Scene_Battle
  400.   #-----------------------------------------
  401.   # YEA - Active Chain Skill
  402.   #-----------------------------------------
  403.   def show_action_sequences(targets, item, subj)
  404.     tsbs_action_init(targets, item, subj)
  405.     tsbs_action_pre(targets, item, subj)
  406.     tsbs_action_main(targets, item, subj)
  407.     unless $imported["YEA-ActiveChainSkills"] && @active_chain_skill &&
  408.         @active_chain_skill > 0
  409.       tsbs_action_post(targets, item, subj)
  410.       tsbs_action_end(targets, item, subj)
  411.       $game_temp.backdrop.reset_transition_flags
  412.       wait(tsbs_wait_dur)
  413.     end
  414.   end
  415.  
  416.   #-----------------------------------------
  417.   # YEA - Skill Steal patch
  418.   #-----------------------------------------
  419.   if $imported["YEA-SkillSteal"]
  420.   alias tsbs_skill_steal_apply_item tsbs_apply_item
  421.   def tsbs_apply_item(target, item, subj = @subject)
  422.     tsbs_skill_steal_apply_item(target, item, subj)
  423.     tsbs_skill_steal(target, item, subj)
  424.   end
  425.  
  426.   def tsbs_skill_steal(target, item, subj)
  427.     return unless item.skill_steal
  428.     return if target.actor?
  429.     return unless subj.actor?
  430.     for skill in target.stealable_skills
  431.       next if subj.skill_learn?(skill)
  432.       @subject.learn_skill(skill.id)
  433.       string = YEA::SKILL_STEAL::MSG_SKILL_STEAL
  434.       skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
  435.       text = sprintf(string, @subject.name, skill_text, target.name)
  436.       @stolen_skills << text
  437.     end
  438.   end
  439.  
  440.   alias tsbs_skill_steal_action_init tsbs_action_init
  441.   def tsbs_action_init(targets, item, subj)
  442.     tsbs_skill_steal_action_init(targets, item, subj)
  443.     @stolen_skills = []
  444.   end
  445.  
  446.   alias tsbs_skill_steal_action_end tsbs_action_end
  447.   def tsbs_action_end(targets, item, subj)
  448.     tsbs_skill_steal_action_end(targets, item, subj)
  449.     @stolen_skills.each do |text_skill|
  450.       @log_window.add_text(text_skill)
  451.       YEA::SKILL_STEAL::MSG_DURATION.times { tsbs_wait_update }
  452.       @log_window.back_one
  453.     end
  454.   end
  455.   end # YEA SKILL STEAL
  456.  
  457.   #-----------------------------------------
  458.   # YEA - Steal Item patch
  459.   #-----------------------------------------
  460.   if $imported["YEA-StealItems"]
  461.   alias tsbs_steal_item_apply_item tsbs_apply_item
  462.   def tsbs_apply_item(target, item, subj = @subject)
  463.     tsbs_steal_item_apply_item(target, item, subj)
  464.     tsbs_apply_steal_results(target, item, subj)
  465.   end
  466.  
  467.   def tsbs_apply_steal_results(target, item, subj)
  468.     return if target.actor?
  469.     return if item.steal_type.nil?
  470.     if target.stealable_items.empty?
  471.       fmt = YEA::STEAL::STEAL_EMPTY_TEXT
  472.       text = sprintf(fmt, target.name)
  473.     elsif target.result.stolen_item.nil?
  474.       fmt = YEA::STEAL::STEAL_FAIL_TEXT
  475.       text = sprintf(fmt, subj.name)
  476.     else
  477.       fmt = YEA::STEAL::STEAL_SUCCESS_TEXT
  478.       actor = subj.name
  479.       item = stolen_item_text(target)
  480.       enemy = target.name
  481.       text = sprintf(fmt, actor, item, enemy)
  482.     end
  483.     @stolen_items << text
  484.   end
  485.  
  486.   alias tsbs_steal_item_action_init tsbs_action_init
  487.   def tsbs_action_init(targets, item, subj)
  488.     tsbs_steal_item_action_init(targets, item, subj)
  489.     @stolen_items = []
  490.   end
  491.  
  492.   alias tsbs_steal_item_action_end tsbs_action_end
  493.   def tsbs_action_end(targets, item, subj)
  494.     tsbs_steal_item_action_end(targets, item, subj)
  495.     @stolen_items.each do |text_item|
  496.       @log_window.add_text(text_item)
  497.       60.times { tsbs_wait_update }
  498.       @log_window.back_one
  499.     end
  500.   end
  501.   end # YEA STEAL ITEM
  502.  
  503. end
  504.  
  505. if $imported["YEA-CommandParty"]
  506. class Game_Party
  507.   alias tsbs_set_party_cooldown set_party_cooldown
  508.   def set_party_cooldown
  509.     tsbs_set_party_cooldown
  510.     battle_members.each do |m|
  511.       m.init_oripost
  512.       m.setup_instant_reset
  513.       m.sprite.start_effect(:appear)
  514.     end
  515.   end
  516. end
  517. end # YEA COMMAND PARTY
Advertisement
Add Comment
Please, Sign In to add comment