Galera eu fuçando pelos forums makers como sempre faço encontrei um script bem legal, mas onde eu achei não falava que fez, dizia creditos desconhecidos. vamos lá vo ensinar a usar primero.
- Este script permitirá que você crie um 2 Player que você pode controlar,
interagir com outros eventos no mapa, igualmente como o Player Principal.
- O jogador pode interagir com acontecimentos no mapa.
- o 2º Jogador pode andar em 8 direções e correr (Shift).
1ºChame o Script atraves de um evento
ficara +o- assim.
- Este script permitirá que você crie um 2 Player que você pode controlar,
interagir com outros eventos no mapa, igualmente como o Player Principal.
- O jogador pode interagir com acontecimentos no mapa.
- o 2º Jogador pode andar em 8 direções e correr (Shift).
1ºChame o Script atraves de um evento
- Código:
$game_player2 = Game_Player2.new
$game_player2.create(x,y,id actor,false)
ficara +o- assim.
- Código:
$game_player2 = Game_Player2.new
$game_player2.create(9,7,2,false)
- Código:
$game_player2.delete
- Código:
=begin
+[FEATURES]+
- Este script permitirá que você crie um 2 Player que você pode controlar,
interagir com outros eventos no mapa, igualmente como o Player Principal.
- O jogador pode interagir com acontecimentos no mapa.
- o 2º Jogador pode andar em 8 direções e correr (Shift).
+[Como Usar]+
Para Chamar o 2º Player, chame o Script:
$game_player2 = Game_Player2.new
$game_player2.create(x, y, actor id, follow?)
x e y = X e Y para saber onde o player vai aparecer (coordenadas)
actor id = Id do Heroi que você vai chamar (exemplo: "4" chamara a Sara)
(ID no Database)
follow? = true (Segir o player principal), false (não seguir o player)
*NÃO É RECOMENDADO COLOCAR TRUE*
Para deletar Player 2, use Chamar script:
$game_player2.delete
=end
#==============================================================================
class Game_Player2 < Game_Character
BAIXO = Input::Y # S in Keyboard
ESQUERDA = Input::X # A in Keyboard
DIREITA = Input::Z # D in Keyboard
CIMA = Input::R # W in Keyboard
ENTER = Input::L # Q in Keyboard
CORRER = Input::A # Shift in Keyboard
CENTER_X = (544 / 2 - 16) * 8
CENTER_Y = (416 / 2 - 16) * 8
attr_reader :vehicle_type
attr_accessor :character_name
def create(x,y,id,need_center = false)
@actor_id = id
moveto(x,y)
@need_center = need_center
refresh
end
def delete
@actor_id = nil
refresh
$game_player2 = nil
end
def initialize
super
@vehicle_type = -1
@vehicle_getting_on = false
@vehicle_getting_off = false
@transferring = false
@new_map_id = 0
@new_x = 0
@new_y = 0
@new_direction = 0
@walking_bgm = nil
end
def stopping?
return false if @vehicle_getting_on
return false if @vehicle_getting_off
return super
end
def reserve_transfer(map_id, x, y, direction)
@transferring = true
@new_map_id = map_id
@new_x = x
@new_y = y
@new_direction = direction
end
def transfer?
return @transferring
end
def perform_transfer
return unless @transferring
@transferring = false
set_direction(@new_direction)
if $game_map.map_id != @new_map_id
$game_map.setup(@new_map_id)
end
moveto(@new_x, @new_y)
end
def map_passable?(x, y)
case @vehicle_type
when 0
return $game_map.boat_passable?(x, y)
when 1
return $game_map.ship_passable?(x, y)
when 2
return true
else
return $game_map.passable?(x, y)
end
end
def can_walk?(x, y)
last_vehicle_type = @vehicle_type
@vehicle_type = -1
result = passable?(x, y)
@vehicle_type = last_vehicle_type
return result
end
def airship_land_ok?(x, y)
unless $game_map.airship_land_ok?(x, y)
return false
end
unless $game_map.events_xy(x, y).empty?
return false
end
return true
end
def in_vehicle?
return @vehicle_type >= 0
end
def in_airship?
return @vehicle_type == 2
end
def dash?
return false if @move_route_forcing
return false if $game_map.disable_dash?
return false if in_vehicle?
return Input.press?(CORRER)
end
def debug_through?
return false unless $TEST
return Input.press?(Input::CTRL)
end
def center(x, y)
display_x = x * 256 - CENTER_X
unless $game_map.loop_horizontal?
max_x = ($game_map.lammer - 17) * 256
display_x = [0, [display_x, max_x].min].max
end
display_y = y * 256 - CENTER_Y
unless $game_map.loop_vertical?
max_y = ($game_map.height - 13) * 256
display_y = [0, [display_y, max_y].min].max
end
$game_map.set_display_pos(display_x, display_y)
end
def moveto(x, y)
super
make_encounter_count
if in_vehicle?
vehicle = $game_map.vehicles[@vehicle_type]
vehicle.refresh
end
end
def increase_steps
super
return if @move_route_forcing
return if in_vehicle?
$game_party.increase_steps
$game_party.on_player_walk
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 in_area?(area)
return false if area == nil
return false if $game_map.map_id != area.map_id
return false if @x < area.rect.x
return false if @y < area.rect.y
return false if @x >= area.rect.x + area.rect.lammer
return false if @y >= area.rect.y + area.rect.height
return true
end
def make_encounter_troop_id
encounter_list = $game_map.encounter_list.clone
for area in $data_areas.values
encounter_list += area.encounter_list if in_area?(area)
end
if encounter_list.empty?
make_encounter_count
return 0
end
return encounter_list[rand(encounter_list.size)]
end
def refresh
if @actor_id != nil and $game_actors[@actor_id] != nil
actor = $game_actors[@actor_id] # Get front actor
@character_name = actor.character_name
@character_index = actor.character_index
else
@character_name = ""
end
end
def check_event_trigger_here(triggers)
return false if $game_map.interpreter.running?
result = false
for event in $game_map.events_xy(@x, @y)
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
result = true if event.starting
end
end
return result
end
def check_event_trigger_there(triggers)
return false if $game_map.interpreter.running?
result = false
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
if result == false and $game_map.counter?(front_x, front_y)
front_x = $game_map.x_with_direction(front_x, @direction)
front_y = $game_map.y_with_direction(front_y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
end
return result
end
def check_event_trigger_touch(x, y)
return false if $game_map.interpreter.running?
result = false
for event in $game_map.events_xy(x, y)
if [1,2].include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
return result
end
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
if Input.press?(BAIXO)
move_down
end
if Input.press?(ESQUERDA)
move_left
end
if Input.press?(DIREITA)
move_right
end
if Input.press?(CIMA)
move_up
end
end
def movable?
return false if moving?
return false if @move_route_forcing
return false if @vehicle_getting_on
return false if @vehicle_getting_off
return false if $game_message.visible
return false if in_airship? and not $game_map.airship.movable?
return true
end
def update
last_real_x = @real_x
last_real_y = @real_y
last_moving = moving?
move_by_input
super
update_scroll(last_real_x, last_real_y) if @need_center
update_vehicle
update_nonmoving(last_moving)
end
def update_scroll(last_real_x, last_real_y)
ax1 = $game_map.adjust_x(last_real_x)
ay1 = $game_map.adjust_y(last_real_y)
ax2 = $game_map.adjust_x(@real_x)
ay2 = $game_map.adjust_y(@real_y)
if ay2 > ay1 and ay2 > CENTER_Y
$game_map.scroll_down(ay2 - ay1)
end
if ax2 < ax1 and ax2 < CENTER_X
$game_map.scroll_left(ax1 - ax2)
end
if ax2 > ax1 and ax2 > CENTER_X
$game_map.scroll_right(ax2 - ax1)
end
if ay2 < ay1 and ay2 < CENTER_Y
$game_map.scroll_up(ay1 - ay2)
end
end
def update_vehicle
return unless in_vehicle?
vehicle = $game_map.vehicles[@vehicle_type]
if @vehicle_getting_on
if not moving?
@direction = vehicle.direction
@move_speed = vehicle.speed
@vehicle_getting_on = false
@transparent = true
end
elsif @vehicle_getting_off
if not moving? and vehicle.altitude == 0
@vehicle_getting_off = false
@vehicle_type = -1
@transparent = false
end
else
vehicle.sync_with_player
end
end
def update_nonmoving(last_moving)
return if $game_map.interpreter.running?
return if moving?
return if check_touch_event if last_moving
if not $game_message.visible and Input.trigger?(ENTER)
return if get_on_off_vehicle
return if check_action_event
end
update_encounter if last_moving
end
#--------------------------------------------------------------------------
# * Update Encounter
#--------------------------------------------------------------------------
def update_encounter
return if $TEST and Input.press?(Input::CTRL) # During test play?
return if in_vehicle? # Riding in vehicle?
if $game_map.bush?(@x, @y) # If in bush
@encounter_count -= 2 # Reduce encounters by 2
else # If not in bush
@encounter_count -= 1 # Reduce encounters by 1
end
end
#--------------------------------------------------------------------------
# * Determine Event Start Caused by Touch (overlap)
#--------------------------------------------------------------------------
def check_touch_event
return false if in_airship?
return check_event_trigger_here([1,2])
end
#--------------------------------------------------------------------------
# * Determine Event Start Caused by [OK] Button
#--------------------------------------------------------------------------
def check_action_event
return false if in_airship?
return true if check_event_trigger_here([0])
return check_event_trigger_there([0,1,2])
end
#--------------------------------------------------------------------------
# * Getting On and Off Vehicles
#--------------------------------------------------------------------------
def get_on_off_vehicle
return false unless movable?
if in_vehicle?
return get_off_vehicle
else
return get_on_vehicle
end
end
#--------------------------------------------------------------------------
# * Board Vehicle
# Assumes that the player is not currently in a vehicle.
#--------------------------------------------------------------------------
def get_on_vehicle
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
if $game_map.airship.pos?(@x, @y) # Is it overlapping with airship?
get_on_airship
return true
elsif $game_map.ship.pos?(front_x, front_y) # Is there a ship in front?
get_on_ship
return true
elsif $game_map.boat.pos?(front_x, front_y) # Is there a boat in front?
get_on_boat
return true
end
return false
end
#--------------------------------------------------------------------------
# * Board Boat
#--------------------------------------------------------------------------
def get_on_boat
@vehicle_getting_on = true # Boarding flag
@vehicle_type = 0 # Set vehicle type
force_move_forward # Move one step forward
@walking_bgm = RPG::BGM::last # Memorize walking BGM
$game_map.boat.get_on # Boarding processing
end
#--------------------------------------------------------------------------
# * Board Ship
#--------------------------------------------------------------------------
def get_on_ship
@vehicle_getting_on = true # Board
@vehicle_type = 1 # Set vehicle type
force_move_forward # Move one step forward
@walking_bgm = RPG::BGM::last # Memorize walking BGM
$game_map.ship.get_on # Boarding processing
end
#--------------------------------------------------------------------------
# * Board Airship
#--------------------------------------------------------------------------
def get_on_airship
@vehicle_getting_on = true # Start boarding operation
@vehicle_type = 2 # Set vehicle type
@through = true # Passage ON
@walking_bgm = RPG::BGM::last # Memorize walking BGM
$game_map.airship.get_on # Boarding processing
end
#--------------------------------------------------------------------------
# * Get Off Vehicle
# Assumes that the player is currently riding in a vehicle.
#--------------------------------------------------------------------------
def get_off_vehicle
if in_airship? # Airship
return unless airship_land_ok?(@x, @y) # Can't land?
else # Boat/ship
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
return unless can_walk?(front_x, front_y) # Can't touch land?
end
$game_map.vehicles[@vehicle_type].get_off # Get off processing
if in_airship? # Airship
@direction = 2 # Face down
else # Boat/ship
force_move_forward # Move one step forward
@transparent = false # Remove transparency
end
@vehicle_getting_off = true # Start getting off operation
@move_speed = 4 # Return move speed
@through = false # Passage OFF
@walking_bgm.play # Restore walking BGM
make_encounter_count # Initialize encounter
end
#--------------------------------------------------------------------------
# * Force One Step Forward
#--------------------------------------------------------------------------
def force_move_forward
@through = true # Passage ON
move_forward # Move one step forward
@through = false # Passage OFF
end
end
class Scene_Title < Scene_Base
alias wor_twopla_scetit_cregam create_game_objects
def create_game_objects
wor_twopla_scetit_cregam
$game_player2 = nil
end
end
class Scene_Map < Scene_Base
alias wor_twopla_scemap_upd update
def update
wor_twopla_scemap_upd
$game_player2.update if $game_player2 != nil
end
end
class Spriteset_Map
alias wor_twopla_sprmap_crecha create_characters
alias wor_twopla_sprmap_updcha update_characters
def create_characters
wor_twopla_sprmap_crecha
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
@chara_two_pushed = false
end
def update_characters
if !(@chara_two_pushed) and $game_player2 != nil
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player2))
@chara_two_pushed = true
elsif @chara_two_pushed and $game_player2 == nil
for i in 0..@character_sprites.size
if @character_sprites[i].character.is_a?(Game_Player2)
@character_sprites[i].character.character_name = ""
@character_sprites[i].update
@character_sprites.delete_at(i)
break
end
end
@chara_two_pushed = false
end
wor_twopla_sprmap_updcha
end
end
class Game_Map
alias wor_twopla_gammap_passable passable?
def passable?(x, y, flag = 0x01)
if $game_player2 != nil and flag
return false if $game_player2.x == x and $game_player2.y == y
end
wor_twopla_gammap_passable(x, y, flag)
end
end