设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3248|回复: 9
打印 上一主题 下一主题

一个战斗命令窗口的插件…

 关闭 [复制链接]

Lv5.捕梦者

御灵的宠物

梦石
12
星屑
8481
在线时间
94 小时
注册时间
2006-12-11
帖子
3156

第2届TG大赛亚军

跳转到指定楼层
1
发表于 2008-2-5 21:39:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
截图:
54被我不小心替换的默认窗口吧……
说明:本来打算晚点再放的,看到新手区已经有两人以上求此效果就提早放了……- -
就是让一些角色战斗不能普通攻击,另一些人不能使用物品什么的……还附带技能分类的一个功能,大家自己看吧orz



使用方式:插入main脚本之前
冲突可能:和图标战斗菜单之类的是100%冲突orz,至于其他战斗系统,我没用alias……插入其他插件前的位置或许冲突没这么大。
本脚本完全兼容柳柳的技能分类脚本,如果使用了技能分类,用它替换技能分类范例里的战斗部分即可
范例工程:http://rpg.blue/upload_program/files/技能分类_82648056.rar

脚本:




  1. DISABLE_ATTACK=[5,7,8]#无法攻击的战斗者
  2. DISABLE_ITEM=[2,3,5]#无法使用物品的战斗者
  3. DISABLE_ESCAPE=[3,2,5]#无法逃跑的战斗者,可以令比如说队长才能下令逃跑...


  4. #==============================================================================
  5. # ■ RPG追加定义,使用@符号分类
  6. #==============================================================================

  7. module RPG
  8. class Skill
  9.    def description
  10.      description = @description.split(/@/)[0]
  11.      return description != nil ? description : ''
  12.    end
  13.    def desc
  14.      desc = @description.split(/@/)[1]
  15.      return desc != nil ? desc : "技能"#普通技能的名字。可以改
  16.    end
  17. end
  18. end

  19. #==============================================================================
  20. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  21. #==============================================================================


  22. class Window_BattleCommand < Window_Selectable
  23.   #--------------------------------------------------------------------------
  24.   def initialize(actor=$game_party.actors[0])
  25.     # 由命令的个数计算出窗口的高
  26.     super(240, 240 , 160, 160)
  27.     @actor=actor
  28.     @item_max = 0
  29.     @commands = []
  30.     refresh
  31.     self.index = 0
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 刷新
  35.   #--------------------------------------------------------------------------
  36.   def refresh
  37.     if !DISABLE_ATTACK.include?(@actor.id)
  38.       @commands.push "攻击"
  39.     end
  40.     for i in [email protected]
  41.       skill = $data_skills[@actor.skills[i]].desc
  42.       if skill != nil and [email protected]?(skill)
  43.         desc = ""
  44.         desc += skill
  45.         @commands.push(desc)
  46.       end
  47.     end
  48.     @commands.push "防御"
  49.     if !DISABLE_ITEM.include?(@actor.id)
  50.       @commands.push "物品"
  51.     end
  52.     if !DISABLE_ESCAPE.include?(@actor.id)
  53.       @commands.push "逃跑"
  54.     end
  55.     @item_max = @commands.size
  56.     height = @item_max  * 32 + 32
  57.     if height > 320
  58.       height = 320
  59.     end
  60.     self.y = 320 - height
  61.     self.height= height
  62.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  63.     self.contents.clear
  64.     for i in 0...@item_max
  65.       draw_item(i, normal_color)
  66.     end
  67.   end
  68.   def command
  69.     return @commands[self.index]
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 描绘项目
  73.   #     index : 项目编号
  74.   #     color : 文字色
  75.   #--------------------------------------------------------------------------
  76.   def draw_item(index, color)
  77.     self.contents.font.color = color
  78.     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
  79.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  80.     self.contents.draw_text(rect, @commands[index])
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 项目无效化
  84.   #     index : 项目编号
  85.   #--------------------------------------------------------------------------
  86.   def disable_item(index)
  87.     draw_item(index, disabled_color)
  88.   end
  89. end
  90. #==============================================================================
  91. # ■ Window_Skill
  92. #------------------------------------------------------------------------------
  93. #  战斗画面显示可以使用的特技浏览的窗口。
  94. #==============================================================================

  95. class Window_Skill_1 < Window_Selectable
  96.   #--------------------------------------------------------------------------
  97.   # ● 初始化对像
  98.   #     actor : 角色
  99.   #--------------------------------------------------------------------------
  100.   def initialize(actor,desc)
  101.      super(0, 128, 640, 352)
  102.     @desc = desc
  103.     @actor = actor
  104.     @column_max = 2
  105.     refresh
  106.     self.index = 0
  107.     # 战斗中的情况下将窗口移至中央并将其半透明化
  108.     if $game_temp.in_battle
  109.       self.y = 64
  110.       self.height = 256
  111.       self.back_opacity = 160
  112.     end
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 获取特技
  116.   #--------------------------------------------------------------------------
  117.   def skill
  118.     return @data[self.index]
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 刷新
  122.   #--------------------------------------------------------------------------
  123.   def refresh
  124.     if self.contents != nil
  125.       self.contents.dispose
  126.       self.contents = nil
  127.     end
  128.     @data = []
  129.     for i in [email protected]
  130.       skill = $data_skills[@actor.skills[i]]
  131.       if skill != nil and $data_skills[@actor.skills[i]].desc == @desc
  132.         @data.push(skill)
  133.       end
  134.     end
  135.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  136.     @item_max = @data.size
  137.     if @item_max > 0
  138.       self.contents = Bitmap.new(width - 32, row_max * 32)
  139.       for i in 0...@item_max
  140.         draw_item(i)
  141.       end
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 描绘项目
  146.   #     index : 项目编号
  147.   #--------------------------------------------------------------------------
  148.   def draw_item(index)
  149.     skill = @data[index]
  150.     if @actor.skill_can_use?(skill.id)
  151.       self.contents.font.color = normal_color
  152.     else
  153.       self.contents.font.color = disabled_color
  154.     end
  155.     x = 4 + index % 2 * (288 + 32)
  156.     y = index / 2 * 32
  157.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  158.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  159.     bitmap = RPG::Cache.icon(skill.icon_name)
  160.     opacity = self.contents.font.color == normal_color ? 255 : 128
  161.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  162.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  163.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 刷新帮助文本
  167.   #--------------------------------------------------------------------------
  168.   def update_help
  169.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  170.   end
  171. end


  172. class Scene_Battle
  173.     def main
  174.     # 初始化战斗用的各种暂时数据
  175.     $game_temp.in_battle = true
  176.     $game_temp.battle_turn = 0
  177.     $game_temp.battle_event_flags.clear
  178.     $game_temp.battle_abort = false
  179.     $game_temp.battle_main_phase = false
  180.     $game_temp.battleback_name = $game_map.battleback_name
  181.     $game_temp.forcing_battler = nil
  182.     # 初始化战斗用事件解释器
  183.     $game_system.battle_interpreter.setup(nil, 0)
  184.     # 准备队伍
  185.     @troop_id = $game_temp.battle_troop_id
  186.     $game_troop.setup(@troop_id)
  187.     # 生成角色命令窗口
  188.     s1 = $data_system.words.attack
  189.     s2 = $data_system.words.skill
  190.     s3 = $data_system.words.guard
  191.     s4 = $data_system.words.item
  192.     @actor_command_window = Window_BattleCommand.new###只改这行……
  193.     @actor_command_window.y = 160
  194.     @actor_command_window.back_opacity = 160
  195.     @actor_command_window.active = false
  196.     @actor_command_window.visible = false
  197.     # 生成其它窗口
  198.     @party_command_window = Window_PartyCommand.new
  199.     @help_window = Window_Help.new
  200.     @help_window.back_opacity = 160
  201.     @help_window.visible = false
  202.     @status_window = Window_BattleStatus.new
  203.     @message_window = Window_Message.new
  204.     # 生成活动块
  205.     @spriteset = Spriteset_Battle.new
  206.     # 初始化等待计数
  207.     @wait_count = 0
  208.     # 执行过渡
  209.     if $data_system.battle_transition == ""
  210.       Graphics.transition(20)
  211.     else
  212.       Graphics.transition(40, "Graphics/Transitions/" +
  213.         $data_system.battle_transition)
  214.     end
  215.     # 开始自由战斗回合
  216.     start_phase1
  217.     # 主循环
  218.     loop do
  219.       # 刷新游戏画面
  220.       Graphics.update
  221.       # 刷新输入信息
  222.       Input.update
  223.       # 刷新画面
  224.       update
  225.       # 如果画面切换的话就中断循环
  226.       if $scene != self
  227.         break
  228.       end
  229.     end
  230.     # 刷新地图
  231.     $game_map.refresh
  232.     # 准备过渡
  233.     Graphics.freeze
  234.     # 释放窗口
  235.     @actor_command_window.dispose
  236.     @party_command_window.dispose
  237.     @help_window.dispose
  238.     @status_window.dispose
  239.     @message_window.dispose
  240.     if @skill_window != nil
  241.       @skill_window.dispose
  242.     end
  243.     if @item_window != nil
  244.       @item_window.dispose
  245.     end
  246.     if @result_window != nil
  247.       @result_window.dispose
  248.     end
  249.     # 释放活动块
  250.     @spriteset.dispose
  251.     # 标题画面切换中的情况
  252.     if $scene.is_a?(Scene_Title)
  253.       # 淡入淡出画面
  254.       Graphics.transition
  255.       Graphics.freeze
  256.     end
  257.     # 战斗测试或者游戏结束以外的画面切换中的情况
  258.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  259.       $scene = nil
  260.     end
  261.   end
  262.   def phase3_setup_command_window
  263.     # 同伴指令窗口无效化
  264.     @party_command_window.active = false
  265.     @party_command_window.visible = false
  266.     @actor_command_window.dispose
  267.     @actor_command_window=Window_BattleCommand.new(@active_battler)
  268.     @actor_command_window.active = true
  269.     @actor_command_window.visible = true
  270.     # 设置角色指令窗口的位置
  271.     @actor_command_window.x =  @actor_index * 160
  272.     # 设置索引为 0
  273.     @actor_command_window.index = 0
  274.   end

  275.   def update_phase3_basic_command
  276.     # 按下 B 键的情况下
  277.     if Input.trigger?(Input::B)
  278.       # 演奏取消 SE
  279.       $game_system.se_play($data_system.cancel_se)
  280.       # 转向前一个角色的指令输入
  281.       phase3_prior_actor
  282.       return
  283.     end
  284.     # 按下 C 键的情况下
  285.     if Input.trigger?(Input::C)
  286.       # 角色指令窗口光标位置分之
  287.       if @actor_command_window.command == "攻击"
  288.         # 演奏确定 SE
  289.         $game_system.se_play($data_system.decision_se)
  290.         # 设置行动
  291.         @active_battler.current_action.kind = 0
  292.         @active_battler.current_action.basic = 0
  293.         # 开始选择敌人
  294.         start_enemy_select
  295.       elsif @actor_command_window.command == "防御"
  296.        # 演奏确定 SE
  297.         $game_system.se_play($data_system.decision_se)
  298.         # 设置行动
  299.         @active_battler.current_action.kind = 0
  300.         @active_battler.current_action.basic = 1
  301.         # 转向下一位角色的指令输入
  302.         phase3_next_actor
  303.       elsif  @actor_command_window.command == "逃跑"
  304.        # 不能逃跑的情况下
  305.         if $game_temp.battle_can_escape == false
  306.           # 演奏冻结 SE
  307.           $game_system.se_play($data_system.buzzer_se)
  308.           return
  309.         end
  310.         # 演奏确定 SE
  311.         $game_system.se_play($data_system.decision_se)
  312.         # 逃走处理
  313.         update_phase2_escape
  314.       elsif @actor_command_window.command == "物品"
  315.         # 演奏确定 SE
  316.         $game_system.se_play($data_system.decision_se)
  317.         # 设置行动
  318.         @active_battler.current_action.kind = 2
  319.         # 开始选择物品
  320.         start_item_select
  321.       else
  322.         # 演奏确定 SE
  323.         $game_system.se_play($data_system.decision_se)
  324.         # 设置行动
  325.         @active_battler.current_action.kind = 1
  326.         # 开始选择特技
  327.         start_skill_select
  328.       end
  329.       return
  330.     end
  331.   end
  332.   def start_skill_select
  333.     # 生成特技窗口
  334.     @skill_window=Window_Skill_1.new(@active_battler, @actor_command_window.command)
  335.     # 关联帮助窗口
  336.     @skill_window.help_window = @help_window
  337.     # 无效化角色指令窗口
  338.     @actor_command_window.active = false
  339.     @actor_command_window.visible = false
  340.   end
  341. end

复制代码
我的Lofter:http://nightoye.lofter.com/

头像被屏蔽

Lv1.梦旅人 (禁止发言)

心无天使

梦石
0
星屑
49
在线时间
0 小时
注册时间
2007-12-15
帖子
1016
2
发表于 2008-2-5 22:09:42 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
1 小时
注册时间
2008-2-6
帖子
17
3
发表于 2008-2-6 07:57:51 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv5.捕梦者

御灵的宠物

梦石
12
星屑
8481
在线时间
94 小时
注册时间
2006-12-11
帖子
3156

第2届TG大赛亚军

4
 楼主| 发表于 2008-2-7 00:31:26 | 只看该作者
.....望LS.那个...那个跟此脚本有关系灭?

摸宠物之
我的Lofter:http://nightoye.lofter.com/

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

心无天使

梦石
0
星屑
49
在线时间
0 小时
注册时间
2007-12-15
帖子
1016
5
发表于 2008-2-7 05:06:46 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7976
在线时间
1183 小时
注册时间
2007-7-29
帖子
2055
6
发表于 2008-2-7 05:26:29 | 只看该作者
技术区。。。回来看看。
类似这种针对新人写出的脚本果然还是最好的。{/qiang}
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-2-7
帖子
23
7
发表于 2008-2-7 05:41:13 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-2-8
帖子
21
8
发表于 2008-2-8 22:48:04 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2006-8-26
帖子
39
9
发表于 2008-2-9 22:18:03 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
74
在线时间
117 小时
注册时间
2007-8-5
帖子
479
10
发表于 2008-2-9 23:14:05 | 只看该作者
恩...8错8错....
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-7-23 21:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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