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

Project1

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

[已经过期] 战斗系统中鼠标指令

[复制链接]

Lv1.梦旅人

梦石
0
星屑
85
在线时间
210 小时
注册时间
2013-7-26
帖子
346
跳转到指定楼层
1
发表于 2014-9-9 11:33:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
进入战斗后,如何做到可以直接通过点击敌人来进行普通攻击。RM的普通攻击都要先点击【攻击】命令才可以攻击。
下面是指令脚本和鼠标脚本
  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.     # 输入下一个角色的命令
  17.     phase3_next_actor
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 转到输入下一个角色的命令
  21.   #--------------------------------------------------------------------------
  22.   def phase3_next_actor
  23.     # 循环
  24.     begin
  25.       # 角色的明灭效果 OFF
  26.       if @active_battler != nil
  27.         @active_battler.blink = false
  28.       end
  29.       # 最后的角色的情况
  30.       if @actor_index == $game_party.actors.size-1
  31.         # 开始主回合
  32.         start_phase4
  33.         return
  34.       end
  35.       # 推进角色索引
  36.       @actor_index += 1
  37.       @active_battler = $game_party.actors[@actor_index]
  38.       @active_battler.blink = true
  39.     # 如果角色是在无法接受指令的状态就再试
  40.     end until @active_battler.inputable?
  41.     # 设置角色的命令窗口
  42.     phase3_setup_command_window
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 转向前一个角色的命令输入
  46.   #--------------------------------------------------------------------------
  47.   def phase3_prior_actor
  48.     # 循环
  49.     begin
  50.       # 角色的明灭效果 OFF
  51.       if @active_battler != nil
  52.         @active_battler.blink = false
  53.       end
  54.       # 最初的角色的情况下
  55.       if @actor_index == 0
  56.         # 开始同伴指令回合
  57.         start_phase2
  58.         return
  59.       end
  60.       # 返回角色索引
  61.       @actor_index -= 1
  62.       @active_battler = $game_party.actors[@actor_index]
  63.       @active_battler.blink = true
  64.     # 如果角色是在无法接受指令的状态就再试
  65.     end until @active_battler.inputable?
  66.     # 设置角色的命令窗口
  67.     phase3_setup_command_window
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 设置角色指令窗口
  71.   #--------------------------------------------------------------------------
  72.   def phase3_setup_command_window
  73.     # 同伴指令窗口无效化
  74.     #@party_command_window.active = false
  75.     #@party_command_window.visible = false
  76.     actor = @active_battler
  77.     # 角色指令窗口无效化
  78.     if actor.id < 20
  79.       @actor_command_window.active = true
  80.       @actor_command_window.visible = true
  81.       @baby_command_window.active = false
  82.       @baby_command_window.visible = false
  83.       #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  84.       # 设置角色指令窗口的位置
  85.       @actor_command_window.x = $game_party.actors[@actor_index].screen_x - 30 #@actor_index * 160
  86.       @actor_command_window.y = $game_party.actors[@actor_index].screen_y - @actor_command_window.height - 32
  87.       #设置宽度
  88.       @actor_command_window.width = 100
  89.       #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  90.       # 设置索引为 0
  91.       @actor_command_window.index = 0
  92.     else
  93.       @baby_command_window.active = true
  94.       @baby_command_window.visible = true
  95.       @actor_command_window.active = false
  96.       @actor_command_window.visible = false
  97.       #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  98.       # 设置角色指令窗口的位置
  99.       @baby_command_window.x = $game_party.actors[@actor_index].screen_x - 30 #@actor_index * 160
  100.       @baby_command_window.y = $game_party.actors[@actor_index].screen_y - @baby_command_window.height - 32
  101.       #设置宽度
  102.       @baby_command_window.width = 100
  103.       #●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  104.       # 设置索引为 0
  105.       @baby_command_window.index = 0
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 刷新画面 (角色命令回合)
  110.   #--------------------------------------------------------------------------
  111.   def update_phase3
  112.     # 敌人光标有效的情况下
  113.     if @enemy_arrow != nil
  114.       update_phase3_enemy_select
  115.     # 角色光标有效的情况下
  116.     elsif @actor_arrow != nil
  117.       update_phase3_actor_select
  118.     # 特技窗口有效的情况下
  119.     elsif @skill_window != nil
  120.       update_phase3_skill_select
  121.     # 物品窗口有效的情况下
  122.     elsif @item_window != nil
  123.       update_phase3_item_select
  124.     #召唤窗口有效的情况下
  125.     elsif @call_window != nil
  126.       update_phase3_call_select
  127.     # 角色指令窗口有效的情况下
  128.     elsif @actor_command_window.active
  129.       update_phase3_basic_command
  130.     elsif @baby_command_window.active
  131.       update_phase3_basic_command
  132.     end
  133.   end
  134.   
  135.   #--------------------------------------------------------------------------
  136.   # ● 刷新画面 (角色命令回合 : 选择特技)
  137.   #--------------------------------------------------------------------------
  138.   def update_phase3_skill_select
  139.     # 设置特技窗口为可视状态
  140.     @skill_window.visible = true
  141.     # 刷新特技窗口
  142.     @skill_window.update
  143.     # 按下 B 键的情况下
  144.     if Input.trigger?(Input::B)
  145.       # 演奏取消 SE
  146.       $game_system.se_play($data_system.cancel_se)
  147.       # 结束特技选择
  148.       end_skill_select
  149.       return
  150.     end
  151.     # 按下 C 键的情况下
  152.     if Input.trigger?(Input::C)
  153.       # 获取特技选择窗口现在选择的特技的数据
  154.       [url=home.php?mod=space&uid=260100]@skill[/url] = @skill_window.skill
  155.       #无法使用的情况下
  156.       # ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  157.       # 去掉后面的那段东西,角色死亡后,仍然可以选择特技!
  158.       if @skill == nil or @skill.occasion == 3
  159.       # ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  160.         # 演奏冻结 SE
  161.         $game_system.se_play($data_system.buzzer_se)
  162.         return
  163.       end
  164.       # 演奏确定 SE
  165.       $game_system.se_play($data_system.decision_se)
  166.       # 设置行动
  167.       @active_battler.current_action.skill_id = @skill.id
  168.       #记录当前使用的法术id
  169.       @active_battler.past_skill = @active_battler.current_action.skill_id
  170.       @active_battler.past_action = 1
  171.       # 设置特技窗口为不可见状态
  172.       @skill_window.visible = false
  173.       # 效果范围是敌单体的情况下
  174.       if @skill.scope == 1
  175.         # 开始选择敌人
  176.         start_enemy_select
  177.       # 效果范围是我方单体的情况下
  178.       elsif @skill.scope == 3 or @skill.scope == 5
  179.         # 开始选择角色
  180.         start_actor_select
  181.       # 效果范围不是单体的情况下
  182.       else
  183.         # 选择特技结束
  184.         end_skill_select
  185.         # 转到下一位角色的指令输入
  186.         phase3_next_actor
  187.       end
  188.       return
  189.     end
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 刷新画面 (角色命令回合 : 选择物品)
  193.   #--------------------------------------------------------------------------
  194.   def update_phase3_item_select
  195.     # 设置物品窗口为可视状态
  196.     @item_window.visible = true
  197.     # 刷新物品窗口
  198.     @item_window.update
  199.     # 按下 B 键的情况下
  200.     if Input.trigger?(Input::B)
  201.       # 演奏取消 SE
  202.       $game_system.se_play($data_system.cancel_se)
  203.       # 选择物品结束
  204.       end_item_select
  205.       return
  206.     end
  207.     # 按下 C 键的情况下
  208.     if Input.trigger?(Input::C)
  209.       # 获取物品窗口现在选择的物品资料
  210.       @item = @item_window.item
  211.       if @item != nil
  212.       # 无法使用的情况下
  213.       if $game_party.item_can_use?(@item.id) or @item.occasion < 2
  214.       else
  215.         # 演奏冻结 SE
  216.         $game_system.se_play($data_system.buzzer_se)
  217.         return
  218.       end
  219.       end
  220.       # 演奏确定 SE
  221.       $game_system.se_play($data_system.decision_se)
  222.       # 设置行动
  223.       @active_battler.current_action.item_id = @item.id
  224.       # 设置物品窗口为不可见状态
  225.       @item_window.visible = false
  226.       # 效果范围是敌单体的情况下
  227.       if @item.scope == 1
  228.         # 开始选择敌人
  229.         start_enemy_select
  230.       # 效果范围是我方单体的情况下
  231.       elsif @item.scope == 3 or @item.scope == 5
  232.         # 开始选择角色
  233.         start_actor_select
  234.       # 效果范围不是单体的情况下
  235.       else
  236.         # 物品选择结束
  237.         end_item_select
  238.         # 转到下一位角色的指令输入
  239.         phase3_next_actor
  240.       end
  241.       return
  242.     end
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  246.   #--------------------------------------------------------------------------
  247.   def update_phase3_enemy_select
  248.     # 刷新敌人箭头
  249.     @enemy_arrow.update
  250.     # 按下 B 键的情况下
  251.     if Input.trigger?(Input::B)
  252.       # 演奏取消 SE
  253.       $game_system.se_play($data_system.cancel_se)
  254.       # 选择敌人结束
  255.       end_enemy_select
  256.       return
  257.     end
  258.     # 按下 C 键的情况下
  259.     if Input.trigger?(Input::C)
  260.       # 演奏确定 SE
  261.       $game_system.se_play($data_system.decision_se)
  262.       # 设置行动
  263.       @active_battler.current_action.target_index = @enemy_arrow.index
  264.       # 选择敌人结束
  265.       end_enemy_select
  266.       # 显示特技窗口中的情况下
  267.       if @skill_window != nil
  268.         # 结束特技选择
  269.         end_skill_select
  270.       end
  271.       # 显示物品窗口的情况下
  272.       if @item_window != nil
  273.         # 结束物品选择
  274.         end_item_select
  275.       end
  276.       # 转到下一位角色的指令输入
  277.       phase3_next_actor
  278.     end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 画面更新 (角色指令回合 : 选择角色)
  282.   #--------------------------------------------------------------------------
  283.   def update_phase3_actor_select
  284.     # 刷新角色箭头
  285.     @actor_arrow.update
  286.     # 按下 B 键的情况下
  287.     if Input.trigger?(Input::B)
  288.       # 演奏取消 SE
  289.       $game_system.se_play($data_system.cancel_se)
  290.       # 选择角色结束
  291.       end_actor_select
  292.       return
  293.     end
  294.     # 按下 C 键的情况下
  295.     if Input.trigger?(Input::C)
  296.       # 演奏确定 SE
  297.       $game_system.se_play($data_system.decision_se)
  298.       # 设置行动
  299.       @active_battler.current_action.target_index = @actor_arrow.index
  300.       # 选择角色结束
  301.       end_actor_select
  302.       # 显示特技窗口中的情况下
  303.       if @skill_window != nil
  304.         # 结束特技选择
  305.         end_skill_select
  306.       end
  307.       # 显示物品窗口的情况下
  308.       if @item_window != nil
  309.         # 结束物品选择
  310.         end_item_select
  311.       end
  312.       # 转到下一位角色的指令输入
  313.       phase3_next_actor
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 画面更新 (角色指令回合 : 选择宝宝)
  318.   #--------------------------------------------------------------------------
  319.   def update_phase3_call_select
  320.     # 刷新角色箭头
  321.     @call_window.update
  322.     # 按下 B 键的情况下
  323.     if Input.trigger?(Input::B)
  324.       # 演奏取消 SE
  325.       $game_system.se_play($data_system.cancel_se)
  326.       # 选择角色结束
  327.       end_call_select
  328.       return
  329.     end
  330.     # 按下 C 键的情况下
  331.     if Input.trigger?(Input::C)
  332.       # 获取物品窗口现在选择的物品资料
  333.       if @call_window.commands.size > 0
  334.         battler_id = @call_window.commands[@call_window.index].id
  335.         if battler_id == @active_battler.baby
  336.          
  337.         elsif $game_actors[battler_id].hp0?
  338.          
  339.         else
  340.           @active_battler.fighting_baby(battler_id)
  341.          
  342.         end
  343.       else
  344.         return
  345.       end
  346.       end_call_select
  347.       phase3_next_actor
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 开始选择宝宝
  352.   #--------------------------------------------------------------------------
  353.   def start_baby_select
  354.     # 生成宝宝选择窗口
  355.     @call_window = Window_Baby_Command.new(@active_battler)
  356.     @call_window.active = true
  357.     @call_window.visible = true
  358.     @call_window.opacity  = 255
  359.     # 设置角色指令窗口的位置
  360.     @call_window.x = @active_battler.screen_x - 30
  361.     @call_window.y = @active_battler.screen_y - @actor_command_window.height
  362.     # 无效化角色指令窗口
  363.     @baby_command_window.active = false
  364.     @baby_command_window.visible = false
  365.     @actor_command_window.active = false
  366.     @actor_command_window.visible = false
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 结束选择宝宝
  370.   #--------------------------------------------------------------------------
  371.   def end_call_select
  372.     # 释放物品窗口
  373.     @call_window.dispose
  374.     @call_window = nil
  375.     # 隐藏帮助窗口
  376.     @help_window.visible = false
  377.     # 有效化角色指令窗口
  378.     if @active_battler.id < 20
  379.       @actor_command_window.active = true
  380.       @actor_command_window.visible = true
  381.     else
  382.       @baby_command_window.active = true
  383.       @baby_command_window.visible = true
  384.     end
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 开始选择敌人
  388.   #--------------------------------------------------------------------------
  389.   def start_enemy_select
  390.     # 生成敌人箭头
  391.     @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport4)
  392.     # 关联帮助窗口
  393.     @enemy_arrow.help_window = @help_window
  394.     # 无效化角色指令窗口
  395.     @baby_command_window.active = false
  396.     @baby_command_window.visible = false
  397.     @actor_command_window.active = false
  398.     @actor_command_window.visible = false
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 开始选择敌人
  402.   #--------------------------------------------------------------------------
  403.   def start_default_enemy_select
  404.     # 生成敌人箭头
  405.     @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport4)
  406.     # 关联帮助窗口
  407.     @enemy_arrow.help_window = @help_window
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 结束选择敌人
  411.   #--------------------------------------------------------------------------
  412.   def end_enemy_select
  413.     # 释放敌人箭头
  414.     @enemy_arrow.dispose
  415.     @enemy_arrow = nil
  416.     @help_window.visible = false
  417.     # 指令为 [战斗] 的情况下
  418.     if @active_battler.id < 20
  419.       if @actor_command_window.index == 0 or @actor_command_window.index == 4
  420.         # 有效化角色指令窗口
  421.         @actor_command_window.active = true
  422.         @actor_command_window.visible = true
  423.         # 隐藏帮助窗口
  424.         @help_window.visible = false
  425.       end
  426.     else
  427.       if @baby_command_window.index == 0
  428.         # 有效化角色指令窗口
  429.         @baby_command_window.active = true
  430.         @baby_command_window.visible = true
  431.         # 隐藏帮助窗口
  432.         @help_window.visible = false
  433.       end
  434.     end
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● 开始选择角色
  438.   #--------------------------------------------------------------------------
  439.   def start_actor_select
  440.     # 生成角色箭头
  441.     @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
  442.     @actor_arrow.index = @actor_index
  443.     # 关联帮助窗口
  444.     @actor_arrow.help_window = @help_window
  445.     # 无效化角色指令窗口
  446.     @baby_command_window.active = false
  447.     @baby_command_window.visible = false
  448.     @actor_command_window.active = false
  449.     @actor_command_window.visible = false
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 结束选择角色
  453.   #--------------------------------------------------------------------------
  454.   def end_actor_select
  455.     # 释放角色箭头
  456.     @actor_arrow.dispose
  457.     @actor_arrow = nil
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # ● 开始选择特技
  461.   #--------------------------------------------------------------------------
  462.   def start_skill_select
  463.     # 生成特技窗口
  464.     @skill_window = Window_Skill.new(@active_battler)
  465.     # 关联帮助窗口
  466.     @skill_window.help_window = @help_window
  467.     # 无效化角色指令窗口
  468.     @actor_command_window.active = false
  469.     @actor_command_window.visible = false
  470.     @baby_command_window.active = false
  471.     @baby_command_window.visible = false
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ● 选择特技结束
  475.   #--------------------------------------------------------------------------
  476.   def end_skill_select
  477.     # 释放特技窗口
  478.     if @skill_window != nil
  479.       @skill_window.dispose
  480.     end
  481.     @skill_window = nil
  482.     # 隐藏帮助窗口
  483.     @help_window.visible = false
  484.     # 有效化角色指令窗口
  485.     if @active_battler.id < 20
  486.       @actor_command_window.active = true
  487.       @actor_command_window.visible = true
  488.     else
  489.       @baby_command_window.active = true
  490.       @baby_command_window.visible = true
  491.     end
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 开始选择物品
  495.   #--------------------------------------------------------------------------
  496.   def start_item_select
  497.     # 生成物品窗口
  498.     @item_window = Window_Item.new
  499.     # 关联帮助窗口
  500.     @item_window.help_window = @help_window
  501.     # 无效化角色指令窗口
  502.     @actor_command_window.active = false
  503.     @actor_command_window.visible = false
  504.     @baby_command_window.active = false
  505.     @baby_command_window.visible = false
  506.   end
  507.   
  508.   #--------------------------------------------------------------------------
  509.   # ● 结束选择物品
  510.   #--------------------------------------------------------------------------
  511.   def end_item_select
  512.     # 释放物品窗口
  513.     @item_window.dispose
  514.     @item_window = nil
  515.     # 隐藏帮助窗口
  516.     @help_window.visible = false
  517.     # 有效化角色指令窗口
  518.     if @active_battler.id < 20
  519.       @actor_command_window.active = true
  520.       @actor_command_window.visible = true
  521.     else
  522.       @baby_command_window.active = true
  523.       @baby_command_window.visible = true
  524.     end
  525.   end
  526. end
复制代码
鼠标脚本
  1. #==============================================================================
  2. # ■ 完整鼠标系统(八方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #   不若怀念修改
  7. #==============================================================================
  8. #下面做一下介绍与使用说明:
  9. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  10. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  11. #后果了吧)
  12. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  13. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  14. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  15. #点,那时在单击NPC即可。
  16. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  17. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  18. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  19. #那两个注释。
  20. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  21. #==============================================================================
  22. class Game_Event
  23.   attr_accessor :flag
  24. end

  25. #==============================================================================
  26. # ■ Game_Map
  27. #------------------------------------------------------------------------------
  28. #  处理地图的类。包含卷动以及可以通行的判断功能。
  29. # 本类的实例请参考 $game_map 。
  30. #==============================================================================

  31. class Game_Map
  32.   #--------------------------------------------------------------------------
  33.   # ● 检查鼠标处是否有自定义的事件并返回类型
  34.   #--------------------------------------------------------------------------
  35.   def check_event_custom(mouse_x, mouse_y)
  36.     for event in $game_map.events.values #循环所有事件检查
  37.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  38.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  39.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  40.         if event.list != nil
  41.         for i in 0...event.list.size
  42.           if event.list[i].parameters[0] == "Item"  #类型判断
  43.             event.flag = 1
  44.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  45.             event.flag = 2
  46.           else
  47.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  48.           end
  49.           return event.flag #返回事件类型标志
  50.         end
  51.         end
  52.       end
  53.     end
  54.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  55.     return $mouse_icon_id #使鼠标图不变化
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 检查鼠标处是否有事件可以开启
  59.   #--------------------------------------------------------------------------
  60.   def check_event_custom_start(mouse_x, mouse_y)
  61.     for event in $game_map.events.values #循环所有事件检查
  62.       #事件角色图片宽度、高度
  63.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  64.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  65.       #判断是否鼠标在事件上
  66.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  67.         way_x = $game_player.x - event.x
  68.         way_y = $game_player.y - event.y
  69.         if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
  70.           for i in 0...event.list.size
  71.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  72.               #判断主角朝向
  73.               if way_x == -1
  74.                 p_direction = 3 if way_y == -1
  75.                 p_direction = 6 if way_y == 0
  76.                 p_direction = 9 if way_y == 1
  77.               elsif way_x == 0
  78.                 p_direction = 2 if way_y == -1
  79.                 p_direction = 8 if way_y == 1
  80.               else
  81.                 p_direction = 1 if way_y == -1
  82.                 p_direction = 4 if way_y == 0
  83.                 p_direction = 7 if way_y == 1
  84.               end
  85.               event.start #开启事件
  86.               return 1, p_direction #返回即将开启事件以及角色朝向
  87.             end
  88.           end
  89.         end
  90.       end
  91.     end
  92.     return 0, 5 #返回不会开启事件以及角色朝向不变
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  96.   #--------------------------------------------------------------------------
  97.   def check_event_custom_exist(mouse_x, mouse_y)
  98.     for event in $game_map.events.values #循环所有事件检查
  99.       #事件角色图片宽度、高度
  100.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  101.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  102.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  103.         for i in 0...event.list.size
  104.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  105.         end
  106.       end
  107.     end
  108.     return 0, event #返回不存在自定义事件,以及事件体
  109.   end
  110. end
  111. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  112. $敌人选框扩大 = 20
  113. $角色选框扩大 = 30


  114. #==============================================================================
  115. # ● API调用
  116. #==============================================================================
  117. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  118. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  119. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  120. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  121. $Window_HWND = $GetActiveWindow.call
  122. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  123. module Mouse  
  124. LEFT = 0x01
  125. RIGHT = 0x02

  126. def self.init(sprite = nil)
  127.    $ShowCursor.call(0)
  128.    
  129.    @show_cursor = false
  130.    
  131.    @mouse_sprite = Sprite.new
  132.    @mouse_sprite.z = 99999
  133.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')

  134.    @left_press = false
  135.    @right_press = false
  136.    @left_trigger = false
  137.    @right_trigger = false
  138.    @left_repeat = false
  139.    @right_repeat = false
  140.    @click_lock = false
  141.    @wait_count = 8#待机动画循环时间
  142.    @mosue_pic = 1#鼠标待机动画编号
  143.    #鼠标点击动画
  144.    @chick_animation = RPG::Sprite.new
  145.    @ani_x = @chick_animation.x
  146.    @ani_y = @chick_animation.y
  147.    #更新
  148.    update
  149. end
  150. #------------------------------------------------------------------------------
  151. # 设置鼠标点击动画
  152. #------------------------------------------------------------------------------
  153. def self.animation(animation,x,y)
  154.    @ani_x = x
  155.    @ani_y = y
  156.    x -= $game_map.display_x / 4
  157.    y -= $game_map.display_y / 4
  158.    if animation == nil
  159.      @chick_animation.animation(nil,0)
  160.    else
  161.      @chick_animation.x = x
  162.      @chick_animation.y = y
  163.      @chick_animation.animation(animation,0)
  164.    end
  165. end
  166. #------------------------------------------------------------------------------
  167. # 更新鼠标点击动画
  168. #------------------------------------------------------------------------------
  169. def self.update_animation
  170.     if $scene.is_a?(Scene_Map)
  171.       x = @ani_x
  172.       y = @ani_y
  173.       x -= $game_map.display_x / 4
  174.       y -= $game_map.display_y / 4
  175.       @chick_animation.x, @chick_animation.y = x, y
  176.     end
  177.     @chick_animation.update
  178. end
  179. def self.exit
  180.    @mouse_sprite.bitmap.dispose
  181.    @mouse_sprite.dispose
  182.    @chick_animation.animation(nil,0)
  183.    @chick_animation.dispose
  184.    @show_cursor = true
  185.    $ShowCursor.call(1)
  186. end
  187. def self.mouse_debug
  188.    return @mouse_debug.bitmap
  189. end

  190. def self.update
  191.    update_animation
  192.   if $_OnFocus.call != 0
  193. left_down = $GetKeyState.call(0x01)
  194. right_down = $GetKeyState.call(0x02)
  195. else
  196. left_down = 0
  197. right_down = 0
  198. end


  199.    if $scene.is_a?(Scene_Map) == false
  200.      $mouse_icon_id = 0
  201.    end
  202.    if $mouse_icon_id != $mouse_icon_id_last
  203.      case $mouse_icon_id
  204.      when 1
  205.        if @a
  206.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  207.        else
  208.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  209.        end
  210.      when 2
  211.        if @a
  212.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  213.        else
  214.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  215.        end
  216.      when 11
  217.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  218.      when 12
  219.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  220.      when 13
  221.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  222.      when 14
  223.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  224.      when 16
  225.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  226.      when 17
  227.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  228.      when 18
  229.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  230.      when 19
  231.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  232.      when 0
  233.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
  234.      end
  235.      $mouse_icon_id_last = $mouse_icon_id
  236.    end
  237.    if $mouse_icon_id == 0
  238.       if @wait_count <= 0
  239.         @mouse_sprite.bitmap = RPG::Cache.icon("mouse#{@mosue_pic}")
  240.         @mosue_pic += 1
  241.         if @mosue_pic >= 12
  242.           @mosue_pic = 1
  243.         end
  244.         @wait_count = 8
  245.       else
  246.         @wait_count -= 1
  247.       end
  248.    end
  249.    @click_lock = false
  250.    mouse_x, mouse_y = self.get_mouse_pos
  251.    if @mouse_sprite != nil
  252.      @mouse_sprite.x = mouse_x
  253.      @mouse_sprite.y = mouse_y
  254.    end
  255.    if left_down[7] == 1
  256.      @left_repeat = (not @left_repeat)
  257.      @left_trigger = (not @left_press)
  258.      @left_press = true
  259.    else
  260.      @left_press = false
  261.      @left_trigger = false
  262.      @left_repeat = false
  263.    end
  264.    if right_down[7] == 1
  265.      @right_repeat = (not @right_repeat)
  266.      @right_trigger = (not @right_press)
  267.      @right_press = true
  268.    else
  269.      @right_press = false
  270.      @right_trigger = false
  271.      @right_repeat = false
  272.    end
  273. end
  274. def self.get_mouse_pos
  275.    point_var = [0, 0].pack('ll')
  276.    if $GetCursorPos.call(point_var) != 0
  277.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  278.        x, y = point_var.unpack('ll')
  279.        if (x < 0) or (x > 10000) then x = 0 end
  280.        if (y < 0) or (y > 10000) then y = 0 end
  281.        if x > 640 then x = 640 end
  282.        if y > 480 then y = 480 end
  283.        return x, y
  284.      else
  285.        return 0, 0
  286.      end
  287.    else
  288.      return 0, 0
  289.    end
  290. end
  291. def self.press?(mouse_code)
  292.    if mouse_code == LEFT
  293.      if @click_lock
  294.        return false
  295.      else
  296.        return @left_press
  297.      end
  298.    elsif mouse_code == RIGHT
  299.      return @right_press
  300.    else
  301.      return false
  302.    end
  303. end
  304. def self.trigger?(mouse_code)
  305.    if mouse_code == LEFT
  306.      if @click_lock
  307.        return false
  308.      else
  309.        return @left_trigger
  310.      end
  311.    elsif mouse_code == RIGHT
  312.      return @right_trigger
  313.    else
  314.      return false
  315.    end
  316. end
  317. def self.repeat?(mouse_code)
  318.    if mouse_code == LEFT
  319.      if @click_lock
  320.        return false
  321.      else
  322.        return @left_repeat
  323.      end
  324.    elsif mouse_code == RIGHT
  325.      return @right_repeat
  326.    else
  327.      return false
  328.    end
  329. end
  330. def self.click_lock?
  331.    return @click_lock
  332. end
  333. def self.click_lock
  334.    @click_lock = true
  335. end
  336. def self.click_unlock
  337.    @click_lock = false
  338. end
  339. end
  340. module Input
  341. if @self_update == nil
  342.    @self_update = method('update')
  343.    @self_press = method('press?')
  344.    @self_trigger = method('trigger?')
  345.    @self_repeat = method('repeat?')
  346. end
  347. def self.update
  348.    @self_update.call
  349.    Mouse.update
  350. end
  351. def self.press?(key_code)
  352.    if @self_press.call(key_code)
  353.      return true
  354.    end
  355.    if key_code == C
  356.      return Mouse.press?(Mouse::LEFT)
  357.    elsif key_code == B
  358.      return Mouse.press?(Mouse::RIGHT)
  359.    else
  360.      return @self_press.call(key_code)
  361.    end
  362. end
  363. def self.trigger?(key_code)
  364.    if @self_trigger.call(key_code)
  365.      return true
  366.    end
  367.    if key_code == C
  368.      return Mouse.trigger?(Mouse::LEFT)
  369.    elsif key_code == B
  370.       
  371.      return Mouse.trigger?(Mouse::RIGHT)
  372.    else
  373.      return @self_trigger.call(key_code)
  374.    end
  375. end
  376. def self.repeat?(key_code)
  377.    if @self_repeat.call(key_code)
  378.      return true
  379.    end
  380.    if key_code == C
  381.      return Mouse.repeat?(Mouse::LEFT)
  382.    elsif key_code == B
  383.      return Mouse.repeat?(Mouse::RIGHT)
  384.    else
  385.      return @self_repeat.call(key_code)
  386.    end
  387. end
  388. end
  389. class Window_Selectable
  390. if @self_alias == nil
  391.    alias self_update update
  392.    @self_alias = true
  393. end
  394. def update
  395.    self_update
  396.    if self.active and @item_max > 0
  397.      index_var = @index
  398.      tp_index = @index
  399.      mouse_x, mouse_y = Mouse.get_mouse_pos
  400.      mouse_not_in_rect = true
  401.      for i in 0...@item_max
  402.        @index = i
  403.        update_cursor_rect
  404.        top_x = self.cursor_rect.x + self.x + 16
  405.        top_y = self.cursor_rect.y + self.y + 16
  406.        bottom_x = top_x + self.cursor_rect.width
  407.        bottom_y = top_y + self.cursor_rect.height
  408.        if (mouse_x > top_x) and (mouse_y > top_y) and
  409.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  410.          mouse_not_in_rect = false
  411.          if tp_index != @index
  412.             $game_system.se_stop
  413.            tp_index = @index
  414.            if @index == 0
  415.              if $title == 1
  416.                Audio.se_play("Audio/SE/"+"轮回",100,100)
  417.              else
  418.                $game_system.se_play($data_system.cursor_se)
  419.              end
  420.            elsif @index ==1
  421.              if $title == 1
  422.                Audio.se_play("Audio/SE/"+"拔剑",100,100)
  423.              else
  424.                $game_system.se_play($data_system.cursor_se)
  425.              end
  426.            elsif @index ==2
  427.              if $title == 1
  428.                Audio.se_play("Audio/SE/"+"退出",100,100)
  429.              else
  430.                $game_system.se_play($data_system.cursor_se)
  431.              end
  432.            else
  433.              $game_system.se_play($data_system.cursor_se)
  434.            end
  435.          end
  436.          break
  437.        end
  438.      end
  439.      if mouse_not_in_rect
  440.        @index = index_var
  441.        update_cursor_rect
  442.        Mouse.click_lock
  443.      else
  444.        Mouse.click_unlock               
  445.      end
  446.    end
  447. end
  448. end
  449. class Window_NameInput
  450. if @self_alias == nil
  451.    alias self_update update
  452.    @self_alias = true
  453. end
  454. def update
  455.    self_update
  456.    if self.active
  457.      index_var = @index
  458.      mouse_x, mouse_y = Mouse.get_mouse_pos
  459.      mouse_not_in_rect = true
  460.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  461.        @index = i
  462.        update_cursor_rect
  463.        top_x = self.cursor_rect.x + self.x + 16
  464.        top_y = self.cursor_rect.y + self.y + 16
  465.        bottom_x = top_x + self.cursor_rect.width
  466.        bottom_y = top_y + self.cursor_rect.height
  467.        if (mouse_x > top_x) and (mouse_y > top_y) and
  468.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  469.          mouse_not_in_rect = false
  470.          break
  471.        end
  472.      end
  473.      if mouse_not_in_rect
  474.        @index = index_var
  475.        update_cursor_rect
  476.        Mouse.click_lock
  477.      else
  478.        Mouse.click_unlock
  479.      end
  480.    end
  481. end
  482. end
  483. class Window_InputNumber
  484. if @self_alias == nil
  485.    alias self_update update
  486.    @self_alias = true
  487. end
  488. def update
  489.    self_update
  490.    mouse_x, mouse_y = Mouse.get_mouse_pos
  491.    if self.active and @digits_max > 0
  492.      index_var = @index
  493.      mouse_not_in_rect = true
  494.      for i in 0...@digits_max
  495.        @index = i
  496.        update_cursor_rect
  497.        top_x = self.cursor_rect.x + self.x + 16
  498.        bottom_x = top_x + self.cursor_rect.width
  499.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  500.          mouse_not_in_rect = false
  501.          break
  502.        end
  503.      end
  504.      if mouse_not_in_rect
  505.        @index = index_var
  506.        update_cursor_rect
  507.        Mouse.click_lock
  508.      else
  509.        Mouse.click_unlock
  510.      end
  511.    end
  512.    if @last_mouse_y == nil
  513.      @last_mouse_y = mouse_y
  514.    end
  515.    check_pos = (@last_mouse_y - mouse_y).abs
  516.    if check_pos > 10
  517.      $game_system.se_play($data_system.cursor_se)
  518.      place = 10 ** (@digits_max - 1 - @index)
  519.      n = @number / place % 10
  520.      @number -= n * place
  521.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  522.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  523.      @number += n * place
  524.      refresh
  525.      @last_mouse_y = mouse_y
  526.    end
  527. end
  528. end
  529. class Scene_File
  530. if @self_alias == nil
  531.    alias self_update update
  532.    @self_alias = true
  533. end
  534. def update
  535.    mouse_x, mouse_y = Mouse.get_mouse_pos
  536.    Mouse.click_lock
  537.    idx = 0
  538.    for i in @savefile_windows
  539.      top_x = i.x + 16
  540.      top_y = i.y + 16
  541.      bottom_x = top_x + i.width
  542.      bottom_y = top_y + i.height
  543.      if (mouse_x > top_x) and (mouse_y > top_y) and
  544.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  545.        i.selected = true
  546.        if @file_index != idx
  547.          @file_index = idx
  548.          $game_system.se_play($data_system.cursor_se)
  549.        end            
  550.        Mouse.click_unlock
  551.      else
  552.        i.selected = false
  553.      end
  554.      idx += 1
  555.    end
  556.    self_update
  557. end
  558. end
  559. class Arrow_Enemy
  560. if @self_alias == nil
  561.    alias self_update update
  562.    @self_alias = true
  563. end
  564. def update
  565.    mouse_x, mouse_y = Mouse.get_mouse_pos
  566.    idx = 0
  567.    for i in $game_troop.enemies do
  568.      if i.exist?
  569.        top_x = i.screen_x - self.ox
  570.        top_y = i.screen_y - self.oy
  571.        bottom_x = top_x + self.src_rect.width
  572.        bottom_y = top_y + self.src_rect.height
  573.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  574.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  575.          if @index != idx
  576.            $game_system.se_play($data_system.cursor_se)
  577.            @index = idx
  578.          end
  579.        end
  580.      end
  581.      idx += 1
  582.    end
  583.    self_update
  584. end
  585. end
  586. class Arrow_Actor
  587. if @self_alias == nil
  588.    alias self_update update
  589.    @self_alias = true
  590. end
  591. def update
  592.    mouse_x, mouse_y = Mouse.get_mouse_pos
  593.    idx = 0
  594.    for i in $game_party.actors do
  595.      if i.esc?
  596.        top_x = i.screen_x - self.ox
  597.        top_y = i.screen_y - self.oy
  598.        bottom_x = top_x + self.src_rect.width
  599.        bottom_y = top_y + self.src_rect.height
  600.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  601.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  602.          if @index != idx
  603.            $game_system.se_play($data_system.cursor_se)
  604.            @index = idx
  605.          end
  606.        end
  607.      end
  608.      idx += 1
  609.    end
  610.    self_update
  611. end
  612. end
  613. #==============================================================================
  614. # ■ Game_Player
  615. #------------------------------------------------------------------------------
  616. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  617. # 本类的实例请参考 $game_player。
  618. #   鼠标控制角色的主程序
  619. #==============================================================================
  620. class Game_Player
  621. if @self_alias == nil
  622.    alias self_update update
  623.    @self_alias = true
  624. end
  625. #--------------------------------------------------------------------------
  626. # ● 得到鼠标的状态
  627. #--------------------------------------------------------------------------
  628. def get_mouse_sta
  629.    return @mouse_sta
  630. end
  631. #--------------------------------------------------------------------------
  632. # ● 完整鼠标系统
  633. #--------------------------------------------------------------------------
  634. def update
  635.    mouse_x, mouse_y = Mouse.get_mouse_pos
  636.    @mtp_x = mouse_x
  637.    @mtp_y = mouse_y
  638.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  639.      #得到鼠标图标方向
  640.      $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y)  if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
  641.    else
  642.      #令鼠标图标为正常
  643.      $mouse_icon_id = 0 if @mouse_sta != 2
  644.    end
  645.    
  646.    #单击鼠标时进行判断寻路或跟随
  647.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  648.      unless $game_system.map_interpreter.running? or
  649.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  650.        #初始化
  651.        @mouse_sta = 1
  652.        p_direction = 5
  653.        #检查鼠标处能否开启事件
  654.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  655.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  656.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  657.        if @mouse_sta != 2
  658.          #鼠标状态不为跟随状态则取数据并初始化路径
  659.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  660.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  661.          @paths = []
  662.          @paths_id = 0
  663.          if event_start == 0 #若不能开启事件
  664.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  665.             #点中了宝宝
  666.             if mouse_x> 415 and mouse_x< 450 and mouse_y> 0 and mouse_y< 41
  667.               $scene = Scene_Baby.new
  668.             #点中了人物
  669.             elsif mouse_x> 510 and mouse_x< 564 and mouse_y> 0 and mouse_y< 53
  670.               common_event_id = 17
  671.               common_event = $data_common_events[common_event_id]
  672.               $game_system.map_interpreter.setup(common_event.list, 0)
  673.             #选中了道具
  674.             elsif mouse_x> 316 and mouse_x< 348 and mouse_y> 450 and mouse_y< 480
  675.               $scene = Scene_Item.new
  676.             #选中了任务
  677.             elsif mouse_x> 466 and mouse_x< 495 and mouse_y> 450 and mouse_y< 480
  678.               $scene = Scene_Task.new
  679.             #选中了系统
  680.             elsif mouse_x> 612 and mouse_x< 640 and mouse_y> 450 and mouse_y< 480
  681.               $scene = Scene_Menu.new
  682.             #选中了BB血槽
  683.             elsif mouse_x> 433 and mouse_x< 505 and mouse_y> 0 and mouse_y< 13
  684.               if $game_party.actors[0].baby != 0
  685.                 baby = $game_actors[$game_party.actors[0].baby]
  686.                 item_id = [2,11,16,17,18,19,20,21,22,23,34,35]
  687.                 if baby.hp < baby.maxhp
  688.                   for i in item_id
  689.                     if $game_party.item_number(i) > 0
  690.                       item = $data_items[i]
  691.                       num = [(baby.maxhp - baby.hp) / item.recover_hp + 1,$game_party.item_number(i)].min
  692.                       for n in 0...num
  693.                         if baby.hp == 0
  694.                           baby.hp = 1
  695.                         end
  696.                         baby.item_effect(item)
  697.                       end
  698.                       $game_party.lose_item(i, num)
  699.                       $game_system.se_play(item.menu_se)
  700.                       $scene.update_head
  701.                       break
  702.                     end
  703.                   end
  704.                 end
  705.               end
  706.             #选中了BB法槽
  707.             elsif mouse_x> 433 and mouse_x< 505 and mouse_y> 15 and mouse_y< 29
  708.               if $game_party.actors[0].baby != 0
  709.                 baby = $game_actors[$game_party.actors[0].baby]
  710.                 item_id = [12,24,25,26,27,28,29,30,31,32,33]
  711.                 if baby.sp < baby.maxsp
  712.                   for i in item_id
  713.                     if $game_party.item_number(i) > 0
  714.                       item = $data_items[i]
  715.                       num = [(baby.maxsp - baby.sp) / item.recover_sp + 1,$game_party.item_number(i)].min
  716.                       for n in 0...num
  717.                         if baby.hp == 0
  718.                           baby.hp = 1
  719.                         end
  720.                         baby.item_effect(item)
  721.                       end
  722.                       $game_party.lose_item(i, num)
  723.                       $game_system.se_play(item.menu_se)
  724.                       $scene.update_head
  725.                       break
  726.                     end
  727.                   end
  728.                 end
  729.               end
  730.             #选中了人物血槽
  731.             elsif mouse_x> 563 and mouse_x< 636 and mouse_y> 0 and mouse_y< 15
  732.                 baby = $game_party.actors[0]
  733.                 item_id = [2,11,16,17,18,19,20,21,22,23,34,35]
  734.                 if baby.hp < baby.maxhp
  735.                   for i in item_id
  736.                     if $game_party.item_number(i) > 0
  737.                       item = $data_items[i]
  738.                       num = [(baby.maxhp - baby.hp) / item.recover_hp + 1,$game_party.item_number(i)].min
  739.                       for n in 0...num
  740.                         if baby.hp == 0
  741.                           baby.hp = 1
  742.                         end
  743.                         baby.item_effect(item)
  744.                       end
  745.                       $game_party.lose_item(i, num)
  746.                       $game_system.se_play(item.menu_se)
  747.                       $scene.update_head
  748.                       break
  749.                     end
  750.                   end
  751.                 end
  752.             #选中了人物法曹
  753.             elsif mouse_x> 563 and mouse_x< 637 and mouse_y> 15 and mouse_y< 29
  754.                 baby = $game_party.actors[0]
  755.                 item_id = [12,24,25,26,27,28,29,30,31,32,33]
  756.                 if baby.sp < baby.maxsp
  757.                   for i in item_id
  758.                     if $game_party.item_number(i) > 0
  759.                       item = $data_items[i]
  760.                       num = [(baby.maxsp - baby.sp) / item.recover_sp + 1,$game_party.item_number(i)].min
  761.                       for n in 0...num
  762.                         if baby.hp == 0
  763.                           baby.hp = 1
  764.                         end
  765.                         baby.item_effect(item)
  766.                       end
  767.                       $game_party.lose_item(i, num)
  768.                       $game_system.se_play(item.menu_se)
  769.                       $scene.update_head
  770.                       break
  771.                     end
  772.                   end
  773.                 end
  774.             else
  775.               if $scene.is_a?(Scene_Map)
  776.                 Mouse.animation($data_animations[138],mouse_x + 14 + $game_map.display_x / 4, mouse_y + 10 + $game_map.display_y / 4)
  777.               end
  778.              find_path = Find_Path.new
  779.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  780.             end
  781.           end
  782.          else #若能开启事件则改变角色朝向
  783.            @direction = p_direction
  784.          end
  785.        end
  786.      end
  787.    elsif Mouse.trigger?(Mouse::RIGHT)
  788.      unless $game_system.map_interpreter.running? or
  789.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  790.         if @mtp_x > self.screen_x
  791.            if @mtp_y - self.screen_y > - 0.4 * ( @mtp_x - self.screen_x ) and
  792.               @mtp_y - self.screen_y < 0.4 * ( @mtp_x - self.screen_x )
  793.              @direction = 6
  794.            end
  795.            if @mtp_y - self.screen_y > 0.4 * ( @mtp_x - self.screen_x ) and
  796.              @mtp_y - self.screen_y < 2.4 * ( @mtp_x - self.screen_x )
  797.              @direction = 3
  798.            end
  799.            if @mtp_y - self.screen_y < - 0.4 * ( @mtp_x - self.screen_x ) and
  800.              @mtp_y - self.screen_y > - 2.4 * ( @mtp_x - self.screen_x )
  801.              @direction = 9
  802.            end
  803.            if @mtp_y - self.screen_y > 2.4 * ( @mtp_x - self.screen_x )
  804.              @direction = 2
  805.            end
  806.            if @mtp_y - self.screen_y < - 2.4 * ( @mtp_x - self.screen_x )
  807.              @direction = 8
  808.            end
  809.          end
  810.        if @mtp_x < self.screen_x
  811.          if @mtp_y - self.screen_y > - 0.4 * ( self.screen_x - @mtp_x ) and
  812.             @mtp_y - self.screen_y < 0.4 * ( self.screen_x - @mtp_x )
  813.            @direction = 4
  814.          end
  815.          if @mtp_y - self.screen_y > 0.4 * ( self.screen_x - @mtp_x ) and
  816.            @mtp_y - self.screen_y < 2.4 * ( self.screen_x - @mtp_x )
  817.            @direction = 1
  818.          end
  819.          if @mtp_y - self.screen_y < - 0.4 * ( self.screen_x - @mtp_x ) and
  820.            @mtp_y - self.screen_y > - 2.4 * ( self.screen_x - @mtp_x )
  821.            @direction = 7
  822.          end
  823.          if @mtp_y - self.screen_y > 2.4 * ( self.screen_x - @mtp_x )
  824.            @direction = 2
  825.          end
  826.          if @mtp_y - self.screen_y < - 2.4 * ( self.screen_x - @mtp_x )
  827.            @direction = 8
  828.          end
  829.        end   
  830.      end
  831.    end

  832.    #开始移动
  833.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  834.      unless moving? or $game_system.map_interpreter.running? or
  835.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  836.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  837.          case @paths[@paths_id] #判断路径
  838.          when 6
  839.            @last_move_x = true
  840.            move_right
  841.            @paths_id += 1
  842.            @direction = 6
  843.          when 4
  844.            @last_move_x = true
  845.            move_left
  846.            @paths_id += 1
  847.            @direction = 4
  848.          when 2
  849.            @last_move_x = false
  850.            move_down
  851.            @direction = 2
  852.            @paths_id += 1
  853.          when 8
  854.            @last_move_x = false
  855.            move_up
  856.            @direction = 8
  857.            @paths_id += 1
  858.          #斜四方向
  859.          when 1
  860.            @last_move_x = false
  861.            move_lower_left
  862.            @direction = 1
  863.            @paths_id += 1
  864.          when 3
  865.            @last_move_x = false
  866.            move_lower_right
  867.            @direction = 3
  868.            @paths_id += 1
  869.          when 7
  870.            @last_move_x = false
  871.            move_upper_left
  872.            @direction = 7
  873.            @paths_id += 1
  874.          when 9
  875.            @last_move_x = false
  876.            move_upper_right
  877.            @direction = 9
  878.            @paths_id += 1
  879.          end
  880.        end
  881.      end
  882.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  883.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  884.        unless moving? or $game_system.map_interpreter.running? or
  885.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  886.          #跟随方向判断并跟随
  887.          if @mtp_x > self.screen_x
  888.            if @mtp_y - self.screen_y > - 0.4 * ( @mtp_x - self.screen_x ) and
  889.               @mtp_y - self.screen_y < 0.4 * ( @mtp_x - self.screen_x )
  890.              move_right
  891.              $mouse_icon_id = 16
  892.              @direction = 6
  893.            end
  894.            if @mtp_y - self.screen_y > 0.4 * ( @mtp_x - self.screen_x ) and
  895.              @mtp_y - self.screen_y < 2.4 * ( @mtp_x - self.screen_x )
  896.              move_lower_right
  897.              $mouse_icon_id = 13
  898.              @direction = 3
  899.            end
  900.            if @mtp_y - self.screen_y < - 0.4 * ( @mtp_x - self.screen_x ) and
  901.              @mtp_y - self.screen_y > - 2.4 * ( @mtp_x - self.screen_x )
  902.              move_upper_right
  903.              $mouse_icon_id = 19
  904.              @direction = 9
  905.            end
  906.            if @mtp_y - self.screen_y > 2.4 * ( @mtp_x - self.screen_x )
  907.              move_down
  908.              $mouse_icon_id = 12
  909.              @direction = 2
  910.            end
  911.            if @mtp_y - self.screen_y < - 2.4 * ( @mtp_x - self.screen_x )
  912.              move_up
  913.              $mouse_icon_id = 18
  914.              @direction = 8
  915.            end
  916.          end
  917.        if @mtp_x < self.screen_x
  918.          if @mtp_y - self.screen_y > - 0.4 * ( self.screen_x - @mtp_x ) and
  919.             @mtp_y - self.screen_y < 0.4 * ( self.screen_x - @mtp_x )
  920.            move_left
  921.            $mouse_icon_id = 14
  922.            @direction = 4
  923.          end
  924.          if @mtp_y - self.screen_y > 0.4 * ( self.screen_x - @mtp_x ) and
  925.            @mtp_y - self.screen_y < 2.4 * ( self.screen_x - @mtp_x )
  926.            move_lower_left
  927.            $mouse_icon_id = 11
  928.            @direction = 1
  929.          end
  930.          if @mtp_y - self.screen_y < - 0.4 * ( self.screen_x - @mtp_x ) and
  931.            @mtp_y - self.screen_y > - 2.4 * ( self.screen_x - @mtp_x )
  932.            move_upper_left
  933.            $mouse_icon_id = 17
  934.            @direction = 7
  935.          end
  936.          if @mtp_y - self.screen_y > 2.4 * ( self.screen_x - @mtp_x )
  937.            move_down
  938.            $mouse_icon_id = 12
  939.            @direction = 2
  940.          end
  941.          if @mtp_y - self.screen_y < - 2.4 * ( self.screen_x - @mtp_x )
  942.            move_up
  943.            $mouse_icon_id = 18
  944.            @direction = 8
  945.          end
  946.        end
  947.      end
  948.    else #没状态的情况
  949.      $mouse_icon_id = 0
  950.      @mouse_sta = 0
  951.      @paths_id = @paths.size #终止寻路移动
  952.    end
  953. end
  954. self_update
  955. end
  956. end
  957. Mouse.init
  958. END { Mouse.exit }
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-21 19:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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