查看: 68|回复: 0

[转载发布] 状态限制

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

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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


    工程


    脚本
    RUBY 代码
    1. #==============================================================================
    2. # ■ States_Restrict(封系状态)
    3. #------------------------------------------------------------------------------
    4. #
    5. #   * 说明:脚本定义了新的限制,原状态限制作废。
    6. #           不建议作为插件使用,最好和其他脚本整合一下(难度很低)。
    7. #
    8. #  * 命名:英语渣,大家就凑合看吧。
    9. #
    10. #   * 冲突:重定义了 update_phase4_step2       主回合步骤 2 : 开始行动
    11. #           重定义了 make_basic_action_result  生成基本行动结果
    12. #           重定义了 make_skill_action_result  生成特技行动结果
    13. #           重定义了 make_item_action_result   生成物品行动结果
    14. #
    15. #==============================================================================
    16. module States_Restrict
    17.   # - 优先级(按照从低到高的顺序排列)
    18.   Priority = []
    19.   # * 攻击
    20.   Priority[0] = ["B", "A", "C"]
    21.   # * 特技
    22.   Priority[1] = ["C", "B", "A"]
    23.   # * 物品
    24.   Priority[2] = ["C", "B", "A"]
    25.   # - 设置
    26.   A_States_Restrict_To_Attack = [16]  # 不可攻击
    27.   B_States_Restrict_To_Attack = []    # 只能普通攻击敌人
    28.   C_States_Restrict_To_Attack = [15]  # 只能普通攻击同伴
    29.   A_States_Restrict_To_Skill = []     # 不可(使用)技能
    30.   B_States_Restrict_To_Skill = [14]   # 只可对敌人(只能使用攻击类技能)
    31.   C_States_Restrict_To_Skill = []     # 只可对同伴(只能使用辅助类技能)
    32.   A_States_Restrict_To_Item = [13]    # 不可(使用)物品
    33.   B_States_Restrict_To_Item = []      # 只可对敌人(只能使用暗器类物品)
    34.   C_States_Restrict_To_Item = []      # 只可对同伴(只能使用辅助类物品)
    35.   States_Restrict_To_Guard = [16]     # 不可防御
    36.   # - 用语(不用管)
    37.   A_States_Restrict_To_Attack_Word = "不可攻击"
    38.   B_States_Restrict_To_Attack_Word = "只能普通攻击敌人"
    39.   C_States_Restrict_To_Attack_Word = "只能普通攻击同伴"
    40.   A_States_Restrict_To_Skill_Word = "不可(使用)技能"
    41.   B_States_Restrict_To_Skill_Word = "只可对敌人"
    42.   C_States_Restrict_To_Skill_Word = "只可对同伴"
    43.   A_States_Restrict_To_Item_Word = "不可(使用)物品"
    44.   B_States_Restrict_To_Item_Word = "只可对敌人"
    45.   C_States_Restrict_To_Item_Word = "只可对同伴"
    46.   States_Restrict_To_Guard_Word = "不可防御"
    47. end
    48. class Game_Battler
    49.   def restriction_zhouzhou
    50.     command = []
    51.     # - 攻击指令
    52.     for index inStates_Restrict::Priority[0]
    53.       if index == "B"
    54.         if(@states & States_Restrict::B_States_Restrict_To_Attack).size > 0
    55.           command[0] = States_Restrict::B_States_Restrict_To_Attack_Word
    56.         end
    57.       elsif index == "A"
    58.         if(@states & States_Restrict::A_States_Restrict_To_Attack).size > 0
    59.           command[0] = States_Restrict::A_States_Restrict_To_Attack_Word
    60.         end
    61.       elsif index == "C"
    62.         if(@states & States_Restrict::C_States_Restrict_To_Attack).size > 0
    63.           command[0] = States_Restrict::C_States_Restrict_To_Attack_Word
    64.         end
    65.       end
    66.     end
    67.     # - 特技指令
    68.     for index inStates_Restrict::Priority[1]
    69.       if index == "C"
    70.         if(@states & States_Restrict::C_States_Restrict_To_Skill).size > 0
    71.           command[1] = States_Restrict::C_States_Restrict_To_Skill_Word
    72.         end
    73.       elsif index == "B"
    74.         if(@states & States_Restrict::B_States_Restrict_To_Skill).size > 0
    75.           command[1] = States_Restrict::B_States_Restrict_To_Skill_Word
    76.         end
    77.       elsif index == "A"
    78.         if(@states & States_Restrict::A_States_Restrict_To_Skill).size > 0
    79.           command[1] = States_Restrict::A_States_Restrict_To_Skill_Word
    80.         end
    81.       end
    82.     end
    83.     # - 物品指令
    84.     for index inStates_Restrict::Priority[2]
    85.       if index == "C"
    86.         if(@states & States_Restrict::C_States_Restrict_To_Item).size > 0
    87.           command[2] = States_Restrict::C_States_Restrict_To_Item_Word
    88.         end
    89.       elsif index == "B"
    90.         if(@states & States_Restrict::B_States_Restrict_To_Item).size > 0
    91.           command[2] = States_Restrict::B_States_Restrict_To_Item_Word
    92.         end
    93.       elsif index == "A"
    94.         if(@states & States_Restrict::A_States_Restrict_To_Item).size > 0
    95.           command[2] = States_Restrict::A_States_Restrict_To_Item_Word
    96.         end
    97.       end
    98.     end
    99.     # - 防御指令
    100.     if(@states & States_Restrict::States_Restrict_To_Guard).size > 0
    101.       command[3] = States_Restrict::States_Restrict_To_Guard_Word
    102.     end
    103.     return command
    104.   end
    105. end
    106. # - 参战人数
    107. class Game_Party
    108.   def exist_size
    109.     actor_size = 0
    110.     for i in$game_party.actors
    111.       actor_size += 1if i.exist?
    112.     end
    113.     return actor_size
    114.   end
    115. end
    116. class Game_Troop
    117.   def exist_size
    118.     actor_size = 0
    119.     for i in$game_troop.enemies
    120.       actor_size += 1if i.exist?
    121.     end
    122.     return actor_size
    123.   end
    124. end
    125. class Scene_Battle
    126.   # - 检查限制
    127.   def check_to_restrict
    128.     re = @active_battler.restriction_zhouzhou
    129.     # - 攻击
    130.     if re[0] != nil
    131.       # - 限制
    132.       if(@active_battler.current_action.kind != 0or
    133.         @active_battler.current_action.basic != 0)and
    134.         re[0] != States_Restrict::A_States_Restrict_To_Attack_Word
    135.         @active_battler.current_action.kind = 0
    136.         @active_battler.current_action.basic = 0
    137.       # - 无效指令
    138.       elsif@active_battler.current_action.kind == 0and
    139.         @active_battler.current_action.basic == 0and
    140.         re[0] == States_Restrict::A_States_Restrict_To_Attack_Word
    141.         # 清除行动强制对像的战斗者
    142.         $game_temp.forcing_battler = nil
    143.         # 移至步骤 1
    144.         @phase4_step = 1
    145.         return
    146.       end
    147.     end
    148.     # - 特技
    149.     if re[1] != nil
    150.       if@active_battler.current_action.kind == 1and
    151.         re[1] == States_Restrict::A_States_Restrict_To_Skill_Word
    152.         # 清除行动强制对像的战斗者
    153.         $game_temp.forcing_battler = nil
    154.         # 移至步骤 1
    155.         @phase4_step = 1
    156.         return
    157.       end
    158.     end
    159.     # - 物品
    160.     if re[2] != nil
    161.       if@active_battler.current_action.kind == 2and
    162.         re[2] == States_Restrict::A_States_Restrict_To_Item_Word
    163.         # 清除行动强制对像的战斗者
    164.         $game_temp.forcing_battler = nil
    165.         # 移至步骤 1
    166.         @phase4_step = 1
    167.         return
    168.       end
    169.     end
    170.     # - 防御
    171.     if re[3] != nil
    172.       if@active_battler.current_action.kind == 0and
    173.         @active_battler.current_action.basic == 1
    174.         # 清除行动强制对像的战斗者
    175.         $game_temp.forcing_battler = nil
    176.         # 移至步骤 1
    177.         @phase4_step = 1
    178.         return
    179.       end
    180.     end
    181.   end
    182.   #--------------------------------------------------------------------------
    183.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
    184.   #--------------------------------------------------------------------------
    185.   def update_phase4_step2
    186.     # 如果不是强制行动
    187.     unless@active_battler.current_action.forcing
    188.       check_to_restrict
    189.     end
    190.     # 清除对像战斗者
    191.     @target_battlers = []
    192.     # 行动种类分支
    193.     case@active_battler.current_action.kind
    194.     when0  # 基本
    195.       make_basic_action_result
    196.     when1  # 特技
    197.       make_skill_action_result
    198.     when2  # 物品
    199.       make_item_action_result
    200.     end
    201.     # 移至步骤 3
    202.     if@phase4_step == 2
    203.       @phase4_step = 3
    204.     end
    205.   end
    206.   #--------------------------------------------------------------------------
    207.   # ● 生成基本行动结果
    208.   #--------------------------------------------------------------------------
    209.   def make_basic_action_result
    210.     # 攻击的情况下
    211.     if@active_battler.current_action.basic == 0
    212.       re = @active_battler.restriction_zhouzhou[0]
    213.       # 设置攻击 ID
    214.       @animation1_id = @active_battler.animation1_id
    215.       @animation2_id = @active_battler.animation2_id
    216.       # 行动方的战斗者是敌人的情况下
    217.       if@active_battler.is_a?(Game_Enemy)
    218.         # - 普通攻击同伴
    219.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
    220.           if$game_troop.exist_size > 1
    221.             target = $game_troop.random_target_enemy
    222.             while target == @active_battler
    223.               target = $game_troop.random_target_enemy
    224.             end
    225.           else
    226.             # 清除强制行动对像的战斗者
    227.             $game_temp.forcing_battler = nil
    228.             # 移至步骤 1
    229.             @phase4_step = 1
    230.             return
    231.           end
    232.         # - 普通攻击敌人
    233.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
    234.           target = $game_party.random_target_actor
    235.         # - 无限制
    236.         elsif re == nil
    237.           index = @active_battler.current_action.target_index
    238.           target = $game_party.smooth_target_actor(index)
    239.         else
    240.           return
    241.         end
    242.       end
    243.       # 行动方的战斗者是角色的情况下
    244.       if@active_battler.is_a?(Game_Actor)
    245.         # - 普通攻击同伴
    246.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
    247.           if$game_party.exist_size > 1
    248.             target = $game_party.random_target_actor
    249.             while target == @active_battler
    250.               target = $game_party.random_target_actor
    251.             end
    252.           else
    253.             # 清除强制行动对像的战斗者
    254.             $game_temp.forcing_battler = nil
    255.             # 移至步骤 1
    256.             @phase4_step = 1
    257.             return
    258.           end
    259.         # - 普通攻击敌人
    260.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
    261.           target = $game_troop.random_target_enemy
    262.         # - 无限制
    263.         elsif re == nil
    264.           index = @active_battler.current_action.target_index
    265.           target = $game_troop.smooth_target_enemy(index)
    266.         else
    267.           return
    268.         end
    269.       end
    270.       # 设置对像方的战斗者序列
    271.       @target_battlers = [target]
    272.       # 应用通常攻击效果
    273.       for target in@target_battlers
    274.         target.attack_effect(@active_battler)
    275.       end
    276.       return
    277.     end
    278.     # 防御的情况下
    279.     if@active_battler.current_action.basic == 1
    280.       # 帮助窗口显示"防御"
    281.       @help_window.set_text($data_system.words.guard, 1)
    282.       return
    283.     end
    284.     # 逃跑的情况下
    285.     if@active_battler.is_a?(Game_Enemy)and
    286.        @active_battler.current_action.basic == 2
    287.       #  帮助窗口显示"逃跑"
    288.       @help_window.set_text("逃跑", 1)
    289.       # 逃跑
    290.       @active_battler.escape
    291.       return
    292.     end
    293.     # 什么也不做的情况下
    294.     if@active_battler.current_action.basic == 3
    295.       # 清除强制行动对像的战斗者
    296.       $game_temp.forcing_battler = nil
    297.       # 移至步骤 1
    298.       @phase4_step = 1
    299.       return
    300.     end
    301.   end
    302.   #--------------------------------------------------------------------------
    303.   # ● 生成特技行动结果
    304.   #--------------------------------------------------------------------------
    305.   def make_skill_action_result
    306.     re = @active_battler.restriction_zhouzhou[1]
    307.     # 获取特技
    308.     [url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[@active_battler.current_action.skill_id]
    309.     # 如果不是强制行动
    310.     unless@active_battler.current_action.forcing
    311.       # 因为 SP 耗尽而无法使用的情况下
    312.       unless@active_battler.skill_can_use?(@skill.id)
    313.         # 清除强制行动对像的战斗者
    314.         $game_temp.forcing_battler = nil
    315.         # 移至步骤 1
    316.         @phase4_step = 1
    317.         return
    318.       end
    319.     end
    320.     # 设置对像侧战斗者
    321.     set_target_battlers(@skill.scope)
    322.     # - 限制特技
    323.     case re
    324.     whenStates_Restrict::A_States_Restrict_To_Skill_Word
    325.       # 清除强制行动对像的战斗者
    326.       $game_temp.forcing_battler = nil
    327.       # 移至步骤 1
    328.       @phase4_step = 1
    329.       return
    330.     whenStates_Restrict::B_States_Restrict_To_Skill_Word
    331.       if@active_battler.is_a?(Game_Actor)
    332.         if@target_battlers[0].is_a?(Game_Actor)
    333.           # 清除强制行动对像的战斗者
    334.           $game_temp.forcing_battler = nil
    335.           # 移至步骤 1
    336.           @phase4_step = 1
    337.           return
    338.         end
    339.       elsif@active_battler.is_a?(Game_Enemy)
    340.         if@target_battlers[0].is_a?(Game_Enemy)
    341.           # 清除强制行动对像的战斗者
    342.           $game_temp.forcing_battler = nil
    343.           # 移至步骤 1
    344.           @phase4_step = 1
    345.           return
    346.         end
    347.       end
    348.     whenStates_Restrict::C_States_Restrict_To_Skill_Word
    349.       if@active_battler.is_a?(Game_Actor)
    350.         if@target_battlers[0].is_a?(Game_Enemy)
    351.           # 清除强制行动对像的战斗者
    352.           $game_temp.forcing_battler = nil
    353.           # 移至步骤 1
    354.           @phase4_step = 1
    355.           return
    356.         end
    357.       elsif@active_battler.is_a?(Game_Enemy)
    358.         if@target_battlers[0].is_a?(Game_Actor)
    359.           # 清除强制行动对像的战斗者
    360.           $game_temp.forcing_battler = nil
    361.           # 移至步骤 1
    362.           @phase4_step = 1
    363.           return
    364.         end
    365.       end
    366.     end
    367.     # 消耗 SP
    368.     @active_battler.sp -= @skill.sp_cost
    369.     # 刷新状态窗口
    370.     @status_window.refresh
    371.     # 在帮助窗口显示特技名
    372.     @help_window.set_text(@skill.name, 1)
    373.     # 设置动画 ID
    374.     @animation1_id = @skill.animation1_id
    375.     @animation2_id = @skill.animation2_id
    376.     # 设置公共事件 ID
    377.     @common_event_id = @skill.common_event_id
    378.     # 应用特技效果
    379.     for target in@target_battlers
    380.       target.skill_effect(@active_battler, @skill)
    381.     end
    382.   end
    383.   #--------------------------------------------------------------------------
    384.   # ● 生成物品行动结果
    385.   #--------------------------------------------------------------------------
    386.   def make_item_action_result
    387.     re = @active_battler.restriction_zhouzhou[2]
    388.     # 获取物品
    389.     @item = $data_items[@active_battler.current_action.item_id]
    390.     # 因为物品耗尽而无法使用的情况下
    391.     unless$game_party.item_can_use?(@item.id)
    392.       # 移至步骤 1
    393.       @phase4_step = 1
    394.       return
    395.     end
    396.     # 设置对像侧战斗者
    397.     set_target_battlers(@item.scope)
    398.     # - 限制物品
    399.     case re
    400.     whenStates_Restrict::A_States_Restrict_To_Item_Word
    401.       # 清除强制行动对像的战斗者
    402.       $game_temp.forcing_battler = nil
    403.       # 移至步骤 1
    404.       @phase4_step = 1
    405.       return
    406.     whenStates_Restrict::B_States_Restrict_To_Item_Word
    407.       if@active_battler.is_a?(Game_Actor)
    408.         if@target_battlers[0].is_a?(Game_Actor)
    409.           # 清除强制行动对像的战斗者
    410.           $game_temp.forcing_battler = nil
    411.           # 移至步骤 1
    412.           @phase4_step = 1
    413.           return
    414.         end
    415.       elsif@active_battler.is_a?(Game_Enemy)
    416.         if@target_battlers[0].is_a?(Game_Enemy)
    417.           # 清除强制行动对像的战斗者
    418.           $game_temp.forcing_battler = nil
    419.           # 移至步骤 1
    420.           @phase4_step = 1
    421.           return
    422.         end
    423.       end
    424.     whenStates_Restrict::C_States_Restrict_To_Item_Word
    425.       if@active_battler.is_a?(Game_Actor)
    426.         if@target_battlers[0].is_a?(Game_Enemy)
    427.           # 清除强制行动对像的战斗者
    428.           $game_temp.forcing_battler = nil
    429.           # 移至步骤 1
    430.           @phase4_step = 1
    431.           return
    432.         end
    433.       elsif@active_battler.is_a?(Game_Enemy)
    434.         if@target_battlers[0].is_a?(Game_Actor)
    435.           # 清除强制行动对像的战斗者
    436.           $game_temp.forcing_battler = nil
    437.           # 移至步骤 1
    438.           @phase4_step = 1
    439.           return
    440.         end
    441.       end
    442.     end
    443.     # 消耗品的情况下
    444.     if@item.consumable
    445.       # 使用的物品减 1
    446.       $game_party.lose_item(@item.id, 1)
    447.     end
    448.     # 在帮助窗口显示物品名
    449.     @help_window.set_text(@item.name, 1)
    450.     # 设置动画 ID
    451.     @animation1_id = @item.animation1_id
    452.     @animation2_id = @item.animation2_id
    453.     # 设置公共事件 ID
    454.     @common_event_id = @item.common_event_id
    455.     # 应用物品效果
    456.     for target in@target_battlers
    457.       target.item_effect(@item)
    458.     end
    459.   end
    460. end
    461. #------------------------------------------------------------------------------
    复制代码

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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    GMT+8, 2024-5-10 13:35 , Processed in 0.063240 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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