Advertisement
roninator2

Grilled paste - Display of remaining turns of state mod - no number

Dec 4th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.89 KB | None | 0 0
  1. =begin
  2. #==============================================================================
  3. [Name] Display of remaining turns of state + α
  4. [Author] Grilled paste
  5. [Distributor] Relaxing Maker miscellaneous goods
  6. http://mata-tuku.ldblog.jp/
  7. # ------------------------------------------------- -----------------------------
  8. [Change log]・2012/10/28 public
  9. ・2012/12/01 Bug fixes. Added "Hide state icon with display priority 0" function
  10. Modified by Roninator2 to change icon and not show number
  11. #==============================================================================
  12.  
  13. #------------------------------------------------------------------------------
  14. [Correspondence]
  15. ・ Only RGSS3 is possible
  16. #------------------------------------------------------------------------------
  17.  
  18. #------------------------------------------------------------------------------
  19. [function]
  20. -Only during battle, the number of remaining turns of state and ability change
  21. is displayed on the icon.
  22. -Hide the icon of the state where the display priority is 0.
  23. #------------------------------------------------------------------------------
  24.  
  25. #------------------------------------------------------------------------------
  26. [how to use]
  27. -There is no special operation. Just install this script and it will work.
  28. #------------------------------------------------------------------------------
  29.  
  30. [Redefined part]
  31. ・Window_Base の draw_actor_icons
  32. #------------------------------------------------------------------------------
  33. [○: New definition, ◎: Alias definition, ●: Redefinition]
  34. #------------------------------------------------------------------------------
  35. =end
  36.  
  37. module R2_State_Icon_Turns
  38.     Switch = 3 # switch used to change behavior from icon change to numbers.
  39.   # set to zero to disable.
  40.   # icon change is set to the number below
  41.   Added = 2
  42.   # the number is how many extra icons to use
  43.   # default = 3, Added = 3, inflicted = icon 5
  44. end
  45. #==============================================================================
  46. # ■ Game_BattlerBase
  47. #==============================================================================
  48. class Game_BattlerBase
  49.   #--------------------------------------------------------------------------
  50.   # ◎ Get the current state as an array of icon numbers
  51.   #--------------------------------------------------------------------------
  52.   alias yknr_ShowStatesTurnsGame_BattlerBase_state_icons :state_icons
  53.   def state_icons
  54.     states = self.states.select {|state| !state.priority.zero? }
  55.     yknr_ShowStatesTurnsGame_BattlerBase_state_icons
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ○ Get the current state as an array of the number of remaining turns
  59.   #--------------------------------------------------------------------------
  60.   def state_turns
  61.     turns = []
  62.     states.each do |s|
  63.       if !s.icon_index.zero?
  64.         is_turn = !s.auto_removal_timing.zero? && !s.priority.zero?
  65.         turn = is_turn ? @state_turns[s.id].truncate : -1
  66.         turns.push(turn)
  67.       end
  68.     end
  69.     turns
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ○ Get the current enhancement /
  73.   #   weakness in an array of the number of remaining turns
  74.   #--------------------------------------------------------------------------
  75.   def buff_turns
  76.     turns = []
  77.     @buffs.each_with_index do |lv, i|
  78.       turns.push(@buff_turns[i].truncate) if !lv.zero?
  79.     end
  80.     turns
  81.   end
  82. end
  83.  
  84. #==============================================================================
  85. # ■ Window_Base
  86. #==============================================================================
  87. class Window_Base < Window
  88.   #--------------------------------------------------------------------------
  89.   # ● Draw state and enhancement / weakness icons
  90.   #--------------------------------------------------------------------------
  91.   def draw_actor_icons(actor, x, y, width = 96)
  92.     last_font = contents.font.clone
  93.     contents.font.size = 19
  94.     contents.font.bold = true
  95.     contents.font.color = crisis_color
  96.     icons = []
  97.     turns = []
  98.     icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
  99.         if $game_switches[R2_State_Icon_Turns::Switch] == true
  100.       turns = actor.state_turns[0, width / 24]
  101.             turns.each_with_index do |n, i| # turns, array index
  102.         if n >= R2_State_Icon_Turns::Added
  103.           turns[i] = R2_State_Icon_Turns::Added
  104.         end
  105.             end
  106.       icons.each_with_index do |n, i| # icon, array index
  107.         draw_icon(n + turns[i], x + 24 * i, y)
  108.       end
  109.         else
  110.       turns = (actor.state_turns + actor.buff_turns)[0, width / 24]
  111.       icons.each_with_index do |n, i|
  112.         draw_icon(n, x + 24 * i, y)
  113.         if $game_party.in_battle && turns[i] != -1
  114.           draw_text(x + 24 * i, y, 24, line_height, turns[i] + 1, 2)
  115.         end
  116.       end
  117.     end
  118.     contents.font = last_font
  119.   end
  120. end
  121.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement