gerkrt

XRXS - Combo Hit

Sep 14th, 2011
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.84 KB | None | 0 0
  1. ################################################################################
  2. ############################# XRXS #############################################
  3. ################################################################################
  4. # Ativa o sistema de Combo Hit
  5. # Improved by gerkrt/gerrtunk.
  6. # Check this page for
  7. # Now it can show the total acumulated damage and its better to configurate
  8. # For the latests updates or bugs fixes of this script check here:
  9. # http://usuarios.multimania.es/kisap/english_list.html
  10. ################################################################################
  11.  
  12. # Nota: Puedes usar valores negativos en las posiciones de las ventanas para
  13. # forzarlos aun mas
  14.  
  15. # Note: You can use negative values in the windows positions to force they more.
  16.  
  17. # Define la posicion X del texto combohit cuando el objetivo es un enemigo
  18. # Defines the X position of the text when the objective is an enemy.
  19. $window_x = 420  
  20.  
  21. # Defines the X position of the text when the objective is an actor.
  22. $window_actor_x = -30  
  23.  
  24. # Define the Y position of the combohit text
  25. $window_y = 32
  26.  
  27. # Define the vocabulary
  28. $golpes_texto = 'Hits: '   # word used for the total hits
  29. $total_texto = 'Total: '   # word used for the total damage
  30.  
  31. class XRXS_BP19
  32.   COMBOHIT_DURATION = 200
  33. end
  34. class Game_Battler
  35.   DAMAGE_INCREASE_PER_HIT = 5
  36. end
  37.  
  38. class Window_ComboHit < Window_Base
  39.   COMBOHIT_FONTNAME  = "Georgia"  
  40.   COMBOHIT_FONTCOLOR = Color.new(255,255,255,255) # rgba
  41. end
  42.  
  43.  
  44. # Modificado para poder configurar la Y
  45. class Window_ComboHit < Window_Base
  46.   def initialize
  47.     super($window_x, $window_y, 300, 140)
  48.     self.contents = Bitmap.new(width - 32, height - 32)
  49.     self.opacity = 0
  50.     self.visible = false
  51.     @active = false
  52.     @show_duration = 0
  53.     @sliding_duration = 0
  54.     self.contents.clear
  55.   end
  56.   def clear
  57.     self.contents.clear
  58.     self.visible = false
  59.   end
  60.  
  61.   # Modificado para que muestre el texto de daño total
  62.   def refresh(hit_combo, duration, total_damage)
  63.  
  64.     self.contents_opacity = 255
  65.     self.visible = true
  66.     @show_duration    = duration
  67.     @sliding_duration = 0
  68.     self.contents.clear
  69.     self.contents.font.name = COMBOHIT_FONTNAME
  70.     self.contents.font.bold = true
  71.     text = hit_combo.to_s + " "
  72.     self.contents.font.size = 36
  73.     self.contents.font.color = COMBOHIT_FONTCOLOR
  74.     text = $golpes_texto + hit_combo.to_s + " "
  75.    
  76.     self.contents.font.size = 22
  77.     self.contents.font.color.set(  0,   0,  0, 192)
  78.     self.contents.font.color = COMBOHIT_FONTCOLOR
  79.     self.contents.draw_text(64, 5, 300, 32, text, 0)
  80.     self.contents.draw_text(64, 9, 300, 64, $total_texto + total_damage.to_s, 0)
  81.  
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ? ??????
  85.   #--------------------------------------------------------------------------
  86.   def update
  87.     if @sliding_duration > 0
  88.       @sliding_duration -= 1
  89.       self.contents_opacity -= 32
  90.       self.x += 1
  91.       if @sliding_duration == 0
  92.         self.visible = false
  93.       end
  94.     elsif @show_duration > 0
  95.       @show_duration -= 1
  96.       if @show_duration == 0
  97.         @sliding_duration = 8
  98.       end
  99.     end
  100.   end
  101. end
  102.  
  103. #==============================================================================
  104. # ¦ Game_Battler
  105. #==============================================================================
  106. class Game_Battler
  107.   alias gb_wep_init initialize
  108.   def initialize
  109.     @total_damage = 0
  110.     gb_wep_init
  111.   end
  112.  
  113.   attr_accessor :total_damage
  114.   #--------------------------------------------------------------------------
  115.   # ? ??????????
  116.   #--------------------------------------------------------------------------
  117.   def combohit
  118.     @combohit = 0 if @combohit.nil?
  119.     @total_damage = 0 if @combohit.nil?
  120.     return @combohit
  121.   end
  122.  
  123.   def combohit_duration
  124.     @combohit_duration = 0 if @combohit_duration.nil?
  125.     return @combohit_duration
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ? ?????????
  129.   # moded to restart damage
  130.   #--------------------------------------------------------------------------  
  131.   def combohit_update
  132.     # ????
  133.     @combohit_duration = 0 if @combohit_duration.nil?
  134.    
  135.     # ????
  136.     if @combohit_duration > 0
  137.       @combohit_duration -= 1
  138.       # Here the damage is restarted
  139.       @combohit = 0 if @combohit_duration == 0
  140.       @total_damage = 0 if @combohit_duration == 0
  141.     end
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ? ???????????
  145.   # modificado para reiniciar damage count si hace falta
  146.   #--------------------------------------------------------------------------  
  147.   def combohit_count
  148.     # ????$damage_count = 0
  149.     @combohit = 0 if @combohit.nil?
  150.    
  151.     #$damage_count = 0 if @combohit.nil?
  152.  
  153.     # ????
  154.     @combohit += 1
  155.     @combohit_duration = XRXS_BP19::COMBOHIT_DURATION
  156.    
  157.    
  158.     unless @motion.nil?
  159.     #  # ??FMBS??
  160.       @combohit_duration = @motion.knock_back_duration
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ? ??????????
  165.   # modificado para que reincie el daño total
  166.   #--------------------------------------------------------------------------  
  167.   def combohit_clear
  168.     @combohit = nil
  169.     @combohit_duration = nil
  170.     #$damage_count = 0
  171.     @total_damage = 0
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ? ?????????
  175.   # moded to add damage to damage total
  176.   #--------------------------------------------------------------------------
  177.   alias xrxs_bp19_attack_effect attack_effect
  178.   def attack_effect(attacker)
  179.     # ????
  180.     bool = xrxs_bp19_attack_effect(attacker)
  181.     # ?????( ???? & ?????? )
  182.     if bool and self.damage.to_i > 0
  183.       # ?????
  184.       add_damage   = self.damage * ([self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)/100
  185.       self.hp     -= add_damage
  186.       self.damage += add_damage
  187.       # ??????+1
  188.       self.combohit_count
  189.       # Add to total damage
  190.       @total_damage += self.damage.to_i
  191.     end
  192.     return bool
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ? ????????
  196.   # moded to add damage to damage total
  197.   #--------------------------------------------------------------------------
  198.   alias xrxs_bp19_skill_effect skill_effect
  199.   def skill_effect(user, skill)
  200.     # ?????????????
  201.     if skill.power <= 0
  202.       # ????
  203.       return xrxs_bp19_skill_effect(user, skill)
  204.     end
  205.     # ?????( ????????? )
  206.     skill = skill.dup
  207.     skill.power = skill.power * (100 + [self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)/100
  208.     # ????
  209.     bool = xrxs_bp19_skill_effect(user, skill)
  210.     #p bool
  211.     # ?????( ???? & ?????? )
  212.     if bool and self.damage.to_i > 0
  213.       # ??????+1
  214.       self.combohit_count
  215.       # Add to total damage
  216.       @total_damage += self.damage.to_i
  217.     end
  218.     return bool
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ? ?????????
  222.   # moded to add damage to damage total
  223.   #--------------------------------------------------------------------------
  224.   alias xrxs_bp19_item_effect item_effect
  225.   def item_effect(item)
  226.     # ??????????????
  227.     unless (item.recover_hp < 0 or item.recover_hp_rate  < 0)
  228.       # ????
  229.       return xrxs_bp19_item_effect(item)
  230.     end
  231.     # ??
  232.     item = item.dup
  233.     # ?????
  234.     rate = (100 + [self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)
  235.     item.recover_hp      = item.recover_hp      * rate / 100
  236.     item.recover_hp_rate = item.recover_hp_rate * rate / 100
  237.     # ????
  238.     bool = xrxs_bp19_item_effect(item)
  239.     # ?????( ???? & ?????? )
  240.     if bool and self.damage.to_i > 0
  241.       # ??????+1
  242.       self.combohit_count
  243.       # Add to total damage
  244.       @total_damage += self.damage.to_i
  245.     end
  246.     return bool
  247.   end
  248. end
  249. #==============================================================================
  250. # ¦ Scene_Battle
  251. #==============================================================================
  252. class Scene_Battle
  253.   #--------------------------------------------------------------------------
  254.   # ? ?????
  255.   #--------------------------------------------------------------------------
  256.   alias xrxs_bp19_main main
  257.   def main
  258.     # ??????????????
  259.     @combohit_window = Window_ComboHit.new
  260.     # ????
  261.     xrxs_bp19_main
  262.     # ????????
  263.     @combohit_window.dispose
  264.     # ??????
  265.     $game_party.actors.each {|actor| actor.combohit_clear}
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ? ??????
  269.   #--------------------------------------------------------------------------
  270.   alias xrxs_bp19_update update
  271.   def update
  272.     # ??????
  273.     @combohit_window.update
  274.     $game_party.actors.each {|actor| actor.combohit_update}
  275.     $game_troop.enemies.each{|enemy| enemy.combohit_update}
  276.     # ????
  277.     xrxs_bp19_update
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ? ?????? (??????? ???? 5 : ??????)
  281.   # modificado para que ponga la X del combohit de forma configurada
  282.   #--------------------------------------------------------------------------
  283.   alias xrxs_bp19_update_phase4_step5 update_phase4_step5
  284.   def update_phase4_step5
  285.     # ????
  286.     xrxs_bp19_update_phase4_step5
  287.     # ?????????????????
  288.     max = 0
  289.     hit_target = nil
  290.     for target in @target_battlers
  291.       if target.combohit > max
  292.         max = target.combohit
  293.         hit_target = target
  294.       end
  295.     end
  296.     # ????? 2 ??????????????????
  297.     if max >= 2 and !hit_target.nil?
  298.       # When target is enemy, window to right
  299.       # When target is actor, window to left
  300.       @combohit_window.x = hit_target.is_a?(Game_Enemy) ? $window_x : $window_actor_x
  301.       @combohit_window.refresh(max, hit_target.combohit_duration, hit_target.total_damage)
  302.     end
  303.   end
  304. end
Advertisement
Add Comment
Please, Sign In to add comment