查看: 75|回复: 0

[转载发布] 恐惧剑刃版CP制战斗

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

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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





    我的思路仅供参考。
    再次更新,这次测试没发现问题。。

    其余问题:
    1. fill_rect过多
    2. 敌人CP没有显示

    太赖暂时不考虑修正 。。


    工程


    CP
    RUBY 代码
    1. #------------------------------------------------------------------------------
    2. # - CP战斗
    3. #------------------------------------------------------------------------------
    4. #------------------------------------------------------------------------------
    5. # - 设置
    6. #------------------------------------------------------------------------------
    7. module CP
    8.   Speed = 1                                # 速度
    9.   Width = 120                              # CP条宽度
    10.   Height = 6                               # CP条高度
    11.   Back_Color = Color.new(0, 0, 0)          # CP条背景色
    12.   Cp_Color = Color.new(255, 255, 64)       # CP条填充色
    13.   Cp_Color_2 = Color.new(255, 128, 255)    # CP条填充色(满)
    14. end
    15. #------------------------------------------------------------------------------
    16. # - 战斗者CP属性
    17. #------------------------------------------------------------------------------
    18. class Game_Battler
    19.   attr_accessor :cp, :cp_speed
    20.   alias initialize_cp_old initialize
    21.   def initialize
    22.     @cp = 0
    23.     @cp_speed = 0
    24.     initialize_cp_old
    25.   end
    26. end
    27. #------------------------------------------------------------------------------
    28. # - 战斗场景
    29. #------------------------------------------------------------------------------
    30. class Scene_Battle
    31.   #----------------------------------------------------------------------------
    32.   # - 主方法
    33.   #----------------------------------------------------------------------------
    34.   alias main_cp_old main
    35.   def main
    36.     @cp_viewport = Viewport.new(0, 465, 640, CP::Height)
    37.     @cp_viewport.z = 9999
    38.     @cp_sprite = Sprite.new(@cp_viewport)
    39.     @cp_sprite.bitmap = Bitmap.new(640, CP::Height)
    40.     cp_bar
    41.     main_cp_old
    42.     @cp_sprite.bitmap.dispose
    43.     @cp_sprite.dispose
    44.     @cp_viewport.dispose
    45.   end
    46.   #--------------------------------------------------------------------------
    47.   # - 速度
    48.   #--------------------------------------------------------------------------
    49.   def cp_speed
    50.     battlers_agi = []
    51.     for battler in$game_party.actors + $game_troop.enemies
    52.       battlers_agi = width - 1
    53.         cp_color = CP::Cp_Color_2
    54.         wid = width - 1
    55.       else
    56.         cp_color = CP::Cp_Color
    57.         wid = actor.cp
    58.       end
    59.       @cp_sprite.bitmap.fill_rect(x + 1, 1, wid, height - 2, cp_color)
    60.     end
    61.   end
    62. end
    63. class Scene_Battle
    64.   alias start_phase2_cp_old start_phase2
    65.   def start_phase2
    66.     cp_bar
    67.     start_phase2_cp_old
    68.   end
    69.   def make_action_orders
    70.     @action_battlers = [@active_battler_cp]
    71.   end
    72.   alias update_phase4_step6_cp_old update_phase4_step6
    73.   def update_phase4_step6
    74.     update_phase4_step6_cp_old
    75.     @active_battler.cp = 0
    76.   end
    77. end
    复制代码


    Scene_Battle 3
    RUBY 代码
    1. #==============================================================================
    2. # ■ Scene_Battle (分割定义 3)
    3. #------------------------------------------------------------------------------
    4. #  处理战斗画面的类。
    5. #==============================================================================
    6. class Scene_Battle
    7.   #--------------------------------------------------------------------------
    8.   # ● 开始角色命令回合
    9.   #--------------------------------------------------------------------------
    10.   def start_phase3
    11.     # 转移到回合 3
    12.     @phase = 3
    13.     # 设置角色为非选择状态
    14.     @actor_index = -1
    15.     @active_battler = nil
    16.     @active_battler_cp = nil
    17.     # 同伴指令窗口无效化
    18.     @party_command_window.active = false
    19.     @party_command_window.visible = false
    20.   end
    21.   #--------------------------------------------------------------------------
    22.   # ● 设置角色指令窗口
    23.   #--------------------------------------------------------------------------
    24.   def phase3_setup_command_window
    25.     if !@active_battler_cp.is_a?(Game_Actor)
    26.       start_phase4 # 回合4
    27.       @phase = 4
    28.       return
    29.     end
    30.     # 角色指令窗口无效化
    31.     @actor_command_window.active = true
    32.     @actor_command_window.visible = true
    33.     @actor_command_window.x = $game_party.actors.index(@active_battler_cp) * 160
    34.     # 设置索引为 0
    35.     @actor_command_window.index = 0
    36.   end
    37.   #--------------------------------------------------------------------------
    38.   # ● 刷新画面 (角色命令回合)
    39.   #--------------------------------------------------------------------------
    40.   def update_phase3
    41.     if judge # 判断胜负
    42.       return
    43.     end
    44.     if@active_battler_cp == nil# 可以刷新
    45.       cp_speed # 新速度
    46.       cp_bar # 刷新cp条
    47.       for battler in$game_party.actors + $game_troop.enemies
    48.         battler.cp += battler.cp_speed
    49.         if battler.cp >= CP::Width - 1
    50.           cp_bar # 变色
    51.           @active_battler_cp = battler # 输入命令者
    52.           phase3_setup_command_window
    53.         end
    54.       end
    55.     end
    56.     # 敌人光标有效的情况下
    57.     if@enemy_arrow != nil
    58.       update_phase3_enemy_select
    59.     # 角色光标有效的情况下
    60.     elsif@actor_arrow != nil
    61.       update_phase3_actor_select
    62.     # 特技窗口有效的情况下
    63.     elsif@skill_window != nil
    64.       update_phase3_skill_select
    65.     # 物品窗口有效的情况下
    66.     elsif@item_window != nil
    67.       update_phase3_item_select
    68.     # 角色指令窗口有效的情况下
    69.     elsif@actor_command_window.active
    70.       update_phase3_basic_command
    71.     end
    72.   end
    73.   #--------------------------------------------------------------------------
    74.   # ● 刷新画面 (角色命令回合 : 基本命令)
    75.   #--------------------------------------------------------------------------
    76.   def update_phase3_basic_command
    77.     # 按下 C 键的情况下
    78.     if Input.trigger?(Input::C)
    79.       # 角色指令窗口光标位置分之
    80.       case@actor_command_window.index
    81.       when0  # 攻击
    82.         # 演奏确定 SE
    83.         $game_system.se_play($data_system.decision_se)
    84.         # 设置行动
    85.         @active_battler_cp.current_action.kind = 0
    86.         @active_battler_cp.current_action.basic = 0
    87.         # 开始选择敌人
    88.         start_enemy_select
    89.       when1  # 特技
    90.         # 演奏确定 SE
    91.         $game_system.se_play($data_system.decision_se)
    92.         # 设置行动
    93.         @active_battler_cp.current_action.kind = 1
    94.         # 开始选择特技
    95.         start_skill_select
    96.       when2  # 防御
    97.         # 演奏确定 SE
    98.         $game_system.se_play($data_system.decision_se)
    99.         # 设置行动
    100.         @active_battler_cp.current_action.kind = 0
    101.         @active_battler_cp.current_action.basic = 1
    102.         start_phase4
    103.         @phase = 4
    104.       when3  # 物品
    105.         # 演奏确定 SE
    106.         $game_system.se_play($data_system.decision_se)
    107.         # 设置行动
    108.         @active_battler_cp.current_action.kind = 2
    109.         # 开始选择物品
    110.         start_item_select
    111.       end
    112.       return
    113.     end
    114.   end
    115.   #--------------------------------------------------------------------------
    116.   # ● 刷新画面 (角色命令回合 : 选择特技)
    117.   #--------------------------------------------------------------------------
    118.   def update_phase3_skill_select
    119.     # 设置特技窗口为可视状态
    120.     @skill_window.visible = true
    121.     # 刷新特技窗口
    122.     @skill_window.update
    123.     # 按下 B 键的情况下
    124.     if Input.trigger?(Input::B)
    125.       # 演奏取消 SE
    126.       $game_system.se_play($data_system.cancel_se)
    127.       # 结束特技选择
    128.       end_skill_select
    129.       return
    130.     end
    131.     # 按下 C 键的情况下
    132.     if Input.trigger?(Input::C)
    133.       # 获取特技选择窗口现在选择的特技的数据
    134.       [url=home.php?mod=space&uid=260100]@skill[/url] = @skill_window.skill
    135.       # 无法使用的情况下
    136.       if@skill == nilornot@active_battler_cp.skill_can_use?(@skill.id)
    137.         # 演奏冻结 SE
    138.         $game_system.se_play($data_system.buzzer_se)
    139.         return
    140.       end
    141.       # 演奏确定 SE
    142.       $game_system.se_play($data_system.decision_se)
    143.       # 设置行动
    144.       @active_battler_cp.current_action.skill_id = @skill.id
    145.       # 设置特技窗口为不可见状态
    146.       @skill_window.visible = false
    147.       if ![1, 3, 5].include?(@skill.scope)
    148.         start_phase4
    149.         @phase = 4
    150.         return
    151.       end
    152.       # 效果范围是敌单体的情况下
    153.       if@skill.scope == 1
    154.         # 开始选择敌人
    155.         start_enemy_select
    156.       # 效果范围是我方单体的情况下
    157.       elsif@skill.scope == 3or@skill.scope == 5
    158.         # 开始选择角色
    159.         start_actor_select
    160.       # 效果范围不是单体的情况下
    161.       else
    162.         # 选择特技结束
    163.         end_skill_select
    164.       end
    165.       return
    166.     end
    167.   end
    168.   #--------------------------------------------------------------------------
    169.   # ● 刷新画面 (角色命令回合 : 选择物品)
    170.   #--------------------------------------------------------------------------
    171.   def update_phase3_item_select
    172.     # 设置物品窗口为可视状态
    173.     @item_window.visible = true
    174.     # 刷新物品窗口
    175.     @item_window.update
    176.     # 按下 B 键的情况下
    177.     if Input.trigger?(Input::B)
    178.       # 演奏取消 SE
    179.       $game_system.se_play($data_system.cancel_se)
    180.       # 选择物品结束
    181.       end_item_select
    182.       return
    183.     end
    184.     # 按下 C 键的情况下
    185.     if Input.trigger?(Input::C)
    186.       # 获取物品窗口现在选择的物品资料
    187.       @item = @item_window.item
    188.       # 无法使用的情况下
    189.       unless$game_party.item_can_use?(@item.id)
    190.         # 演奏冻结 SE
    191.         $game_system.se_play($data_system.buzzer_se)
    192.         return
    193.       end
    194.       # 演奏确定 SE
    195.       $game_system.se_play($data_system.decision_se)
    196.       # 设置行动
    197.       @active_battler_cp.current_action.item_id = @item.id
    198.       # 设置物品窗口为不可见状态
    199.       @item_window.visible = false
    200.       if ![1, 3, 5].include?(@item.scope)
    201.         start_phase4
    202.         @phase = 4
    203.         return
    204.       end
    205.       # 效果范围是敌单体的情况下
    206.       if@item.scope == 1
    207.         # 开始选择敌人
    208.         start_enemy_select
    209.       # 效果范围是我方单体的情况下
    210.       elsif@item.scope == 3or@item.scope == 5
    211.         # 开始选择角色
    212.         start_actor_select
    213.       # 效果范围不是单体的情况下
    214.       else
    215.         # 物品选择结束
    216.         end_item_select
    217.       end
    218.       return
    219.     end
    220.   end
    221.   #--------------------------------------------------------------------------
    222.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
    223.   #--------------------------------------------------------------------------
    224.   def update_phase3_enemy_select
    225.     # 刷新敌人箭头
    226.     @enemy_arrow.update
    227.     # 按下 B 键的情况下
    228.     if Input.trigger?(Input::B)
    229.       # 演奏取消 SE
    230.       $game_system.se_play($data_system.cancel_se)
    231.       # 选择敌人结束
    232.       end_enemy_select
    233.       return
    234.     end
    235.     # 按下 C 键的情况下
    236.     if Input.trigger?(Input::C)
    237.       # 演奏确定 SE
    238.       $game_system.se_play($data_system.decision_se)
    239.       # 设置行动
    240.       @active_battler_cp.current_action.target_index = @enemy_arrow.index
    241.       # 选择敌人结束
    242.       end_enemy_select
    243.       # 显示特技窗口中的情况下
    244.       if@skill_window != nil
    245.         # 结束特技选择
    246.         end_skill_select
    247.       end
    248.       # 显示物品窗口的情况下
    249.       if@item_window != nil
    250.         # 结束物品选择
    251.         end_item_select
    252.       end
    253.       start_phase4
    254.       @phase = 4
    255.       return
    256.     end
    257.   end
    258.   #--------------------------------------------------------------------------
    259.   # ● 画面更新 (角色指令回合 : 选择角色)
    260.   #--------------------------------------------------------------------------
    261.   def update_phase3_actor_select
    262.     # 刷新角色箭头
    263.     @actor_arrow.update
    264.     # 按下 B 键的情况下
    265.     if Input.trigger?(Input::B)
    266.       # 演奏取消 SE
    267.       $game_system.se_play($data_system.cancel_se)
    268.       # 选择角色结束
    269.       end_actor_select
    270.       return
    271.     end
    272.     # 按下 C 键的情况下
    273.     if Input.trigger?(Input::C)
    274.       # 演奏确定 SE
    275.       $game_system.se_play($data_system.decision_se)
    276.       # 设置行动
    277.       @active_battler_cp.current_action.target_index = @actor_arrow.index
    278.       # 选择角色结束
    279.       end_actor_select
    280.       # 显示特技窗口中的情况下
    281.       if@skill_window != nil
    282.         # 结束特技选择
    283.         end_skill_select
    284.       end
    285.       # 显示物品窗口的情况下
    286.       if@item_window != nil
    287.         # 结束物品选择
    288.         end_item_select
    289.       end
    290.       start_phase4
    291.       @phase = 4
    292.       return
    293.     end
    294.   end
    295.   #--------------------------------------------------------------------------
    296.   # ● 开始选择特技
    297.   #--------------------------------------------------------------------------
    298.   def start_skill_select
    299.     # 生成特技窗口
    300.     @skill_window = Window_Skill.new(@active_battler_cp)
    301.     # 关联帮助窗口
    302.     @skill_window.help_window = @help_window
    303.     # 无效化角色指令窗口
    304.     @actor_command_window.active = false
    305.     @actor_command_window.visible = false
    306.   end
    307. end
    复制代码

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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    GMT+8, 2024-5-11 02:43 , Processed in 0.048150 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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