전투 배틀러에서 캐릭터가 착용하고 있는 무기에 따라 배틀러 그래픽 무기도 바뀌는 스크립트입니다. 사용법 : 배틀러에 사용할 무기 그래픽을 준비합니다. {Battler_Name} + "-" + {Weapon_Name} + ".png" 호출합니다. Sprite_Battler with 교체해주세요 #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ # バトラ?表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの?態を自動的に?化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス?? #-------------------------------------------------------------------------- attr_accessor :battler # バトラ? #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビュ?ポ?ト # battler : バトラ? (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @weapon = Sprite_Weapon.new(viewport, battler) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end @weapon.dispose super end #-------------------------------------------------------------------------- # ● フレ?ム更新 #-------------------------------------------------------------------------- def update super @weapon.battler = @battler @weapon.update # バトラ?が 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 = @width / 2 self.oy = @height @weapon.draw_weapon # ??不能または?れ?態なら不透明度を 0 にする if @battler.dead? or @battler.hidden self.opacity = 0 @weapon.hide end 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 if self.opacity < 255 self.opacity += 3 @weapon.plus_opacity end else if self.opacity > 207 self.opacity -= 3 @weapon.minus_opacity end end end # 明滅 if @battler.blink blink_on @weapon.turn_blink_on else blink_off @weapon.turn_blink_off end # 不可視の場合 unless @battler_visible # 出現 if not @battler.hidden and not @battler.dead? and (@battler.damage == nil or @battler.damage_pop) appear @weapon.make_appear @battler_visible = true end end # 可視の場合 if @battler_visible # 逃走 if @battler.hidden $game_system.se_play($data_system.escape_se) escape @weapon.make_escape @battler_visible = false end # 白フラッシュ if @battler.white_flash whiten @weapon.make_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) else $game_system.se_play($data_system.actor_collapse_se) end collapse @weapon.make_collapse @battler_visible = false end end # スプライトの座標を設定 self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z @weapon.align end end class Sprite_Weapon... 더해주세요 #============================================================================== # ■ Sprite_Weapon #------------------------------------------------------------------------------ # バトラ?表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの?態を自動的に?化させます。 #============================================================================== class Sprite_Weapon < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス?? #-------------------------------------------------------------------------- attr_accessor :battler # バトラ? #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビュ?ポ?ト # battler : バトラ? (Game_Battler) #-------------------------------------------------------------------------- attr_reader :has_weapon def initialize(viewport, battler = nil) super(viewport) @battler = battler if @battler.is_a?(Game_Actor) @weapon_id = @battler.weapon_id else @weapon_id = nil end end def update super if @battler == nil self.bitmap = nil return end if @battler.weapon_id != @weapon_id @weapon_id = @battler.weapon_id unless @battler.is_a?(Game_Actor) @has_weapon = false return end @weapon_name = build_weapon_name unless File.exists?("./Graphics/Battlers/" + @weapon_name + ".png") @has_weapon = false return end @has_weapon = true end end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end def draw_weapon unless @has_weapon return end @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@weapon_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height end def hide unless @has_weapon return end self.opacity = 0 end def make_appear unless @has_weapon return end appear end def make_whiten unless @has_weapon return end whiten end def make_escape unless @has_weapon return end escape end def plus_opacity unless @has_weapon return end self.opacity += 3 end def minus_opacity unless @has_weapon return end self.opacity -= 3 end def turn_blink_on unless @has_weapon return end blink_on end def turn_blink_off unless @has_weapon return end blink_off end def make_collapse unless @has_weapon return end collapse end def align unless @has_weapon return end self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z end # ---------------------------build_weapon_name def build_weapon_name unless $data_weapons[@weapon_id] == nil return @battler.battler_name + "-" + $data_weapons[@weapon_id].name else return "" end end end