Advertisement
TheSixth

Simple Face HUD

Jul 7th, 2017
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.59 KB | None | 0 0
  1. =begin
  2.  
  3. - Simple Face HUD
  4.   Made by: Sixth
  5.  
  6. A simple script to show the face of the party leader on the map scene.
  7. Check out the setting area if you want, but other than that, it's pretty much
  8. a plug-and-play script.
  9.  
  10. Put this script between Materials and Main.
  11.  
  12. Terms of use:
  13.  * Free to use for whatever purposes you want.
  14.  * Credit me (Sixth) in your game, pretty please! :P
  15.  * Posting modified versions of this script is allowed as long as you notice me
  16.    about it with a link to it!
  17.  
  18. =end
  19.  
  20. module FacePic
  21.  
  22.   # Some self-explanatory settings below...
  23.   Settings = {
  24.     :pos => [8,8],      # X and Y position
  25.     :opa => 255,        # Opacity level
  26.     :z => 200,          # Z level
  27.     :zoom => [0.8,0.8], # Zoom level (1.0 = original size)
  28.     :switch => 0,       # 0 = Always show, >0 = Shown when switch is ON
  29.   }
  30.  
  31. end
  32.  
  33. # End of setting area! Don't change anything below unless you know... and so on.
  34.  
  35. class FaceHUD
  36.  
  37.   def initialize(data,view=nil)
  38.     @data = data
  39.     @view = view
  40.     @id = $game_party.leader.id
  41.     init_pic
  42.     update_vis if @data[:switch] > 0
  43.   end
  44.  
  45.   def init_pic
  46.     @pic = Sprite.new(@view)
  47.     @pic.x = @data[:pos][0]
  48.     @pic.y = @data[:pos][1]
  49.     @pic.z = @data[:z]
  50.     @pic.opacity = @data[:opa]
  51.     @pic.zoom_x = @data[:zoom][0]
  52.     @pic.zoom_y = @data[:zoom][1]
  53.     refresh
  54.   end
  55.  
  56.   def refresh
  57.     @pic.bitmap.dispose if @pic.bitmap
  58.     @pic.bitmap = Cache.face($game_actors[@id].face_name).clone
  59.     @pic.src_rect.width = @pic.src_rect.height = 96
  60.     index = $game_actors[@id].face_index
  61.     @pic.src_rect.x = index % 4 * 96
  62.     @pic.src_rect.y = index / 4 * 96
  63.   end
  64.    
  65.   def update
  66.     update_vis if @data[:switch] > 0 && @vis != $game_switches[@data[:switch]]
  67.     update_face if @id != $game_party.leader.id
  68.   end
  69.  
  70.   def update_vis
  71.     @vis = $game_switches[@data[:switch]]
  72.     @pic.visible = @vis
  73.   end
  74.  
  75.   def update_face
  76.     @id = $game_party.leader.id
  77.     refresh
  78.   end
  79.  
  80.   def disposed?
  81.     return @disposed
  82.   end
  83.  
  84.   def dispose
  85.     @pic.bitmap.dispose
  86.     @pic.dispose
  87.     @disposed = true
  88.   end
  89.  
  90. end
  91.  
  92. class Spriteset_Map
  93.  
  94.   alias add_face_hud0273 create_timer
  95.   def create_timer
  96.     add_face_hud0273
  97.     init_face_hud
  98.   end
  99.  
  100.   def init_face_hud
  101.     @face_hud = FaceHUD.new(FacePic::Settings,@viewport2)
  102.   end
  103.  
  104.   alias upd_face_hud0071 update_timer
  105.   def update_timer
  106.     upd_face_hud0071
  107.     @face_hud.update
  108.   end
  109.  
  110.   alias disp_face_hud9665 dispose_timer
  111.   def dispose_timer
  112.     disp_face_hud9665
  113.     @face_hud.dispose
  114.   end
  115.  
  116. end
  117.  
  118. # End of script! Yay!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement