请问如何设置八方面移动?
请问如何设置八方面移动?如果是脚本怎么插入? houyuxiaoyang 发表于 2013-2-12 22:06 static/image/common/back.gif
需要脚本……我只知道这么多
你可以去6R搜索
作为版主,你应该严谨一点。
这跟答案无关啊!分割分割 问题补充:
脚本插入到main前,按insert或者右键插入插入~~ houyuxiaoyang 发表于 2013-2-12 22:12 static/image/common/back.gif
问题补充:
脚本插入到main前,按insert或者右键插入插入~~
不得不吐槽现在还没人回答 #===============================================================================
#
# Yanfly Engine Melody - Extended Movement
# Last Date Updated: 2010.02.05
# Level: Easy, Normal, Hard
#
# This script adds for easy 8 directional movement and character sheet support.
# Although the character sheets need to be specially made, once done, they're
# extremely flexibile and offer a plethora of options. 8 directional movement
# allows the player to save a lot of time traveling basically anywhere quicker.
# There's also the ability to adjust the innate default dashing speed.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.02.05 - Compatibility with Battle Engine Melody.
# o 2010.01.05 - Added Reverse Poses.
# o 2010.01.10 - Idling pose options added.
# o 2010.01.08 - Started Script and Finished.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Setting up 8 Directional Sprite Sheets
# -----------------------------------------------------------------------------
# 1. Create a typical 4 column by 2 row sprite sheet. The columns are as follow
#
# Down Down Left Down Dash Down Left Dash
# Left Upper Left Left Dash Upper Left Dash
# Right Down Right Right Dash Down Right Dash
# Up Upper Right Up Dash Up Right Dash
#
# Ready/Idle Victory Pose 2H Swing
# Damage Evade/Dodge 1H Swing
# Dazed/CriticalDead 1-3 Cast/Use Item
# Marching Downed/Fallen Channeling
#
# 2. For the file name, place _8D after it.
# example: Actor_01.png would look like Actor_01_8D.png
#
# 3. And just use them as your actor's graphic. It's as easy as that. You can
# download some of the pre-made actor sheets on Pockethouse as reference.
#
# -----------------------------------------------------------------------------
# Equip Tags - Insert the following tags into Weapon and Armour noteboxes.
# -----------------------------------------------------------------------------
# <dash speed: +x%>or<dash speed: -x%>
# Equipping the said piece of weapon/armour will increase or decrease the
# player's onscreen dash speed by n%. This effect is cumulative across all
# of the party members with the item equipped.
#
# -----------------------------------------------------------------------------
# Movement Route Event Editor Call Scripts
# -----------------------------------------------------------------------------
# @mirror = true or @mirror = false
# This will mirror the image of the used character set. They will still face
# the same direction but use the other side's character sheet instead.
#
# @pose = "value"
# This will cause your to do a unique pose so long as they have an _8D sheet.
# Replace value with any of the cases below:
#
# Normal Ready Damage Critical
# March Victory Evade Fallen
# Dead1 Dead2 Dead3 2H Swing
# 1H Swing Cast Channel
# 1H Swing Reverse2H Swing Reverse
#
# break_pose
# This breaks the character out of a pose and back to regular standing format.
# Important for those long pose sequences. If the player regains movement, the
# player will also break out of a pose when the next movement input is done.
#
#===============================================================================
# Compatibility
# -----------------------------------------------------------------------------
# - Works With: Anything that doesn't affect movement systems.
#===============================================================================
$imported = {} if $imported == nil
$imported["ExtendedMovement"] = true
module YEM
module MOVEMENT
# The following constant allows for 8 directional movement. Set it to
# false if you don't wish for it to occur.
ENABLE_8D_MOVEMENT = true
# If the above is enabled, tap directioning is also available. For those
# wondering what tap directioning is, the player can just tap a direction
# and the player character will face that direction rather than straight
# out walking that direction. The following adjusts how many frames the
# game will allow leeway for tap facing.
TAP_COUNTER = 6
# The next two constants allow you to set idle poses after your player
# doesn't touch any directional keys for however many frames. Remember,
# there are 60 frames in a second. If you don't want a pose to trigger,
# just leave the array empty and nothing will happen. Otherwise, fill
# the array with any poses you would like the character do. Poses will
# be randomly selected from the array.
IDLE_POSE = ["Ready", "March", "Victory"]
IDLE_FRAMES = 360
# The following determines the dash speed given to your player. The speed
# value is a percentage out of 100. With 150, the player dashes +50% faster.
# With 200, the player dashes twice as fast. You know the drill.
DASH_SPEED_VARIABLE = 26
DEFAULT_DASH_SPEED= 150
end # MOVEMENT
end # YEM
#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================
module YEM
module REGEXP
module BASEITEM
DASH_SPEED = /^<(?:DASH_SPEED|dash speed):[ ]*([\+\-]\d+)([%%])>/i
end
end
end
module YEM::MOVEMENT
SUFFIX = "8D"
end # YEM::MOVEMENT
#===============================================================================
# RPG::BaseItem
#===============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# new method: dash_speed_bonus
#--------------------------------------------------------------------------
def dash_speed_bonus
return @dash_speed_bonus if @dash_speed_bonus != nil
@dash_speed_bonus = 0
self.note.split(/[\r\n]+/).each { |line|
case line
when YEM::REGEXP::BASEITEM::DASH_SPEED
@dash_speed_bonus = $1.to_i
end
} # end self.note.split
return @dash_speed_bonus
end
end # RPG::BaseItem
#===============================================================================
# Game_Character
#===============================================================================
class Game_Character
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :mirror
attr_accessor :pose
attr_accessor :pattern
attr_accessor :pre_pose
attr_accessor :walk_anime
attr_accessor :step_anime
attr_accessor :move_frequency
attr_accessor :anti_straighten
attr_accessor :dash_speed
#--------------------------------------------------------------------------
# new method: break_pose
#--------------------------------------------------------------------------
def break_pose
return unless @pose != nil and @pose != ""
@pattern = 1
@pose = nil
@anti_straighten = false
@walk_anime = true
@step_anime = false
set_direction(@pre_pose) if @pre_pose != nil
@pre_pose = nil
end
#--------------------------------------------------------------------------
# alias method: update_stop
#--------------------------------------------------------------------------
alias update_stop_em update_stop unless $@
def update_stop
return if @anti_straighten
update_stop_em
end
#--------------------------------------------------------------------------
# alias method: move_lower_left
#--------------------------------------------------------------------------
alias move_lower_left_em move_lower_left
def move_lower_left
move_lower_left_em
@direction = 1 unless @direction_fix
end
#--------------------------------------------------------------------------
# alias method: move_lower_right
#--------------------------------------------------------------------------
alias move_lower_right_em move_lower_right
def move_lower_right
move_lower_right_em
@direction = 3 unless @direction_fix
end
#--------------------------------------------------------------------------
# alias method: move_upper_left
#--------------------------------------------------------------------------
alias move_upper_left_em move_upper_left
def move_upper_left
move_upper_left_em
@direction = 7 unless @direction_fix
end
#--------------------------------------------------------------------------
# alias method: move_upper_right
#--------------------------------------------------------------------------
alias move_upper_right_em move_upper_right
def move_upper_right
move_upper_right_em
@direction = 9 unless @direction_fix
end
if YEM::MOVEMENT::ENABLE_8D_MOVEMENT
#--------------------------------------------------------------------------
# overwrite method: move_random
#--------------------------------------------------------------------------
def move_random
case rand(7)
when 0;move_down
when 1;move_left
when 2;move_right
when 3;move_up
when 4
if !dir8_passable?(2) and dir8_passable?(4)
move_left
elsif dir8_passable?(2) and !dir8_passable?(4)
move_down
else
move_down
move_left
@direction = 1
end
when 5
if !dir8_passable?(2) and dir8_passable?(6)
move_right
elsif dir8_passable?(2) and !dir8_passable?(6)
move_down
else
move_down
move_right
@direction = 3
end
when 6
if !dir8_passable?(8) and dir8_passable?(4)
move_left
elsif dir8_passable?(8) and !dir8_passable?(4)
move_up
else
move_up
move_left
@direction = 7
end
when 7
if !dir8_passable?(8) and dir8_passable?(6)
move_right
elsif dir8_passable?(8) and !dir8_passable?(6)
move_up
else
move_up
move_right
@direction = 9
end
end
end
#--------------------------------------------------------------------------
# overwrite method: move_toward_player
#--------------------------------------------------------------------------
def move_toward_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx != 0 or sy != 0
if sx.abs > sy.abs
sx > 0 ? move_left : move_right
if @move_failed and sy != 0
sy > 0 ? move_up : move_down
end
elsif sx.abs < sy.abs
sy > 0 ? move_up : move_down
if @move_failed and sx != 0
sx > 0 ? move_left : move_right
end
elsif sx.abs == sy.abs
if sx > 0 and sy > 0
move_up
move_left
@direction = 7
elsif sx < 0 and sy > 0
move_up
move_right
@direction = 9
elsif sx > 0 and sy < 0
move_down
move_left
@direction = 1
elsif sx < 0 and sy < 0
move_down
move_right
@direction = 3
end
end
end
end
#--------------------------------------------------------------------------
# overwrite method: move_away_from_player
#--------------------------------------------------------------------------
def move_away_from_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx != 0 or sy != 0
if sx.abs > sy.abs
sx > 0 ? move_right : move_left
if @move_failed and sy != 0
sy > 0 ? move_down : move_up
end
elsif sx.abs < sy.abs
sy > 0 ? move_down : move_up
if @move_failed and sx != 0
sx > 0 ? move_right : move_left
end
elsif sx.abs == sy.abs
if sx > 0 and sy > 0
move_down
move_right
@direction = 3
elsif sx < 0 and sy > 0
move_down
move_left
@direction = 1
elsif sx > 0 and sy < 0
move_up
move_right
@direction = 9
elsif sx < 0 and sy < 0
move_up
move_left
@direction = 7
end
end
end
end
#--------------------------------------------------------------------------
# overwrite method: move_forward
#--------------------------------------------------------------------------
def move_forward
case @direction
when 2;move_down(false)
when 4;move_left(false)
when 6;move_right(false)
when 8;move_up(false)
when 1
if !dir8_passable?(2) and dir8_passable?(4)
move_left
elsif dir8_passable?(2) and !dir8_passable?(4)
move_down
else
move_down
move_left
end
when 3
if !dir8_passable?(2) and dir8_passable?(6)
move_right
elsif dir8_passable?(2) and !dir8_passable?(6)
move_down
else
move_down
move_right
end
when 7
if !dir8_passable?(8) and dir8_passable?(4)
move_left
elsif dir8_passable?(8) and !dir8_passable?(4)
move_up
else
move_up
move_left
end
when 9
if !dir8_passable?(8) and dir8_passable?(6)
move_right
elsif dir8_passable?(8) and !dir8_passable?(6)
move_up
else
move_up
move_right
end
end
end
#--------------------------------------------------------------------------
# overwrite method: move_backward
#--------------------------------------------------------------------------
def move_backward
last_direction_fix = @direction_fix
@direction_fix = true
case @direction
when 2;move_up(false)
when 4;move_right(false)
when 6;move_left(false)
when 8;move_down(false)
when 9
if !dir8_passable?(2) and dir8_passable?(4)
move_left
elsif dir8_passable?(2) and !dir8_passable?(4)
move_down
else
move_down
move_left
end
when 7
if !dir8_passable?(2) and dir8_passable?(6)
move_right
elsif dir8_passable?(2) and !dir8_passable?(6)
move_down
else
move_down
move_right
end
when 3
if !dir8_passable?(8) and dir8_passable?(4)
move_left
elsif dir8_passable?(8) and !dir8_passable?(4)
move_up
else
move_up
move_left
end
when 1
if !dir8_passable?(8) and dir8_passable?(6)
move_right
elsif dir8_passable?(8) and !dir8_passable?(6)
move_up
else
move_up
move_right
end
end
@direction_fix = last_direction_fix
end
#--------------------------------------------------------------------------
# overwrite method: turn_random
#--------------------------------------------------------------------------
def turn_random
case rand(7)
when 0; turn_up
when 1; turn_right
when 2; turn_left
when 3; turn_down
when 4; set_direction(1)
when 5; set_direction(3)
when 6; set_direction(7)
when 7; set_direction(9)
end
end
#--------------------------------------------------------------------------
# overwrite method: turn_toward_player
#--------------------------------------------------------------------------
def turn_toward_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
elsif sx.abs < sy.abs
sy > 0 ? turn_up : turn_down
elsif sx.abs == sy.abs
if sx > 0 and sy > 0
set_direction(7)
elsif sx < 0 and sy > 0
set_direction(9)
elsif sx > 0 and sy < 0
set_direction(1)
elsif sx < 0 and sy < 0
set_direction(3)
end
end
end
#--------------------------------------------------------------------------
# overwrite method: turn_away_from_player
#--------------------------------------------------------------------------
def turn_away_from_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx.abs > sy.abs
sx > 0 ? turn_right : turn_left
elsif sx.abs < sy.abs
sy > 0 ? turn_down : turn_up
elsif sx.abs == sy.abs
if sx > 0 and sy > 0
set_direction(3)
elsif sx < 0 and sy > 0
set_direction(1)
elsif sx > 0 and sy < 0
set_direction(9)
elsif sx < 0 and sy < 0
set_direction(7)
end
end
end
#--------------------------------------------------------------------------
# new method: dir8_passable?
#--------------------------------------------------------------------------
def dir8_passable?(direction)
case direction
when 1
return passable?(@x-1, @y+1)
when 2
return passable?(@x, @y+1)
when 3
return passable?(@x+1, @y+1)
when 4
return passable?(@x-1, @y)
when 6
return passable?(@x+1, @y)
when 7
return passable?(@x-1, @y-1)
when 8
return passable?(@x, @y-1)
when 9
return passable?(@x+1, @y-1)
end
end
end # YEM::MOVEMENT::ENABLE_8D_MOVEMENT
end # Game_Character
#===============================================================================
# Game_Player
#===============================================================================
class Game_Player < Game_Character
if YEM::MOVEMENT::ENABLE_8D_MOVEMENT
#--------------------------------------------------------------------------
# overwrite method: move_by_input
#--------------------------------------------------------------------------
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
@tap_counter = YEM::MOVEMENT::TAP_COUNTER if @tap_counter == nil
@idle_frames = 0 if @idle_frames == nil
if Input.dir8 != 0
break_pose
@tap_counter -= 1
@direction = Input.dir8
@idle_frames = 0
return if @tap_counter > 0
else
@idle_frames += 1
@tap_counter = YEM::MOVEMENT::TAP_COUNTER
end
if @idle_frames > YEM::MOVEMENT::IDLE_FRAMES and
(@pose == nil or @pose == "")
@pose = YEM::MOVEMENT::IDLE_POSE[rand(YEM::MOVEMENT::IDLE_POSE.size + 1)]
end
case Input.dir8
when 2; move_down
when 4; move_left
when 6; move_right
when 8; move_up
when 1
if !dir8_passable?(2) and dir8_passable?(4)
move_left
elsif dir8_passable?(2) and !dir8_passable?(4)
move_down
else
move_down
move_left
@direction = Input.dir8
end
when 3
if !dir8_passable?(2) and dir8_passable?(6)
move_right
elsif dir8_passable?(2) and !dir8_passable?(6)
move_down
else
move_down
move_right
@direction = Input.dir8
end
when 7
if !dir8_passable?(8) and dir8_passable?(4)
move_left
elsif dir8_passable?(8) and !dir8_passable?(4)
move_up
else
move_up
move_left
@direction = Input.dir8
end
when 9
if !dir8_passable?(8) and dir8_passable?(6)
move_right
elsif dir8_passable?(8) and !dir8_passable?(6)
move_up
else
move_up
move_right
@direction = Input.dir8
end
end
end
end # YEM::MOVEMENT::ENABLE_8D_MOVEMENT
#--------------------------------------------------------------------------
# overwrite method: update_move
#--------------------------------------------------------------------------
def update_move
distance = 2 ** @move_speed
if dash?
distance *= @dash_speed
distance /= 100
end
distance = Integer(distance)
@real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
@real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
@real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
@real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
update_bush_depth unless moving?
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
end
#--------------------------------------------------------------------------
# overwrite method: update_dash_speed
#--------------------------------------------------------------------------
def update_dash_speed
dash_variable = YEM::MOVEMENT::DASH_SPEED_VARIABLE
if $game_variables[dash_variable] <= 0
$game_variables[dash_variable] = YEM::MOVEMENT::DEFAULT_DASH_SPEED
end
@dash_speed = $game_variables[YEM::MOVEMENT::DASH_SPEED_VARIABLE]
for member in $game_party.members
for item in member.equips.compact do @dash_speed += item.dash_speed_bonus end
end
end
end # Game_Player
#===============================================================================
# Game_Interpreter
#===============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# alias method: command_122
#--------------------------------------------------------------------------
alias command_122_em command_122 unless $@
def command_122
n = command_122_em
$game_player.update_dash_speed if @params[0] ==
YEM::MOVEMENT::DASH_SPEED_VARIABLE
return n
end
end # Game_Interpreter
#===============================================================================
# Sprite_Character
#===============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# constants
#--------------------------------------------------------------------------
DIR8_FRAMES ={ 1=>2, 2=>2, 3=>6, 4=>4, 6=>6, 7=>4, 8=>8, 9=>8 }
#--------------------------------------------------------------------------
# alias method: update_bitmap
#--------------------------------------------------------------------------
alias update_bitmap_em update_bitmap unless $@
def update_bitmap
name_changed = (@character_name != @character.character_name)
update_bitmap_em
@appropiate_file = nil if name_changed
end
#--------------------------------------------------------------------------
# overwrite method: update_src_rect
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
index = @character.character_index
if !posing?
@pose_pattern = nil
@pose_duration = nil
end
if posing?
pose_creation
elsif dashing? and diagonal?
@index_value = index+3
elsif dashing?
@index_value = index+2
elsif diagonal?
@index_value = index+1
else
@index_value = index
end
pattern = @character.pattern < 3 ? @character.pattern : 1
@dir8 = DIR8_FRAMES[@character.direction]
self.mirror = mirror?
sx = (@index_value % 4 * 3 + pattern) * @cw
sy = (@index_value / 4 * 4 + (@dir8 - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
#--------------------------------------------------------------------------
# new method: posing?
#--------------------------------------------------------------------------
def posing?
return false unless appropiate_filename?
pose = (@character.pose != nil and !@character.pose != "")
if pose and @pose_duration == nil
@pose_duration = (18 - @character.move_frequency * 2)
@pose_pattern = -1
end
@pose_duration = 0 if !pose
return pose
end
#--------------------------------------------------------------------------
# new method: diagonal?
#--------------------------------------------------------------------------
def diagonal?
return false unless YEM::MOVEMENT::ENABLE_8D_MOVEMENT
return false unless appropiate_filename?
return true if [1, 3, 7, 9].include?(@character.direction)
return false
end
#--------------------------------------------------------------------------
# new method: dashing?
#--------------------------------------------------------------------------
def dashing?
return false unless @character.dash?
return false unless appropiate_filename?
return true if Input.dir8 != 0
return false
end
#--------------------------------------------------------------------------
# new method: appropiate_filename?
#--------------------------------------------------------------------------
def appropiate_filename?
if @appropiate_file == nil
name = @character_name[/(.*)_(.*)/]
@appropiate_file = ($2.to_s == YEM::MOVEMENT::SUFFIX)
end
return @appropiate_file
end
#--------------------------------------------------------------------------
# new method: mirror?
#--------------------------------------------------------------------------
def mirror?
@index_value = [@index_value, @index_value+7].min
if @character.mirror and (@character.pose == nil or @character.pose == "")
case @dir8
when 2
@dir8 = 6 if diagonal?
when 4
@dir8 = diagonal? ? 8 : 6
when 6
@dir8 = diagonal? ? 2 : 4
when 8
@dir8 = 4 if diagonal?
end
end
return @character.mirror
end
#--------------------------------------------------------------------------
# new method: pose_creation
#--------------------------------------------------------------------------
def pose_creation
@character.pre_pose = @character.direction if @character.pre_pose == nil
case @character.pose.upcase
#---
when "NORMAL"
@index_value = @character.character_index
@character.break_pose
#---
when "READY", "IDLE"
@index_value = 4
@character.set_direction(2)
@character.step_anime = true
when "DAMAGE", "DMG"
@index_value = 4
@character.set_direction(4)
play_character_pose
when "PIYORI", "CRITICAL", "DAZED", "DAZE", "DIZZY"
@index_value = 4
@character.set_direction(6)
@character.step_anime = true
when "MARCH", "FORWARD"
@index_value = 4
@character.set_direction(8)
@character.step_anime = true
#---
when "VICTORY", "POSE"
@index_value = 5
@character.set_direction(2)
play_character_pose
when "EVADE", "DODGE"
@index_value = 5
@character.set_direction(4)
play_character_pose
when "DEAD", "DEAD1"
@index_value = 5
@character.set_direction(6)
@character.anti_straighten = true
@character.walk_anime = false
@character.pattern = 0
when "DEAD2"
@index_value = 5
@character.set_direction(6)
@character.anti_straighten = true
@character.walk_anime = false
@character.pattern = 1
when "DEAD3"
@index_value = 5
@character.set_direction(6)
@character.anti_straighten = true
@character.walk_anime = false
@character.pattern = 2
when "DOWN", "DOWNED", "FALLEN"
@index_value = 5
@character.set_direction(8)
#---
when "2H", "2H SWING"
@index_value = 6
@character.set_direction(2)
play_character_pose
when "1H", "1H SWING"
@index_value = 6
@character.set_direction(4)
play_character_pose
when "2H REVERSE", "2H SWING REVERSE"
@index_value = 6
@character.set_direction(2)
play_character_pose(true)
when "1H REVERSE", "1H SWING REVERSE"
@index_value = 6
@character.set_direction(4)
play_character_pose(true)
when "CAST", "INVOKE", "ITEM", "MAGIC"
@index_value = 6
@character.set_direction(6)
play_character_pose
when "CHANT", "CHANNEL", "CHARGE"
@index_value = 6
@character.set_direction(8)
@character.step_anime = true
#---
else
@index_value = @character.character_index
@character.set_direction(2)
end
end
#--------------------------------------------------------------------------
# new method: play_character_pose
#--------------------------------------------------------------------------
def play_character_pose(reverse = false)
update_amount = (18 - @character.move_frequency * 2)
@character.anti_straighten = true
@character.walk_anime = false
@pose_duration += 1
if @pose_pattern == nil
@character.pattern = reverse ? 2 : 0
@pose_pattern = reverse ? 2 : 0
end
if reverse and @pose_pattern > 0 and @pose_duration > update_amount
@pose_duration = 0
@pose_pattern -= 1
@character.pattern = @pose_pattern
elsif !reverse and @pose_pattern < 2 and @pose_duration > update_amount
@pose_duration = 0
@pose_pattern += 1
@character.pattern = @pose_pattern
end
end
end # Sprite_Character
#===============================================================================
# Scene_Map
#===============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# alias method: start
#--------------------------------------------------------------------------
alias start_map_em start unless $@
def start
start_map_em
$game_player.update_dash_speed
end
end # Scene_Map
#===============================================================================
#
# END OF FILE
#
#===============================================================================打开脚本编辑器,滚动条拉到最下面,把上面的代码插在main那栏之前。 咱发个日文的...
#==============================================================================
# ■ Game_Character_re
#------------------------------------------------------------------------------
# キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
# クラスのスーパークラスとして使用されます。(再定義)
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ● キャラクター衝突判定
# x : X 座標
# y : Y 座標
# プレイヤーと乗り物を含め、通常キャラの衝突を検出する。
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
for event in $game_map.events_xy(x, y) # イベントの座標と一致
unless event.through # すり抜け OFF?
return true if self.is_a?(Game_Event) # 自分がイベント
return true if event.priority_type == 1 # 相手が通常キャラ
end
end
if @priority_type == 1 # 自分が通常キャラ
return true if $game_player.pos_nt?(x, y) # プレイヤーの座標と一致
return true if $game_subplayer1.pos_nt?(x,y)# サブプレイヤーの座標と一致#追加
return true if $game_subplayer2.pos_nt?(x,y)# サブプレイヤーの座標と一致#追加
return true if $game_subplayer3.pos_nt?(x,y)# サブプレイヤーの座標と一致#追加
return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致
return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致
end
return false
end
end
#==============================================================================
# ■ Game_Player_re
#------------------------------------------------------------------------------
# プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
# (再定義)
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :gather_on # メンバー集合フラグ #追加
attr_reader :member # 強制動作を行うプレイヤー番号(0:全員)#追加
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super
@vehicle_type = -1
@vehicle_getting_on = false # 乗る動作の途中フラグ
@vehicle_getting_off = false # 降りる動作の途中フラグ
@transferring = false # 場所移動フラグ
@new_map_id = 0 # 移動先 マップ ID
@new_x = 0 # 移動先 X 座標
@new_y = 0 # 移動先 Y 座標
@new_direction = 0 # 移動後の向き
@walking_bgm = nil # 歩行時の BGM 記憶用
@gather_on = false # 追加
@gather_count = 0 # 集合用カウンター #追加
@member = 0
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if $game_party.members.size == 0
@character_name = ""
@character_index = 0
else
actor = $game_party.members # 先頭のアクターを取得
@character_name = actor.character_name
@character_index = actor.character_index
end
$game_subplayer1.refresh(1)#追加
$game_subplayer2.refresh(2)#追加
$game_subplayer3.refresh(3)#追加
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 # 透明化
$game_subplayer1.transparent = true # 透明化 #追加
$game_subplayer2.transparent = true # 透明化 #追加
$game_subplayer3.transparent = true # 透明化 #追加
end
elsif @vehicle_getting_off # 降りる途中?
if not moving? and vehicle.altitude == 0
@vehicle_getting_off = false # 降りる動作終了
@vehicle_type = -1 # 乗り物タイプ消去
@transparent = false # 透明を解除
$game_subplayer1.moveto($game_player.x,$game_player.y) #追加
$game_subplayer1.transparent = false # 透明を解除 #追加
$game_subplayer2.moveto($game_player.x,$game_player.y) #追加
$game_subplayer2.transparent = false # 透明を解除 #追加
$game_subplayer3.moveto($game_player.x,$game_player.y) #追加
$game_subplayer3.transparent = false # 透明を解除 #追加
end
else # 乗り物に乗っている
vehicle.sync_with_player # プレイヤーと同時に動かす
end
end
#--------------------------------------------------------------------------
# ● 乗り物から降りる
# 現在乗り物に乗っていることが前提。
#--------------------------------------------------------------------------
def get_off_vehicle
if in_airship? # 飛行船
return unless airship_land_ok?(@x, @y) # 着陸できない?
else # 小型船・大型船
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) # 接岸できない?
end
$game_map.vehicles[@vehicle_type].get_off # 降りる処理
if in_airship? # 飛行船
@direction = 2 # 下を向く
else # 小型船・大型船
force_move_forward # 一歩前進
@transparent = false # 透明を解除
end
@vehicle_getting_off = true # 降りる動作の開始
@move_speed = 4 # 移動速度を戻す
$game_subplayer1.move_speed = 4 # 移動速度を戻す# 追加
$game_subplayer2.move_speed = 4 # 移動速度を戻す# 追加
$game_subplayer3.move_speed = 4 # 移動速度を戻す# 追加
@through = false # すり抜け OFF
@walking_bgm.play # 歩行時の BGM 復帰
make_encounter_count # エンカウント初期化
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_down(turn_ok = true)
pos = [] #追加
if passable?(@x, @y+1) # 通行可能
turn_down
pos.push(@x,@y) #追加
@y = $game_map.round_y(@y+1)
@real_y = (@y-1)*256
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else # 通行不可能
turn_down if turn_ok
check_event_trigger_touch(@x, @y+1) # 接触イベントの起動判定
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_left(turn_ok = true)
pos = [] #追加
if passable?(@x-1, @y) # 通行可能
turn_left
pos.push(@x,@y) #追加
@x = $game_map.round_x(@x-1)
@real_x = (@x+1)*256
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else # 通行不可能
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y) # 接触イベントの起動判定
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_right(turn_ok = true)
pos = [] #追加
if passable?(@x+1, @y) # 通行可能
turn_right
pos.push(@x,@y) #追加
@x = $game_map.round_x(@x+1)
@real_x = (@x-1)*256
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else # 通行不可能
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y) # 接触イベントの起動判定
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_up(turn_ok = true)
pos = [] #追加
if passable?(@x, @y-1) # 通行可能
turn_up
pos.push(@x,@y) #追加
@y = $game_map.round_y(@y-1)
@real_y = (@y+1)*256
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else # 通行不可能
turn_up if turn_ok
check_event_trigger_touch(@x, @y-1) # 接触イベントの起動判定
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左下に移動
#--------------------------------------------------------------------------
def move_lower_left
pos = [] #追加
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y+1))
pos.push(@x,@y) #追加
@x -= 1
@y += 1
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右下に移動
#--------------------------------------------------------------------------
def move_lower_right
pos = [] #追加
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y+1))
pos.push(@x,@y) #追加
@x += 1
@y += 1
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左上に移動
#--------------------------------------------------------------------------
def move_upper_left
pos = [] #追加
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y-1))
pos.push(@x,@y) #追加
@x -= 1
@y -= 1
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右上に移動
#--------------------------------------------------------------------------
def move_upper_right
pos = [] #追加
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y-1))
pos.push(@x,@y) #追加
@x += 1
@y -= 1
$game_subplayer1.move(pos) #追加
increase_steps
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● キャラクター衝突判定
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
for event in $game_map.events_xy(x, y) # イベントの座標と一致
unless event.through # すり抜け OFF?
return true if self.is_a?(Game_Event) # 自分がイベント
return true if event.priority_type == 1 # 相手が通常キャラ
end
end
if @priority_type == 1 # 自分が通常キャラ
return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致
return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致
end
return false
end
#--------------------------------------------------------------------------
# ● 移動タイプ : カスタム
#--------------------------------------------------------------------------
def move_type_custom
if stopping?
command = @move_route.list[@move_route_index] # 移動コマンドを取得
@move_failed = false
if command.code == 0 # リストの最後
if @move_route.repeat # [動作を繰り返す]
@move_route_index = 0
elsif @move_route_forcing # 移動ルート強制中
@move_route_forcing = false # 強制を解除
@move_route = @original_move_route # オリジナルを復帰
@move_route_index = @original_move_route_index
@original_move_route = nil
end
else
case command.code
when 1 # 下に移動
move_down
when 2 # 左に移動
move_left
when 3 # 右に移動
move_right
when 4 # 上に移動
move_up
when 5 # 左下に移動
move_lower_left
when 6 # 右下に移動
move_lower_right
when 7 # 左上に移動
move_upper_left
when 8 # 右上に移動
move_upper_right
when 9 # ランダムに移動
move_random
when 10 # プレイヤーに近づく
move_toward_player
when 11 # プレイヤーから遠ざかる
move_away_from_player
when 12 # 一歩前進
move_forward
when 13 # 一歩後退
move_backward
when 14 # ジャンプ
#以下変更
if command.parameters==0 && command.parameters==0
if @member==1
jump(command.parameters, command.parameters)
elsif @member==2
$game_subplayer1.jump(command.parameters, command.parameters)
elsif @member==3
$game_subplayer2.jump(command.parameters, command.parameters)
elsif @member==4
$game_subplayer3.jump(command.parameters, command.parameters)
elsif @member==0
$game_subplayer3.jump(command.parameters, command.parameters)
$game_subplayer2.jump(command.parameters, command.parameters)
$game_subplayer1.jump(command.parameters, command.parameters)
jump(command.parameters, command.parameters)
end
else
$game_subplayer3.jump(command.parameters, command.parameters)
$game_subplayer2.jump(command.parameters, command.parameters)
$game_subplayer1.jump(command.parameters, command.parameters)
jump(command.parameters, command.parameters)
end
#ここまで
when 15 # ウェイト
@wait_count = command.parameters - 1
when 16 # 下を向く
#以下変更
if @member==1
turn_down
elsif @member==2
$game_subplayer1.turn_down
elsif @member==3
$game_subplayer2.turn_down
elsif @member==4
$game_subplayer3.turn_down
elsif @member==0
$game_subplayer3.turn_down
$game_subplayer2.turn_down
$game_subplayer1.turn_down
turn_down
end
#ここまで
when 17 # 左を向く
#以下変更
if @member==1
turn_left
elsif @member==2
$game_subplayer1.turn_left
elsif @member==3
$game_subplayer2.turn_left
elsif @member==4
$game_subplayer3.turn_left
elsif @member==0
$game_subplayer3.turn_left
$game_subplayer2.turn_left
$game_subplayer1.turn_left
turn_left
end
#ここまで
when 18 # 右を向く
#以下変更
if @member==1
turn_right
elsif @member==2
$game_subplayer1.turn_right
elsif @member==3
$game_subplayer2.turn_right
elsif @member==4
$game_subplayer3.turn_right
elsif @member==0
$game_subplayer3.turn_right
$game_subplayer2.turn_right
$game_subplayer1.turn_right
turn_right
end
#ここまで
when 19 # 上を向く
#以下変更
if @member==1
turn_up
elsif @member==2
$game_subplayer1.turn_up
elsif @member==3
$game_subplayer2.turn_up
elsif @member==4
$game_subplayer3.turn_up
elsif @member==0
$game_subplayer3.turn_up
$game_subplayer2.turn_up
$game_subplayer1.turn_up
turn_up
end
#ここまで
when 20 # 右に 90 度回転
#以下変更
if @member==1
turn_right_90
elsif @member==2
$game_subplayer1.turn_right_90
elsif @member==3
$game_subplayer2.turn_right_90
elsif @member==4
$game_subplayer3.turn_right_90
elsif @member==0
$game_subplayer3.turn_right_90
$game_subplayer2.turn_right_90
$game_subplayer1.turn_right_90
turn_right_90
end
#ここまで
when 21 # 左に 90 度回転
#以下変更
if @member==1
turn_left_90
elsif @member==2
$game_subplayer1.turn_left_90
elsif @member==3
$game_subplayer2.turn_left_90
elsif @member==4
$game_subplayer3.turn_left_90
elsif @member==0
$game_subplayer3.turn_left_90
$game_subplayer2.turn_left_90
$game_subplayer1.turn_left_90
turn_left_90
end
#ここまで
when 22 # 180 度回転
#以下変更
if @member==1
turn_180
elsif @member==2
$game_subplayer1.turn_180
elsif @member==3
$game_subplayer2.turn_180
elsif @member==4
$game_subplayer3.turn_180
elsif @member==0
$game_subplayer3.turn_180
$game_subplayer2.turn_180
$game_subplayer1.turn_180
turn_180
end
#ここまで
when 23 # 右か左に 90 度回転
#以下変更
if @member==1
turn_right_or_left_90
elsif @member==2
$game_subplayer1.turn_right_or_left_90
elsif @member==3
$game_subplayer2.turn_right_or_left_90
elsif @member==4
$game_subplayer3.turn_right_or_left_90
elsif @member==0
$game_subplayer3.turn_right_or_left_90
$game_subplayer2.turn_right_or_left_90
$game_subplayer1.turn_right_or_left_90
turn_right_or_left_90
end
#ここまで
when 24 # ランダムに方向転換
#以下変更
if @member==1
turn_random
elsif @member==2
$game_subplayer1.turn_random
elsif @member==3
$game_subplayer2.turn_random
elsif @member==4
$game_subplayer3.turn_random
elsif @member==0
$game_subplayer3.turn_random
$game_subplayer2.turn_random
$game_subplayer1.turn_random
turn_random
end
#ここまで
when 25 # プレイヤーの方を向く
#以下変更
if @member==1
turn_toward_player
elsif @member==2
$game_subplayer1.turn_toward_player
elsif @member==3
$game_subplayer2.turn_toward_player
elsif @member==4
$game_subplayer3.turn_toward_player
elsif @member==0
$game_subplayer3.turn_toward_player
$game_subplayer2.turn_toward_player
$game_subplayer1.turn_toward_player
turn_toward_player
end
#ここまで
when 26 # プレイヤーの逆を向く
#以下変更
if @member==1
turn_away_from_player
elsif @member==2
$game_subplayer1.turn_away_from_player
elsif @member==3
$game_subplayer2.turn_away_from_player
elsif @member==4
$game_subplayer3.turn_away_from_player
elsif @member==0
$game_subplayer3.turn_away_from_player
$game_subplayer2.turn_away_from_player
$game_subplayer1.turn_away_from_player
turn_away_from_player
end
#ここまで
when 27 # スイッチ ON
$game_switches] = true
$game_map.need_refresh = true
when 28 # スイッチ OFF
$game_switches] = false
$game_map.need_refresh = true
when 29 # 移動速度の変更
#以下変更
@move_speed = command.parameters
$game_subplayer1.move_speed = command.parameters
$game_subplayer2.move_speed = command.parameters
$game_subplayer3.move_speed = command.parameters
#ここまで
when 30 # 移動頻度の変更
@move_frequency = command.parameters
when 31 # 歩行アニメ ON
#以下変更
if @member==1
@walk_anime = true
elsif @member==2
$game_subplayer1.walk_anime = true
elsif @member==3
$game_subplayer2.walk_anime = true
elsif @member==4
$game_subplayer3.walk_anime = true
elsif @member==0
$game_subplayer3.walk_anime = true
$game_subplayer2.walk_anime = true
$game_subplayer1.walk_anime = true
@walk_anime = true
end
#ここまで
when 32 # 歩行アニメ OFF
#以下変更
if @member==1
@walk_anime = false
elsif @member==2
$game_subplayer1.walk_anime = false
elsif @member==3
$game_subplayer2.walk_anime = false
elsif @member==4
$game_subplayer3.walk_anime = false
elsif @member==0
$game_subplayer3.walk_anime = false
$game_subplayer2.walk_anime = false
$game_subplayer1.walk_anime = false
@walk_anime = false
end
#ここまで
when 33 # 足踏みアニメ ON
#以下変更
if @member==1
@step_anime = true
elsif @member==2
$game_subplayer1.step_anime = true
elsif @member==3
$game_subplayer2.step_anime = true
elsif @member==4
$game_subplayer3.step_anime = true
elsif @member==0
$game_subplayer3.step_anime = true
$game_subplayer2.step_anime = true
$game_subplayer1.step_anime = true
@step_anime = true
end
#ここまで
when 34 # 足踏みアニメ OFF
#以下変更
if @member==1
@step_anime = false
elsif @member==2
$game_subplayer1.step_anime = false
elsif @member==3
$game_subplayer2.step_anime = false
elsif @member==4
$game_subplayer3.step_anime = false
elsif @member==0
$game_subplayer3.step_anime = false
$game_subplayer2.step_anime = false
$game_subplayer1.step_anime = false
@step_anime = false
end
#ここまで
when 35 # 向き固定 ON
#以下変更
if @member==1
@direction_fix = true
elsif @member==2
$game_subplayer1.direction_fix = true
elsif @member==3
$game_subplayer2.direction_fix = true
elsif @member==4
$game_subplayer3.direction_fix = true
elsif @member==0
$game_subplayer3.direction_fix = true
$game_subplayer2.direction_fix = true
$game_subplayer1.direction_fix = true
@direction_fix = true
end
#ここまで
when 36 # 向き固定 OFF
#以下変更
if @member==1
@direction_fix = false
elsif @member==2
$game_subplayer1.direction_fix = false
elsif @member==3
$game_subplayer2.direction_fix = false
elsif @member==4
$game_subplayer3.direction_fix = false
elsif @member==0
$game_subplayer3.direction_fix = false
$game_subplayer2.direction_fix = false
$game_subplayer1.direction_fix = false
@direction_fix = false
end
#ここまで
when 37 # すり抜け ON
#以下変更
@through = true
$game_subplayer1.through = true
$game_subplayer2.through = true
$game_subplayer3.through = true
#ここまで
when 38 # すり抜け OFF
#以下変更
@through = false
$game_subplayer1.through = false
$game_subplayer2.through = false
$game_subplayer3.through = false
#ここまで
when 39 # 透明化 ON
#以下変更
if @member==1
@transparent = true
elsif @member==2
$game_subplayer1.transparent = true
elsif @member==3
$game_subplayer2.transparent = true
elsif @member==4
$game_subplayer3.transparent = true
elsif @member==0
$game_subplayer3.transparent = true
$game_subplayer2.transparent = true
$game_subplayer1.transparent = true
@transparent = true
end
#ここまで
when 40 # 透明化 OFF
#以下変更
if @member==1
@transparent = false
elsif @member==2
$game_subplayer1.transparent = false
elsif @member==3
$game_subplayer2.transparent = false
elsif @member==4
$game_subplayer3.transparent = false
elsif @member==0
$game_subplayer3.transparent = false
$game_subplayer2.transparent = false
$game_subplayer1.transparent = false
@transparent = false
end
#ここまで
when 41 # グラフィック変更
#以下変更
if @member==1
set_graphic(command.parameters, command.parameters)
elsif @member==2
$game_subplayer1.set_graphic(command.parameters, command.parameters)
elsif @member==3
$game_subplayer2.set_graphic(command.parameters, command.parameters)
elsif @member==4
$game_subplayer3.set_graphic(command.parameters, command.parameters)
elsif @member==0
$game_subplayer3.set_graphic(command.parameters, command.parameters)
$game_subplayer2.set_graphic(command.parameters, command.parameters)
$game_subplayer1.set_graphic(command.parameters, command.parameters)
set_graphic(command.parameters, command.parameters)
end
#ここまで
when 42 # 不透明度の変更
#以下変更
if @member==1
@opacity = command.parameters
elsif @member==2
$game_subplayer1.opacity = command.parameters
elsif @member==3
$game_subplayer2.opacity = command.parameters
elsif @member==4
$game_subplayer3.opacity = command.parameters
elsif @member==0
$game_subplayer3.opacity = command.parameters
$game_subplayer2.opacity = command.parameters
$game_subplayer1.opacity = command.parameters
@opacity = command.parameters
end
#ここまで
when 43 # 合成方法の変更
#以下変更
if @member==1
@blend_type = command.parameters
elsif @member==2
$game_subplayer1.blend_type = command.parameters
elsif @member==3
$game_subplayer2.blend_type = command.parameters
elsif @member==4
$game_subplayer3.blend_type = command.parameters
elsif @member==0
$game_subplayer3.blend_type = command.parameters
$game_subplayer2.blend_type = command.parameters
$game_subplayer1.blend_type = command.parameters
@blend_type = command.parameters
end
#ここまで
when 44 # SE の演奏
command.parameters.play
when 45 # スクリプト
eval(command.parameters)
end
if not @move_route.skippable and @move_failed
return# [移動できない場合は無視] OFF & 移動失敗
end
@move_route_index += 1
end
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 @gather_on # 集合中 #追加
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
#以下スーパークラスのupdateメソッドをコピー
if jumping? # ジャンプ中
update_jump
elsif moving? # 移動中
update_move
else # 停止中
update_stop
end
if @wait_count > 0 # ウェイト中
@wait_count -= 1
elsif @gather_on # 追加
update_gather # 追加
elsif @move_route_forcing # 移動ルート強制中
move_type_custom
elsif not @locked # ロック中以外
update_self_movement
end
update_animation
#ここまで
update_scroll(last_real_x, last_real_y)
update_vehicle
update_nonmoving(last_moving)
end
#--------------------------------------------------------------------------
# ● サブキャラクター集合メソッド(これを,スクリプトにより呼び出す) #追加
#--------------------------------------------------------------------------
def gather
@gather_on = true
end
#--------------------------------------------------------------------------
# ● サブキャラクター集合更新 #追加
#--------------------------------------------------------------------------
def update_gather
return unless @gather_on
return if $game_subplayer3.moving?
pos = []
pos.push(@x,@y)
if(@gather_count==0)
$game_subplayer1.move(pos);@gather_count+=1
elsif(@gather_count==1)
$game_subplayer2.move(pos);@gather_count+=1
elsif(@gather_count==2)
$game_subplayer3.move(pos);@gather_count+=1
elsif(@gather_count==3)
@gather_count=0;@gather_on=false
end
end
#--------------------------------------------------------------------------
# ● 強制行動キャラクタを選択する(これを,スクリプトにより呼び出す) #追加
#--------------------------------------------------------------------------
def set_member(x)
@member = x
end
end
#==============================================================================
# ■ Game_Interpreter_re
#------------------------------------------------------------------------------
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。(再定義)
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 場所移動
#--------------------------------------------------------------------------
def command_201
return true if $game_temp.in_battle
if $game_player.transfer? or # 場所移動中
$game_message.visible # メッセージ表示中
return false
end
if @params == 0 # 直接指定
map_id = @params
x = @params
y = @params
direction = @params
else # 変数で指定
map_id = $game_variables[@params]
x = $game_variables[@params]
y = $game_variables[@params]
direction = @params
end
$game_player.reserve_transfer(map_id, x, y, direction)
$game_subplayer1.reserve_transfer(map_id, x, y, direction) #追加
$game_subplayer2.reserve_transfer(map_id, x, y, direction) #追加
$game_subplayer3.reserve_transfer(map_id, x, y, direction) #追加
@index += 1
return false
end
#--------------------------------------------------------------------------
# ● 透明状態の変更
#--------------------------------------------------------------------------
def command_211
$game_player.transparent = (@params == 0)
$game_subplayer1.transparent = (@params == 0)#追加
$game_subplayer2.transparent = (@params == 0)#追加
$game_subplayer3.transparent = (@params == 0)#追加
return true
end
#--------------------------------------------------------------------------
# ● アニメーションの表示
#--------------------------------------------------------------------------
def command_212
character = get_character(@params)
if character == $game_player
if $game_player.member == 0
$game_player.animation_id = @params
$game_subplayer1.animation_id = @params
$game_subplayer2.animation_id = @params
$game_subplayer3.animation_id = @params
elsif $game_player.member == 1
$game_player.animation_id = @params
elsif $game_player.member == 2
$game_subplayer1.animation_id = @params
elsif $game_player.member == 3
$game_subplayer2.animation_id = @params
elsif $game_player.member == 4
$game_subplayer3.animation_id = @params
end
elsif character != nil
character.animation_id = @params
end
return true
end
#--------------------------------------------------------------------------
# ● フキダシアイコンの表示
#--------------------------------------------------------------------------
def command_213
character = get_character(@params)
if character == $game_player
if $game_player.member == 0
$game_player.balloon_id = @params
$game_subplayer1.balloon_id = @params
$game_subplayer2.balloon_id = @params
$game_subplayer3.balloon_id = @params
elsif $game_player.member == 1
$game_player.balloon_id = @params
elsif $game_player.member == 2
$game_subplayer1.balloon_id = @params
elsif $game_player.member == 3
$game_subplayer2.balloon_id = @params
elsif $game_player.member == 4
$game_subplayer3.balloon_id = @params
end
elsif character != nil
character.balloon_id = @params
end
return true
end
end
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# ファイル画面の処理を行うクラスです。
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● セーブデータの書き込み
# file : 書き込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push()
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches,file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($game_subplayer1, file) #追加
Marshal.dump($game_subplayer2, file) #追加
Marshal.dump($game_subplayer3, file) #追加
end
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
# file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches= Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$game_subplayer1 = Marshal.load(file)#追加
$game_subplayer2 = Marshal.load(file)#追加
$game_subplayer3 = Marshal.load(file)#追加
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end
#==============================================================================
# ■ Scene_Map_re
#------------------------------------------------------------------------------
# マップ画面の処理を行うクラスです。(再定義)
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
$game_map.interpreter.update # インタプリタを更新
$game_map.update # マップを更新
$game_player.update # プレイヤーを更新
$game_subplayer1.update # サブプレイヤーを更新 #追加
$game_subplayer2.update # サブプレイヤーを更新 #追加
$game_subplayer3.update # サブプレイヤーを更新 #追加
$game_system.update # タイマーを更新
@spriteset.update # スプライトセットを更新
@message_window.update # メッセージウィンドウを更新
unless $game_message.visible # メッセージ表示中以外
update_transfer_player
update_encounter
update_call_menu
update_call_debug
update_scene_change
end
end
#--------------------------------------------------------------------------
# ● 場所移動の処理
#--------------------------------------------------------------------------
def update_transfer_player
return unless $game_player.transfer?
fade = (Graphics.brightness > 0)
fadeout(30) if fade
@spriteset.dispose # スプライトセットを解放
$game_player.perform_transfer # 場所移動の実行
$game_subplayer1.perform_transfer # 場所移動の実行 #追加
$game_subplayer2.perform_transfer # 場所移動の実行 #追加
$game_subplayer3.perform_transfer # 場所移動の実行 #追加
$game_map.autoplay # BGM と BGS の自動切り替え
$game_map.update
Graphics.wait(15)
@spriteset = Spriteset_Map.new# スプライトセットを再作成
fadein(30) if fade
Input.update
end
end
#==============================================================================
# ■ Scene_Title_re
#------------------------------------------------------------------------------
# タイトル画面の処理を行うクラスです。(再定義)
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# ● 各種ゲームオブジェクトの作成
#--------------------------------------------------------------------------
def create_game_objects
$game_temp = Game_Temp.new
$game_message = Game_Message.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_subplayer1 = Game_Subplayer.new #追加
$game_subplayer2 = Game_Subplayer.new #追加
$game_subplayer3 = Game_Subplayer.new #追加
end
#--------------------------------------------------------------------------
# ● コマンド : ニューゲーム
#--------------------------------------------------------------------------
def command_new_game
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members # 初期パーティ
$game_map.setup($data_system.start_map_id) # 初期位置のマップ
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$game_subplayer1.moveto($data_system.start_x, $data_system.start_y)#追加
$game_subplayer1.refresh(1) #追加
$game_subplayer2.moveto($data_system.start_x, $data_system.start_y)#追加
$game_subplayer2.refresh(2) #追加
$game_subplayer3.moveto($data_system.start_x, $data_system.start_y)#追加
$game_subplayer3.refresh(3) #追加
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
RPG::BGM.stop
$game_map.autoplay
end
end
#==============================================================================
# ■ Spriteset_Map_re
#------------------------------------------------------------------------------
# マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
# Scene_Map クラスの内部で使用されます。(再定義)
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● キャラクタースプライトの作成
#--------------------------------------------------------------------------
def create_characters
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events)
@character_sprites.push(sprite)
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_subplayer3))#追加
@character_sprites.push(Sprite_Character.new(@viewport1, $game_subplayer2))#追加
@character_sprites.push(Sprite_Character.new(@viewport1, $game_subplayer1))#追加
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
end
end
#==============================================================================
# ■ Game_Subplayer
#------------------------------------------------------------------------------
# サブプレイヤーを扱うクラスです。
# このクラスのインスタンスは $game_subplayer1~3で参照されます。
# Game_Playerクラスを元に作っています
#==============================================================================
class Game_Subplayer < Game_Character
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
CENTER_X = (544 / 2 - 16) * 8 # 画面中央の X 座標 * 8
CENTER_Y = (416 / 2 - 16) * 8 # 画面中央の Y 座標 * 8
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :move_speed # 移動速度
attr_accessor :walk_anime # 歩行アニメ
attr_accessor :step_anime # 足踏みアニメ
attr_accessor :direction_fix # 向き固定
attr_accessor :through # すり抜け
attr_accessor :opacity # 不透明度
attr_accessor :blend_type # 合成方法
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super
@transferring = false # 場所移動フラグ
@new_map_id = 0 # 移動先 マップ ID
@new_x = 0 # 移動先 X 座標
@new_y = 0 # 移動先 Y 座標
@new_direction = 0 # 移動後の向き
@number = 0 # 何番目のキャラか
end
#--------------------------------------------------------------------------
# ● 場所移動の予約
# map_id : マップ ID
# x : X 座標
# y : Y 座標
# direction : 移動後の向き
#--------------------------------------------------------------------------
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 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 dash?
return false if $game_player.move_route_forcing
return false if $game_map.disable_dash?
return false if $game_player.gather_on # 集合中
return Input.press?(Input::A)
end
#--------------------------------------------------------------------------
# ● デバッグすり抜け状態判定
#--------------------------------------------------------------------------
def debug_through?
return false unless $TEST
return Input.press?(Input::CTRL)
end
#--------------------------------------------------------------------------
# ● 画面中央に来るようにマップの表示位置を設定
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def center(x, y)
display_x = x * 256 - CENTER_X # 座標を計算
unless $game_map.loop_horizontal? # 横にループしない?
max_x = ($game_map.width - 17) * 256 # 最大値を計算
display_x = .min].max # 座標を修正
end
display_y = y * 256 - CENTER_Y # 座標を計算
unless $game_map.loop_vertical? # 縦にループしない?
max_y = ($game_map.height - 13) * 256 # 最大値を計算
display_y = .min].max # 座標を修正
end
$game_map.set_display_pos(display_x, display_y) # 表示位置変更
end
#--------------------------------------------------------------------------
# ● 指定位置に移動
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def moveto(x, y)
super
center(x, y) # センタリング
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(number)
@number = number
if $game_party.members.size <= number
@character_name = ""
@character_index = 0
else
actor = $game_party.members # アクターを取得
@character_name = actor.character_name
@character_index = actor.character_index
end
end
#--------------------------------------------------------------------------
# ● 動き
#--------------------------------------------------------------------------
def move(xy)
if @x==xy && @y==xy
return
elsif @x==xy+1 && @y==xy
move_left
elsif @x==xy-1 && @y==xy
move_right
elsif @x==xy && @y==xy+1
move_up
elsif @x==xy && @y==xy-1
move_down
elsif @x==xy+1 && @y==xy+1
move_upper_left
elsif @x==xy-1 && @y==xy+1
move_upper_right
elsif @x==xy+1 && @y==xy-1
move_lower_left
elsif @x==xy-1 && @y==xy-1
move_lower_right
#画面ループの端っこの時
elsif @x==0 && xy>@x+1 && @y==xy
move_left
elsif xy==0 && @x+1>xy && @y==xy
move_right
elsif @x==xy && @y==0 && xy>@y+1
move_up
elsif @x==xy && xy==0 && @y+1>xy
move_down
#画面ループの端っこで,ナナメ移動の場合
elsif @x<0 || @y<0
temp_x = $game_map.round_x(@x)
temp_y = $game_map.round_y(@y)
if temp_x==xy+1 && @y==xy
move_left
elsif temp_x==xy-1 && @y==xy
move_right
elsif @x==xy && temp_y==xy+1
move_up
elsif @x==xy && temp_y==xy-1
move_down
end
end
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_down(turn_ok = true)
pos = []
if passable?(@x, @y+1) # 通行可能
turn_down
pos.push(@x,@y)
@y = $game_map.round_y(@y+1)
@real_y = (@y-1)*256
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else # 通行不可能
turn_down if turn_ok
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_left(turn_ok = true)
pos = []
if passable?(@x-1, @y) # 通行可能
turn_left
pos.push(@x,@y)
@x = $game_map.round_x(@x-1)
@real_x = (@x+1)*256
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else # 通行不可能
turn_left if turn_ok
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_right(turn_ok = true)
pos = []
if passable?(@x+1, @y) # 通行可能
turn_right
pos.push(@x,@y)
@x = $game_map.round_x(@x+1)
@real_x = (@x-1)*256
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else # 通行不可能
turn_right if turn_ok
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_ok : その場での向き変更を許可
#--------------------------------------------------------------------------
def move_up(turn_ok = true)
pos = []
if passable?(@x, @y-1) # 通行可能
turn_up
pos.push(@x,@y)
@y = $game_map.round_y(@y-1)
@real_y = (@y+1)*256
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else # 通行不可能
turn_up if turn_ok
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左下に移動
#--------------------------------------------------------------------------
def move_lower_left
pos = []
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y+1))
pos.push(@x,@y)
@x -= 1
@y += 1
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右下に移動
#--------------------------------------------------------------------------
def move_lower_right
pos = []
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y+1))
pos.push(@x,@y)
@x += 1
@y += 1
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 左上に移動
#--------------------------------------------------------------------------
def move_upper_left
pos = []
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y-1))
pos.push(@x,@y)
@x -=1
@y -=1
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● 右上に移動
#--------------------------------------------------------------------------
def move_upper_right
pos = []
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y-1))
pos.push(@x,@y)
@x += 1
@y -= 1
if @number == 1
$game_subplayer2.move(pos)
elsif @number == 2
$game_subplayer3.move(pos)
end
@move_failed = false
else
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ● キャラクター衝突判定
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
for event in $game_map.events_xy(x, y) # イベントの座標と一致
unless event.through # すり抜け OFF?
return true if self.is_a?(Game_Event) # 自分がイベント
return true if event.priority_type == 1 # 相手が通常キャラ
end
end
if @priority_type == 1 # 自分が通常キャラ
return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致
return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致
end
return false
end
end
页:
[1]