Advertisement
LiTTleDRAgo

[RGSS] Icon & Battler Graphic in Event

Oct 22nd, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.22 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # [Xp] Icon & Battler Graphic in Event
  3. # Version: 1.01
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #==============================================================================
  7. # ** Game_Character
  8. #------------------------------------------------------------------------------
  9. #  This class deals with events. It handles functions including event page
  10. # switching via condition determinants, and running parallel process events.
  11. # It's used within the Game_Map class.
  12. #==============================================================================
  13. class Game_Character
  14.   attr_accessor :graphic_ex
  15.   def icon_graphic(val) @character_name,@graphic_ex = '(Icon)', val end
  16.   def battler_graphic(val) @character_name,@graphic_ex = '(Battler)', val end
  17. end
  18.  
  19. #==============================================================================
  20. # ** Sprite_Character
  21. #------------------------------------------------------------------------------
  22. #  This sprite is used to display the character.It observes the Game_Character
  23. #  class and automatically changes sprite conditions.
  24. #==============================================================================
  25.  
  26. class Sprite_Character < RPG::Sprite
  27.   #--------------------------------------------------------------------------
  28.   # * Frame Update
  29.   #--------------------------------------------------------------------------
  30.   alias update_for_item_icon update
  31.   def update
  32.     super
  33.     if @character.character_name == '(Icon)' or
  34.       @character.character_name == '(Battler)'
  35.       if @tile_id != @character.tile_id or
  36.          @character_name != @character.character_name or
  37.          @character_hue != @character.character_hue
  38.         @tile_id = @character.tile_id
  39.         @character_name = @character.character_name
  40.         @character_hue = @character.character_hue
  41.         @icon_name = @character.graphic_ex
  42.         bit = @icon_name.nil? ? '' : @icon_name
  43.         if @character_name == '(Icon)'
  44.           self.bitmap = RPG::Cache.icon(bit)
  45.           self.src_rect.set(0, 0, 24, 24)
  46.           self.ox = 12
  47.           self.oy = 24
  48.         elsif @character_name == '(Battler)'
  49.           self.bitmap = RPG::Cache.battler(bit, @character_hue)
  50.           @width = bitmap.width
  51.           @height = bitmap.height
  52.           self.ox = @width / 2
  53.           self.oy = @height
  54.         end
  55.       end
  56.       update_for_icon_sprite
  57.     else
  58.       update_for_item_icon
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● Create Icon Sprite
  63.   #--------------------------------------------------------------------------
  64.   def update_for_icon_sprite
  65.     self.visible = (not @character.transparent)
  66.     self.x = @character.screen_x
  67.     self.y = @character.screen_y
  68.     self.z = @character.screen_z(24)
  69.     self.opacity = @character.opacity
  70.     self.blend_type = @character.blend_type
  71.     self.bush_depth = @character.bush_depth
  72.     if @character.animation_id != 0
  73.       animation = $data_animations[@character.animation_id]
  74.       animation(animation, true)
  75.       @character.animation_id = 0
  76.     end
  77.   end  
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement