Sistema avançado de passos!

Fórum para a postagem de tutoriais e dúvidas de Rpg Maker 2000 e 2003.
Responder
lucas09
Membro (Recruta)
Mensagens: 33
Registrado em: Qui Nov 16, 2006 8:19 pm
Maker Preferido: Rpg Maker 2003
Localização: Fortaleza-CE

Sistema avançado de passos!

Mensagem por lucas09 » Qua Nov 22, 2006 10:28 pm

Passos por pixel
Deixe seu jogo mais realista!!!
Com este script, seu personagem dará passos de 6 pixels.
Sendo que o normal é de 32 pixel.
E não é só isso... Também poderá usar o botão "C" para alternar
os comandos de correr e caminhar.
Seu personagem andará também na diagonal, por tanto terá oito direções.

Para isso, crie um nova classe acima do main, com qualquer
nome e cole este script abaixo:

Código: Selecionar todos

class Game_Player <Game_Character> distance2
@real_x = @real_x - @revise_x
@real_y = @real_y - @revise_y
@revise_x = 0
@revise_y = 0
anime_update
else
@real_x -= (distance1 * @revise_x / distance2).round
@real_y -= (distance1 * @revise_y / distance2).round
@revise_x = @real_x - @x * 128
@revise_y = @real_y - @y * 128
anime_update
end
else
super
end
else
@move = false
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
@event_run = false
case Input.dir8
when 1
move_lower_left_p
when 2
move_down_p
when 3
move_lower_right_p
when 4
move_left_p
when 6
move_right_p
when 7
move_upper_left_p
when 8
move_up_p
when 9
move_upper_right_p
end
end
last_real_x = @real_x
last_real_y = @real_y
@real_x = @x * 128 + @revise_x
@real_y = @y * 128 + @revise_y
last_moving = moving?
move_on
if (last_real_x != @real_x or last_real_y != @real_y)
@move_distance = 0 if @move_distance == nil
@move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
(last_real_y - @real_y) ** 2)
if @move_distance >= 128
@move_distance %= 128
increase_steps
end
anime_update
elsif @walk_anime
@pattern = @original_pattern
end
end
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y - last_real_y)
end
if @real_x < last_real_x and @real_x - $game_map.display_x <CENTER_X> last_real_x and @real_x - $game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x - last_real_x)
end
if @real_y < last_real_y and @real_y - $game_map.display_y <CENTER_Y> @x
turn_left
else
turn_right
end
else
if (last_real_y / 128.0).round > @y
turn_up
else
turn_down
end
end
elsif (last_real_x / 128.0).round > @x
turn_left
elsif (last_real_x / 128.0).round <x> @y
turn_up
elsif (last_real_y / 128.0).round <y> 0
@encounter_count -= 1
end
end
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
def moving?
unless @dot_m
result = super
return result
end
if @move_route_forcing
if @move == false
return false
end
super
else
return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
end
end
def moving_a?
if @move == false
if (@move_route.list[@move_route_index].code <= 14 or
@move_route.list[@move_route_index].code == 25)
@move = true
end
return false
end
moving?
end
def update_jump
@jump_count -= 1
@real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
if @jump_count == 0
@revise_x = 0
@revise_y = 0
end
end
def move_type_custom
unless @dot_m
super
return
end
if jumping? or moving_a?
return
end
while @move_route_index < @move_route.list.size
command = @move_route.list[@move_route_index]
if command.code == 0
if @move_route.repeat
@move_route_index = 0
end
unless @move_route.repeat
if @move_route_forcing and not @move_route.repeat
@move_route_forcing = false
@move_route = @original_move_route
@move_route_index = @original_move_route_index
@original_move_route = nil
end
@stop_count = 0
end
return
end
if command.code <14>= 16 and command.code <26>= 27
case command.code
when 27
$game_switches[command.parameters[0]] = true
$game_map.need_refresh = true
when 28
$game_switches[command.parameters[0]] = false
$game_map.need_refresh = true
when 29
@move_speed = command.parameters[0]
when 30
@move_frequency = command.parameters[0]
when 31
@walk_anime = true
when 32
@walk_anime = false
when 33
@step_anime = true
when 34
@step_anime = false
when 35
@direction_fix = true
when 36
@direction_fix = false
when 37
@through = true
when 38
@through = false
when 39
@always_on_top = true
when 40
@always_on_top = false
when 41
@tile_id = 0
@character_name = command.parameters[0]
@character_hue = command.parameters[1]
if @original_direction != command.parameters[2]
@direction = command.parameters[2]
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != command.parameters[3]
@pattern = command.parameters[3]
@original_pattern = @pattern
end
when 42
@opacity = command.parameters[0]
when 43
@blend_type = command.parameters[0]
when 44
$game_system.se_play(command.parameters[0])
when 45
result = eval(command.parameters[0])
end
@move_route_index += 1
return
end
end
end
def move_down_p
turn_down
distance = 2 ** @move_speed
down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
def down1(x, y, distance, down = false)
result = down2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x, y+1)
return result
end
if @revise_x <SIDE> SIDE
@revise_x = SIDE
end
end
return result
end
elsif @revise_x > SIDE
result = down2(x, y + 1, distance, 6)
result &= down2(x + 1, y, distance)
if result == false
if down
move_lower_left_p
if @revise_x <SIDE> 0
unless passable?(x, y, d)
if @revise_y < 0
@revise_y = 0
end
return false
end
end
return true
end
def move_left_p
turn_left
distance = 2 ** @move_speed
left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
def left1(x, y, distance, left = false)
result = left2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x-1, y)
return result
end
if @revise_y <UP> 0
@revise_y = 0
end
end
return result
end
elsif @revise_y > 0
result = left2(x - 1, y, distance, 2)
result &= left2(x, y + 1, distance)
if result == false
if left
move_upper_left_p
if @revise_y < -UP
@revise_y = -UP
end
end
return result
end
end
@revise_x -= distance
return result
end
def left2(x, y, distance, d = 4)
if @revise_x - distance <SIDE> -SIDE
@revise_x = -SIDE
end
return false
end
end
return true
end
def move_right_p
# ‰E‚ðŒü‚­
turn_right
distance = 2 ** @move_speed
right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
def right1(x, y, distance, right = false)
result = right2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x+1, y)
return result
end
if @revise_y <UP> 0
@revise_y = 0
end
end
return result
end
elsif @revise_y > 0
result = right2(x + 1, y, distance, 2)
result &= right2(x, y + 1, distance)
if result == false
if right
move_upper_right_p
if @revise_y <UP> SIDE
unless passable?(x, y, d)
if @revise_x < SIDE
@revise_x = SIDE
end
return false
end
end
return true
end
def move_up_p
turn_up
distance = 2 ** @move_speed
up1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance, true)
end
def up1(x, y, distance, up = false)
result = up2(x, y, distance)
if result == false
@event_run = check_event_trigger_touch(x, y-1)
return result
end
if @revise_x <SIDE> SIDE
@revise_x = SIDE
end
end
return result
end
elsif @revise_x > SIDE
result = up2(x, y - 1, distance, 6)
result &= up2(x + 1, y, distance)
if result == false
if up
move_upper_left_p
if @revise_x < -SIDE
@revise_x = -SIDE
end
end
return result
end
end
@revise_y -= distance
return result
end
def up2(x, y, distance, d = 8)
if @revise_y - distance <UP> -UP
@revise_y = -UP
end
return false
end
end
return true
end
def move_lower_left_p
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
distance = (2 ** @move_speed) / Math.sqrt(2)
if @direction == 2
turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_down if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 2, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_y > 0 and -UP > @revise_y - distance
@revise_y = 0
end
turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_left if @event_run
end
else
turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_left if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 4, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_x + distance> SIDE and -SIDE > @revise_x
@revise_x = -SIDE
end
turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_down if @event_run
end
end
end
def move_lower_right_p
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
distance = (2 ** @move_speed) / Math.sqrt(2)
if @direction == 2
turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_down if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 2, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_y > 0 and -UP > @revise_y - distance
@revise_y = 0
end
turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_right if @event_run
end
else
turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_right if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 6, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_x > SIDE and -SIDE > @revise_x - distance
@revise_x = SIDE
end
turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_down if @event_run
end
end
end
def move_upper_left_p
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
distance = (2 ** @move_speed) / Math.sqrt(2)
if @direction == 8
turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_up if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 8, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_y + distance > 0 and -UP > @revise_y
@revise_y = -UP
end
turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_left if @event_run
end
else
turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_left if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 4, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_x > SIDE and -SIDE > @revise_x - distance
@revise_x = SIDE
end
turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_up if @event_run
end
end
end
def move_upper_right_p
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
distance = (2 ** @move_speed) / Math.sqrt(2)
if @direction == 8
turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_up if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 8, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_y + distance > 0 and -UP > @revise_y
@revise_y = -UP
end
turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_right if @event_run
end
else
turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_right if @event_run
unless @event_run
if last_move?(@real_x, @real_y, 6, distance)
result = check_event_trigger_here([1,2], false)
if result == true
return
end
end
move_on
if @revise_x > SIDE and -SIDE > @revise_x - distance
@revise_x = SIDE
end
turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
((@y * 128 + @revise_y) / 128.0).round, distance)
turn_up if @event_run
end
end
end
def check_event_trigger_here(triggers, run = true)
result = false
if $game_system.map_interpreter.running?
return result
end
for event in $game_map.events.values
if event.x == ((@x * 128 + @revise_x) / 128.0).round and
event.y == ((@y * 128 + @revise_y) / 128.0).round and
triggers.include?(event.trigger)
if not event.jumping? and event.over_trigger?
if event.list.size > 1
if run == true
event.start
end
result = true
end
end
end
end
return result
end
def move_on
if @y <y> (@x + @revise_x / 128.0).round
@x -= 1
@revise_x += 128
end
if @x <x> (@y + @revise_y / 128.0).round
@y -= 1
@revise_y += 128
end
end
def anime_update
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
if @anime_count > 18 - @move_speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % 4
end
@anime_count = 0
end
end
alias :moveto_original :moveto
def moveto(x, y)
@revise_x = 0
@revise_y = 0
moveto_original(x, y)
end
def last_move?(x, y, direction, distance)
if direction == 2 or direction == 6
distance *= -1
end
if (direction == 2 or direction == 8) and
(y / 128.0).round != ((y - distance) / 128.0).round
return true
end
if (direction == 4 or direction == 6) and
(x / 128.0).round != ((x - distance) / 128.0).round
return true
end
return false
end
end
class Game_Character
def screen_x
return ((@real_x - $game_map.display_x) / 4).ceil + 16
end
def screen_y
y = ((@real_y - $game_map.display_y) / 4).ceil + 32
if @jump_count >= @jump_peak
n = @jump_count - @jump_peak
else
n = @jump_peak - @jump_count
end
return y - (@jump_peak * @jump_peak - n * n) / 2
end
def update_move
distance = 2 ** @move_speed
if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
distance /= Math.sqrt(2)
end
if @y * 128 > @real_y
@real_y = [@real_y + distance, @y * 128].min
end
if @x * 128 <real_x> @real_x
@real_x = [@real_x + distance, @x * 128].min
end
if @y * 128 < @real_y
@real_y = [@real_y - distance, @y * 128].max
end
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
end
end
class Game_Event <Game_Character> 1
if $game_player.event != 0
$game_player.move_speed = $game_player.event
elsif self.trigger == 0
$game_player.move_speed = $game_player.walk
end
@starting = true
end
end
end

Avatar do usuário
Killer Ghost
Administrador
Mensagens: 10338
Registrado em: Sáb Nov 19, 2005 8:49 pm
Maker Preferido: Outro
Localização: Saint Paul
Contato:

Mensagem por Killer Ghost » Qua Nov 22, 2006 10:41 pm

Lembrando, que se a pessoa tem um micro lento isso só vai atrapalhar. :(
A Casa do Maker está de volta. :happy:

Projetos:
Rpg Maker VX Ace:
Student Adventures ACE 21%

Rpg Maker MV:
As Crônicas do Fim do Mundo 44%
Casa do Maker - O Retorno 1%

Solid Snake
Super Membro
Mensagens: 389
Registrado em: Sáb Nov 26, 2005 10:10 pm
Maker Preferido: Rpg Maker 2003
Localização: Curitiba-PR
Contato:

Mensagem por Solid Snake » Qua Nov 22, 2006 11:25 pm

Cara esse script é bom,mais o calcanhar de aquiles dele é mesmo o que o Killer flo ele é meio pesado pra pc's mais lentox...Mais no mais ele é otimo.

E continue esse seu trabalho aqui no forum heim nota 10...
Todos os Dias após a meia-noite no canal IRC visitem: #casadomaker

Imagem

helivelton
Membro (Marechal)
Mensagens: 1350
Registrado em: Qua Fev 28, 2007 4:04 pm
Maker Preferido: Rpg Maker 2003

Mensagem por helivelton » Qua Mar 21, 2007 2:06 pm

Esse é um bom script mas....
Mas dava pra fazer o mesmo num script menor.
Mas esse é um bom script vlw.

Responder