Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. =begin
  2. #==============================================================================#
  3. #   AMN MOG - Battle Hud EX - States Addon
  4. #   Version   1.01
  5. #   Author:   AMoonlessNight
  6. #   Date:     22 Sep 2020
  7. #   Latest:   22 Sep 2020
  8. #==============================================================================#
  9. #   UPDATE LOG
  10. #------------------------------------------------------------------------------#
  11. # 22 Sep 2020 - created the script
  12. #==============================================================================#
  13. #   TERMS OF USE
  14. #------------------------------------------------------------------------------#
  15. # - Please credit AMoonlessNight or A-Moonless-Night
  16. # - Free for non-commercial use; contact for commercial use
  17. # - Follow the original terms and conditions of Moghunter's script
  18. # - If you would like to edit/adjust this script, please make edits as a new
  19. #   script (do not edit this script directly) and provide proper credit
  20. # - I'd love to see your game if you end up using one of my scripts
  21. #==============================================================================#
  22. #   Original script by Moghunter
  23. #   https://atelierrgss.wordpress.com/
  24. #==============================================================================#
  25.  
  26. This script is an addon for Moghunter's Battle Hud EX script. It makes it so
  27. that you can have states spaced out, instead of just showing one at a time. You
  28. can also set it so that states scroll through if there are more than the max
  29. number.
  30.  
  31. =end
  32.  
  33. module MOG_BATTLE_HUD_EX
  34. #==============================================================================
  35. # ** EDITABLE REGION BELOW
  36. #------------------------------------------------------------------------------
  37. #  Change the values in the area below to suit your needs.
  38. #==============================================================================
  39.  
  40.  
  41.   # Maximum number of states to show at once
  42.   STATES_MAX = 2
  43.  
  44.   # Spacing between states
  45.   STATES_SPACING = 4
  46.  
  47.   # Whether to scroll through if there are more states than STATES_MAX
  48.   STATES_SCROLL_IF_OVER_MAX = true
  49.   # NOTE: If you have STATES_SCROLLING_ANIMATION set to TRUE, then the states
  50.   # will scroll through smoothly. Otherwise, they will tick through each whole
  51.   # state icon.
  52.  
  53.   # Time to wait before switching states
  54.   STATES_WAIT_TIME = 30
  55.  
  56.  
  57. #==============================================================================
  58. # ** END OF EDITABLE REGION
  59. #------------------------------------------------------------------------------
  60. #  Please do not edit below this point unless you know what you are doing.
  61. #==============================================================================  
  62. end
  63.  
  64. class Battle_Hud_EX
  65.   STATE_ICON_SIZE = 24 + STATES_SPACING
  66.  
  67.   alias amn_mogbhs_bathudex_createstates  create_states
  68.   def create_states(viewport)
  69.     @max_states_size = [[STATES_MAX, 1].max, (Graphics.width / STATE_ICON_SIZE).floor].min
  70.     amn_mogbhs_bathudex_createstates(viewport)
  71.     if STATES_VISIBLE
  72.       @state_scroll_viewport = Viewport.new(@status.x, @status.y, STATE_ICON_SIZE * @max_states_size, 24)
  73.       @state_scroll_viewport.z = @status.z
  74.       @state_scroll_plane = Plane.new(@state_scroll_viewport)
  75.       @state_scroll_plane.z = @state_scroll_viewport.z
  76.     end
  77.   end
  78.  
  79.   alias amn_mogbhs_bathudex_refreshstates refresh_states
  80.   def refresh_states
  81.     amn_mogbhs_bathudex_refreshstates
  82.     @states_size = [STATE_ICON_SIZE * @status_size_real, 24].max
  83.     @state_scroll_viewport.rect.width = [@states_size, STATE_ICON_SIZE * @max_states_size].min
  84.     @actor_status.dispose
  85.     @actor_status = Bitmap.new(@states_size, 24)
  86.     @actor.states.reject{|s| HIDE_STATES_ID.include?(s.id)}.each_with_index do |s, i|
  87.       rect = Rect.new(s.icon_index % 16 * 24, s.icon_index / 16 * 24, 24, 24)
  88.       @actor_status.blt(STATE_ICON_SIZE * i, 0, @icon_image, rect)
  89.     end
  90.     @state_scroll_plane.bitmap = @actor_status
  91.     @state_scroll_plane.ox = 0
  92.   end
  93.    
  94.   def flow_states
  95.     return if @actor_status == nil
  96.     return unless @actor.states.size > 0
  97.     return unless @status_size_real > @max_states_size && STATES_SCROLL_IF_OVER_MAX
  98.     if STATES_SCROLLING_ANIMATION
  99.       @state_scroll_plane.ox += 1
  100.     else
  101.       @status_flow[1] += 1
  102.       if @status_flow[1] > STATES_WAIT_TIME
  103.         @status_flow[1] = 0
  104.         @state_scroll_plane.ox += STATE_ICON_SIZE
  105.       end
  106.     end
  107.   end
  108.  
  109.   alias amn_mogbhs_bathudex_disposestates dispose_states
  110.   def dispose_states
  111.     if @state_scroll_plane
  112.       @state_scroll_plane.bitmap.dispose if @state_scroll_plane.bitmap
  113.       @state_scroll_plane.dispose
  114.     end
  115.     @state_scroll_viewport.dispose if @state_scroll_viewport
  116.     amn_mogbhs_bathudex_disposestates
  117.   end
  118.  
  119.   alias amn_mogbhs_bathudex_updatestates  update_states
  120.   def update_states
  121.     amn_mogbhs_bathudex_updatestates
  122.     if @status && @state_scroll_plane.opacity != @status.opacity
  123.       @state_scroll_plane.opacity = @status.opacity
  124.     end
  125.   end
  126.  
  127. end