Project1
标题:
鼠标脚本 如何只在菜单中使用鼠标
[打印本页]
作者:
gqhondafit
时间:
2011-7-10 15:48
标题:
鼠标脚本 如何只在菜单中使用鼠标
如何只能在菜单中使用鼠标,但在游戏中不能用鼠标控制人物、事件?
脚本也可以,但最好能详细些
谢啦! dsu_plus_rewardpost_czw
作者:
忧雪の伤
时间:
2011-7-10 17:41
把那部分都给砍了就好XD。
给出鼠标脚本让别人帮你修改吧(为什么你不改啊
作者:
R-零
时间:
2011-7-10 17:53
所谓“别人”就是悲哀的吾等么
将 Game_player 和 Game_map这两个脚本放到鼠控脚本后面对某些版本有效
@@1349607750
作者:
gqhondafit
时间:
2011-7-16 22:17
忧雪の伤 发表于 2011-7-10 17:41
把那部分都给砍了就好XD。
给出鼠标脚本让别人帮你修改吧(为什么你不改啊 ...
可是我不会改:)
gqhondafit于2011-7-16 22:21补充以下内容:
这个是我用的脚本:
01.#==============================================================================
02.# 本脚本来自www.66rpg.com,源自geocities.jp,转载和使用请注明此内容
03.#
04.# 初始鼠标图案在35行和64行改,变换的鼠标图案在62行改
05.# 这个脚本的思路是判断鼠标所在位置是否有事件,所以响应的情况只有一种。
06.# 如果想有多种响应的话,思路复杂,比如拆分事件名称等,做出来的东西将繁琐。
07.# —— JesseKiss
08.#==============================================================================
09.#=================以下两个用来调整战斗时的手感问题,可以自己试试。
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.
27.module Mouse
28. LEFT = 0x01
29. RIGHT = 0x02
30.
31. def self.init(sprite = nil)
32.# $HookStart.call($Window_HWND)
33. $ShowCursor.call(0)
34.
35. @show_cursor = false
36.
37. @mouse_sprite = Sprite.new
38. @mouse_sprite.z = 99999
39. @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/028-Herb04.png')
40. #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))
41.
42. @left_press = false
43. @right_press = false
44. @left_trigger = false
45. @right_trigger = false
46. @left_repeat = false
47. @right_repeat = false
48. @click_lock = false
49.
50. update
51. end
52. def self.exit
53. @mouse_sprite.bitmap.dispose
54. @mouse_sprite.dispose
55. @show_cursor = true
56.# $HookEnd.call
57. $ShowCursor.call(1)
58. end
59. def self.mouse_debug
60. return @mouse_debug.bitmap
61. end
62. def self.update
63. left_down = $GetKeyState.call(0x01)
64. right_down = $GetKeyState.call(0x02)
65. if $pop == 1
66. @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/049-Skill06.png')
67. else
68. @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/j9.png')
69. end
70. @click_lock = false
71. mouse_x, mouse_y = self.get_mouse_pos
72. if @mouse_sprite != nil
73. @mouse_sprite.x = mouse_x
74. @mouse_sprite.y = mouse_y
75. end
76. if left_down[7] == 1
77. @left_repeat = (not @left_repeat)
78. @left_trigger = (not @left_press)
79. @left_press = true
80. else
81. @left_press = false
82. @left_trigger = false
83. @left_repeat = false
84. end
85. if right_down[7] == 1
86. @right_repeat = (not @right_repeat)
87. @right_trigger = (not @right_press)
88. @right_press = true
89. else
90. @right_press = false
91. @right_trigger = false
92. @right_repeat = false
93. end
94. end
95. def self.get_mouse_pos
96. point_var = [0, 0].pack('ll')
97. if $GetCursorPos.call(point_var) != 0
98. if $ScreenToClient.call($Window_HWND, point_var) != 0
99. x, y = point_var.unpack('ll')
100. if (x < 0) or (x > 10000) then x = 0 end
101. if (y < 0) or (y > 10000) then y = 0 end
102. if x > 640 then x = 640 end
103. if y > 480 then y = 480 end
104. return x, y
105. else
106. return 0, 0
107. end
108. else
109. return 0, 0
110. end
111. end
112. def self.press?(mouse_code)
113. if mouse_code == LEFT
114. if @click_lock
115. return false
116. else
117. return @left_press
118. end
119. elsif mouse_code == RIGHT
120. return @right_press
121. else
122. return false
123. end
124. end
125. def self.trigger?(mouse_code)
126. if mouse_code == LEFT
127. if @click_lock
128. return false
129. else
130. return @left_trigger
131. end
132. elsif mouse_code == RIGHT
133. return @right_trigger
134. else
135. return false
136. end
137. end
138. def self.repeat?(mouse_code)
139. if mouse_code == LEFT
140. if @click_lock
141. return false
142. else
143. return @left_repeat
144. end
145. elsif mouse_code == RIGHT
146. return @right_repeat
147. else
148. return false
149. end
150. end
151. def self.click_lock?
152. return @click_lock
153. end
154. def self.click_lock
155. @click_lock = true
156. end
157. def self.click_unlock
158. @click_lock = false
159. end
160.end
161.module Input
162. if @self_update == nil
163. @self_update = method('update')
164. @self_press = method('press?')
165. @self_trigger = method('trigger?')
166. @self_repeat = method('repeat?')
167. end
168. def self.update
169. @self_update.call
170. Mouse.update
171. end
172. def self.press?(key_code)
173. if @self_press.call(key_code)
174. return true
175. end
176. if key_code == C
177. return Mouse.press?(Mouse::LEFT)
178. elsif key_code == B
179. return Mouse.press?(Mouse::RIGHT)
180. else
181. return @self_press.call(key_code)
182. end
183. end
184. def self.trigger?(key_code)
185. if @self_trigger.call(key_code)
186. return true
187. end
188. if key_code == C
189. return Mouse.trigger?(Mouse::LEFT)
190. elsif key_code == B
191. return Mouse.trigger?(Mouse::RIGHT)
192. else
193. return @self_trigger.call(key_code)
194. end
195. end
196. def self.repeat?(key_code)
197. if @self_repeat.call(key_code)
198. return true
199. end
200. if key_code == C
201. return Mouse.repeat?(Mouse::LEFT)
202. elsif key_code == B
203. return Mouse.repeat?(Mouse::RIGHT)
204. else
205. return @self_repeat.call(key_code)
206. end
207. end
208.end
209.class Window_Selectable
210. if @self_alias == nil
211. alias self_update update
212. @self_alias = true
213. end
214. def update
215. #self.cursor_rect.empty
216. self_update
217. if self.active and @item_max > 0
218. index_var = @index
219. tp_index = @index
220. mouse_x, mouse_y = Mouse.get_mouse_pos
221. mouse_not_in_rect = true
222. for i in 0...@item_max
223. @index = i
224. update_cursor_rect
225. top_x = self.cursor_rect.x + self.x + 16
226. top_y = self.cursor_rect.y + self.y + 16
227. bottom_x = top_x + self.cursor_rect.width
228. bottom_y = top_y + self.cursor_rect.height
229. if (mouse_x > top_x) and (mouse_y > top_y) and
230. (mouse_x < bottom_x) and (mouse_y < bottom_y)
231. mouse_not_in_rect = false
232. if tp_index != @index
233. tp_index = @index
234. $game_system.se_play($data_system.cursor_se)
235. end
236. break
237. end
238. end
239. if mouse_not_in_rect
240. @index = index_var
241. update_cursor_rect
242. Mouse.click_lock
243. else
244. Mouse.click_unlock
245. end
246. end
247. end
248.end
249.class Window_NameInput
250. if @self_alias == nil
251. alias self_update update
252. @self_alias = true
253. end
254. def update
255. #self.cursor_rect.empty
256. self_update
257. if self.active
258. index_var = @index
259. mouse_x, mouse_y = Mouse.get_mouse_pos
260. mouse_not_in_rect = true
261. for i in (0...CHARACTER_TABLE.size).to_a.push(180)
262. @index = i
263. update_cursor_rect
264. top_x = self.cursor_rect.x + self.x + 16
265. top_y = self.cursor_rect.y + self.y + 16
266. bottom_x = top_x + self.cursor_rect.width
267. bottom_y = top_y + self.cursor_rect.height
268. #
269. if (mouse_x > top_x) and (mouse_y > top_y) and
270. (mouse_x < bottom_x) and (mouse_y < bottom_y)
271. mouse_not_in_rect = false
272. break
273. end
274. end
275. if mouse_not_in_rect
276. @index = index_var
277. update_cursor_rect
278. Mouse.click_lock
279. else
280. Mouse.click_unlock
281. end
282. end
283. end
284.end
285.class Window_InputNumber
286. if @self_alias == nil
287. alias self_update update
288. @self_alias = true
289. end
290. def update
291. #self.cursor_rect.empty
292. self_update
293. mouse_x, mouse_y = Mouse.get_mouse_pos
294. if self.active and @digits_max > 0
295. index_var = @index
296. mouse_not_in_rect = true
297. for i in 0...@digits_max
298. @index = i
299. update_cursor_rect
300. top_x = self.cursor_rect.x + self.x + 16
301. bottom_x = top_x + self.cursor_rect.width
302. #
303. if (mouse_x > top_x) and (mouse_x < bottom_x)
304. mouse_not_in_rect = false
305. break
306. end
307. end
308. if mouse_not_in_rect
309. @index = index_var
310. update_cursor_rect
311. Mouse.click_lock
312. else
313. Mouse.click_unlock
314. end
315. end
316. if @last_mouse_y == nil
317. @last_mouse_y = mouse_y
318. end
319. check_pos = (@last_mouse_y - mouse_y).abs
320. if check_pos > 10
321. $game_system.se_play($data_system.cursor_se)
322. place = 10 ** (@digits_max - 1 - @index)
323. n = @number / place % 10
324. @number -= n * place
325. n = (n + 1) % 10 if mouse_y < @last_mouse_y
326. n = (n + 9) % 10 if mouse_y > @last_mouse_y
327. @number += n * place
328. refresh
329. @last_mouse_y = mouse_y
330. end
331. end
332.end
333.class Scene_File
334. if @self_alias == nil
335. alias self_update update
336. @self_alias = true
337. end
338. def update
339. mouse_x, mouse_y = Mouse.get_mouse_pos
340. Mouse.click_lock
341. idx = 0
342. for i in @savefile_windows
343. top_x = i.x + 16
344. top_y = i.y + 16
345. bottom_x = top_x + i.width
346. bottom_y = top_y + i.height
347. if (mouse_x > top_x) and (mouse_y > top_y) and
348. (mouse_x < bottom_x) and (mouse_y < bottom_y)
349. i.selected = true
350. if @file_index != idx
351. @file_index = idx
352. $game_system.se_play($data_system.cursor_se)
353. end
354. Mouse.click_unlock
355. else
356. i.selected = false
357. end
358. idx += 1
359. end
360. self_update
361. end
362.end
363.class Arrow_Enemy
364. if @self_alias == nil
365. alias self_update update
366. @self_alias = true
367. end
368. def update
369. mouse_x, mouse_y = Mouse.get_mouse_pos
370. idx = 0
371. for i in $game_troop.enemies do
372. if i.exist?
373. top_x = i.screen_x - self.ox
374. top_y = i.screen_y - self.oy
375. bottom_x = top_x + self.src_rect.width
376. bottom_y = top_y + self.src_rect.height
377. if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
378. (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
379. if @index != idx
380. $game_system.se_play($data_system.cursor_se)
381. @index = idx
382. end
383. end
384. end
385. idx += 1
386. end
387. self_update
388. end
389.end
390.class Arrow_Actor
391. if @self_alias == nil
392. alias self_update update
393. @self_alias = true
394. end
395. def update
396. mouse_x, mouse_y = Mouse.get_mouse_pos
397. idx = 0
398. for i in $game_party.actors do
399. if i.exist?
400. top_x = i.screen_x - self.ox
401. top_y = i.screen_y - self.oy
402. bottom_x = top_x + self.src_rect.width
403. bottom_y = top_y + self.src_rect.height
404. if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
405. (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
406. if @index != idx
407. $game_system.se_play($data_system.cursor_se)
408. @index = idx
409. end
410. end
411. end
412. idx += 1
413. end
414. self_update
415. end
416.end
417.class Game_Player
418. if @self_alias == nil
419. alias self_update update
420. @self_alias = true
421. end
422. def update
423. mouse_x, mouse_y = Mouse.get_mouse_pos
424. $e_id = $game_map.check_event(mouse_x/32,mouse_y/32)
425. if $e_id != -1 then
426. $pop = 1
427. ####点击启动事件###################
428.
429. if Mouse.press?(Mouse::LEFT)
430. # 信息窗口一个也不显示的时候
431. unless moving? or $game_system.map_interpreter.running? or
432. @move_route_forcing or $game_temp.message_window_showing
433. $game_map.events[$e_id].start
434. end
435. end
436. ####################
437. else
438. $pop = 0
439. end
440. if @last_move_x == nil
441. @last_move_x = false
442. end
443. if Mouse.press?(Mouse::LEFT)
444. last_moving = moving?
445. last_direction = @direction
446. unless moving? or $game_system.map_interpreter.running? or
447. @move_route_forcing or $game_temp.message_window_showing
448. last_x = @x
449. if @last_move_x
450. @last_move_x = false
451. elsif mouse_x > screen_x + 16
452. move_right
453. elsif mouse_x < screen_x - 16
454. move_left
455. end
456. last_y = @y
457. if last_x != @x
458. @last_move_x = true
459. elsif mouse_y > screen_y
460. move_down
461. elsif mouse_y < screen_y - 32
462. move_up
463. end
464. if last_y != @y
465. @last_move_x = false
466. elsif not @last_move_x
467. case last_direction
468. when 2
469. turn_down
470. when 4
471. turn_left
472. when 6
473. turn_right
474. when 8
475. turn_up
476. end
477. end
478. end
479. end
480. self_update
481. end
482.end
483.Mouse.init
484.END { Mouse.exit }
485.
486.class Game_Map
487.alias check_event_1 check_event
488. def check_event(x, y)
489. for event in $game_map.events.values
490. if event.screen_x/32 == x and event.screen_y/32-1 == y
491. return event.id
492. end
493. end
494. return -1
495. end
496.end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1