じ☆ve冰风 发表于 2024-4-19 21:31:12

发一个自己做的脚本试一下



战场上的相机,因为到处都找不到独立可用的,我自己做了一个。

RUBY 代码
#==============================================================================
#
# ◇ ◇ 尚未完成的 Flan系统(芙兰朵露·斯卡雷特)by =Lucifer·Heroin= ◇ ◇
#
# ◇ ◇ 战场上的相机
#==============================================================================
class Scene_Battle

# ● 定义实例变量,相当于一个临时容器,传递战斗指令的状态

attr_reader   :spriteset
# 为了别处能够调用战场背景的缩放,位移
# 但不能写入,以免影响 Spriteset_Battle 里卷动操作。

attr_reader   :flan_speed
# 镜头变化的速度(方便控制战斗节奏)固定住,其他任何地方只能读取他。


# 一个初始化函数。没有任何别的作用。仅在开战时被调用一次。
def flan_start

    @flan_speed = 15

end

# flan_start 初始化各种实变量
# flan_battle 连接战场,刷新画面
# flan_jud 得到敌人,角色的信息
# @field_id 当前角色,或者指向敌人的 ID
# 0,1,2,3 是角色。6..13 是敌人,所以敌人index默认 +6
# 17 角色使用全体技能。


#====◆=============================================================
def main
    # 初始化战斗用的各种暂时数据
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # 初始化战斗用事件解释器
    $game_system.battle_interpreter.setup(nil, 0)
    # 准备队伍
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)

    #====◆=============================================================
    flan_start
    # 关键接入口,初始化各种实变量
    #=================================================================

    # 生成角色命令窗口
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, )
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 生成其它窗口
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    # 生成活动块
    @spriteset = Spriteset_Battle.new
    # 初始化等待计数
    @wait_count = 0
    # 执行过渡
    if$data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
      $data_system.battle_transition)
    end
    # 开始自由战斗回合
    start_phase1
    # 主循环
    loopdo
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果画面切换的话就中断循环
      if$scene != self
      break
      end
    end
    # 刷新地图
    $game_map.refresh
    # 准备过渡
    Graphics.freeze
    # 释放窗口
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if@skill_window != nil
      @skill_window.dispose
    end
    if@item_window != nil
      @item_window.dispose
    end
    if@result_window != nil
      @result_window.dispose
    end
    # 释放活动块
    @spriteset.dispose
    # 标题画面切换中的情况
    if$scene.is_a?(Scene_Title)
      # 淡入淡出画面
      Graphics.transition
      Graphics.freeze
    end
    # 战斗测试或者游戏结束以外的画面切换中的情况
    if$BTESTandnot$scene.is_a?(Scene_Gameover)
      $scene = nil
    end
end
#====◆=============================================================
def update
    # 执行战斗事件中的情况下
    if$game_system.battle_interpreter.running?
      # 刷新解释器
      $game_system.battle_interpreter.update
      # 强制行动的战斗者不存在的情况下
      if$game_temp.forcing_battler == nil
      # 执行战斗事件结束的情况下
      unless$game_system.battle_interpreter.running?
          # 继续战斗的情况下、再执行战斗事件的设置
          unless judge
            setup_battle_event
          end
      end
      # 如果不是结束战斗回合的情况下
      if@phase != 5
          # 刷新状态窗口
          @status_window.refresh
      end
      end
    end
    # 系统 (计时器)、刷新画面
    $game_system.update
    $game_screen.update
    # 计时器为 0 的情况下
    if$game_system.timer_workingand$game_system.timer == 0
      # 中断战斗
      $game_temp.battle_abort = true
    end
    # 刷新窗口
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    @message_window.update
    # 刷新活动块

    #====◆=============================================================
    # 这里必须有,用来刷新 flan_battle,实际改变背景
    @spriteset.flan_battle
    @spriteset.update
    #=================================================================

    # 处理过渡中的情况下
    if$game_temp.transition_processing
      # 清除处理过渡中标志
      $game_temp.transition_processing = false
      # 执行过渡
      if$game_temp.transition_name == ""
      Graphics.transition(20)
      else
      Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # 显示信息窗口中的情况下
    if$game_temp.message_window_showing
      return
    end
    # 显示效果中的情况下
    if@spriteset.effect?
      return
    end
    # 游戏结束的情况下
    if$game_temp.gameover
      # 切换到游戏结束画面
      $scene = Scene_Gameover.new
      return
    end
    # 返回标题画面的情况下
    if$game_temp.to_title
      # 切换到标题画面
      $scene = Scene_Title.new
      return
    end
    # 中断战斗的情况下
    if$game_temp.battle_abort
      # 还原为战斗前的 BGM
      $game_system.bgm_play($game_temp.map_bgm)
      # 战斗结束
      battle_end(1)
      return
    end
    # 等待中的情况下
    if@wait_count > 0
      # 减少等待计数
      @wait_count -= 1
      return
    end
    # 强制行动的角色存在、
    # 并且战斗事件正在执行的情况下
    if$game_temp.forcing_battler == niland
       $game_system.battle_interpreter.running?
      return
    end
    # 回合分支
    case@phase
    when1# 自由战斗回合
      update_phase1
    when2# 同伴命令回合
      update_phase2
    when3# 角色命令回合
      update_phase3
    when4# 主回合
      update_phase4
    when5# 战斗结束回合
      update_phase5
    end
end
#====◆=============================================================
def phase3_setup_command_window
    # 同伴指令窗口无效化
    @party_command_window.active = false
    @party_command_window.visible = false
    # 角色指令窗口无效化
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # 设置角色指令窗口的位置
    @actor_command_window.x = @actor_index * 160
    # 设置索引为 0
    @actor_command_window.index = 0

    #====◆=============================================================
    a = @actor_index
    $scene.spriteset.flan_jud(a)
    # 包含了转向下一个,前一个
    #=================================================================

end
#====◆=============================================================
def make_basic_action_result
    # 攻击的情况下
    if@active_battler.current_action.basic == 0
      # 设置攻击 ID
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      # 行动方的战斗者是敌人的情况下
      if@active_battler.is_a?(Game_Enemy)

      #=================================================================
      # 完全OK,敌人普通攻击,行动方
      #=================================================================

      if@active_battler.restriction == 3
          target = $game_troop.random_target_enemy
      elsif@active_battler.restriction == 2
          target = $game_party.random_target_actor
      else
          index = @active_battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
      end
      end
      # 行动方的战斗者是角色的情况下
      if@active_battler.is_a?(Game_Actor)
      if@active_battler.restriction == 3
          target = $game_party.random_target_actor
      elsif@active_battler.restriction == 2

          #这个时候的 index 是 -1
          target = $game_troop.random_target_enemy
          #====◆ 1 ==========================================================

          a = target.index + 6
          $scene.spriteset.flan_jud(a)
          # 角色普通攻击,对随机,的敌人 ID
          #=================================================================
      else
          index = @active_battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)

          #====◆ 2 ==========================================================
          a = index + 6
          $scene.spriteset.flan_jud(a)
          # 角色普通攻击,对选择,的敌人 ID
          #=================================================================

      end
      end
      # 设置对像方的战斗者序列
      @target_battlers =
      # 应用通常攻击效果
      for target in@target_battlers
      target.attack_effect(@active_battler)
      end
      return
    end

    # 防御的情况下
    if@active_battler.current_action.basic == 1

      #====◆ 3 ==========================================================
      # 区分敌人和角色,角色 ID
      if@active_battler.is_a?(Game_Actor)

      # 行动方的 ID,角色 0,1,2,3 敌人 0,1,2...
      a = @active_battler.index
      $scene.spriteset.flan_jud(a)
      end
      #=================================================================

      # 帮助窗口显示"防御"
      @help_window.set_text($data_system.words.guard, 1)
      return
    end
    # 逃跑的情况下
    if@active_battler.is_a?(Game_Enemy)and
       @active_battler.current_action.basic == 2

       #=================================================================
       # 敌人,完全OK
       #=================================================================

      #帮助窗口显示"逃跑"
      @help_window.set_text("逃跑", 1)
      # 逃跑
      @active_battler.escape
      return
    end
    # 什么也不做的情况下
    if@active_battler.current_action.basic == 3

      #=================================================================
      # 区分敌人和角色,完全OK
      # 跳过速度过快,CP战的情况下,就不至于那么快
      #=================================================================

      # 清除强制行动对像的战斗者
      $game_temp.forcing_battler = nil
      # 移至步骤 1
      @phase4_step = 1
      return
    end
end

#--------------------------------------------------------------------------
# ● 设置物品或特技对像方的战斗者
#   scope : 特技或者是物品的范围
#--------------------------------------------------------------------------
def set_target_battlers(scope)
    # 行动方的战斗者是敌人的情况下
    if@active_battler.is_a?(Game_Enemy)
      # 效果范围分支
      case scope
      when1# 敌单体
      index = @active_battler.current_action.target_index
      @target_battlers.push($game_party.smooth_target_actor(index))
      when2# 敌全体

      #====◆ 4 ==========================================================

      a = @active_battler.index + 6
      $scene.spriteset.flan_jud(a)
      # 使用技能对角色全体,的敌人 ID
      #=================================================================

      for actor in$game_party.actors
          if actor.exist?
            @target_battlers.push(actor)
          end
      end
      when3# 我方单体
      index = @active_battler.current_action.target_index
      @target_battlers.push($game_troop.smooth_target_enemy(index))
      when4# 我方全体
      for enemy in$game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
      end
      when5# 我方单体 (HP 0)
      index = @active_battler.current_action.target_index
      enemy = $game_troop.enemies
      if enemy != niland enemy.hp0?
          @target_battlers.push(enemy)
      end
      when6# 我方全体 (HP 0)
      for enemy in$game_troop.enemies
          if enemy != niland enemy.hp0?
            @target_battlers.push(enemy)
          end
      end
      when7# 使用者
      @target_battlers.push(@active_battler)
      end
    end

    # 行动方的战斗者是角色的情况下
    if@active_battler.is_a?(Game_Actor)
      # 效果范围分支
      case scope
      when1# 敌单体
      index = @active_battler.current_action.target_index
      @target_battlers.push($game_troop.smooth_target_enemy(index))

      #====◆ 5 ==========================================================
      a = index + 6
      $scene.spriteset.flan_jud(a)
      # 角色使用技能或物品,对敌方单体,目标敌人 ID
      #=================================================================

      when2# 敌全体

      #====◆ 6 ==========================================================
      $scene.spriteset.flan_jud(17)
      # 完全OK,角色使用技能或物品对敌全
      #=================================================================

      for enemy in$game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
      end
      when3# 我方单体
      index = @active_battler.current_action.target_index
      @target_battlers.push($game_party.smooth_target_actor(index))
      when4# 我方全体
      for actor in$game_party.actors
          if actor.exist?
            @target_battlers.push(actor)
          end
      end
      when5# 我方单体 (HP 0)
      index = @active_battler.current_action.target_index
      actor = $game_party.actors
      if actor != niland actor.hp0?
          @target_battlers.push(actor)
      end
      when6# 我方全体 (HP 0)
      for actor in$game_party.actors
          if actor != niland actor.hp0?
            @target_battlers.push(actor)
          end
      end
      when7# 使用者
      @target_battlers.push(@active_battler)
      end
    end
end
#====◆=============================================================
end


#==============================================================================

#==============================================================================
class Arrow_Enemy < Arrow_Base
def update
    super
    $game_troop.enemies.size.timesdo
      breakifself.enemy.exist?
      @Index += 1
      @index %= $game_troop.enemies.size
    end
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.timesdo
      @index += 1
      @index %= $game_troop.enemies.size
      breakifself.enemy.exist?
      end

      #====◆=============================================================
      a = @index + 6
      $scene.spriteset.flan_jud(a)
      # 这里任何操作,实际就是发出了信号
      # 在这里可以知道现在选中的敌人,将信息传给战斗背景
      #=================================================================
    end
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.timesdo
      @index += $game_troop.enemies.size - 1
      @index %= $game_troop.enemies.size
      breakifself.enemy.exist?
      end

      #====◆=============================================================
      a = @index + 6
      $scene.spriteset.flan_jud(a)
      #=================================================================
    end

    ifself.enemy != nil
      self.x = self.enemy.screen_x
      self.y = self.enemy.screen_y
    end
end
end
#==============================================================================


#==============================================================================
class Win_Test < Window_Base


attr_accessor :a_x
attr_accessor :a_y
attr_accessor :a_z

attr_accessor :b_x
attr_accessor :b_y
attr_accessor :b_z

def initialize# 初始化窗口
    super(300, 50, 300, 200)
    self.contents = Bitmap.new(width - 32, height - 32)

    @a_x = 0
    @a_y = 0
    @a_z = 0

    @b_x = 0
    @b_y = 0
    @b_z = 0

    refresh
end

def refresh# 刷新显示
    self.contents.clear

    text1="t_x "+@a_x.to_i.to_s+","+@a_y.to_i.to_s+","+(@a_z*100).to_i.to_s
    text2="feild "+@b_x.to_i.to_s+","+@b_y.to_i.to_s+","+(@b_z*100).to_i.to_s

    self.contents.draw_text(0, 0, 300, 32, text1)
    self.contents.draw_text(0, 32, 300, 32, text2)

    #-------------------------------------
end
end
#==============================================================================


#==============================================================================
class Spriteset_Battle

attr_reader   :field_x
attr_reader   :field_y
attr_reader   :field_zoom
# 别处只可读取,不能写入影响背景。
# 当背景缩放时,告诉 Game_Enemy 同步要缩放多少
# 真正的当前背景缩放大小

def initialize
    @viewport1 = Viewport.new(0, 0, 640, 320)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000

    #====◆=============================================================
    @field_x = 0
    @field_y = 0
    @field_zoom = 1.0

    # 以下仅在战场内部使用。win_tes 主动复制了这些数据
    @g_x = 320# 为了刚开战居中放大一次
    @g_y = 80
    @g_zm = 1.0# gap_zoom,在卷动前临时存入当前缩放值

    @t_x = 320
    @t_y = 80
    @t_zm = 1.3# target_zoom,在卷动前临时存入目标缩放值

    @field_id = 17
    @flan_energy = $scene.flan_speed

    #=================================================================
    @win_tes = Win_Test.new##
    @win_tes.opacity = 64


    @battleback_sprite = Sprite.new(@viewport1)
    @enemy_sprites = []
    for enemy in$game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    @actor_sprites = []
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @weather = RPG::Weather.new(@viewport1)
    @picture_sprites = []
    for i in51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
      $game_screen.pictures))
    end
    @timer_sprite = Sprite_Timer.new
    update
end
def dispose
    if@battleback_sprite.bitmap != nil
      @battleback_sprite.bitmap.dispose
    end
    @battleback_sprite.dispose
    for sprite in@enemy_sprites + @actor_sprites
      sprite.dispose
    end
    @weather.dispose
    for sprite in@picture_sprites
      sprite.dispose
    end
    @timer_sprite.dispose
    @win_tes.dispose##
    #=================================================================

    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
    @viewport4.dispose
end
def update
    @actor_sprites.battler = $game_party.actors
    @actor_sprites.battler = $game_party.actors
    @actor_sprites.battler = $game_party.actors
    @actor_sprites.battler = $game_party.actors
    if@battleback_name != $game_temp.battleback_name
      flan_battle
      # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇
    end

    flan_text
    flan_scroll



    # 修正,告诉 Game_Enemy 当前背景画面大小
    # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
#=begin
    for enemy in$game_troop.enemies
      enemy.enemy_x = @field_x
      enemy.enemy_y = @field_y
      enemy.enemy_zoom = @field_zoom
    end
#=end

    @win_tes.a_x = @t_x
    @win_tes.a_y = @t_y
    @win_tes.a_z = @t_zm
    @win_tes.b_x = @field_x
    @win_tes.b_y = @field_y
    @win_tes.b_z = @field_zoom

    # 将选中的目标,的屏幕 x,y 传给 win_tes
    # 这个坐标是现在画面上怪的实际坐标,不是数据库里的
    #====◆=============================================================
    @win_tes.refresh##


    for sprite in@enemy_sprites + @actor_sprites
      sprite.update
    end
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    for sprite in@picture_sprites
      sprite.update
    end
    @timer_sprite.update
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    @viewport4.color = $game_screen.flash_color
    @viewport1.update
    @viewport2.update
    @viewport4.update
end
# #=================================================================

def flan_battle # 因为这里也在刷新,所以不能有动态的东西
    @battleback_name = $game_temp.battleback_name
    if@battleback_sprite.bitmap != nil
      @battleback_sprite.bitmap.dispose
    end

    @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
    @battleback_sprite.src_rect.set(0, 0, 640, 320)

    @battleback_sprite.zoom_x = @field_zoom
    @battleback_sprite.zoom_y = @field_zoom

    # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
    @battleback_sprite.ox = @field_x
    @battleback_sprite.x = @field_x
    @battleback_sprite.oy = @field_y
    @battleback_sprite.y = @field_y

end

#------------------ #------------------ #------------------
def flan_text

    text1 = "成员 " + @field_id.to_s
    text2 = "En " + @flan_energy.to_s

    @battleback_sprite.bitmap.font.size = 14
    @battleback_sprite.bitmap.draw_text(250, 100, 120, 32, text1)
    @battleback_sprite.bitmap.draw_text(250, 115, 120, 32, text2)

end

#------------------ #------------------ #------------------
def flan_jud(a)# 仅在外部被启动

    @g_x =@field_x # 暂存现在的场景中心点
    @g_y =@field_y
    @g_zm =@field_zoom

    @field_id = a # 外部操作得到当前角色或敌人信息
    # 根据 ID 来判断,并得出目标缩放的 中心点,大小

    case@field_id
    when17# 全屏居中
      @t_x = 320
      @t_y = 160
      @t_zm = 1.0

    when0..3# 角色行动
      @t_x = 240 + 80 * a
      @t_y = 80
      @t_zm = 1.3

    when6..13# 聚焦敌人

      emx = $game_troop.enemies.or_x
      emy = $game_troop.enemies.or_y
      emz = $game_troop.enemies.or_z
      @t_zm = (1 /emz)/2 + 1
      @t_x = emx
      @t_y = emy - 180 * emz

      # 对于缩放后的修,因为怪的位置太高,导致只看到脚
      # 并且越是远的敌人修正越少。
      # 判断是否会漏黑,重新设定 @t_
      # if (320 - @t_x)

    end

    @flan_energy = $scene.flan_speed
end

#------------------ #------------------ #------------------
def flan_scroll
    # 卷动操作,也就是在有能量时,循环修正当前画面大小,t_,g_ 都不会自己改变

    if@flan_energy > 0

      e = $scene.flan_speed - @flan_energy + 1
      #------------------
      x = @t_x - @g_x
      @field_x = @g_x + x * e**2 / $scene.flan_speed**2

      y = @t_y - @g_y
      @field_y = @g_y + y * e**2 / $scene.flan_speed**2

      z = @t_zm - @g_zm# 从原先 →到目标
      @field_zoom = @g_zm + z * e**2 / $scene.flan_speed**2
      #------------------

      @flan_energy -= 1
    end

end
#---------------------------------------------------
end
#==============================================================================


#==============================================================================
class Sprite_Battler < RPG::Sprite

def update
    super
    if@battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    if@battler.battler_name != @battler_nameor
       @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
      if@battler.dead? or@battler.hidden
      self.opacity = 0
      end
    end
    if@battler.damage == niland
       @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 += 3ifself.opacity < 255
      else
      self.opacity -= 3ifself.opacity > 207
      end
    end
    if@battler.blink
      blink_on
    else
      blink_off
    end
    unless@battler_visible
      ifnot@battler.hiddenandnot@battler.dead? and
         (@battler.damage == nilor@battler.damage_pop)
      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 == niland@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
      @battler_visible = false
      end
    end
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
    #---------------------------------------------------
    # 如果是敌人的话,读取敌人函数(传递过来的缩放值)并改变精灵大小

    if@battler.is_a?(Game_Enemy)
      self.zoom_x = @battler.screen_zoom
      self.zoom_y = @battler.screen_zoom

    end
    # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇

end
end
#==============================================================================


#==============================================================================
class Game_Enemy < Game_Battler

attr_accessor :enemy_x
attr_accessor :enemy_y
attr_accessor :enemy_zoom
# 可读可写被,背景缩放改变时,写入新值。
# Sprite_Battler 里需要时,读取这个值,改变画面上敌人缩放,位置

#---------------------------------------------------
def initialize(troop_id, member_index)
    super()
    @troop_id = troop_id
    @member_index = member_index
    troop = $data_troops[@troop_id]
    @enemy_id = troop.members[@member_index].enemy_id
    enemy = $data_enemies[@enemy_id]
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @sp = maxsp

    #---------------------------------------------------
    @size = troop.members.size
    @enemy_x = 0
    @enemy_y = 0
    @enemy_zoom = 1.0

    @hidden = troop.members[@member_index].hidden
    @immortal = troop.members[@member_index].immortal
end
#---------------------------------------------------
# 设计,重新摆放阵型,罗列敌人队伍从 1只怪,到 8只怪
# 缩放产生透视,最小 0.25,最大 1.0,中等 0.5。
def screen_x
    case@size
    # - - - - - - - - #
    when1
      return320
    # - - - - - - - - #
    when2
      case@member_index
      when0
      return200
      when1
      return440
      end
    # - - - - - - - - #
    when3
      case@member_index
      when0
      return200
      when1
      return320
      when2
      return440
      end
    # - - - - - - - - #
    when5
      case@member_index
      when0
      return160
      when1
      return240
      when2
      return320
      when3
      return400
      when4
      return480
      end


    else# 防止出现没设计过的
      return$data_troops[@troop_id].members[@member_index].x
    end
end
#---------------------------------------------------


def screen_y
    case@size
    # - - - - - - - - #
    when1,2
      return240
    # - - - - - - - - #
    when3
      case@member_index
      when0
      return240
      when1
      return200
      when2
      return240
      end
    # - - - - - - - - #
    when5
      case@member_index
      when0
      return240
      when1
      return160
      when2
      return200
      when3
      return160
      when4
      return240
      end



    else
      return$data_troops[@troop_id].members[@member_index].y
    end
end
#---------------------------------------------------


def screen_zoom
    case@size
    # - - - - - - - - #
    when1,2
      return0.75
    when3
      case@member_index
      when0
      return0.75
      when1
      return0.5
      when2
      return0.75
      end
    # - - - - - - - - #
    when5
      case@member_index
      when0
      return0.75
      when1
      return0.25
      when2
      return0.5
      when3
      return0.25
      when4
      return0.75
      end


    else# 没设计的怪都是“最大”
      return0.75
    end
end



#---------------------------------------------------
alias:or_x:screen_x# 给原始敌人的屏幕坐标起别名
alias:or_y:screen_y# 从此,or_x 才是数据库里的,不会被修改
alias:or_z:screen_zoom

# 重新定义,经过缩放后怪物在屏幕上的位置,给 Sprite_Battler 调用
def screen_x
    return@enemy_x - (@enemy_x - or_x) * @enemy_zoom
end

def screen_y
    return@enemy_y - (@enemy_y - or_y) * @enemy_zoom
end

def screen_zoom
    return@enemy_zoom * or_z
end

#---------------------------------------------------
end

             本帖来自P1论坛作者lucifer4223,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=336842若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: 发一个自己做的脚本试一下