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

Project1

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

[已经过期] 這個鼠標腳本誰幫忙改一下、200经验

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
跳转到指定楼层
1
发表于 2012-2-7 11:19:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 糖糖◎雨 于 2012-2-7 11:21 编辑

    这个鼠标脚本有点击触发事件功能,但是遇到并行处理或自动执行的事件中末尾设置为暂时消除事件时,误点击就会出现脚本错误。哪位高手帮忙改一下、感激不尽
以下是我用的那个脚本:
  1. #==============================================================================
  2. # 本脚本来自www.66rpg.com,源自geocities.jp,转载和使用请注明此内容
  3. #
  4. # 初始鼠标图案在39行和68行改,变换的鼠标图案在66行改
  5. # 这个脚本的思路是判断鼠标所在位置是否有事件,所以响应的情况只有一种。
  6. # 如果想有多种响应的话,思路复杂,比如拆分事件名称等,做出来的东西将繁琐。
  7. # —— JesseKiss
  8. #==============================================================================
  9. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  10. $敌人选框扩大 = 20
  11. $角色选框扩大 = 30
  12. #==============================================================================
  13. # API调用
  14. #==============================================================================
  15. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  16. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  17. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  18. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  19. $Window_HWND = $GetActiveWindow.call
  20. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  21. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  22. #$HookStart = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  23. #$HookEnd = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  24. #$GetMouseStatus = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  25. #$Window_HWND = $FindWindow.call(nil, 'mousetry')

  26. module Mouse
  27. LEFT = 0x01
  28. RIGHT = 0x02

  29. def self.init(sprite = nil)
  30. # $HookStart.call($Window_HWND)
  31. $ShowCursor.call(0)

  32. @show_cursor = false

  33. @mouse_sprite = Sprite.new
  34. @mouse_sprite.z = 99999
  35. @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')
  36. #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

  37. @left_press = false
  38. @right_press = false
  39. @left_trigger = false
  40. @right_trigger = false
  41. @left_repeat = false
  42. @right_repeat = false
  43. @click_lock = false

  44. update
  45. end
  46. def self.exit
  47. @mouse_sprite.bitmap.dispose
  48. @mouse_sprite.dispose
  49. @show_cursor = true
  50. # $HookEnd.call
  51. $ShowCursor.call(1)
  52. end
  53. def self.mouse_debug
  54. return @mouse_debug.bitmap
  55. end
  56. def self.update
  57. left_down = $GetKeyState.call(0x01)
  58. right_down = $GetKeyState.call(0x02)
  59. #if $pop == 1
  60. #@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/041-Item10.png')
  61. #else
  62. #@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/CD.png')
  63. #end
  64. @click_lock = false
  65. mouse_x, mouse_y = self.get_mouse_pos
  66. if @mouse_sprite != nil
  67. @mouse_sprite.x = mouse_x
  68. @mouse_sprite.y = mouse_y
  69. end
  70. if left_down[7] == 1
  71. @left_repeat = (not @left_repeat)
  72. @left_trigger = (not @left_press)
  73. @left_press = true
  74. else
  75. @left_press = false
  76. @left_trigger = false
  77. @left_repeat = false
  78. end
  79. if right_down[7] == 1
  80. @right_repeat = (not @right_repeat)
  81. @right_trigger = (not @right_press)
  82. @right_press = true
  83. else
  84. @right_press = false
  85. @right_trigger = false
  86. @right_repeat = false
  87. end
  88. end
  89. def self.get_mouse_pos
  90. point_var = [0, 0].pack('ll')
  91. if $GetCursorPos.call(point_var) != 0
  92. if $ScreenToClient.call($Window_HWND, point_var) != 0
  93. x, y = point_var.unpack('ll')
  94. if (x < 0) or (x > 10000) then x = 0 end
  95. if (y < 0) or (y > 10000) then y = 0 end
  96. if x > 640 then x = 640 end
  97. if y > 480 then y = 480 end
  98. return x, y
  99. else
  100. return 0, 0
  101. end
  102. else
  103. return 0, 0
  104. end
  105. end
  106. def self.press?(mouse_code)
  107. if mouse_code == LEFT
  108. if @click_lock
  109. return false
  110. else
  111. return @left_press
  112. end
  113. elsif mouse_code == RIGHT
  114. return @right_press
  115. else
  116. return false
  117. end
  118. end
  119. def self.trigger?(mouse_code)
  120. if mouse_code == LEFT
  121. if @click_lock
  122. return false
  123. else
  124. return @left_trigger
  125. end
  126. elsif mouse_code == RIGHT
  127. return @right_trigger
  128. else
  129. return false
  130. end
  131. end
  132. def self.repeat?(mouse_code)
  133. if mouse_code == LEFT
  134. if @click_lock
  135. return false
  136. else
  137. return @left_repeat
  138. end
  139. elsif mouse_code == RIGHT
  140. return @right_repeat
  141. else
  142. return false
  143. end
  144. end
  145. def self.click_lock?
  146. return @click_lock
  147. end
  148. def self.click_lock
  149. @click_lock = true
  150. end
  151. def self.click_unlock
  152. @click_lock = false
  153. end
  154. end
  155. module Input
  156. if @self_update == nil
  157. @self_update = method('update')
  158. @self_press = method('press?')
  159. @self_trigger = method('trigger?')
  160. @self_repeat = method('repeat?')
  161. end
  162. def self.update
  163. @self_update.call
  164. Mouse.update
  165. end
  166. def self.press?(key_code)
  167. if @self_press.call(key_code)
  168. return true
  169. end
  170. if key_code == C
  171. return Mouse.press?(Mouse::LEFT)
  172. elsif key_code == B
  173. return Mouse.press?(Mouse::RIGHT)
  174. else
  175. return @self_press.call(key_code)
  176. end
  177. end
  178. def self.trigger?(key_code)
  179. if @self_trigger.call(key_code)
  180. return true
  181. end
  182. if key_code == C
  183. return Mouse.trigger?(Mouse::LEFT)
  184. elsif key_code == B
  185. return Mouse.trigger?(Mouse::RIGHT)
  186. else
  187. return @self_trigger.call(key_code)
  188. end
  189. end
  190. def self.repeat?(key_code)
  191. if @self_repeat.call(key_code)
  192. return true
  193. end
  194. if key_code == C
  195. return Mouse.repeat?(Mouse::LEFT)
  196. elsif key_code == B
  197. return Mouse.repeat?(Mouse::RIGHT)
  198. else
  199. return @self_repeat.call(key_code)
  200. end
  201. end
  202. end
  203. class Window_Selectable
  204. if @self_alias == nil
  205. alias self_update update
  206. @self_alias = true
  207. end
  208. def update
  209. #self.cursor_rect.empty
  210. self_update
  211. if self.active and @item_max > 0
  212. index_var = @index
  213. tp_index = @index
  214. mouse_x, mouse_y = Mouse.get_mouse_pos
  215. mouse_not_in_rect = true
  216. for i in 0...@item_max
  217. @index = i
  218. update_cursor_rect
  219. top_x = self.cursor_rect.x + self.x + 16
  220. top_y = self.cursor_rect.y + self.y + 16
  221. bottom_x = top_x + self.cursor_rect.width
  222. bottom_y = top_y + self.cursor_rect.height
  223. if (mouse_x > top_x) and (mouse_y > top_y) and
  224. (mouse_x < bottom_x) and (mouse_y < bottom_y)
  225. mouse_not_in_rect = false
  226. if tp_index != @index
  227. tp_index = @index
  228. $game_system.se_play($data_system.cursor_se)
  229. end
  230. break
  231. end
  232. end
  233. if mouse_not_in_rect
  234. @index = index_var
  235. update_cursor_rect
  236. Mouse.click_lock
  237. else
  238. Mouse.click_unlock
  239. end
  240. end
  241. end
  242. end
  243. class Window_NameInput
  244. if @self_alias == nil
  245. alias self_update update
  246. @self_alias = true
  247. end
  248. def update
  249. #self.cursor_rect.empty
  250. self_update
  251. if self.active
  252. index_var = @index
  253. mouse_x, mouse_y = Mouse.get_mouse_pos
  254. mouse_not_in_rect = true
  255. for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  256. @index = i
  257. update_cursor_rect
  258. top_x = self.cursor_rect.x + self.x + 16
  259. top_y = self.cursor_rect.y + self.y + 16
  260. bottom_x = top_x + self.cursor_rect.width
  261. bottom_y = top_y + self.cursor_rect.height
  262. #
  263. if (mouse_x > top_x) and (mouse_y > top_y) and
  264. (mouse_x < bottom_x) and (mouse_y < bottom_y)
  265. mouse_not_in_rect = false
  266. break
  267. end
  268. end
  269. if mouse_not_in_rect
  270. @index = index_var
  271. update_cursor_rect
  272. Mouse.click_lock
  273. else
  274. Mouse.click_unlock
  275. end
  276. end
  277. end
  278. end
  279. class Window_InputNumber
  280. if @self_alias == nil
  281. alias self_update update
  282. @self_alias = true
  283. end
  284. def update
  285. #self.cursor_rect.empty
  286. self_update
  287. mouse_x, mouse_y = Mouse.get_mouse_pos
  288. if self.active and @digits_max > 0
  289. index_var = @index
  290. mouse_not_in_rect = true
  291. for i in 0...@digits_max
  292. @index = i
  293. update_cursor_rect
  294. top_x = self.cursor_rect.x + self.x + 16
  295. bottom_x = top_x + self.cursor_rect.width
  296. #
  297. if (mouse_x > top_x) and (mouse_x < bottom_x)
  298. mouse_not_in_rect = false
  299. break
  300. end
  301. end
  302. if mouse_not_in_rect
  303. @index = index_var
  304. update_cursor_rect
  305. Mouse.click_lock
  306. else
  307. Mouse.click_unlock
  308. end
  309. end
  310. if @last_mouse_y == nil
  311. @last_mouse_y = mouse_y
  312. end
  313. check_pos = (@last_mouse_y - mouse_y).abs
  314. if check_pos > 10
  315. $game_system.se_play($data_system.cursor_se)
  316. place = 10 ** (@digits_max - 1 - @index)
  317. n = @number / place % 10
  318. @number -= n * place
  319. n = (n + 1) % 10 if mouse_y < @last_mouse_y
  320. n = (n + 9) % 10 if mouse_y > @last_mouse_y
  321. @number += n * place
  322. refresh
  323. @last_mouse_y = mouse_y
  324. end
  325. end
  326. end
  327. class Scene_File
  328. if @self_alias == nil
  329. alias self_update update
  330. @self_alias = true
  331. end
  332. def update
  333. mouse_x, mouse_y = Mouse.get_mouse_pos
  334. Mouse.click_lock
  335. idx = 0
  336. for i in @savefile_windows
  337. top_x = i.x + 16
  338. top_y = i.y + 16
  339. bottom_x = top_x + i.width
  340. bottom_y = top_y + i.height
  341. if (mouse_x > top_x) and (mouse_y > top_y) and
  342. (mouse_x < bottom_x) and (mouse_y < bottom_y)
  343. i.selected = true
  344. if @file_index != idx
  345. @file_index = idx
  346. $game_system.se_play($data_system.cursor_se)
  347. end
  348. Mouse.click_unlock
  349. else
  350. i.selected = false
  351. end
  352. idx += 1
  353. end
  354. self_update
  355. end
  356. end
  357. class Arrow_Enemy
  358. if @self_alias == nil
  359. alias self_update update
  360. @self_alias = true
  361. end
  362. def update
  363. mouse_x, mouse_y = Mouse.get_mouse_pos
  364. idx = 0
  365. for i in $game_troop.enemies do
  366. if i.exist?
  367. top_x = i.screen_x - self.ox
  368. top_y = i.screen_y - self.oy
  369. bottom_x = top_x + self.src_rect.width
  370. bottom_y = top_y + self.src_rect.height
  371. if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  372. (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  373. if @index != idx
  374. $game_system.se_play($data_system.cursor_se)
  375. @index = idx
  376. end
  377. end
  378. end
  379. idx += 1
  380. end
  381. self_update
  382. end
  383. end
  384. class Arrow_Actor
  385. if @self_alias == nil
  386. alias self_update update
  387. @self_alias = true
  388. end
  389. def update
  390. mouse_x, mouse_y = Mouse.get_mouse_pos
  391. idx = 0
  392. for i in $game_party.actors do
  393. if i.exist?
  394. top_x = i.screen_x - self.ox
  395. top_y = i.screen_y - self.oy
  396. bottom_x = top_x + self.src_rect.width
  397. bottom_y = top_y + self.src_rect.height
  398. if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  399. (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  400. if @index != idx
  401. $game_system.se_play($data_system.cursor_se)
  402. @index = idx
  403. end
  404. end
  405. end
  406. idx += 1
  407. end
  408. self_update
  409. end
  410. end
  411. class Game_Player
  412. if @self_alias == nil
  413. alias self_update update
  414. @self_alias = true
  415. end
  416. def update
  417. mouse_x, mouse_y = Mouse.get_mouse_pos
  418. $e_id = $game_map.check_event(mouse_x/32,mouse_y/32)
  419. if $e_id != -1 then
  420. $pop = 1
  421. ####点击启动事件###################

  422. if Mouse.press?(Mouse::LEFT)
  423. # 信息窗口一个也不显示的时候
  424. unless moving? or $game_system.map_interpreter.running? or
  425. @move_route_forcing or $game_temp.message_window_showing
  426. $game_map.events[$e_id].start
  427. end
  428. end
  429. ####################
  430. else
  431. $pop = 0
  432. end
  433. if @last_move_x == nil
  434. @last_move_x = false
  435. end
  436. if Mouse.press?(Mouse::LEFT)
  437. last_moving = moving?
  438. last_direction = @direction
  439. unless moving? or $game_system.map_interpreter.running? or
  440. @move_route_forcing or $game_temp.message_window_showing
  441. last_x = @x
  442. if @last_move_x
  443. @last_move_x = false
  444. elsif mouse_x > screen_x + 16
  445. move_right
  446. elsif mouse_x < screen_x - 16
  447. move_left
  448. end
  449. last_y = @y
  450. if last_x != @x
  451. @last_move_x = true
  452. elsif mouse_y > screen_y
  453. move_down
  454. elsif mouse_y < screen_y - 32
  455. move_up
  456. end
  457. if last_y != @y
  458. @last_move_x = false
  459. elsif not @last_move_x
  460. case last_direction
  461. when 2
  462. turn_down
  463. when 4
  464. turn_left
  465. when 6
  466. turn_right
  467. when 8
  468. turn_up
  469. end
  470. end
  471. end
  472. end
  473. self_update
  474. end
  475. end
  476. Mouse.init
  477. END { Mouse.exit }

  478. class Game_Map
  479. alias check_event_1 check_event
  480. def check_event(x, y)
  481. for event in $game_map.events.values
  482. if event.screen_x/32 == x and event.screen_y/32-1 == y
  483. return event.id
  484. end
  485. end
  486. return -1
  487. end
  488. end
复制代码

评分

参与人数 1星屑 +200 收起 理由
「旅」 + 200 无满意答案,返回积分~

查看全部评分

《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
3 小时
注册时间
2012-2-7
帖子
17
2
发表于 2012-2-7 11:37:24 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
57 小时
注册时间
2009-7-9
帖子
124
3
发表于 2012-2-7 16:53:21 | 只看该作者
你用list来表示吧。
最后class Game_map


class Game_Map
  

for event in $game_map.events.values #循环所有事件检查
      event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
      event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
      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
        for i in 0...event.list.size
          if event.list[i].parameters[0] == "zidong" #自动判断
            retrun
          elsif event.list[i].parameters[0] == "binglie" #并列判断
           retrun
         end
     end
  end
end

这个应该在鼠标系统整合里有,
用法:在事件里开头插入注释 zidong
会直接返回 ,这样就不会执行了

点评

脚本发生错误、  发表于 2012-2-10 10:09
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
9 小时
注册时间
2012-2-8
帖子
53
4
发表于 2012-2-8 20:50:47 | 只看该作者
谢谢,lz提供的脚本素材!!!{:nm_8:}

评分

参与人数 1星屑 -40 收起 理由
「旅」 -40 纯水

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-28 16:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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