Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with sprites in battle

Queed

Member

Ok, so I have the BOF battle system right? I need a script that will overlay another spirte sheet of a weapon overtop of each character depending on what weapon they have equipped. This may be hard or easy I don't really know but any help would be much appreaciated. Here's the code for the sprite part of it:

Code:
#==============================================================================
# â–  Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
# スプライトの状態を自動的に変化させます。
#==============================================================================

class Sprite_Battler < Animated_Sprite
 #--------------------------------------------------------------------------
 # ● 公開インスタンス変数
 #--------------------------------------------------------------------------
 attr_accessor :battler                  # バトラー
 attr_accessor :frame_width
 #--------------------------------------------------------------------------
 # ● オブジェクト初期化
 #     viewport : ビューポート
 #     battler  : バトラー (Game_Battler)
 #--------------------------------------------------------------------------
 def initialize(viewport, battler = nil)
   super(viewport)
   @battler = battler
   @battler_visible = false
   @dead = false
   #aqui se define el tama?o por cada cuadro q hace la animacion del personaje,
   #puedes apreciarlo mas claramente viendo el archivo del personaje
   @frame_width, @frame_height = 160, 160
   @frames = 6
   @enemy_frames = 6
   @enemy_poses = 5
   @delay = 4
   @battler.is_a?(Game_Enemy) ? enemy_pose(0) : pose(0)
 end
 #--------------------------------------------------------------------------
 # ● 解放
 #--------------------------------------------------------------------------
 def dispose
   if self.bitmap != nil
     self.bitmap.dispose
   end
   super
 end
 #--------------------------------------------------------------------------
 # - Poses para los personajes (hero)
 #   number : pose' number
 #--------------------------------------------------------------------------
 def pose(number)
   case number
   when 0  # Normal stance, loops
     change(@frames, @delay, 0, 0, 0)
   when 1  # Attack, no loop
     change(@frames, @delay, 0, @frame_height, 0, true)
   when 2 # Skill, loops
     change(@frames, @delay, 0, @frame_height * 2)
   when 3 # Hurt, loops
     change(@frames, @delay, 0, @frame_height * 3)
   when 4 # Defend, loops
     change(@frames, @delay, 0, @frame_height * 4)
   when 5 # Death, loops
     change(@frames, @delay, 0, @frame_height * 5)
   when 6 # Victory, loops
     change(@frames, @delay, 0, @frame_height * 2)
   when 7 # Walk, loops
     change(@frames, @delay, 0, @frame_height * 6)
   when 8 # Item, no loop
     change(@frames, @delay, 0, @frame_height * 2, 0, true)
   #when 9
   # change(@frames, @delay, 0, @frame_height * 9)
   # ...etc.
   else
     change(@frames, @delay, 0, 0, 0)
   end
 end
 
 #--------------------------------------------------------------------------
 # - Poses para los enemigos (en caso de q sea animado)
 #   number : pose' number
 #--------------------------------------------------------------------------
 def enemy_pose(number)
   return unless $game_system.animated_enemy
   case number
   when 0  # Normal stance, loops
     change(@enemy_frames, @delay, 0, 0, 0)
   when 1  # Attack, no loop
     change(@enemy_frames, @delay, 0, @frame_height, 0, true)
   when 2 # Skill, loops
     change(@enemy_frames, @delay, 0, @frame_height * 2)
   when 3 # Hurt, loops
     change(@enemy_frames, @delay, 0, @frame_height * 3, 0, true)
   when 4
   change(@enemy_frames, @delay, 0, @frame_height * 4, 0, true)
   # ...etc.
   else
     change(@enemy_frames, @delay, 0, 0, 0)
   end
 end
 
 #--------------------------------------------------------------------------
 # ● フレーム更新
 #--------------------------------------------------------------------------
 def update
   super
   # バトラーが nil の場合
   if @battler == nil
     self.bitmap = nil
     loop_animation(nil)
     return
   end
   # ファイル名か色相が現在のものと異なる場合
   if @battler.battler_name != @battler_name or
      @battler.battler_hue != @battler_hue
     # ビットマップを取得、設定
     @battler_name = @battler.battler_name
     @battler_hue = @battler.battler_hue
     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
     @width = bitmap.width
     @height = bitmap.height
     self.ox = @frame_width / 2
     self.oy = @frame_height
     if @battler.is_a?(Game_Enemy) and $game_system.animated_enemy
       @frame_width = self.bitmap.width / @enemy_frames
       @frame_height = self.bitmap.height / @enemy_poses
       self.ox = @frame_width / 2
       self.oy = @frame_height
       enemy_pose(0)
     elsif @battler.is_a?(Game_Enemy)
       @frame_width, @frame_height = bitmap.width, bitmap.height
       change
       self.ox = @width / 2
       self.oy = @height
     end
     # 戦闘不能または隠れ状態なら不透明度を 0 にする
     if @battler.dead? or @battler.hidden
       self.opacity = 0
     end
     self.x =  @battler.screen_x
     self.y =  @battler.screen_y
     self.z = @battler.screen_z
   end
   # アニメーション ID が現在のものと異なる場合
   if @battler.damage == nil and
      @battler.state_animation_id != @state_animation_id
     @state_animation_id = @battler.state_animation_id
     loop_animation($data_animations[@state_animation_id])
   end
   # 表示されるべきアクターの場合
   if @battler.is_a?(Game_Actor) and @battler_visible
     # メインフェーズでないときは不透明度をやや下げる
     if $game_temp.battle_main_phase
       self.opacity += 3 if self.opacity < 255
     else
       self.opacity -= 3 if self.opacity > 207
     end
   end
   # 明滅
   if @battler.blink
     blink_on
   else
     blink_off
   end
   # 不可視の場合
   unless @battler_visible
     # 出現
     if not @battler.hidden and not @battler.dead? and
        (@battler.damage == nil or @battler.damage_pop)
       appear
       @battler_visible = true
     end
     if not @battler.hidden and
        (@battler.damage == nil or @battler.damage_pop) and
        @battler.is_a?(Game_Actor)
       appear
       @battler_visible = true
     end
   end
   # 可視の場合
   if @battler_visible
     # 逃走
     if @battler.hidden
       $game_system.se_play($data_system.escape_se)
       escape
       @battler_visible = false
     end
     # 白フラッシュ
     if @battler.white_flash
       whiten
       @battler.white_flash = false
     end
     # アニメーション
     if @battler.animation_id != 0
       animation = $data_animations[@battler.animation_id]
       animation(animation, @battler.animation_hit)
       @battler.animation_id = 0
     end
     # ダメージ
     if @battler.damage_pop
       damage(@battler.damage, @battler.critical)
       @battler.damage = nil
       @battler.critical = false
       @battler.damage_pop = false
     end
     # コラプス
     if @battler.damage == nil and @battler.dead?
       if @battler.is_a?(Game_Enemy)
         $game_system.se_play($data_system.enemy_collapse_se)
         enemy_pose(4)
         @battler_visible = false
       else
         $game_system.se_play($data_system.actor_collapse_se) unless @dead
         @dead = true
         pose(5)
       end
     else
       @dead = false
     end
   end
   # スプライトの座標を設定
 end
end

All it would require is another sprite being displayed depending on the weapon name or ID or something. I really need this so thanks if you can help.

Just in case you have no idea what I'm talking about here's a picture lol...

http://img82.imageshack.us/img82/2928/char1hg6.png[/IMG]
My original charater sprite.

http://img50.imageshack.us/img50/9617/char2ye3.png[/IMG]
The weapon sprite that I will have.

http://img299.imageshack.us/img299/2531/char3ge0.png[/IMG]
What I want the final result to look like in battle. (2 serperate pictures overlapped)
 
I understand whole-heartedly what he wants and has been in my 'Considered Addons' list in my Animated Battlers topic. :yes: It is akin to what they apparently had in RM2K3 (if anyone actually used it :s ).

Nope... haven't figured it out yet either. O_o But it is akin to a 'Visual Equipment' script... but for (or including) battlers.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top