Vlue

Actor Sprites

Apr 20th, 2014
2,863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.13 KB | None | 0 0
  1. #Actor Sprites v1.0c
  2. #----------#
  3. #Features: Shows Actor Sprites in battle. Nothing fancy.
  4. #
  5. #Usage:    Plug and play
  6. #
  7. #----------#
  8. #-- Script by: V.M of D.T
  9. #
  10. #- Questions or comments can be:
  11. #    given by email: [email protected]
  12. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  13. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  14. #
  15. #--- Free to use in any project, commercial or non-commercial, with credit given
  16. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  17.  
  18. #x,y value for each party member
  19. ACTOR_FORMATION = {
  20.   0 => [350,200],
  21.   1 => [370,230],
  22.   2 => [390,260],
  23.   3 => [410,290]
  24. }
  25.  
  26. class Game_Actor
  27.   def use_sprite?
  28.     true
  29.   end
  30.   def screen_x
  31.     ACTOR_FORMATION[self.index] ? ACTOR_FORMATION[self.index][0] : 0
  32.   end
  33.   def screen_y
  34.     ACTOR_FORMATION[self.index] ? ACTOR_FORMATION[self.index][1] : 0
  35.   end
  36.   def screen_z
  37.     200
  38.   end
  39. end
  40.  
  41. class Spriteset_Battle
  42.   def create_actors
  43.     @actor_sprites = []
  44.     $game_party.battle_members.each do |actor|
  45.       @actor_sprites.push(Sprite_Battler.new(@viewport1, actor))
  46.     end
  47.   end
  48.   def update_actors
  49.     @actor_sprites.each {|sprite| sprite.update }
  50.   end
  51. end
  52.  
  53. class Sprite_Battler
  54.   alias sprite_update_bitmap update_bitmap
  55.   def update_bitmap
  56.     return sprite_update_bitmap if @battler.is_a?(Game_Enemy)
  57.     if @char_bitmap.nil?
  58.       return unless @battler.character_name
  59.       new_bitmap = Cache.character(@battler.character_name)
  60.       if @battler.character_name.include?("$")
  61.         @char_bitmap = Bitmap.new(new_bitmap.width,new_bitmap.height)
  62.         @char_bitmap.blt(0,0,new_bitmap,Rect.new(0,0,new_bitmap.width,new_bitmap.height))
  63.         self.bitmap = Bitmap.new(new_bitmap.width/3,new_bitmap.height/4)
  64.         self.bitmap.blt(0,0,@char_bitmap,Rect.new(0,new_bitmap.height/4,new_bitmap.width/3,new_bitmap.height/4))
  65.       else
  66.         @char_bitmap = Bitmap.new(new_bitmap.width/4,new_bitmap.height/2)
  67.         xx = @battler.character_index % 4 * new_bitmap.width/4
  68.         yy = @battler.character_index / 4 * new_bitmap.height/2
  69.         @char_bitmap.blt(0,0,new_bitmap,Rect.new(xx,yy,new_bitmap.width/4,new_bitmap.height/2))
  70.         self.bitmap = Bitmap.new(new_bitmap.width/12,new_bitmap.height/8)
  71.         self.bitmap.blt(0,0,@char_bitmap,Rect.new(0,new_bitmap.height/8,new_bitmap.width/12,new_bitmap.height/8))
  72.       end    
  73.       init_visibility
  74.     end
  75.     @timer = 0 unless @timer
  76.     if Graphics.frame_count % 20 == 0
  77.       @timer += 1
  78.       @timer = 0 if @timer == 3
  79.     end
  80.     self.bitmap.clear
  81.     self.bitmap.blt(0,0,@char_bitmap,Rect.new(@char_bitmap.width/3 * @timer,@char_bitmap.height/4,@char_bitmap.width/3,@char_bitmap.height/4))
  82.   end
  83. end
  84.  
  85. class Scene_Battle
  86.     def show_attack_animation(targets)
  87.     if @subject.actor?
  88.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  89.       show_normal_animation(targets, @subject.atk_animation_id2, true)
  90.     else
  91.       Sound.play_enemy_attack
  92.       show_normal_animation(targets, 1, false)
  93.       abs_wait_short
  94.     end
  95.   end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment