Advertisement
TheSixth

Tall Character Sprite Display Fix for Yanfly's Party System

Nov 4th, 2017
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.78 KB | None | 0 0
  1. =begin
  2.  
  3. Yanfly's Party System has a little issue with displaying taller sprites in the
  4. actor list window. This little snippet aims to provide a fix for that.
  5.  
  6. Made by: Sixth
  7.  
  8. Install this script below Yanfly's Party System script!
  9.  
  10. Note that this script renders the ACTOR_Y_BUFFER setting in Yanfly's script
  11. unusable! Instead of that static setting, this script provides more dynamic
  12. ways of setting your character sprite up for the actor list window.
  13.  
  14. =end
  15.  
  16. module PSys_Fix
  17.   #-----------------------------------------------------------------------------
  18.   # This many pixels will be added to the drawn portion of the character sprite.
  19.   # Use this to move the drawn area up/down.
  20.   # Negative values will move the drawing area up, while positive values will
  21.   # move it down.
  22.   # Add any custom settings here if needed.
  23.   #
  24.   # Format 1 -> ["filename",character_index] => value,
  25.   # Format 2 -> "filename" => value,
  26.   #
  27.   # Format 1 will apply the settings only to the specified character index,
  28.   # while Format 2 will apply the setting to the whole sprite-sheet.
  29.   #
  30.   # Any images missing a setting here will load the :default setting instead!
  31.   #-----------------------------------------------------------------------------
  32.   AddY = {
  33.     :default => 0, # Default setting, do NOT remove!
  34.     ["Riding",4] => 16,
  35.     ["People3",4] => 2,
  36.     # <-- Add more settings here if needed!
  37.   }
  38.  
  39.   #-----------------------------------------------------------------------------
  40.   # This will be the height of the drawn portion of the character sprite.
  41.   # Can not exceed the item_height of the window (which is usually 24 by
  42.   # default)! Even if you set it to higher here, it will be reset to the maximum
  43.   # amount (which is the item_height of the window).
  44.   # Add any custom settings here if needed.
  45.   #
  46.   # Format 1 -> ["filename",character_index] => value,
  47.   # Format 2 -> "filename" => value,
  48.   #
  49.   # Format 1 will apply the setting only to the specified character index,
  50.   # while Format 2 will apply the setting to the whole sprite-sheet.
  51.   #
  52.   # Any images missing a setting here will load the :default setting instead!
  53.   #-----------------------------------------------------------------------------
  54.   Heights = {
  55.     :default => 22, # Default setting, do NOT remove!
  56.     # <-- Add more settings here if needed!
  57.   }
  58.  
  59. end
  60.  
  61. # End of settings! O_O
  62.  
  63. class Game_Actor < Game_Battler
  64.  
  65.   def psys_addy
  66.     if PSys_Fix::AddY[character_name]
  67.       return PSys_Fix::AddY[character_name]
  68.     elsif PSys_Fix::AddY[[character_name,character_index]]
  69.       return PSys_Fix::AddY[[character_name,character_index]]
  70.     else
  71.       return PSys_Fix::AddY[:default]
  72.     end
  73.   end
  74.  
  75.   def psys_height
  76.     if PSys_Fix::Heights[character_name]
  77.       return PSys_Fix::Heights[character_name]
  78.     elsif PSys_Fix::Heights[[character_name,character_index]]
  79.       return PSys_Fix::Heights[[character_name,character_index]]
  80.     else
  81.       return PSys_Fix::Heights[:default]
  82.     end
  83.   end
  84.  
  85. end
  86.  
  87. class Window_PartyList < Window_Selectable
  88.  
  89.   def draw_actor(actor, rect)
  90.     bitmap = Cache.character(actor.character_name)
  91.     sign = actor.character_name[/^[\!\$]./]
  92.     if sign && sign.include?('$')
  93.       cw = bitmap.width / 3
  94.       ch = bitmap.height / 4
  95.     else
  96.       cw = bitmap.width / 12
  97.       ch = bitmap.height / 8
  98.     end
  99.     n = actor.character_index
  100.     hh = [ch,actor.psys_height].min
  101.     cx = (n%4*3+1)*cw
  102.     cy = (n/4*4)*ch + actor.psys_addy
  103.     src_rect = Rect.new(cx, cy, cw, hh)
  104.     xx = rect.x + 16 - cw / 2
  105.     yy = rect.y + ((rect.height - hh) / 2)
  106.     contents.blt(xx, yy, bitmap, src_rect)
  107.     change_color(list_colour(actor), enabled?(actor))
  108.     draw_text(rect.x+32, rect.y, rect.width-32, line_height, actor.name)
  109.   end
  110.  
  111. end
  112. # End of script! O_O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement