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

Project1

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

[已经解决] 求高人帮忙修改鼠标脚本

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2009-4-6
帖子
34
跳转到指定楼层
1
发表于 2011-7-31 11:07:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 逍遥仙诚 于 2011-7-31 11:14 编辑

仙剑2的那种效果图
这是我用的脚本,怎样修改能像仙剑2的那种效果:对话时更改鼠标图形
  1. #==============================================================================
  2. # ■ 完整鼠标系统(四方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end
  24. #==============================================================================
  25. # ■ Game_Map
  26. #------------------------------------------------------------------------------
  27. #  处理地图的类。包含卷动以及可以通行的判断功能。
  28. # 本类的实例请参考 $game_map 。
  29. #==============================================================================
  30. class Game_Map
  31.   #--------------------------------------------------------------------------
  32.   # ● 检查鼠标处是否有自定义的事件并返回类型
  33.   #--------------------------------------------------------------------------
  34.   def check_event_custom(mouse_x, mouse_y)
  35.     for event in $game_map.events.values #循环所有事件检查
  36.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
  37.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
  38.       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
  39.         for i in 0...event.list.size
  40.           if event.list[i].parameters[0] == "Item" #类型判断
  41.             event.flag = 1
  42.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  43.             event.flag = 2
  44.           else
  45.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  46.           end
  47.           return event.flag #返回事件类型标志
  48.         end
  49.       end
  50.     end
  51.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  52.     return $mouse_icon_id #使鼠标图不变化
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 检查鼠标处是否有事件可以开启
  56.   #--------------------------------------------------------------------------
  57.   def check_event_custom_start(mouse_x, mouse_y)
  58.     for event in $game_map.events.values #循环所有事件检查
  59.       #事件角色图片宽度、高度
  60.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  61.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  62.       #判断是否鼠标在事件上
  63.       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
  64.         way_x = $game_player.x - event.x
  65.         way_y = $game_player.y - event.y
  66.         if ([1, -1].include?($game_player.x-event.x) and $game_player.y-event.y == 0) or ([1, -1].include?($game_player.y-event.y) and $game_player.x-event.x == 0)
  67.           for i in 0...event.list.size
  68.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  69.               #判断主角朝向
  70.               if way_x == -1
  71.                 p_direction = 6 if way_y == 0
  72.               elsif way_x == 0
  73.                 p_direction = 2 if way_y == -1
  74.                 p_direction = 8 if way_y == 1
  75.               else
  76.                 p_direction = 4 if way_y == 0
  77.               end
  78.               event.start #开启事件
  79.               return 1, p_direction #返回即将开启事件以及角色朝向
  80.             end
  81.           end
  82.         end
  83.       end
  84.     end
  85.     return 0, 5 #返回不会开启事件以及角色朝向不变
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  89.   #--------------------------------------------------------------------------
  90.   def check_event_custom_exist(mouse_x, mouse_y)
  91.     for event in $game_map.events.values #循环所有事件检查
  92.       #事件角色图片宽度、高度
  93.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  94.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  95.       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
  96.         for i in 0...event.list.size
  97.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  98.         end
  99.       end
  100.     end
  101.     return 0, event #返回不存在自定义事件,以及事件体
  102.   end
  103. end


  104. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  105. $敌人选框扩大 = 20
  106. $角色选框扩大 = 30


  107. #==============================================================================
  108. # ● API调用
  109. #==============================================================================
  110. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  111. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  112. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  113. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  114. $Window_HWND = $GetActiveWindow.call
  115. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  116. module Mouse  
  117. LEFT = 0x01
  118. RIGHT = 0x02

  119. def self.init(sprite = nil)
  120.    $ShowCursor.call(0)
  121.    
  122.    @show_cursor = false

  123.    @mouse_ani_viewport = Viewport.new(0,0,640,480)
  124.    @mouse_ani_viewport.z = 1
  125.    @mouse_ani = RPG::Sprite.new(@mouse_ani_viewport)
  126.    @mouse_ani.z = 1
  127.    
  128.    @mouse_sprite = Sprite.new
  129.    @mouse_sprite.z = 99999
  130.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标')
  131.    
  132.    $data_animations = load_data("Data/Animations.rxdata")
  133.    @mouse_wait_count = $data_animations[211].frame_max * 2
  134.    @mouse_wait = 0
  135.    @b = 1
  136.    
  137.    @left_press = false
  138.    @right_press = false
  139.    @left_trigger = false
  140.    @right_trigger = false
  141.    @left_repeat = false
  142.    @right_repeat = false
  143.    @click_lock = false
  144.    
  145.    update
  146. end
  147. def self.exit
  148.    @mouse_sprite.bitmap.dispose
  149.    @mouse_sprite.dispose
  150.    @mouse_ani.dispose
  151.    @show_cursor = true
  152.    $ShowCursor.call(1)
  153. end
  154. def self.mouse_debug
  155.    return @mouse_debug.bitmap
  156. end
  157.   #.........................................................................
  158. def self.set_ani(x, y)
  159.    @ani_x = x
  160.    @ani_y = y
  161.    x -= $game_map.display_x / 4
  162.    y -= $game_map.display_y / 4
  163.    @mouse_ani.x, @mouse_ani.y = x, y
  164.    @mouse_ani.animation($data_animations[211],true)
  165.    @mouse_wait = @mouse_wait_count
  166. end
  167. def self.update_ani
  168.    if @mouse_wait > 0
  169.      x = @ani_x
  170.      y = @ani_y
  171.      x -= $game_map.display_x / 4
  172.      y -= $game_map.display_y / 4
  173.      @mouse_ani.x, @mouse_ani.y = x, y
  174.      @mouse_ani.update
  175.      @mouse_wait -= 1
  176.    end
  177. end
  178. def self.update
  179.     update_ani
  180.    left_down = $GetKeyState.call(0x01)
  181.    right_down = $GetKeyState.call(0x02)
  182.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  183.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  184.      @a = !@a
  185.    end
  186.    if $scene.is_a?(Scene_Map) == false
  187.      $mouse_icon_id = 0
  188.    end
  189.    if $mouse_icon_id != $mouse_icon_id_last
  190.      case $mouse_icon_id
  191.      when 1
  192.        if @a
  193.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  194.        else
  195.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  196.        end
  197.      when 2
  198.        if @a
  199.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  200.        else
  201.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  202.        end
  203. =begin
  204.      when 11
  205.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  206.      when 12
  207.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  208.      when 13
  209.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  210.      when 14
  211.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  212.      when 16
  213.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  214.      when 17
  215.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  216.      when 18
  217.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  218.      when 19
  219.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  220. =end
  221.      when 0
  222.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标')
  223.      end
  224.      $mouse_icon_id_last = $mouse_icon_id
  225.    end
  226.    @click_lock = false
  227.    mouse_x, mouse_y = self.get_mouse_pos
  228.    if @mouse_sprite != nil
  229.      @mouse_sprite.x = mouse_x
  230.      @mouse_sprite.y = mouse_y
  231.    end
  232.    if left_down[7] == 1
  233.      @left_repeat = (not @left_repeat)
  234.      @left_trigger = (not @left_press)
  235.      @left_press = true
  236.    else
  237.      @left_press = false
  238.      @left_trigger = false
  239.      @left_repeat = false
  240.    end
  241.    if right_down[7] == 1
  242.      @right_repeat = (not @right_repeat)
  243.      @right_trigger = (not @right_press)
  244.      @right_press = true
  245.    else
  246.      @right_press = false
  247.      @right_trigger = false
  248.      @right_repeat = false
  249.    end
  250. end
  251. def self.get_mouse_pos
  252.    point_var = [0, 0].pack('ll')
  253.    if $GetCursorPos.call(point_var) != 0
  254.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  255.        x, y = point_var.unpack('ll')
  256.        if (x < 0) or (x > 10000) then x = 0 end
  257.        if (y < 0) or (y > 10000) then y = 0 end
  258.        if x > 640 then x = 640 end
  259.        if y > 480 then y = 480 end
  260.        return x, y
  261.      else
  262.        return 0, 0
  263.      end
  264.    else
  265.      return 0, 0
  266.    end
  267. end
  268. def self.press?(mouse_code)
  269.    if mouse_code == LEFT
  270.      if @click_lock
  271.        return false
  272.      else
  273.        return @left_press
  274.      end
  275.    elsif mouse_code == RIGHT
  276.      return @right_press
  277.    else
  278.      return false
  279.    end
  280. end
  281. def self.trigger?(mouse_code)
  282.    if mouse_code == LEFT
  283.      if @click_lock
  284.        return false
  285.      else
  286.        return @left_trigger
  287.      end
  288.    elsif mouse_code == RIGHT
  289.      return @right_trigger
  290.    else
  291.      return false
  292.    end
  293. end
  294. def self.repeat?(mouse_code)
  295.    if mouse_code == LEFT
  296.      if @click_lock
  297.        return false
  298.      else
  299.        return @left_repeat
  300.      end
  301.    elsif mouse_code == RIGHT
  302.      return @right_repeat
  303.    else
  304.      return false
  305.    end
  306. end
  307. def self.click_lock?
  308.    return @click_lock
  309. end
  310. def self.click_lock
  311.    @click_lock = true
  312. end
  313. def self.click_unlock
  314.    @click_lock = false
  315. end
  316. end
  317. module Input
  318. if @self_update == nil
  319.    @self_update = method('update')
  320.    @self_press = method('press?')
  321.    @self_trigger = method('trigger?')
  322.    @self_repeat = method('repeat?')
  323. end
  324. def self.update
  325.    @self_update.call
  326.    Mouse.update
  327. end
  328. def self.press?(key_code)
  329.    if @self_press.call(key_code)
  330.      return true
  331.    end
  332.    if key_code == C
  333.      return Mouse.press?(Mouse::LEFT)
  334.    elsif key_code == B
  335.      return Mouse.press?(Mouse::RIGHT)
  336.    else
  337.      return @self_press.call(key_code)
  338.    end
  339. end
  340. def self.trigger?(key_code)
  341.    if @self_trigger.call(key_code)
  342.      return true
  343.    end
  344.    if key_code == C
  345.      return Mouse.trigger?(Mouse::LEFT)
  346.    elsif key_code == B
  347.      return Mouse.trigger?(Mouse::RIGHT)
  348.    else
  349.      return @self_trigger.call(key_code)
  350.    end
  351. end
  352. def self.repeat?(key_code)
  353.    if @self_repeat.call(key_code)
  354.      return true
  355.    end
  356.    if key_code == C
  357.      return Mouse.repeat?(Mouse::LEFT)
  358.    elsif key_code == B
  359.      return Mouse.repeat?(Mouse::RIGHT)
  360.    else
  361.      return @self_repeat.call(key_code)
  362.    end
  363. end
  364. end
  365. class Window_Selectable
  366. if @self_alias == nil
  367.    alias self_update update
  368.    @self_alias = true
  369. end
  370. def update
  371.    self_update
  372.    if self.active and @item_max > 0
  373.      index_var = @index
  374.      tp_index = @index
  375.      mouse_x, mouse_y = Mouse.get_mouse_pos
  376.      mouse_not_in_rect = true
  377.      for i in 0...@item_max
  378.        @index = i
  379.        update_cursor_rect
  380.        top_x = self.cursor_rect.x + self.x + 16
  381.        top_y = self.cursor_rect.y + self.y + 16
  382.        bottom_x = top_x + self.cursor_rect.width
  383.        bottom_y = top_y + self.cursor_rect.height
  384.        if (mouse_x > top_x) and (mouse_y > top_y) and
  385.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  386.          mouse_not_in_rect = false
  387.          if tp_index != @index
  388.            tp_index = @index
  389.            $game_system.se_play($data_system.cursor_se)
  390.          end
  391.          break
  392.        end
  393.      end
  394.      if mouse_not_in_rect
  395.        @index = index_var
  396.        update_cursor_rect
  397.        Mouse.click_lock
  398.      else
  399.        Mouse.click_unlock               
  400.      end
  401.    end
  402. end
  403. end
  404. class Window_Selectable_Minny
  405.   if @self_alias == nil
  406.     alias self_update update
  407.     @self_alias = true
  408.   end
  409.   def update
  410.     #self.cursor_rect.empty
  411.     self_update
  412.     if self.active and @item_max > 0
  413.       index_var = @index
  414.       tp_index = @index
  415.       mouse_x, mouse_y = Mouse.get_mouse_pos
  416.       mouse_not_in_rect = true
  417.       for i in 0...@item_max
  418.         @index = i
  419.         update_cursor_rect
  420.         top_x = self.cursor_rect.x + self.x + 16
  421.         top_y = self.cursor_rect.y + self.y + 16
  422.         bottom_x = top_x + self.cursor_rect.width
  423.         bottom_y = top_y + self.cursor_rect.height
  424.         if (mouse_x > top_x) and (mouse_y > top_y) and
  425.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  426.           mouse_not_in_rect = false
  427.           if tp_index != @index
  428.             tp_index = @index
  429.             $game_system.se_play($data_system.cursor_se)
  430.           end
  431.           break
  432.         end
  433.       end
  434.       if mouse_not_in_rect
  435.         @index = index_var
  436.         update_cursor_rect
  437.         Mouse.click_lock
  438.       else
  439.         Mouse.click_unlock               
  440.       end
  441.     end
  442.   end
  443. end

  444. class Window_NameInput
  445. if @self_alias == nil
  446.    alias self_update update
  447.    @self_alias = true
  448. end
  449. def update
  450.    self_update
  451.    if self.active
  452.      index_var = @index
  453.      mouse_x, mouse_y = Mouse.get_mouse_pos
  454.      mouse_not_in_rect = true
  455.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  456.        @index = i
  457.        update_cursor_rect
  458.        top_x = self.cursor_rect.x + self.x + 16
  459.        top_y = self.cursor_rect.y + self.y + 16
  460.        bottom_x = top_x + self.cursor_rect.width
  461.        bottom_y = top_y + self.cursor_rect.height
  462.        if (mouse_x > top_x) and (mouse_y > top_y) and
  463.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  464.          mouse_not_in_rect = false
  465.          break
  466.        end
  467.      end
  468.      if mouse_not_in_rect
  469.        @index = index_var
  470.        update_cursor_rect
  471.        Mouse.click_lock
  472.      else
  473.        Mouse.click_unlock
  474.      end
  475.    end
  476. end
  477. end
  478. class Window_InputNumber
  479. if @self_alias == nil
  480.    alias self_update update
  481.    @self_alias = true
  482. end
  483. def update
  484.    self_update
  485.    mouse_x, mouse_y = Mouse.get_mouse_pos
  486.    if self.active and @digits_max > 0
  487.      index_var = @index
  488.      mouse_not_in_rect = true
  489.      for i in 0...@digits_max
  490.        @index = i
  491.        update_cursor_rect
  492.        top_x = self.cursor_rect.x + self.x + 16
  493.        bottom_x = top_x + self.cursor_rect.width
  494.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  495.          mouse_not_in_rect = false
  496.          break
  497.        end
  498.      end
  499.      if mouse_not_in_rect
  500.        @index = index_var
  501.        update_cursor_rect
  502.        Mouse.click_lock
  503.      else
  504.        Mouse.click_unlock
  505.      end
  506.    end
  507.    if @last_mouse_y == nil
  508.      @last_mouse_y = mouse_y
  509.    end
  510.    check_pos = (@last_mouse_y - mouse_y).abs
  511.    if check_pos > 10
  512.      $game_system.se_play($data_system.cursor_se)
  513.      place = 10 ** (@digits_max - 1 - @index)
  514.      n = @number / place % 10
  515.      @number -= n * place
  516.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  517.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  518.      @number += n * place
  519.      refresh
  520.      @last_mouse_y = mouse_y
  521.    end
  522. end
  523. end
  524. class Scene_File
  525. if @self_alias == nil
  526.    alias self_update update
  527.    @self_alias = true
  528. end
  529. def update
  530.    mouse_x, mouse_y = Mouse.get_mouse_pos
  531.    Mouse.click_lock
  532.    idx = 0
  533.    for i in @savefile_windows
  534.      top_x = i.x + 16
  535.      top_y = i.y + 16
  536.      bottom_x = top_x + i.width
  537.      bottom_y = top_y + i.height
  538.      if (mouse_x > top_x) and (mouse_y > top_y) and
  539.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  540.        i.selected = true
  541.        if @file_index != idx
  542.          @file_index = idx
  543.          $game_system.se_play($data_system.cursor_se)
  544.        end            
  545.        Mouse.click_unlock
  546.      else
  547.        i.selected = false
  548.      end
  549.      idx += 1
  550.    end
  551.    self_update
  552. end
  553. end
  554. class Arrow_Enemy
  555. if @self_alias == nil
  556.    alias self_update update
  557.    @self_alias = true
  558. end
  559. def update
  560.    mouse_x, mouse_y = Mouse.get_mouse_pos
  561.    idx = 0
  562.    for i in $game_troop.enemies do
  563.      if i.exist?
  564.        top_x = i.screen_x - self.ox
  565.        top_y = i.screen_y - self.oy
  566.        bottom_x = top_x + self.src_rect.width
  567.        bottom_y = top_y + self.src_rect.height
  568.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  569.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  570.          if @index != idx
  571.            $game_system.se_play($data_system.cursor_se)
  572.            @index = idx
  573.          end
  574.        end
  575.      end
  576.      idx += 1
  577.    end
  578.    self_update
  579. end
  580. end
  581. class Arrow_Actor
  582. if @self_alias == nil
  583.    alias self_update update
  584.    @self_alias = true
  585. end
  586. def update
  587.    mouse_x, mouse_y = Mouse.get_mouse_pos
  588.    idx = 0
  589.    for i in $game_party.actors do
  590.      if i.exist?
  591.        top_x = i.screen_x - self.ox
  592.        top_y = i.screen_y - self.oy
  593.        bottom_x = top_x + self.src_rect.width
  594.        bottom_y = top_y + self.src_rect.height
  595.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  596.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  597.          if @index != idx
  598.            $game_system.se_play($data_system.cursor_se)
  599.            @index = idx
  600.          end
  601.        end
  602.      end
  603.      idx += 1
  604.    end
  605.    self_update
  606. end
  607. end
  608. #==============================================================================
  609. # ■ Game_Player
  610. #------------------------------------------------------------------------------
  611. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  612. # 本类的实例请参考 $game_player。
  613. #   鼠标控制角色的主程序
  614. #==============================================================================
  615. class Game_Player
  616. if @self_alias == nil
  617.    alias self_update update
  618.    @self_alias = true
  619. end
  620. #--------------------------------------------------------------------------
  621. # ● 得到鼠标的状态
  622. #--------------------------------------------------------------------------
  623. def get_mouse_sta
  624.    return @mouse_sta
  625. end
  626. #--------------------------------------------------------------------------
  627. # ● 完整鼠标系统
  628. #--------------------------------------------------------------------------
  629.   #--------------------------------------------------------------------------
  630. # ● 完整鼠标系统
  631. #--------------------------------------------------------------------------
  632. def update
  633.    mouse_x, mouse_y = Mouse.get_mouse_pos
  634.    @mtp_x = mouse_x
  635.    @mtp_y = mouse_y
  636.    # 地图界面按扭操作系统★★★★★★★★★★★★★★★★★★★★★
  637.    # 操作提示
  638. # 物品按扭
  639.    if @mtp_x >= 128 and @mtp_x <= 143 and @mtp_y >= 0 and @mtp_y <= 14
  640.      $game_screen.pictures[43].show("选框", 0, 128, 0, 100.0, 100.0, 255, 0)
  641.      if Input.trigger?(Input::C)
  642.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[43].erase
  643.        $scene = Scene_Item.new
  644.       end
  645.    else
  646.      $game_screen.pictures[43].erase
  647.    end
  648. # 存挡按扭
  649.    if @mtp_x >= 124 and @mtp_x <= 138 and @mtp_y >= 15 and @mtp_y <= 27
  650.      $game_screen.pictures[42].show("选框", 0, 124, 14, 100.0, 100.0, 255, 0)
  651.      if Input.trigger?(Input::C)
  652.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[42].erase
  653.        $scene = Scene_Save.new
  654.       end
  655.    else
  656.      $game_screen.pictures[42].erase
  657.    end
  658.     if @mtp_x >= 118 and @mtp_x <= 133 and @mtp_y >= 28 and @mtp_y <= 43
  659.      $game_screen.pictures[41].show("选框", 0, 118, 28, 100.0, 100.0, 255, 0)
  660.      if Input.trigger?(Input::C)
  661.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[41].erase
  662.        $scene = Scene_End.new
  663.       end
  664.    else
  665.      $game_screen.pictures[41].erase
  666.    end
  667.    #------------------------------------------------------
  668.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  669.      #得到鼠标图标方向
  670.      $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)
  671.    else
  672.      #令鼠标图标为正常
  673.      $mouse_icon_id = 0 if @mouse_sta != 2
  674.    end
  675.    
  676.    #单击鼠标时进行判断寻路或跟随
  677.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  678.      unless $game_system.map_interpreter.running? or
  679.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  680.        #初始化
  681.        @mouse_sta = 1
  682.        p_direction = 5
  683.        #检查鼠标处能否开启事件
  684.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  685.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  686.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  687.        if @mouse_sta != 2
  688.          #鼠标状态不为跟随状态则取数据并初始化路径
  689.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  690.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  691.          @paths = []
  692.          @paths_id = 0
  693.          if event_start == 0 #若不能开启事件
  694.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  695.              Mouse.set_ani(mouse_x + $game_map.display_x / 4, mouse_y + $game_map.display_y / 4)
  696.              find_path = Find_Path.new
  697.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  698.            end
  699.          else #若能开启事件则改变角色朝向
  700.            @direction = p_direction
  701.          end
  702.        end
  703.      end
  704.    end

  705.    #开始移动
  706.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  707.      unless moving? or $game_system.map_interpreter.running? or
  708.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  709.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  710.          case @paths[@paths_id] #判断路径
  711.          when 6
  712.            @last_move_x = true
  713.            move_right
  714.            @paths_id += 1
  715.            @direction = 6
  716.          when 4
  717.            @last_move_x = true
  718.            move_left
  719.            @paths_id += 1
  720.            @direction = 4
  721.          when 2
  722.            @last_move_x = false
  723.            move_down
  724.            @direction = 2
  725.            @paths_id += 1
  726.          when 8
  727.            @last_move_x = false
  728.            move_up
  729.            @direction = 8
  730.            @paths_id += 1
  731.          end
  732.        end
  733.      end
  734.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  735.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  736.        unless moving? or $game_system.map_interpreter.running? or
  737.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  738.          #跟随方向判断并跟随
  739.          if @mtp_x > self.screen_x
  740.            if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
  741.               @mtp_y - self.screen_y < @mtp_x - self.screen_x
  742.              move_right
  743.              $mouse_icon_id = 16
  744.              @direction = 6
  745.            end
  746.            if @mtp_y - self.screen_y > @mtp_x - self.screen_x
  747.              move_down
  748.              $mouse_icon_id = 12
  749.              @direction = 2
  750.            end
  751.            if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
  752.              move_up
  753.              $mouse_icon_id = 18
  754.              @direction = 8
  755.            end
  756.          end
  757.          if @mtp_x < self.screen_x
  758.            if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
  759.               @mtp_y - self.screen_y < self.screen_x - @mtp_x
  760.              move_left
  761.              $mouse_icon_id = 14
  762.              @direction = 4
  763.            end
  764.            if @mtp_y - self.screen_y > self.screen_x - @mtp_x
  765.              move_down
  766.              $mouse_icon_id = 12
  767.              @direction = 2
  768.            end
  769.            if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
  770.              move_up
  771.              $mouse_icon_id = 18
  772.              @direction = 8
  773.            end
  774.          end
  775.        end
  776.      else #没状态的情况
  777.        $mouse_icon_id = 0
  778.        @mouse_sta = 0
  779.        @paths_id = @paths.size #终止寻路移动
  780.      end
  781.    end
  782. self_update
  783. end
  784. end
  785. Mouse.init
  786. END { Mouse.exit }
复制代码

Lv1.梦旅人

梦石
0
星屑
49
在线时间
486 小时
注册时间
2009-7-23
帖子
449
2
发表于 2011-7-31 17:47:26 | 只看该作者
本帖最后由 2578699 于 2011-7-31 17:47 编辑

貌似有那样的鼠标脚本耶
搜索看看吧。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
154 小时
注册时间
2011-7-9
帖子
423
3
发表于 2011-8-1 08:27:01 | 只看该作者
很简单-啊
在Mouse模块中的
def self.update加入
$game_system.map_interpreter.running? ? @mouse_sprite.bitmap = Bitmap.new("对话时候的图标") : @mouse_sprite.bitmap = Bitmap.new("平常的图标") 就Ok啦
New Game:  【QQ堂4.6单机版】(9月新版!【点此】)个人提供快速网盘http://ad.jlweb.tk/upload/ --- 密码:abcdefg
激零工作室孵化中.....网游make中。。招收游戏监督一名,上线时间:5~12 小时 招收脚本员,美工数位。。
本人Q:330639889 验证:zs    ----广:愿意帮我宣传签名的,站内PM
下面的东西是什么?!请进:http://tieba.baidu.com/p/1453289014【2012最新炸弹型ARPG游戏,历时2年间断坚持制作!】
[img=646,262]http://ftp.66rpg.com/WEB_PLUS/attachment/forum/201203/28/1655578kbk8bqkfazk2
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2009-4-6
帖子
34
4
 楼主| 发表于 2011-8-1 09:54:13 | 只看该作者
灵魂の补给 发表于 2011-8-1 08:27
很简单-啊
在Mouse模块中的
def self.update加入

我对脚本的认识基本属于幼稚园水平所以能不能说的详细点


逍遥仙诚于2011-8-1 10:13补充以下内容:
仙剑2的鼠标在平时是鼠标形状,在对话就变成另一种形状

点评

为啥我不能在示范图里找到鼠标- -  发表于 2011-8-1 09:59
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
154 小时
注册时间
2011-7-9
帖子
423
5
发表于 2011-8-1 15:17:53 | 只看该作者
那好吧,把下面脚本直接放入游戏:
alias self.newupdate self.update
def self.newupdate
self.update
if $game_system.map_interpreter.running?
@mouse_sprite.bitmap = Bitmap.new("(对话)另一种形状")
else
@mouse_sprite.bitmap = Bitmap.new("鼠标形状")
end
请修改上面的中文,改成你的鼠标文件名!
New Game:  【QQ堂4.6单机版】(9月新版!【点此】)个人提供快速网盘http://ad.jlweb.tk/upload/ --- 密码:abcdefg
激零工作室孵化中.....网游make中。。招收游戏监督一名,上线时间:5~12 小时 招收脚本员,美工数位。。
本人Q:330639889 验证:zs    ----广:愿意帮我宣传签名的,站内PM
下面的东西是什么?!请进:http://tieba.baidu.com/p/1453289014【2012最新炸弹型ARPG游戏,历时2年间断坚持制作!】
[img=646,262]http://ftp.66rpg.com/WEB_PLUS/attachment/forum/201203/28/1655578kbk8bqkfazk2
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-21 00:10

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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