查看: 54|回复: 0

[转载发布] 发一个自己做的脚本试一下

[复制链接]
  • TA的每日心情
    开心
    7 天前
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月四日(秋) | 显示全部楼层 |阅读模式


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

    RUBY 代码
    1. #==============================================================================
    2. #
    3. # ◇ ◇ 尚未完成的 Flan系统(芙兰朵露·斯卡雷特)by =Lucifer·Heroin= ◇ ◇
    4. #
    5. # ◇ ◇ 战场上的相机
    6. #==============================================================================
    7. class Scene_Battle
    8.   # ● 定义实例变量,相当于一个临时容器,传递战斗指令的状态
    9.   attr_reader   :spriteset
    10.   # 为了别处能够调用战场背景的缩放,位移
    11.   # 但不能写入,以免影响 Spriteset_Battle 里卷动操作。
    12.   attr_reader   :flan_speed
    13.   # 镜头变化的速度(方便控制战斗节奏)固定住,其他任何地方只能读取他。
    14.   # 一个初始化函数。没有任何别的作用。仅在开战时被调用一次。
    15.   def flan_start
    16.     @flan_speed = 15
    17.   end
    18. # flan_start 初始化各种实变量
    19. # flan_battle 连接战场,刷新画面
    20. # flan_jud 得到敌人,角色的信息
    21. # @field_id 当前角色,或者指向敌人的 ID
    22. # 0,1,2,3 是角色。6..13 是敌人,所以敌人index默认 +6
    23. # 17 角色使用全体技能。
    24. #====◆=============================================================
    25.   def main
    26.     # 初始化战斗用的各种暂时数据
    27.     $game_temp.in_battle = true
    28.     $game_temp.battle_turn = 0
    29.     $game_temp.battle_event_flags.clear
    30.     $game_temp.battle_abort = false
    31.     $game_temp.battle_main_phase = false
    32.     $game_temp.battleback_name = $game_map.battleback_name
    33.     $game_temp.forcing_battler = nil
    34.     # 初始化战斗用事件解释器
    35.     $game_system.battle_interpreter.setup(nil, 0)
    36.     # 准备队伍
    37.     @troop_id = $game_temp.battle_troop_id
    38.     $game_troop.setup(@troop_id)
    39.     #====◆=============================================================
    40.     flan_start
    41.     # 关键接入口,初始化各种实变量
    42.     #====  =============================================================
    43.     # 生成角色命令窗口
    44.     s1 = $data_system.words.attack
    45.     s2 = $data_system.words.skill
    46.     s3 = $data_system.words.guard
    47.     s4 = $data_system.words.item
    48.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    49.     @actor_command_window.y = 160
    50.     @actor_command_window.back_opacity = 160
    51.     @actor_command_window.active = false
    52.     @actor_command_window.visible = false
    53.     # 生成其它窗口
    54.     @party_command_window = Window_PartyCommand.new
    55.     @help_window = Window_Help.new
    56.     @help_window.back_opacity = 160
    57.     @help_window.visible = false
    58.     @status_window = Window_BattleStatus.new
    59.     @message_window = Window_Message.new
    60.     # 生成活动块
    61.     @spriteset = Spriteset_Battle.new
    62.     # 初始化等待计数
    63.     @wait_count = 0
    64.     # 执行过渡
    65.     if$data_system.battle_transition == ""
    66.       Graphics.transition(20)
    67.     else
    68.       Graphics.transition(40, "Graphics/Transitions/" +
    69.         $data_system.battle_transition)
    70.     end
    71.     # 开始自由战斗回合
    72.     start_phase1
    73.     # 主循环
    74.     loopdo
    75.       # 刷新游戏画面
    76.       Graphics.update
    77.       # 刷新输入信息
    78.       Input.update
    79.       # 刷新画面
    80.       update
    81.       # 如果画面切换的话就中断循环
    82.       if$scene != self
    83.         break
    84.       end
    85.     end
    86.     # 刷新地图
    87.     $game_map.refresh
    88.     # 准备过渡
    89.     Graphics.freeze
    90.     # 释放窗口
    91.     @actor_command_window.dispose
    92.     @party_command_window.dispose
    93.     @help_window.dispose
    94.     @status_window.dispose
    95.     @message_window.dispose
    96.     if@skill_window != nil
    97.       @skill_window.dispose
    98.     end
    99.     if@item_window != nil
    100.       @item_window.dispose
    101.     end
    102.     if@result_window != nil
    103.       @result_window.dispose
    104.     end
    105.     # 释放活动块
    106.     @spriteset.dispose
    107.     # 标题画面切换中的情况
    108.     if$scene.is_a?(Scene_Title)
    109.       # 淡入淡出画面
    110.       Graphics.transition
    111.       Graphics.freeze
    112.     end
    113.     # 战斗测试或者游戏结束以外的画面切换中的情况
    114.     if$BTESTandnot$scene.is_a?(Scene_Gameover)
    115.       $scene = nil
    116.     end
    117.   end
    118. #====◆=============================================================
    119.   def update
    120.     # 执行战斗事件中的情况下
    121.     if$game_system.battle_interpreter.running?
    122.       # 刷新解释器
    123.       $game_system.battle_interpreter.update
    124.       # 强制行动的战斗者不存在的情况下
    125.       if$game_temp.forcing_battler == nil
    126.         # 执行战斗事件结束的情况下
    127.         unless$game_system.battle_interpreter.running?
    128.           # 继续战斗的情况下、再执行战斗事件的设置
    129.           unless judge
    130.             setup_battle_event
    131.           end
    132.         end
    133.         # 如果不是结束战斗回合的情况下
    134.         if@phase != 5
    135.           # 刷新状态窗口
    136.           @status_window.refresh
    137.         end
    138.       end
    139.     end
    140.     # 系统 (计时器)、刷新画面
    141.     $game_system.update
    142.     $game_screen.update
    143.     # 计时器为 0 的情况下
    144.     if$game_system.timer_workingand$game_system.timer == 0
    145.       # 中断战斗
    146.       $game_temp.battle_abort = true
    147.     end
    148.     # 刷新窗口
    149.     @help_window.update
    150.     @party_command_window.update
    151.     @actor_command_window.update
    152.     @status_window.update
    153.     @message_window.update
    154.     # 刷新活动块
    155.     #====◆=============================================================
    156.     # 这里必须有,用来刷新 flan_battle,实际改变背景
    157.     @spriteset.flan_battle
    158.     @spriteset.update
    159.     #====  =============================================================
    160.     # 处理过渡中的情况下
    161.     if$game_temp.transition_processing
    162.       # 清除处理过渡中标志
    163.       $game_temp.transition_processing = false
    164.       # 执行过渡
    165.       if$game_temp.transition_name == ""
    166.         Graphics.transition(20)
    167.       else
    168.         Graphics.transition(40, "Graphics/Transitions/" +
    169.           $game_temp.transition_name)
    170.       end
    171.     end
    172.     # 显示信息窗口中的情况下
    173.     if$game_temp.message_window_showing
    174.       return
    175.     end
    176.     # 显示效果中的情况下
    177.     if@spriteset.effect?
    178.       return
    179.     end
    180.     # 游戏结束的情况下
    181.     if$game_temp.gameover
    182.       # 切换到游戏结束画面
    183.       $scene = Scene_Gameover.new
    184.       return
    185.     end
    186.     # 返回标题画面的情况下
    187.     if$game_temp.to_title
    188.       # 切换到标题画面
    189.       $scene = Scene_Title.new
    190.       return
    191.     end
    192.     # 中断战斗的情况下
    193.     if$game_temp.battle_abort
    194.       # 还原为战斗前的 BGM
    195.       $game_system.bgm_play($game_temp.map_bgm)
    196.       # 战斗结束
    197.       battle_end(1)
    198.       return
    199.     end
    200.     # 等待中的情况下
    201.     if@wait_count > 0
    202.       # 减少等待计数
    203.       @wait_count -= 1
    204.       return
    205.     end
    206.     # 强制行动的角色存在、
    207.     # 并且战斗事件正在执行的情况下
    208.     if$game_temp.forcing_battler == niland
    209.        $game_system.battle_interpreter.running?
    210.       return
    211.     end
    212.     # 回合分支
    213.     case@phase
    214.     when1  # 自由战斗回合
    215.       update_phase1
    216.     when2  # 同伴命令回合
    217.       update_phase2
    218.     when3  # 角色命令回合
    219.       update_phase3
    220.     when4  # 主回合
    221.       update_phase4
    222.     when5  # 战斗结束回合
    223.       update_phase5
    224.     end
    225.   end
    226. #====◆=============================================================
    227.   def phase3_setup_command_window
    228.     # 同伴指令窗口无效化
    229.     @party_command_window.active = false
    230.     @party_command_window.visible = false
    231.     # 角色指令窗口无效化
    232.     @actor_command_window.active = true
    233.     @actor_command_window.visible = true
    234.     # 设置角色指令窗口的位置
    235.     @actor_command_window.x = @actor_index * 160
    236.     # 设置索引为 0
    237.     @actor_command_window.index = 0
    238.     #====◆=============================================================
    239.     a = @actor_index
    240.     $scene.spriteset.flan_jud(a)
    241.     # 包含了转向下一个,前一个
    242.     #====  =============================================================
    243.   end
    244. #====◆=============================================================
    245.   def make_basic_action_result
    246.     # 攻击的情况下
    247.     if@active_battler.current_action.basic == 0
    248.       # 设置攻击 ID
    249.       @animation1_id = @active_battler.animation1_id
    250.       @animation2_id = @active_battler.animation2_id
    251.       # 行动方的战斗者是敌人的情况下
    252.       if@active_battler.is_a?(Game_Enemy)
    253.         #====  =============================================================
    254.         # 完全OK,敌人普通攻击,行动方
    255.         #====  =============================================================
    256.         if@active_battler.restriction == 3
    257.           target = $game_troop.random_target_enemy
    258.         elsif@active_battler.restriction == 2
    259.           target = $game_party.random_target_actor
    260.         else
    261.           index = @active_battler.current_action.target_index
    262.           target = $game_party.smooth_target_actor(index)
    263.         end
    264.       end
    265.       # 行动方的战斗者是角色的情况下
    266.       if@active_battler.is_a?(Game_Actor)
    267.         if@active_battler.restriction == 3
    268.           target = $game_party.random_target_actor
    269.         elsif@active_battler.restriction == 2
    270.           #这个时候的 index 是 -1
    271.           target = $game_troop.random_target_enemy
    272.           #====◆ 1 ==========================================================
    273.           a = target.index + 6
    274.           $scene.spriteset.flan_jud(a)
    275.           # 角色普通攻击,对随机,的敌人 ID
    276.           #====  =============================================================
    277.         else
    278.           index = @active_battler.current_action.target_index
    279.           target = $game_troop.smooth_target_enemy(index)
    280.           #====◆ 2 ==========================================================
    281.           a = index + 6
    282.           $scene.spriteset.flan_jud(a)
    283.           # 角色普通攻击,对选择,的敌人 ID
    284.           #====  =============================================================
    285.         end
    286.       end
    287.       # 设置对像方的战斗者序列
    288.       @target_battlers = [target]
    289.       # 应用通常攻击效果
    290.       for target in@target_battlers
    291.         target.attack_effect(@active_battler)
    292.       end
    293.       return
    294.     end
    295.     # 防御的情况下
    296.     if@active_battler.current_action.basic == 1
    297.       #====◆ 3 ==========================================================
    298.       # 区分敌人和角色,角色 ID
    299.       if@active_battler.is_a?(Game_Actor)
    300.         # 行动方的 ID,角色 0,1,2,3 敌人 0,1,2...
    301.         a = @active_battler.index
    302.         $scene.spriteset.flan_jud(a)
    303.       end
    304.       #====  =============================================================
    305.       # 帮助窗口显示"防御"
    306.       @help_window.set_text($data_system.words.guard, 1)
    307.       return
    308.     end
    309.     # 逃跑的情况下
    310.     if@active_battler.is_a?(Game_Enemy)and
    311.        @active_battler.current_action.basic == 2
    312.        #====  =============================================================
    313.        # 敌人,完全OK
    314.        #====  =============================================================
    315.       #  帮助窗口显示"逃跑"
    316.       @help_window.set_text("逃跑", 1)
    317.       # 逃跑
    318.       @active_battler.escape
    319.       return
    320.     end
    321.     # 什么也不做的情况下
    322.     if@active_battler.current_action.basic == 3
    323.       #====  =============================================================
    324.       # 区分敌人和角色,完全OK
    325.       # 跳过速度过快,CP战的情况下,就不至于那么快
    326.       #====  =============================================================
    327.       # 清除强制行动对像的战斗者
    328.       $game_temp.forcing_battler = nil
    329.       # 移至步骤 1
    330.       @phase4_step = 1
    331.       return
    332.     end
    333.   end
    334.   #--------------------------------------------------------------------------
    335.   # ● 设置物品或特技对像方的战斗者
    336.   #     scope : 特技或者是物品的范围
    337.   #--------------------------------------------------------------------------
    338.   def set_target_battlers(scope)
    339.     # 行动方的战斗者是敌人的情况下
    340.     if@active_battler.is_a?(Game_Enemy)
    341.       # 效果范围分支
    342.       case scope
    343.       when1  # 敌单体
    344.         index = @active_battler.current_action.target_index
    345.         @target_battlers.push($game_party.smooth_target_actor(index))
    346.       when2  # 敌全体
    347.         #====◆ 4 ==========================================================
    348.         a = @active_battler.index + 6
    349.         $scene.spriteset.flan_jud(a)
    350.         # 使用技能对角色全体,的敌人 ID
    351.         #====  =============================================================
    352.         for actor in$game_party.actors
    353.           if actor.exist?
    354.             @target_battlers.push(actor)
    355.           end
    356.         end
    357.       when3  # 我方单体
    358.         index = @active_battler.current_action.target_index
    359.         @target_battlers.push($game_troop.smooth_target_enemy(index))
    360.       when4  # 我方全体
    361.         for enemy in$game_troop.enemies
    362.           if enemy.exist?
    363.             @target_battlers.push(enemy)
    364.           end
    365.         end
    366.       when5  # 我方单体 (HP 0)
    367.         index = @active_battler.current_action.target_index
    368.         enemy = $game_troop.enemies[index]
    369.         if enemy != niland enemy.hp0?
    370.           @target_battlers.push(enemy)
    371.         end
    372.       when6  # 我方全体 (HP 0)
    373.         for enemy in$game_troop.enemies
    374.           if enemy != niland enemy.hp0?
    375.             @target_battlers.push(enemy)
    376.           end
    377.         end
    378.       when7  # 使用者
    379.         @target_battlers.push(@active_battler)
    380.       end
    381.     end
    382.     # 行动方的战斗者是角色的情况下
    383.     if@active_battler.is_a?(Game_Actor)
    384.       # 效果范围分支
    385.       case scope
    386.       when1  # 敌单体
    387.         index = @active_battler.current_action.target_index
    388.         @target_battlers.push($game_troop.smooth_target_enemy(index))
    389.         #====◆ 5 ==========================================================
    390.         a = index + 6
    391.         $scene.spriteset.flan_jud(a)
    392.         # 角色使用技能或物品,对敌方单体,目标敌人 ID
    393.         #====  =============================================================
    394.       when2  # 敌全体
    395.         #====◆ 6 ==========================================================
    396.         $scene.spriteset.flan_jud(17)
    397.         # 完全OK,角色使用技能或物品对敌全
    398.         #====  =============================================================
    399.         for enemy in$game_troop.enemies
    400.           if enemy.exist?
    401.             @target_battlers.push(enemy)
    402.           end
    403.         end
    404.       when3  # 我方单体
    405.         index = @active_battler.current_action.target_index
    406.         @target_battlers.push($game_party.smooth_target_actor(index))
    407.       when4  # 我方全体
    408.         for actor in$game_party.actors
    409.           if actor.exist?
    410.             @target_battlers.push(actor)
    411.           end
    412.         end
    413.       when5  # 我方单体 (HP 0)
    414.         index = @active_battler.current_action.target_index
    415.         actor = $game_party.actors[index]
    416.         if actor != niland actor.hp0?
    417.           @target_battlers.push(actor)
    418.         end
    419.       when6  # 我方全体 (HP 0)
    420.         for actor in$game_party.actors
    421.           if actor != niland actor.hp0?
    422.             @target_battlers.push(actor)
    423.           end
    424.         end
    425.       when7  # 使用者
    426.         @target_battlers.push(@active_battler)
    427.       end
    428.     end
    429.   end
    430. #====◆=============================================================
    431. end
    432. #==============================================================================
    433. #==============================================================================
    434. class Arrow_Enemy < Arrow_Base
    435.   def update
    436.     super
    437.     $game_troop.enemies.size.timesdo
    438.       breakifself.enemy.exist?
    439.       [url=home.php?mod=space&uid=370741]@Index[/url] += 1
    440.       @index %= $game_troop.enemies.size
    441.     end
    442.     if Input.repeat?(Input::RIGHT)
    443.       $game_system.se_play($data_system.cursor_se)
    444.       $game_troop.enemies.size.timesdo
    445.         @index += 1
    446.         @index %= $game_troop.enemies.size
    447.         breakifself.enemy.exist?
    448.       end
    449.       #====◆=============================================================
    450.       a = @index + 6
    451.       $scene.spriteset.flan_jud(a)
    452.       # 这里任何操作,实际就是发出了信号
    453.       # 在这里可以知道现在选中的敌人,将信息传给战斗背景
    454.       #====  =============================================================
    455.     end
    456.     if Input.repeat?(Input::LEFT)
    457.       $game_system.se_play($data_system.cursor_se)
    458.       $game_troop.enemies.size.timesdo
    459.         @index += $game_troop.enemies.size - 1
    460.         @index %= $game_troop.enemies.size
    461.         breakifself.enemy.exist?
    462.       end
    463.       #====◆=============================================================
    464.       a = @index + 6
    465.       $scene.spriteset.flan_jud(a)
    466.       #====  =============================================================
    467.     end
    468.     ifself.enemy != nil
    469.       self.x = self.enemy.screen_x
    470.       self.y = self.enemy.screen_y
    471.     end
    472.   end
    473. end
    474. #==============================================================================
    475. #==============================================================================
    476. class Win_Test < Window_Base
    477.   attr_accessor :a_x
    478.   attr_accessor :a_y
    479.   attr_accessor :a_z
    480.   attr_accessor :b_x
    481.   attr_accessor :b_y
    482.   attr_accessor :b_z
    483.   def initialize  # 初始化窗口
    484.     super(300, 50, 300, 200)
    485.     self.contents = Bitmap.new(width - 32, height - 32)
    486.     @a_x = 0
    487.     @a_y = 0
    488.     @a_z = 0
    489.     @b_x = 0
    490.     @b_y = 0
    491.     @b_z = 0
    492.     refresh
    493.   end
    494.   def refresh  # 刷新显示
    495.     self.contents.clear
    496.     text1="t_x "+@a_x.to_i.to_s+","+@a_y.to_i.to_s+","+(@a_z*100).to_i.to_s
    497.     text2="feild "+@b_x.to_i.to_s+","+@b_y.to_i.to_s+","+(@b_z*100).to_i.to_s
    498.     self.contents.draw_text(0, 0, 300, 32, text1)
    499.     self.contents.draw_text(0, 32, 300, 32, text2)
    500.     #-------------------------------------
    501.   end
    502. end
    503. #==============================================================================
    504. #==============================================================================
    505. class Spriteset_Battle
    506.   attr_reader   :field_x
    507.   attr_reader   :field_y
    508.   attr_reader   :field_zoom
    509.   # 别处只可读取,不能写入影响背景。
    510.   # 当背景缩放时,告诉 Game_Enemy 同步要缩放多少
    511.   # 真正的当前背景缩放大小
    512.   def initialize
    513.     @viewport1 = Viewport.new(0, 0, 640, 320)
    514.     @viewport2 = Viewport.new(0, 0, 640, 480)
    515.     @viewport3 = Viewport.new(0, 0, 640, 480)
    516.     @viewport4 = Viewport.new(0, 0, 640, 480)
    517.     @viewport2.z = 101
    518.     @viewport3.z = 200
    519.     @viewport4.z = 5000
    520.     #====◆=============================================================
    521.     @field_x = 0
    522.     @field_y = 0
    523.     @field_zoom = 1.0
    524.     # 以下仅在战场内部使用。win_tes 主动复制了这些数据
    525.     @g_x = 320# 为了刚开战居中放大一次
    526.     @g_y = 80
    527.     @g_zm = 1.0# gap_zoom,在卷动前临时存入当前缩放值
    528.     @t_x = 320
    529.     @t_y = 80
    530.     @t_zm = 1.3# target_zoom,在卷动前临时存入目标缩放值
    531.     @field_id = 17
    532.     @flan_energy = $scene.flan_speed
    533.     #====  =============================================================
    534.     @win_tes = Win_Test.new##
    535.     @win_tes.opacity = 64
    536.     @battleback_sprite = Sprite.new(@viewport1)
    537.     @enemy_sprites = []
    538.     for enemy in$game_troop.enemies.reverse
    539.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    540.     end
    541.     @actor_sprites = []
    542.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
    543.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
    544.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
    545.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
    546.     @weather = RPG::Weather.new(@viewport1)
    547.     @picture_sprites = []
    548.     for i in51..100
    549.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
    550.         $game_screen.pictures[i]))
    551.     end
    552.     @timer_sprite = Sprite_Timer.new
    553.     update
    554.   end
    555.   def dispose
    556.     if@battleback_sprite.bitmap != nil
    557.       @battleback_sprite.bitmap.dispose
    558.     end
    559.     @battleback_sprite.dispose
    560.     for sprite in@enemy_sprites + @actor_sprites
    561.       sprite.dispose
    562.     end
    563.     @weather.dispose
    564.     for sprite in@picture_sprites
    565.       sprite.dispose
    566.     end
    567.     @timer_sprite.dispose
    568.     @win_tes.dispose##
    569.     #====  =============================================================
    570.     @viewport1.dispose
    571.     @viewport2.dispose
    572.     @viewport3.dispose
    573.     @viewport4.dispose
    574.   end
    575.   def update
    576.     @actor_sprites[0].battler = $game_party.actors[0]
    577.     @actor_sprites[1].battler = $game_party.actors[1]
    578.     @actor_sprites[2].battler = $game_party.actors[2]
    579.     @actor_sprites[3].battler = $game_party.actors[3]
    580.     if@battleback_name != $game_temp.battleback_name
    581.       flan_battle
    582.       # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇
    583.     end
    584.     flan_text
    585.     flan_scroll
    586.     # 修正,告诉 Game_Enemy 当前背景画面大小
    587.     # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
    588. #=begin
    589.     for enemy in$game_troop.enemies
    590.       enemy.enemy_x = @field_x
    591.       enemy.enemy_y = @field_y
    592.       enemy.enemy_zoom = @field_zoom
    593.     end
    594. #=end
    595.     @win_tes.a_x = @t_x
    596.     @win_tes.a_y = @t_y
    597.     @win_tes.a_z = @t_zm
    598.     @win_tes.b_x = @field_x
    599.     @win_tes.b_y = @field_y
    600.     @win_tes.b_z = @field_zoom
    601.     # 将选中的目标,的屏幕 x,y 传给 win_tes
    602.     # 这个坐标是现在画面上怪的实际坐标,不是数据库里的
    603.     #====◆=============================================================
    604.     @win_tes.refresh##
    605.     for sprite in@enemy_sprites + @actor_sprites
    606.       sprite.update
    607.     end
    608.     @weather.type = $game_screen.weather_type
    609.     @weather.max = $game_screen.weather_max
    610.     @weather.update
    611.     for sprite in@picture_sprites
    612.       sprite.update
    613.     end
    614.     @timer_sprite.update
    615.     @viewport1.tone = $game_screen.tone
    616.     @viewport1.ox = $game_screen.shake
    617.     @viewport4.color = $game_screen.flash_color
    618.     @viewport1.update
    619.     @viewport2.update
    620.     @viewport4.update
    621.   end
    622.   # #====  =============================================================
    623.   def flan_battle # 因为这里也在刷新,所以不能有动态的东西
    624.     @battleback_name = $game_temp.battleback_name
    625.     if@battleback_sprite.bitmap != nil
    626.       @battleback_sprite.bitmap.dispose
    627.     end
    628.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
    629.     @battleback_sprite.src_rect.set(0, 0, 640, 320)
    630.     @battleback_sprite.zoom_x = @field_zoom
    631.     @battleback_sprite.zoom_y = @field_zoom
    632.     # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
    633.     @battleback_sprite.ox = @field_x
    634.     @battleback_sprite.x = @field_x
    635.     @battleback_sprite.oy = @field_y
    636.     @battleback_sprite.y = @field_y
    637.   end
    638.   #------------------ #------------------ #------------------
    639.   def flan_text
    640.     text1 = "成员 " + @field_id.to_s
    641.     text2 = "En " + @flan_energy.to_s
    642.     @battleback_sprite.bitmap.font.size = 14
    643.     @battleback_sprite.bitmap.draw_text(250, 100, 120, 32, text1)
    644.     @battleback_sprite.bitmap.draw_text(250, 115, 120, 32, text2)
    645.   end
    646.   #------------------ #------------------ #------------------
    647.   def flan_jud(a)  # 仅在外部被启动
    648.     @g_x =@field_x # 暂存现在的场景中心点
    649.     @g_y =@field_y
    650.     @g_zm =@field_zoom
    651.     @field_id = a # 外部操作得到当前角色或敌人信息
    652.     # 根据 ID 来判断,并得出目标缩放的 中心点,大小
    653.     case@field_id
    654.     when17# 全屏居中
    655.       @t_x = 320
    656.       @t_y = 160
    657.       @t_zm = 1.0
    658.     when0..3# 角色行动
    659.       @t_x = 240 + 80 * a
    660.       @t_y = 80
    661.       @t_zm = 1.3
    662.     when6..13# 聚焦敌人
    663.       emx = $game_troop.enemies[a-6].or_x
    664.       emy = $game_troop.enemies[a-6].or_y
    665.       emz = $game_troop.enemies[a-6].or_z
    666.       @t_zm = (1 /emz)/2 + 1
    667.       @t_x = emx
    668.       @t_y = emy - 180 * emz
    669.       # 对于缩放后的修,因为怪的位置太高,导致只看到脚
    670.       # 并且越是远的敌人修正越少。
    671.       # 判断是否会漏黑,重新设定 @t_
    672.       # if (320 - @t_x)
    673.     end
    674.     @flan_energy = $scene.flan_speed
    675.   end
    676.   #------------------ #------------------ #------------------
    677.   def flan_scroll
    678.     # 卷动操作,也就是在有能量时,循环修正当前画面大小,t_,g_ 都不会自己改变
    679.     if@flan_energy > 0
    680.       e = $scene.flan_speed - @flan_energy + 1
    681.       #------------------
    682.       x = @t_x - @g_x
    683.       @field_x = @g_x + x * e**2 / $scene.flan_speed**2
    684.       y = @t_y - @g_y
    685.       @field_y = @g_y + y * e**2 / $scene.flan_speed**2
    686.       z = @t_zm - @g_zm  # 从原先 →到目标
    687.       @field_zoom = @g_zm + z * e**2 / $scene.flan_speed**2
    688.       #------------------
    689.       @flan_energy -= 1
    690.     end
    691.   end
    692.   #---------------------------------------------------
    693. end
    694. #==============================================================================
    695. #==============================================================================
    696. class Sprite_Battler < RPG::Sprite
    697.   def update
    698.     super
    699.     if@battler == nil
    700.       self.bitmap = nil
    701.       loop_animation(nil)
    702.       return
    703.     end
    704.     if@battler.battler_name != @battler_nameor
    705.        @battler.battler_hue != @battler_hue
    706.       @battler_name = @battler.battler_name
    707.       @battler_hue = @battler.battler_hue
    708.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
    709.       @width = bitmap.width
    710.       @height = bitmap.height
    711.       self.ox = @width / 2
    712.       self.oy = @height
    713.       if@battler.dead? or@battler.hidden
    714.         self.opacity = 0
    715.       end
    716.     end
    717.     if@battler.damage == niland
    718.        @battler.state_animation_id != @state_animation_id
    719.       @state_animation_id = @battler.state_animation_id
    720.       loop_animation($data_animations[@state_animation_id])
    721.     end
    722.     if@battler.is_a?(Game_Actor)and@battler_visible
    723.       if$game_temp.battle_main_phase
    724.         self.opacity += 3ifself.opacity < 255
    725.       else
    726.         self.opacity -= 3ifself.opacity > 207
    727.       end
    728.     end
    729.     if@battler.blink
    730.       blink_on
    731.     else
    732.       blink_off
    733.     end
    734.     unless@battler_visible
    735.       ifnot@battler.hiddenandnot@battler.dead? and
    736.          (@battler.damage == nilor@battler.damage_pop)
    737.         appear
    738.         @battler_visible = true
    739.       end
    740.     end
    741.     if@battler_visible
    742.       if@battler.hidden
    743.         $game_system.se_play($data_system.escape_se)
    744.         escape
    745.         @battler_visible = false
    746.       end
    747.       if@battler.white_flash
    748.         whiten
    749.         @battler.white_flash = false
    750.       end
    751.       if@battler.animation_id != 0
    752.         animation = $data_animations[@battler.animation_id]
    753.         animation(animation, @battler.animation_hit)
    754.         @battler.animation_id = 0
    755.       end
    756.       if@battler.damage_pop
    757.         damage(@battler.damage, @battler.critical)
    758.         @battler.damage = nil
    759.         @battler.critical = false
    760.         @battler.damage_pop = false
    761.       end
    762.       if@battler.damage == niland@battler.dead?
    763.         if@battler.is_a?(Game_Enemy)
    764.           $game_system.se_play($data_system.enemy_collapse_se)
    765.         else
    766.           $game_system.se_play($data_system.actor_collapse_se)
    767.         end
    768.         collapse
    769.         @battler_visible = false
    770.       end
    771.     end
    772.     self.x = @battler.screen_x
    773.     self.y = @battler.screen_y
    774.     self.z = @battler.screen_z
    775.     #---------------------------------------------------
    776.     # 如果是敌人的话,读取敌人函数(传递过来的缩放值)并改变精灵大小
    777.     if@battler.is_a?(Game_Enemy)
    778.       self.zoom_x = @battler.screen_zoom
    779.       self.zoom_y = @battler.screen_zoom
    780.     end
    781.     # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇
    782.   end
    783. end
    784. #==============================================================================
    785. #==============================================================================
    786. class Game_Enemy < Game_Battler
    787.   attr_accessor :enemy_x
    788.   attr_accessor :enemy_y
    789.   attr_accessor :enemy_zoom
    790.   # 可读可写被,背景缩放改变时,写入新值。
    791.   # Sprite_Battler 里需要时,读取这个值,改变画面上敌人缩放,位置
    792.   #---------------------------------------------------
    793.   def initialize(troop_id, member_index)
    794.     super()
    795.     @troop_id = troop_id
    796.     @member_index = member_index
    797.     troop = $data_troops[@troop_id]
    798.     @enemy_id = troop.members[@member_index].enemy_id
    799.     enemy = $data_enemies[@enemy_id]
    800.     @battler_name = enemy.battler_name
    801.     @battler_hue = enemy.battler_hue
    802.     @hp = maxhp
    803.     @sp = maxsp
    804.     #---------------------------------------------------
    805.     @size = troop.members.size
    806.     @enemy_x = 0
    807.     @enemy_y = 0
    808.     @enemy_zoom = 1.0
    809.     @hidden = troop.members[@member_index].hidden
    810.     @immortal = troop.members[@member_index].immortal
    811.   end
    812.   #---------------------------------------------------
    813.   # 设计,重新摆放阵型,罗列敌人队伍从 1只怪,到 8只怪
    814.   # 缩放产生透视,最小 0.25,最大 1.0,中等 0.5。
    815.   def screen_x
    816.     case@size
    817.     # - - - - - - - - #
    818.     when1
    819.       return320
    820.     # - - - - - - - - #
    821.     when2
    822.       case@member_index
    823.       when0
    824.         return200
    825.       when1
    826.         return440
    827.       end
    828.     # - - - - - - - - #
    829.     when3
    830.       case@member_index
    831.       when0
    832.         return200
    833.       when1
    834.         return320
    835.       when2
    836.         return440
    837.       end
    838.     # - - - - - - - - #
    839.     when5
    840.       case@member_index
    841.       when0
    842.         return160
    843.       when1
    844.         return240
    845.       when2
    846.         return320
    847.       when3
    848.         return400
    849.       when4
    850.         return480
    851.       end
    852.     else  # 防止出现没设计过的
    853.       return$data_troops[@troop_id].members[@member_index].x
    854.     end
    855.   end
    856.   #---------------------------------------------------
    857.   def screen_y
    858.     case@size
    859.     # - - - - - - - - #
    860.     when1,2
    861.       return240
    862.     # - - - - - - - - #
    863.     when3
    864.       case@member_index
    865.       when0
    866.         return240
    867.       when1
    868.         return200
    869.       when2
    870.         return240
    871.       end
    872.     # - - - - - - - - #
    873.     when5
    874.       case@member_index
    875.       when0
    876.         return240
    877.       when1
    878.         return160
    879.       when2
    880.         return200
    881.       when3
    882.         return160
    883.       when4
    884.         return240
    885.       end
    886.     else
    887.       return$data_troops[@troop_id].members[@member_index].y
    888.     end
    889.   end
    890.   #---------------------------------------------------
    891.   def screen_zoom
    892.     case@size
    893.     # - - - - - - - - #
    894.     when1,2
    895.       return0.75
    896.     when3
    897.       case@member_index
    898.       when0
    899.         return0.75
    900.       when1
    901.         return0.5
    902.       when2
    903.         return0.75
    904.       end
    905.     # - - - - - - - - #
    906.     when5
    907.       case@member_index
    908.       when0
    909.         return0.75
    910.       when1
    911.         return0.25
    912.       when2
    913.         return0.5
    914.       when3
    915.         return0.25
    916.       when4
    917.         return0.75
    918.       end
    919.     else# 没设计的怪都是“最大”
    920.       return0.75
    921.     end
    922.   end
    923.   #---------------------------------------------------
    924.   alias:or_x:screen_x# 给原始敌人的屏幕坐标起别名
    925.   alias:or_y:screen_y# 从此,or_x 才是数据库里的,不会被修改
    926.   alias:or_z:screen_zoom
    927.   # 重新定义,经过缩放后怪物在屏幕上的位置,给 Sprite_Battler 调用
    928.   def screen_x
    929.     return@enemy_x - (@enemy_x - or_x) * @enemy_zoom
    930.   end
    931.   def screen_y
    932.     return@enemy_y - (@enemy_y - or_y) * @enemy_zoom
    933.   end
    934.   def screen_zoom
    935.     return@enemy_zoom * or_z
    936.   end
    937.   #---------------------------------------------------
    938. end
    复制代码

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

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-17 17:42 , Processed in 0.051419 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表