Autore: ProGM
Demo:
http://www.mediafire.com/?0t9upnoygthIstruzioni Script:
Scrivi questo codice su chiama script per salire o scendere dalla macchina:
CODICE
$car = true
Script:
CODICE
$car = false
class Game_Car < Game_Character
CENTER_X = (320 - 16) * 4 # Center screen x-coordinate * 4
CENTER_Y = (240 - 16) * 4 # Center screen y-coordinate * 4
def initialize
super
@id = 4
@directions = [nil, 1, 1, 4, 4, 7, 7, 8, 8, 9, 9, 6, 6, 3, 3, 2, 2]
@direction = 8
@move_speed = 4
end
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
unless $game_map.valid?(new_x, new_y)
return false
end
if $DEBUG and Input.press?(Input::CTRL)
return true
end
super
end
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
def moveto(x, y)
super
center(x, y)
make_encounter_count
end
def increase_steps
super
unless @move_route_forcing
$game_party.increase_steps
if $game_party.steps % 2 == 0
$game_party.check_map_slip_damage
end
end
end
def encounter_count
return @encounter_count
end
def make_encounter_count
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
def refresh
if $game_party.actors.size == 0
@character_name = ""
@character_hue = 0
return
end
actor = $game_party.actors[0]
@character_name = actor.character_name
@character_hue = actor.character_hue
@opacity = 255
@blend_type = 0
end
def check_event_trigger_here(triggers)
result = false
if $game_system.map_interpreter.running?
return result
end
for event in $game_map.events.values
if event.x == @x and event.y == @y and triggers.include?(event.trigger)
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
def check_event_trigger_there(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
if result == false
if $game_map.counter?(new_x, new_y)
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
def check_event_trigger_touch(x, y)
result = false
if $game_system.map_interpreter.running?
return result
end
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == x and event.y == y and [1,2].include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
def move_forward
case @direction
when 1
move_lower_left
when 2
move_down(false)
when 3
move_lower_right
when 4
move_left(false)
when 6
move_right(false)
when 7
move_upper_left
when 8
move_up(false)
when 9
move_upper_right
end
end
def move_backward
# Remember direction fix situation
last_direction_fix = @direction_fix
# Force directino fix
@direction_fix = true
# Branch by direction
case @direction
when 1
move_upper_right
when 2 # Down
move_up(false)
when 3
move_upper_left
when 4 # Left
move_right(false)
when 6 # Right
move_left(false)
when 7
move_lower_right
when 8 # Up
move_down(false)
when 9
move_lower_left
end
# Return direction fix situation back to normal
@direction_fix = last_direction_fix
end
def update
last_moving = moving?
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# Move player in the direction the directional button is being pressed
case Input.dir8
when 8
if @moving_type != "backward"
move_forward
@move_speed += 0.2 unless @move_speed >= 5
@moving_type = "forward"
else
if @move_speed >= 4.0
@move_speed -= 0.2
move_backward
else
@moving_type = ""
end
end
when 7
@id -= 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
move_forward
@move_speed += 0.1 unless @move_speed >= 5
@moving_type = "forward"
when 9
@id += 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
move_forward
@move_speed += 0.1 unless @move_speed >= 5
@moving_type = "forward"
when 1
@id += 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
move_backward
@move_speed += 0.1 unless @move_speed >= 5
@moving_type = "backward"
when 3
@id -= 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
move_backward
@move_speed += 0.1 unless @move_speed >= 5
@moving_type = "backward"
when 4 #sx
if @move_speed >= 4.0
@id -= 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
end
@move_speed -= 0.2 if @move_speed >= 4.0
move_forward if @move_speed >= 4.0 and @moving_type == "forward"
move_backward if @move_speed >= 4.0 and @moving_type == "backward"
when 6 #dx
if @move_speed >= 4.0
@id += 1
@id = 16 if @id == 0
@id = 1 if @id == 17
@direction = @directions[@id]
end
@move_speed -= 0.2 if @move_speed >= 4.0
move_forward if @move_speed >= 4.0 and @moving_type == "forward"
move_backward if @move_speed >= 4.0 and @moving_type == "backward"
when 2
if @moving_type != "forward"
move_backward
@move_speed += 0.1 unless @move_speed >= 5
@moving_type = "backward"
else
if @move_speed >= 4.0
@move_speed -= 0.2
move_forward
else
@moving_type = ""
end
end
else
@move_speed -= 0.2 if @move_speed >= 4.0
move_forward if @move_speed >= 4.0 and @moving_type == "forward"
move_backward if @move_speed >= 4.0 and @moving_type == "backward"
end
end
last_real_x = @real_x
last_real_y = @real_y
super
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
$game_map.scroll_left(last_real_x - @real_x)
end
if @real_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
$game_map.scroll_up(last_real_y - @real_y)
end
unless moving?
if last_moving
result = check_event_trigger_here([1,2])
if result == false
unless $DEBUG and Input.press?(Input::CTRL)
if @encounter_count > 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
end
end
class Sprite_Character < RPG::Sprite
attr_accessor :character # character
def initialize(viewport, character = nil)
super(viewport)
@character = character
update
end
def update
if $car
$car = false
x = $game_player.x
y = $game_player.y
if $game_player.is_a?(Game_Player)
$game_player= Game_Car.new
else
$game_player= Game_Player.new
end
$game_player.moveto(x, y)
$game_player.refresh
$game_map.refresh
$scene = Scene_Map.new
return
end
super
if @character.is_a?(Game_Car)
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 8
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
case @character.direction
when 1
sy = 1
when 2
sy = 8
when 3
sy = 7
when 4
sy = 2
when 6
sy = 6
when 7
sy = 3
when 8
sy = 4
when 9
sy = 5
end
sy = (sy - 1) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
else
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
Sono tanti che vedono il cielo guardando il riflesso dell' acqua.
E' pi