Advertisement
roninator2

Cozziekuns Earthbound-ish Odometer roll - mod

Dec 7th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.54 KB | None | 0 0
  1. #==============================================================================
  2. # ** Earthbound-Ish Odometer Roll
  3. #------------------------------------------------------------------------------
  4. # Version: 1.2
  5. # Author: cozziekuns
  6. # fix by roninator2
  7. # Date: February 17, 2013
  8. #==============================================================================
  9. # Description:
  10. #------------------------------------------------------------------------------
  11. # This script attempts to emulate the battle system of the Earthbound/Mother
  12. # series; most notably Earthbound and Earthbound 2 (Mother 2 and 3). This
  13. # certain addon addresses the infamous HP/MP scrolling system that made battles
  14. # that much more intense.
  15. #==============================================================================
  16. # Instructions:
  17. #------------------------------------------------------------------------------
  18. # Paste this script into its own slot in the Script Editor, above Main but
  19. # below Materials. Edit the modules to your liking.
  20. #==============================================================================
  21. # Graphics:
  22. #------------------------------------------------------------------------------
  23. # You must have two Odometer pictures in your Graphics/System folder. One of
  24. # them must be named "Odometer_HP", and the other one must be named
  25. # "Odometer_MP". Obviously, they represent the odometer for HP and MP values,
  26. # respectively
  27. #==============================================================================
  28.  
  29. #==============================================================================
  30. # ** Cozziekuns
  31. #==============================================================================
  32.  
  33. module Cozziekuns
  34.  
  35.   module Earthboundish
  36.    
  37.     Odometer_Roll_Speed = 4 # Smaller speeds are faster than larger speeds.
  38.     Four_Digits = true
  39.   end
  40.  
  41. end
  42.  
  43. include Cozziekuns
  44.  
  45. #==============================================================================
  46. # ** Game_Actor
  47. #==============================================================================
  48.  
  49. class Game_Actor
  50.  
  51.   attr_accessor :odometer_hp
  52.   attr_accessor :odometer_mp
  53.   attr_accessor :odometer_tp
  54.  
  55.   alias coz_ebisohd_gmactr_setup setup
  56.   def setup(actor_id, *args)
  57.     coz_ebisohd_gmactr_setup(actor_id, *args)
  58.     @odometer_hp = 0
  59.     @odometer_mp = 0
  60.     @odometer_tp = 0
  61.   end
  62.  
  63.   alias coz_ebishod_gmactr_execute_damage execute_damage
  64.   def execute_damage(user, *args)
  65.     if $game_party.in_battle
  66.       on_damage(@result.hp_damage) if @result.hp_damage > 0
  67.       @odometer_hp += @result.hp_damage
  68.       @odometer_mp += @result.mp_damage
  69.       user.hp += @result.hp_drain
  70.       user.mp += @result.mp_drain
  71.     else
  72.       coz_ebishod_gmactr_execute_damage(user, *args)
  73.     end
  74.   end
  75.  
  76.   [:hp, :mp].each { |stat|
  77.     alias_method("coz_ebishod_gmactr_item_effect_recover_#{stat}".to_sym, "item_effect_recover_#{stat}".to_sym)
  78.     define_method("item_effect_recover_#{stat}".to_sym) { |user, item, effect|
  79.       if $game_party.in_battle
  80.         value = (send("m#{stat}".to_sym) * effect.value1 + effect.value2) * rec
  81.         value *= user.pha if item.is_a?(RPG::Item)
  82.         value = value.to_i
  83.         @result.send("#{stat}_damage=".to_sym, @result.send("#{stat}_damage".to_sym) - value)
  84.         @result.success = true
  85.         send("odometer_#{stat}=".to_sym, send("odometer_#{stat}".to_sym) - value)
  86.       else
  87.         send("coz_ebishod_gmactr_item_effect_recover_#{stat}".to_sym, user, item, effect)        
  88.       end
  89.     }
  90.   }
  91.  
  92. end
  93.  
  94. #==============================================================================
  95. # ** Game_Enemy
  96. #==============================================================================
  97.  
  98. class Game_Enemy
  99.  
  100.   def execute_damage(user)
  101.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  102.     self.hp -= @result.hp_damage
  103.     self.mp -= @result.mp_damage
  104.     user.odometer_hp -= @result.hp_drain
  105.     user.odometer_mp -= @result.mp_drain
  106.   end
  107.  
  108. end
  109.  
  110. #==============================================================================
  111. # ** Window_BattleStatus
  112. #==============================================================================
  113.  
  114. class Window_BattleStatus
  115.  
  116.   def refresh_hpmp(actor, index)
  117.     rect = item_rect(index)
  118.     if gauge_area_rect(index) == item_rect(index)
  119.       rect.y += line_height * 2
  120.       rect.height -= line_height * 2
  121.       contents.clear_rect(rect)
  122.     else
  123.       contents.clear_rect(gauge_area_rect(index))
  124.     end
  125.     draw_gauge_area(gauge_area_rect(index), actor)
  126.   end
  127.  
  128.   [:hp, :mp, :tp].each { |stat|
  129.     define_method("draw_actor_#{stat}".to_sym) { |actor, x, y, width|
  130.       change_color(system_color)
  131.       draw_text(x, y, 30, line_height, Vocab.send("#{stat}_a"))
  132.       od_x = x + contents.text_size(Vocab.send("#{stat}_a")).width + 4
  133.       actor_hp = actor.send("#{stat}".to_sym).to_i
  134.       actor_od_hp = actor.send("odometer_#{stat}".to_sym)
  135.       draw_odometer(od_x, y, stat, actor_hp, actor_od_hp)
  136.     }
  137.   }
  138.  
  139.   if Cozziekuns::Earthboundish::Four_Digits
  140.   def draw_odometer(x, y, type, value, od_value)
  141.     bitmap = Cache.system("Odometer_#{type.upcase}")
  142.     places = [1000, 100, 10, 1]
  143.     od_ary = value.to_s.split("").collect { |str| str.to_i }
  144.     (4 - od_ary.size).times { od_ary.unshift(0) }
  145.     od_ary.each_index { |i|
  146.       src_y = (9 - od_ary[i]) * 20
  147.       if (od_ary.join.to_i) % places[i] == 0 and od_value != 0
  148.         src_y += 20 / Earthboundish::Odometer_Roll_Speed * (Graphics.frame_count % Earthboundish::Odometer_Roll_Speed)
  149.       end
  150.       contents.blt(x + i * 24, y + 2, bitmap, Rect.new(0, src_y, 24, 20))
  151.     }
  152.   end
  153.   else
  154.   def draw_odometer(x, y, type, value, od_value)
  155.     bitmap = Cache.system("Odometer_#{type.upcase}")
  156.     places = [100, 10, 1]
  157.     od_ary = value.to_s.split("").collect { |str| str.to_i }
  158.     (3 - od_ary.size).times { od_ary.unshift(0) }
  159.     od_ary.each_index { |i|
  160.       src_y = (9 - od_ary[i]) * 20
  161.       if (od_ary.join.to_i) % places[i] == 0 and od_value != 0
  162.         src_y += 20 / Earthboundish::Odometer_Roll_Speed * (Graphics.frame_count % Earthboundish::Odometer_Roll_Speed)
  163.       end
  164.       contents.blt(x + i * 24, y + 2, bitmap, Rect.new(0, src_y, 24, 20))
  165.     }
  166.   end
  167.   end
  168.  
  169. end
  170.  
  171. #==============================================================================
  172. # ** Scene_Battle
  173. #==============================================================================
  174.  
  175. class Scene_Battle
  176.  
  177.   alias coz_ebishod_scbtl_update_basic update_basic
  178.   def update_basic(*args)
  179.     coz_ebishod_scbtl_update_basic(*args)
  180.     update_odometer
  181.   end
  182.  
  183.   def update_odometer
  184.     $game_party.members.each { |actor|
  185.       if actor.odometer_hp != 0 or actor.odometer_mp != 0
  186.         if actor.odometer_hp != 0 and Graphics.frame_count % Earthboundish::Odometer_Roll_Speed == 0
  187.           damage = actor.odometer_hp > 0 ? 1 : - 1
  188.           actor.hp -= damage
  189.           actor.odometer_hp -= damage
  190.         end
  191.         if actor.odometer_mp != 0 and Graphics.frame_count % Earthboundish::Odometer_Roll_Speed == 0
  192.           damage = actor.odometer_mp > 0 ? 1 : - 1
  193.           actor.mp -= damage
  194.           actor.odometer_mp -= damage
  195.         end
  196.         @status_window.refresh_hpmp(actor, actor.index)
  197.         if actor.hp == 0 or (actor.hp == actor.mhp) and damage != nil
  198.           damage = 0
  199.           actor.odometer_hp = 0
  200.         end
  201.         if actor.mp == 0 or (actor.mp == actor.mmp) and damage != nil
  202.           damage = 0
  203.           actor.odometer_mp = 0
  204.         end
  205.         @status_window.refresh_hpmp(actor, actor.index)
  206.       end
  207.     }
  208.   end
  209.  
  210. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement