Hello,
ThatÂÂÂ ´s my first Topic of a Script...:D
!!!! JUST THE GAME_PLAYER EDIT IS MADE BY ME, THE REST IS FROM PEOPLE OF MY GUILD !!!!
So... Someone has asked for this. Here is it. A Diablo like Movement ( without Pathfinding ). The Only thing you must do, are these 6 Steps. so..go go go...
STEP I
create a new Script above Main and paste this into it:
STEP II
create a new Script BELOW the one above and paste this into it:
STEP III
make a new Script BELOW the Second and paste this into it:
STEP IV
to make the Mouse moving. go to Main and paste this below
line 14 -- Graphics.freeze
Go to Scene_Title and paste the following under
$game_player = Game_Player.new
Now go to Scene_Map and search for this Lines:
under the second End, paste this:
in def update after "loop do" paste this:
STEP V
To make the Player move, youÂÂÂ ´ll need a Common Event, or a Script that sets the variables 3 to heroÂÂÂ ´s Tile_X and the Variable 4 to heroÂÂÂ ´s Tile_Y.
STEP VI
now the last part. YouÂÂÂ ´ve made all the edits and the Common Event. Now we can make the Move-Code.
Go to Game_Player and serach for this lines:
Replace them all ( with the TWO Ends ) with that:
STEP VII
IMPORT THE TWO PICTURES FROM THE ATTACHMENT TO YOUR PICTURES FOLDER....
YOU`VE DONE. NOW TEST YOUR MOVEMENT. YOU CAN MOVE WHILE PRESSING THE LEFT MOUSEBUTTON.
Ps.: 8-Directions.
###########################################################################################
Credits to:
--==Sir Lord Biowulve==--
Geo
Light Dark Side
###########################################################################################
end---------
ThatÂÂÂ ´s my first Topic of a Script...:D
!!!! JUST THE GAME_PLAYER EDIT IS MADE BY ME, THE REST IS FROM PEOPLE OF MY GUILD !!!!
So... Someone has asked for this. Here is it. A Diablo like Movement ( without Pathfinding ). The Only thing you must do, are these 6 Steps. so..go go go...
STEP I
create a new Script above Main and paste this into it:
MOUSE MODULE
Spoiler
module Input
VK_LBUTTON = 1
VK_RBUTTON = 2
VK_MBUTTON = 4
SM_SWAPBUTTON = 23
$mousez = Win32API.new 'user32', 'ShowCursor', 'l',''
gsm = Win32API.new 'user32', 'GetSystemMetrics', 'i', 'i'
@@swapped = gsm.call(SM_SWAPBUTTON) != 0
@@key_state = Win32API.new 'user32', 'GetAsyncKeyState',
'i', 'i'
@@cursor_pos = Win32API.new 'user32', 'GetCursorPos',
'p', 'i'
module_function
def mouse_global_pos
pos = [0, 0].pack('ll')
if @@cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def mouse_pos(catch_anywhere = false)
x, y = screen_to_client(*mouse_global_pos)
width, height = client_size
if catch_anywhere or (x >= 0 and y >= 0 and x < width and y < height)
if($game_map.display_x == 0 or $game_map.display_x == ($game_map.width-20)*128)
$game_variables[1] = x / 32 +$game_map.display_x / 128
else
$game_variables[1] = (x+16) / 32 +$game_map.display_x / 128
end
$game_variables[2] = y / 32 + $game_map.display_y / 128
x = x-16
y = y-16
end
return x, y
else
return nil
end
end
def mouse_lbutton(ignore_swap = false)
if @@swapped and !ignore_swap
button = @@key_state.call(VK_RBUTTON)
else
button = @@key_state.call(VK_LBUTTON)
end
return(button == -32767 or button == 32768)
end
def mouse_rbutton(ignore_swap = false)
if @@swapped and !ignore_swap
button = @@key_state.call(VK_LBUTTON)
else
button = @@key_state.call(VK_RBUTTON)
end
return(button == -32767 or button == 32768)
end
def mouse_mbuton
button = @@key_state.call(VK_MBUTTON)
return(button == -32767 or button == 32768)
end
$scr2cli = Win32API.new 'user32', 'ScreenToClient', %w(l p), 'i'
$client_rect = Win32API.new 'user32', 'GetClientRect', %w(l p), 'i'
$readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA',
%w(p p p p l p), 'l'
$findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if $scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def hwnd
game_name = "\0" * 256
$readini.call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return $findwindow.call('RGSS Player',game_name)
end
def client_size
rect = [0, 0, 0, 0].pack('l4')
$client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
VK_LBUTTON = 1
VK_RBUTTON = 2
VK_MBUTTON = 4
SM_SWAPBUTTON = 23
$mousez = Win32API.new 'user32', 'ShowCursor', 'l',''
gsm = Win32API.new 'user32', 'GetSystemMetrics', 'i', 'i'
@@swapped = gsm.call(SM_SWAPBUTTON) != 0
@@key_state = Win32API.new 'user32', 'GetAsyncKeyState',
'i', 'i'
@@cursor_pos = Win32API.new 'user32', 'GetCursorPos',
'p', 'i'
module_function
def mouse_global_pos
pos = [0, 0].pack('ll')
if @@cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def mouse_pos(catch_anywhere = false)
x, y = screen_to_client(*mouse_global_pos)
width, height = client_size
if catch_anywhere or (x >= 0 and y >= 0 and x < width and y < height)
if($game_map.display_x == 0 or $game_map.display_x == ($game_map.width-20)*128)
$game_variables[1] = x / 32 +$game_map.display_x / 128
else
$game_variables[1] = (x+16) / 32 +$game_map.display_x / 128
end
$game_variables[2] = y / 32 + $game_map.display_y / 128
x = x-16
y = y-16
end
return x, y
else
return nil
end
end
def mouse_lbutton(ignore_swap = false)
if @@swapped and !ignore_swap
button = @@key_state.call(VK_RBUTTON)
else
button = @@key_state.call(VK_LBUTTON)
end
return(button == -32767 or button == 32768)
end
def mouse_rbutton(ignore_swap = false)
if @@swapped and !ignore_swap
button = @@key_state.call(VK_LBUTTON)
else
button = @@key_state.call(VK_RBUTTON)
end
return(button == -32767 or button == 32768)
end
def mouse_mbuton
button = @@key_state.call(VK_MBUTTON)
return(button == -32767 or button == 32768)
end
$scr2cli = Win32API.new 'user32', 'ScreenToClient', %w(l p), 'i'
$client_rect = Win32API.new 'user32', 'GetClientRect', %w(l p), 'i'
$readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA',
%w(p p p p l p), 'l'
$findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if $scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def hwnd
game_name = "\0" * 256
$readini.call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return $findwindow.call('RGSS Player',game_name)
end
def client_size
rect = [0, 0, 0, 0].pack('l4')
$client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
STEP II
create a new Script BELOW the one above and paste this into it:
MOUSE CURSOR
Spoiler
class Maus_Anzeigen
def initialize
$mausz = 0
x, y = Input.mouse_pos
if x and y
$temp = Maus_Auswahl.new(x,y)
end
end
def update
x, y = Input.mouse_pos
if x and y
if $temp
$temp.dispose
$temp = Maus_Auswahl.new(x,y)
else
$temp = Maus_Auswahl.new(x,y)
end
end
end
end
class Maus_Auswahl < Sprite
def initialize(px, py)
super()
@x = px
@y = py
$mausz += 1
if $mausz < 10
if $key.getkey >= 2
#RIGHT CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz2.png")
$game_switches[1] = false
$game_switches[2] = true
$mausz = 1
else
if $key.getkey >= 1
#LEFT CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz2.png")
$game_switches[1] = true
$game_switches[2] = false
$mausz = 1
else
#NO CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz.png")
$game_switches[1] = false
$game_switches[2] = false
$mausz = 1
end
end
end
self.x = @x
self.y = @y
self.z = 65535
self.opacity = 255
self.visible = true
end
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
end
def initialize
$mausz = 0
x, y = Input.mouse_pos
if x and y
$temp = Maus_Auswahl.new(x,y)
end
end
def update
x, y = Input.mouse_pos
if x and y
if $temp
$temp.dispose
$temp = Maus_Auswahl.new(x,y)
else
$temp = Maus_Auswahl.new(x,y)
end
end
end
end
class Maus_Auswahl < Sprite
def initialize(px, py)
super()
@x = px
@y = py
$mausz += 1
if $mausz < 10
if $key.getkey >= 2
#RIGHT CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz2.png")
$game_switches[1] = false
$game_switches[2] = true
$mausz = 1
else
if $key.getkey >= 1
#LEFT CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz2.png")
$game_switches[1] = true
$game_switches[2] = false
$mausz = 1
else
#NO CLICK
self.bitmap = RPG::Cache.picture("ZielKreuz.png")
$game_switches[1] = false
$game_switches[2] = false
$mausz = 1
end
end
end
self.x = @x
self.y = @y
self.z = 65535
self.opacity = 255
self.visible = true
end
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
end
STEP III
make a new Script BELOW the Second and paste this into it:
KEY_SCRIPT
Spoiler
class Key_Abfrage
def initialize
@GetAsyncKeyState = Win32API.new 'user32', 'GetAsyncKeyState', 'l', 'l'
@keybd_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
end
def getkey
for i in 0..2
if @GetAsyncKeyState.call(i) != 0
return i
end
end
return 0
end
def getkey_id(id)
if @GetAsyncKeyState.call(id) != 0
return 1
end
return 0
end
def getkey_var(var)
for i in 0..255
if @GetAsyncKeyState.call(i) != 0
$game_variables[var] = i
end
end
end
def getkey_var_id(var,id)
if @GetAsyncKeyState.call(id) != 0
$game_variables[var] = 1
else
$game_variables[var] = 0
end
end
def setkey_id_down(id)
@keybd_event.call(id,0,0,0)
end
def setkey_var_down(var)
@keybd_event.call($game_variables[var],0,0,0)
end
def setkey_id_up(id)
@keybd_event.call(id,0,2,0)
end
def setkey_var_up(var)
@keybd_event.call($game_variables[var],0,2,0)
end
end
def initialize
@GetAsyncKeyState = Win32API.new 'user32', 'GetAsyncKeyState', 'l', 'l'
@keybd_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
end
def getkey
for i in 0..2
if @GetAsyncKeyState.call(i) != 0
return i
end
end
return 0
end
def getkey_id(id)
if @GetAsyncKeyState.call(id) != 0
return 1
end
return 0
end
def getkey_var(var)
for i in 0..255
if @GetAsyncKeyState.call(i) != 0
$game_variables[var] = i
end
end
end
def getkey_var_id(var,id)
if @GetAsyncKeyState.call(id) != 0
$game_variables[var] = 1
else
$game_variables[var] = 0
end
end
def setkey_id_down(id)
@keybd_event.call(id,0,0,0)
end
def setkey_var_down(var)
@keybd_event.call($game_variables[var],0,0,0)
end
def setkey_id_up(id)
@keybd_event.call(id,0,2,0)
end
def setkey_var_up(var)
@keybd_event.call($game_variables[var],0,2,0)
end
end
STEP IV
to make the Mouse moving. go to Main and paste this below
line 14 -- Graphics.freeze
Quote:
$key = Key_Abfrage.new
Go to Scene_Title and paste the following under
$game_player = Game_Player.new
Quote:
$maus = Maus_Anzeigen.new
Now go to Scene_Map and search for this Lines:
Quote:
if $scene != self
break
end
end
break
end
end
under the second End, paste this:
Quote:
$maus.update
in def update after "loop do" paste this:
Quote:
$maus.update
STEP V
To make the Player move, youÂÂÂ ´ll need a Common Event, or a Script that sets the variables 3 to heroÂÂÂ ´s Tile_X and the Variable 4 to heroÂÂÂ ´s Tile_Y.
STEP VI
now the last part. YouÂÂÂ ´ve made all the edits and the Common Event. Now we can make the Move-Code.
Go to Game_Player and serach for this lines:
Quote:
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
Replace them all ( with the TWO Ends ) with that:
Quote:
if $game_switches[1] == true
if $game_variables[1] > $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
move_right
else
if $game_variables[2] == $game_variables[4]
move_right
else
move_up
move_right
end
end
else
if $game_variables[1] < $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
move_left
else
if $game_variables[2] == $game_variables[4]
move_left
else
move_up
move_left
end
end
else
if $game_variables[1] == $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
else
if $game_variables[2] < $game_variables[4]
move_up
else
#nix
end
end
else
#nix
end
end
end
else
#nix
end
end
if $game_variables[1] > $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
move_right
else
if $game_variables[2] == $game_variables[4]
move_right
else
move_up
move_right
end
end
else
if $game_variables[1] < $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
move_left
else
if $game_variables[2] == $game_variables[4]
move_left
else
move_up
move_left
end
end
else
if $game_variables[1] == $game_variables[3]
if $game_variables[2] > $game_variables[4]
move_down
else
if $game_variables[2] < $game_variables[4]
move_up
else
#nix
end
end
else
#nix
end
end
end
else
#nix
end
end
STEP VII
IMPORT THE TWO PICTURES FROM THE ATTACHMENT TO YOUR PICTURES FOLDER....
YOU`VE DONE. NOW TEST YOUR MOVEMENT. YOU CAN MOVE WHILE PRESSING THE LEFT MOUSEBUTTON.
Ps.: 8-Directions.
###########################################################################################
Credits to:
--==Sir Lord Biowulve==--
Geo
Light Dark Side
###########################################################################################
end---------