Project1
标题:
关于鼠标的问题
[打印本页]
作者:
七夕£雪夜
时间:
2008-11-18 18:07
提示:
作者被禁止或删除 内容自动屏蔽
作者:
塑望
时间:
2008-11-18 18:14
应该是漏了死亡后的操作判断吧
没看见脚本 不好说
作者:
任我逍遥
时间:
2008-11-18 20:40
提示:
作者被禁止或删除 内容自动屏蔽
作者:
doranikofu
时间:
2008-11-18 20:53
lz用的什么战斗脚本?
作者:
七夕£雪夜
时间:
2008-11-22 05:28
提示:
作者被禁止或删除 内容自动屏蔽
作者:
七夕£雪夜
时间:
2008-11-29 04:59
提示:
作者被禁止或删除 内容自动屏蔽
作者:
七夕£雪夜
时间:
2008-11-29 20:21
提示:
作者被禁止或删除 内容自动屏蔽
作者:
柳之一
时间:
2008-11-29 20:23
要么你在定义战斗部分啊,技能啊什么的,把那个部分给冲突掉了
要么就是原鼠标里面没有这个分歧判断。
要么就是误删,复制不完全等等
作者:
七夕£雪夜
时间:
2008-11-30 21:17
提示:
作者被禁止或删除 内容自动屏蔽
作者:
hgfor
时间:
2008-12-2 23:45
试试这个脚 本.
class Game_Event
attr_accessor :flag
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 处理地图的类。包含卷动以及可以通行的判断功能。
# 本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
def check_event_custom(x, y)
for event in $game_map.events.values
if event.screen_x/32 == x and event.screen_y/32 - 1 == y
for i in 0...event.list.size
if event.list[i].parameters[0] == "Enemy"
event.flag = 1
elsif event.list[i].parameters[0] == "Npc"
event.flag = 2
else
#print $pop
event.flag = 0 if $game_player.get_mouse_open != 2
end
return event.flag
end
end
end
return 0 if $game_player.get_mouse_open != 2
return $pop
end
end
#=================以下两个用来调整战斗时的手感问题,可以自己试试。
$敌人选框扩大 = 20
$角色选框扩大 = 30
#==============================================================================
# API调用
#==============================================================================
$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
$GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
#$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
#$HookStart = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
#$HookEnd = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
#$GetMouseStatus = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
#$Window_HWND = $FindWindow.call(nil, 'mousetry')
module Mouse
LEFT = 0x01
RIGHT = 0x02
def self.newbitmap(newbitmap = 'Graphics/Icons/001-Weapon01.png')
@mouse_sprite.bitmap = Bitmap.new(newbitmap)
end
def self.init(sprite = nil)
# $HookStart.call($Window_HWND)
$ShowCursor.call(0)
@show_cursor = false
@mouse_sprite = Sprite.new
@mouse_sprite.z = 99999
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑.png')
#@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))
@left_press = false
@right_press = false
@left_trigger = false
@right_trigger = false
@left_repeat = false
@right_repeat = false
@click_lock = false
update
end
def self.exit
@mouse_sprite.bitmap.dispose
@mouse_sprite.dispose
@show_cursor = true
# $HookEnd.call
$ShowCursor.call(1)
end
def self.mouse_debug
return @mouse_debug.bitmap
end
def self.update
left_down = $GetKeyState.call(0x01)
right_down = $GetKeyState.call(0x02)
###########################################################################
if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
@total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
@a = !@a
end
if $scene.is_a?(Scene_Map) == false
$pop = 0
end
case $pop
when 1
if @a
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
else
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
end
when 2
if @a
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
else
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
end
when 11
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
when 12
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
when 13
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
when 14
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
when 16
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
when 17
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
when 18
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
when 19
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
when 0
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
end
########################################################################
@click_lock = false
mouse_x, mouse_y = self.get_mouse_pos
if @mouse_sprite != nil
@mouse_sprite.x = mouse_x
@mouse_sprite.y = mouse_y
end
if left_down[7] == 1
@left_repeat = (not @left_repeat)
@left_trigger = (not @left_press)
@left_press = true
else
@left_press = false
@left_trigger = false
@left_repeat = false
end
if right_down[7] == 1
@right_repeat = (not @right_repeat)
@right_trigger = (not @right_press)
@right_press = true
else
@right_press = false
@right_trigger = false
@right_repeat = false
end
end
def self.get_mouse_pos
point_var = [0, 0].pack('ll')
if $GetCursorPos.call(point_var) != 0
if $ScreenToClient.call($Window_HWND, point_var) != 0
x, y = point_var.unpack('ll')
if (x < 0) or (x > 10000) then x = 0 end
if (y < 0) or (y > 10000) then y = 0 end
if x > 640 then x = 640 end
if y > 480 then y = 480 end
return x, y
else
return 0, 0
end
else
return 0, 0
end
end
def self.press?(mouse_code)
if mouse_code == LEFT
if @click_lock
return false
else
return @left_press
end
elsif mouse_code == RIGHT
return @right_press
else
return false
end
end
def self.trigger?(mouse_code)
if mouse_code == LEFT
if @click_lock
return false
else
return @left_trigger
end
elsif mouse_code == RIGHT
return @right_trigger
else
return false
end
end
def self.repeat?(mouse_code)
if mouse_code == LEFT
if @click_lock
return false
else
return @left_repeat
end
elsif mouse_code == RIGHT
return @right_repeat
else
return false
end
end
def self.click_lock?
return @click_lock
end
def self.click_lock
@click_lock = true
end
def self.click_unlock
@click_lock = false
end
end
module Input
if @self_update == nil
@self_update = method('update')
@self_press = method('press?')
@self_trigger = method('trigger?')
@self_repeat = method('repeat?')
end
def self.update
@self_update.call
Mouse.update
end
def self.press?(key_code)
if @self_press.call(key_code)
return true
end
if key_code == C
return Mouse.press?(Mouse::LEFT)
elsif key_code == B
return Mouse.press?(Mouse::RIGHT)
else
return @self_press.call(key_code)
end
end
def self.trigger?(key_code)
if @self_trigger.call(key_code)
return true
end
if key_code == C
mousetrig = Mouse.trigger?(Mouse::LEFT)
return mousetrig
elsif key_code == B
return Mouse.trigger?(Mouse::RIGHT)
else
return @self_trigger.call(key_code)
end
end
def self.repeat?(key_code)
if @self_repeat.call(key_code)
return true
end
if key_code == C
return Mouse.repeat?(Mouse::LEFT)
elsif key_code == B
return Mouse.repeat?(Mouse::RIGHT)
else
return @self_repeat.call(key_code)
end
end
end
class Window_Selectable
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
#self.cursor_rect.empty
self_update
if self.active and @item_max > 0
index_var = @index
tp_index = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in 0...@item_max
@index = i
update_cursor_rect
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false
if tp_index != @index
tp_index = @index
$game_system.se_play($data_system.cursor_se)
end
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect
Mouse.click_lock
else
Mouse.click_unlock
end
end
end
end
class Window_NameInput
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
#self.cursor_rect.empty
self_update
if self.active
index_var = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in (0...CHARACTER_TABLE.size).to_a.push(180)
@index = i
update_cursor_rect
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
#
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect
Mouse.click_lock
else
Mouse.click_unlock
end
end
end
end
class Window_InputNumber
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
#self.cursor_rect.empty
self_update
mouse_x, mouse_y = Mouse.get_mouse_pos
if self.active and @digits_max > 0
index_var = @index
mouse_not_in_rect = true
for i in 0...@digits_max
@index = i
update_cursor_rect
top_x = self.cursor_rect.x + self.x + 16
bottom_x = top_x + self.cursor_rect.width
#
if (mouse_x > top_x) and (mouse_x < bottom_x)
mouse_not_in_rect = false
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect
Mouse.click_lock
else
Mouse.click_unlock
end
end
if @last_mouse_y == nil
@last_mouse_y = mouse_y
end
check_pos = (@last_mouse_y - mouse_y).abs
if check_pos > 10
$game_system.se_play($data_system.cursor_se)
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
n = (n + 1) % 10 if mouse_y < @last_mouse_y
n = (n + 9) % 10 if mouse_y > @last_mouse_y
@number += n * place
refresh
@last_mouse_y = mouse_y
end
end
end
class Scene_File
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
Mouse.click_lock
idx = 0
for i in @savefile_windows
top_x = i.x + 16
top_y = i.y + 16
bottom_x = top_x + i.width
bottom_y = top_y + i.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
i.selected = true
if @file_index != idx
@file_index = idx
$game_system.se_play($data_system.cursor_se)
end
Mouse.click_unlock
else
i.selected = false
end
idx += 1
end
self_update
end
end
class Arrow_Enemy
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
idx = 0
for i in $game_troop.enemies do
if i.exist?
top_x = i.screen_x - self.ox
top_y = i.screen_y - self.oy
bottom_x = top_x + self.src_rect.width
bottom_y = top_y + self.src_rect.height
if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
(mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
if @index != idx
$game_system.se_play($data_system.cursor_se)
@index = idx
end
end
end
idx += 1
end
self_update
end
end
class Arrow_Actor
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
idx = 0
for i in $game_party.actors do
if i.exist?
top_x = i.screen_x - self.ox
top_y = i.screen_y - self.oy
bottom_x = top_x + self.src_rect.width
bottom_y = top_y + self.src_rect.height
if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
(mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
if @index != idx
$game_system.se_play($data_system.cursor_se)
@index = idx
end
end
end
idx += 1
end
self_update
end
end
class Game_Player
if @self_alias == nil
alias self_update update
@self_alias = true
end
###################
def new_mtp
@mtp_x = screen_x
@mtp_y = screen_y
end
def get_mouse_open
return @mouse_open
end
#################
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
unless $game_system.map_interpreter.running? and @mouse_open == 2
$pop = $game_map.check_event_custom(mouse_x/32,mouse_y/32 + 1)
if $pop != 2
$pop = $game_map.check_event_custom(mouse_x/32,mouse_y/32) if not [11, 12, 13, 14, 16, 17, 18, 19].include?($pop)
end
else
$pop = 0 if @mouse_open != 2
end
if @last_move_x == nil
@last_move_x = false
end
if Mouse.trigger?(Mouse::LEFT)
unless $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
@mouse_open = 1
if @paths_id != nil and @paths_id != @paths.size
@mouse_open = 2
end
if @mouse_open != 2
@mtp_x, @mtp_y = Mouse.get_mouse_pos
@trg_x = (@mtp_x + $game_map.display_x / 4) / 32
@trg_y = (@mtp_y + $game_map.display_y / 4) / 32
if $game_map.check_event_custom(@mtp_x/32,@mtp_y/32 + 1) == 2
@trg_y += 1
end
@paths = $path_finding.find_player_short_path(@trg_x, @trg_y)
if @paths == nil or @paths == []
#print @mtp_x
#print self.screen_x
if @mtp_x > self.screen_x
if @mtp_y - self.screen_y > - 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < 0.4 * ( @mtp_x - self.screen_x )
@direction = 6
end
if @mtp_y - self.screen_y > 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < 2.4 * ( @mtp_x - self.screen_x )
@direction = 3
end
if @mtp_y - self.screen_y < - 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y > - 2.4 * ( @mtp_x - self.screen_x )
@direction = 9
end
if @mtp_y - self.screen_y > 2.4 * ( @mtp_x - self.screen_x )
@direction = 2
end
if @mtp_y - self.screen_y < - 2.4 * ( @mtp_x - self.screen_x )
@direction = 8
end
end
if @mtp_x < self.screen_x
if @mtp_y - self.screen_y > - 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < 0.4 * ( self.screen_x - @mtp_x )
@direction = 4
end
if @mtp_y - self.screen_y > 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < 2.4 * ( self.screen_x - @mtp_x )
@direction = 1
end
if @mtp_y - self.screen_y < - 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y > - 2.4 * ( self.screen_x - @mtp_x )
@direction = 7
end
if @mtp_y - self.screen_y > 2.4 * ( self.screen_x - @mtp_x )
@direction = 2
end
if @mtp_y - self.screen_y < - 2.4 * ( self.screen_x - @mtp_x )
@direction = 8
end
end
end
@paths_id = 0
end
#print @paths
end
end
#####################################
if @mtp_x == nil or @mtp_y == nil
new_mtp
end
#####################################
#####################################
if @mouse_open != nil and @mouse_open == 1
last_moving = moving?
last_direction = @direction
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
last_x = @x
last_y = @y
if @paths_id != nil and @paths != nil and @paths_id <= @paths.size
if @paths[@paths_id] == 6
@last_move_x = true
move_right
@paths_id += 1
@direction = 6
elsif @paths[@paths_id] == 4
@last_move_x = true
move_left
@paths_id += 1
@direction = 4
elsif @paths[@paths_id] == 2
@last_move_x = false
move_down
@direction = 2
@paths_id += 1
elsif @paths[@paths_id] == 8
@last_move_x = false
move_up
@direction = 8
@paths_id += 1
elsif @paths[@paths_id] == 1
@last_move_x = false
move_lower_left
@direction = 1
@paths_id += 1
elsif @paths[@paths_id] == 3
@last_move_x = false
move_lower_right
@direction = 3
@paths_id += 1
elsif @paths[@paths_id] == 7
@last_move_x = false
move_upper_left
@direction = 7
@paths_id += 1
elsif @paths[@paths_id] == 9
@last_move_x = false
move_upper_right
@direction = 9
@paths_id += 1
end
end
end
elsif @mouse_open != nil and @mouse_open == 2
if Mouse.press?(Mouse::LEFT)
last_moving = moving?
last_direction = @direction
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
last_x = @x
@mtp_x = mouse_x
@mtp_y = mouse_y
if @mtp_x > self.screen_x
if @mtp_y - self.screen_y > - 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < 0.4 * ( @mtp_x - self.screen_x )
move_right
$pop = 16
@direction = 6
end
if @mtp_y - self.screen_y > 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < 2.4 * ( @mtp_x - self.screen_x )
move_lower_right
$pop = 13
@direction = 3
end
if @mtp_y - self.screen_y < - 0.4 * ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y > - 2.4 * ( @mtp_x - self.screen_x )
move_upper_right
$pop = 19
@direction = 9
end
if @mtp_y - self.screen_y > 2.4 * ( @mtp_x - self.screen_x )
move_down
$pop = 12
@direction = 2
end
if @mtp_y - self.screen_y < - 2.4 * ( @mtp_x - self.screen_x )
move_up
$pop = 18
@direction = 8
end
end
if @mtp_x < self.screen_x
if @mtp_y - self.screen_y > - 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < 0.4 * ( self.screen_x - @mtp_x )
move_left
$pop = 14
@direction = 4
end
if @mtp_y - self.screen_y > 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < 2.4 * ( self.screen_x - @mtp_x )
move_lower_left
$pop = 11
@direction = 1
end
if @mtp_y - self.screen_y < - 0.4 * ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y > - 2.4 * ( self.screen_x - @mtp_x )
move_upper_left
$pop = 17
@direction = 7
end
if @mtp_y - self.screen_y > 2.4 * ( self.screen_x - @mtp_x )
move_down
$pop = 12
@direction = 2
end
if @mtp_y - self.screen_y < - 2.4 * ( self.screen_x - @mtp_x )
move_up
$pop = 18
@direction = 8
end
end
#if @last_move_x
# @last_move_x = false
#elsif mouse_x > screen_x + 16
# move_right
#elsif mouse_x < screen_x - 16
# move_left
#end
#last_y = @y
#if last_x != @x
## @last_move_x = true
#elsif mouse_y > screen_y
# move_down
#elsif mouse_y < screen_y - 32
# move_up
#end
#if last_y != @y
# @last_move_x = false
#elsif not @last_move_x
# case last_direction
# when 2
# turn_down
# when 4
# turn_left
## when 6
# turn_right
# when 8
# turn_up
# end
#end
end
else
$pop = 0
@mouse_open = 0
@paths_id = @paths.size
end
end
#########################################################
self_update
end
end
Mouse.init
END { Mouse.exit }
###############################################################################
复制代码
作者:
七夕£雪夜
时间:
2008-12-3 05:06
提示:
作者被禁止或删除 内容自动屏蔽
作者:
liuxi544
时间:
2008-12-11 05:56
我看是这
154行 @mouse_bitmap = Bitmap.new('Graphics/System/Mouse/mouse.png')
因为系统提示154行出现未知错误!!!
作者:
七夕£雪夜
时间:
2008-12-12 04:56
提示:
作者被禁止或删除 内容自动屏蔽
作者:
不取名字了
时间:
2008-12-22 22:42
提示:
作者被禁止或删除 内容自动屏蔽
作者:
七夕£雪夜
时间:
2008-12-23 05:36
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1