Agrandir ou rendre plus petit le charaset du héro

Publié le par Cidragon6

Il sera possible grâce à ce script de modifier tous simplement la taille de votre personnage principal, et ce, trés facilement.

Aprés avoir mis ce script, il vous suffira par exemple et mettre *W a la fin du nom de votre carte afin que le héro devienne plus petit, puis *B pour qu'il devienne plus grand ! C'est idéal de devenir petit pour les cartes du monde !

De plus, il y a incorposé dans ce script celui qui permet d'activer ou nom le system qui permet de faire suivre les autres personnages de l'équipe en file indienne...

Qui est désactivable grâce a l'interrupteur 1...

Pour que le héros soit grand, mettez à la fin du nom de votre carte : *B ( ex : Map001*B)

Pour que le héros soit petit, mettez à la fin du nom de votre carte : *W (ex : Map002*W)

Voici les scripts :


Créez un nouveau script et nommez le "Caterpillar"


TRAIN_ACTOR_TRANSPARENT_SWITCH = true
TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX = 20
# ------------------------------------
DOWN_LEFT = 1
DOWN_RIGHT = 3
UP_LEFT = 7
UP_RIGHT = 9
JUMP = 5
# ------------------------------------
class Game_Party_Actor < Game_Character
# ------------------------------------
def initialize
super()
@through = true
end
# ------------------------------------
def setup(actor)
if actor != nil
@character_name = actor.character_name
@character_hue = actor.character_hue
else
@character_name = ""
@character_hue = 0
end
@opacity = 255
@blend_type = 0
end
# ------------------------------------
def screen_z(height = 0)
if $game_player.x == @x and $game_player.y == @y
return $game_player.screen_z(height) - 1
end
super(height)
end
# ------------------------------------ 
def move_down(turn_enabled = true)
if turn_enabled
turn_down
end
if passable?(@x, @y, Input::DOWN)
turn_down
@y += 1
end
end
# ------------------------------------ 
def move_left(turn_enabled = true)
if turn_enabled
turn_left
end
if passable?(@x, @y, Input::LEFT)
turn_left
@x -= 1
end
end
# ------------------------------------
def move_right(turn_enabled = true)
if turn_enabled
turn_right
end
if passable?(@x, @y, Input::RIGHT)
turn_right
@x += 1
end
end
# ------------------------------------ 
def move_up(turn_enabled = true)
if turn_enabled
turn_up
end
if passable?(@x, @y, Input::UP)
turn_up
@y -= 1
end
end
# ------------------------------------
def move_lower_left
unless @direction_fix
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
end
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
@x -= 1
@y += 1
end
end
# ------------------------------------ 
def move_lower_right
unless @direction_fix
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
end
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
@x += 1
@y += 1
end
end
# ------------------------------------ 
def move_upper_left
unless @direction_fix
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
end
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
@x -= 1
@y -= 1
end
end
# ------------------------------------
def move_upper_right
unless @direction_fix
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
end
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
@x += 1
@y -= 1
end
end
# ------------------------------------
def set_move_speed(move_speed)
@move_speed = move_speed
end
end



class Spriteset_Map
# ------------------------------------
def setup_actor_character_sprites?
return @setup_actor_character_sprites_flag != nil
end
# ------------------------------------
def setup_actor_character_sprites(characters)
if !setup_actor_character_sprites?
index_game_player = 0
@character_sprites.each_index do |i|
if @character_sprites[i].character.instance_of?(Game_Player)
index_game_player = i
break
end
end
for character in characters.reverse
@character_sprites.unshift(
Sprite_Character.new(@viewport1, character)
)
end
@setup_actor_character_sprites_flag = true
end
end
end



class Scene_Map
# ------------------------------------
def setup_actor_character_sprites(characters)
@spriteset.setup_actor_character_sprites(characters)
end
end



class Game_Party
# ------------------------------------
def set_transparent_actors(transparent)
@transparent = transparent
end
# ------------------------------------
def setup_actor_character_sprites
if @characters == nil
@characters = []
for i in 1 .. 4
@characters.push(Game_Party_Actor.new)
end
end
if @actors_chach == nil
@actors_chach = []
end
if @actors_chach != @actors
@actors_chach = @actors.clone
for i in 1 .. 4
@characters[i - 1].setup(actors[i])
end
end
if $scene.instance_of?(Scene_Map)
$scene.setup_actor_character_sprites(@characters)
end
end
# ------------------------------------
def update_party_actors
setup_actor_character_sprites
transparent = $game_player.transparent
if transparent == false
if TRAIN_ACTOR_TRANSPARENT_SWITCH
transparent = $game_switches[TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX]
else
transparent = $game_player.transparent
end
end
for character in @characters
character.transparent = transparent
character.set_move_speed($game_player.get_move_speed)
character.update
end
end
# ------------------------------------
def moveto_party_actors( x, y )
setup_actor_character_sprites
for character in @characters
character.moveto( x, y )
end
if @move_list == nil
@move_list = []
end
for i in 0 .. 10
@move_list[i] = nil
end
end
def move_party_actors
if @move_list == nil
@move_list = []
for i in 0 .. 10
@move_list[i] = nil
end
end
@move_list.each_index do |i|
if @characters[i] != nil
case @move_list[i].type
when Input::DOWN
@characters[i].move_down(@move_list[i].args[0])
when Input::LEFT
@characters[i].move_left(@move_list[i].args[0])
when Input::RIGHT
@characters[i].move_right(@move_list[i].args[0])
when Input::UP
@characters[i].move_up(@move_list[i].args[0])
when DOWN_LEFT
@characters[i].move_lower_left
when DOWN_RIGHT
@characters[i].move_lower_right
when UP_LEFT
@characters[i].move_upper_left
when UP_RIGHT
@characters[i].move_upper_right
when JUMP
@characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
end
end
end
end



class Move_List_Element
# ------------------------------------
def initialize(type,args)
@type = type
@args = args
end
def type() return @type end
def args() return @args end
end
# ------------------------------------
def add_move_list(type,*args)
@move_list.unshift(Move_List_Element.new(type,args)).pop
end
# ------------------------------------
def move_down_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::DOWN,turn_enabled)
end
# ------------------------------------
def move_left_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::LEFT,turn_enabled)
end
# ------------------------------------
def move_right_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::RIGHT,turn_enabled)
end
# ------------------------------------
def move_up_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::UP,turn_enabled)
end
# ------------------------------------
def move_lower_left_party_actors
move_party_actors
add_move_list(DOWN_LEFT)
end
# ------------------------------------
def move_lower_right_party_actors
move_party_actors
add_move_list(DOWN_RIGHT)
end
# ------------------------------------
def move_upper_left_party_actors
move_party_actors
add_move_list(UP_LEFT)
end
# ------------------------------------
def move_upper_right_party_actors
move_party_actors
add_move_list(UP_RIGHT)
end
# ------------------------------------
def jump_party_actors(x_plus, y_plus)
move_party_actors
add_move_list(JUMP,x_plus, y_plus)
end
end



module Game_Player_Module
# ------------------------------------
def update
$game_party.update_party_actors
super
end
# ------------------------------------
def moveto( x, y )
super
$game_party.moveto_party_actors( x, y )
end
# ------------------------------------
def move_down(turn_enabled = true)
if passable?(@x, @y, Input::DOWN)
$game_party.move_down_party_actors(turn_enabled)
end
super(turn_enabled)
end
# ------------------------------------
def move_left(turn_enabled = true)
if passable?(@x, @y, Input::LEFT)
$game_party.move_left_party_actors(turn_enabled)
end
super(turn_enabled)
end
# ------------------------------------
def move_right(turn_enabled = true)
if passable?(@x, @y, Input::RIGHT)
$game_party.move_right_party_actors(turn_enabled)
end
super(turn_enabled)
end
# ------------------------------------
def move_up(turn_enabled = true)
if passable?(@x, @y, Input::UP)
$game_party.move_up_party_actors(turn_enabled)
end
super(turn_enabled)
end
# ------------------------------------
def move_lower_left
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
$game_party.move_lower_left_party_actors
end
super
end
# ------------------------------------
def move_lower_right
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
$game_party.move_lower_right_party_actors
end
super
end
# ------------------------------------
def move_upper_left
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
$game_party.move_upper_left_party_actors
end
super
end
# ------------------------------------
def move_upper_right
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
$game_party.move_upper_right_party_actors
end
super
end
# ------------------------------------
def jump(x_plus, y_plus)
new_x = @x + x_plus
new_y = @y + y_plus
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
$game_party.jump_party_actors(x_plus, y_plus)
end
super(x_plus, y_plus)
end
# ------------------------------------
def get_move_speed
return @move_speed
end
end


class Game_Player
include Game_Player_Module
end


 Créez un nouveau script au dessus de "Main" et appellez le "Sprite_Character"


#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
#
 キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを
# 監視し、スプライトの状態を自動的に変化させます。
#==============================================================================

class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# ●
公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :character #
キャラクター
#--------------------------------------------------------------------------
# ●
オブジェクト初期化
# viewport : ビューポート
# character : キャラクター (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["w_sm"]) # Here
@event_size = true # Here, ^ too
else # Here 
@event_size = false # Here
end # Here
if $game_map.worldmap # Here
@zoom_y = 0.3 # Here
@zoom_x = 0.3 # Here
elsif $game_map.bigger # Optional
@zoom_y = 1.9 # Optional
@zoom_x = 1.9 # Optional
else # Here
@zoom_y = 1 # Here
@zoom_x = 1 # Here
end # Here
update
end
#--------------------------------------------------------------------------
# ●
フレーム更新
#--------------------------------------------------------------------------
def update
super
#
タイル ID、ファイル名、色相のどれかが現在のものと異なる場合
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
#
タイル ID とファイル名、色相を記憶
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
#
タイル ID が有効な値の場合
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
#
タイル ID が無効な値の場合
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
if @character.is_a?(Game_Player) or @event_size or @character.is_a?(Game_Party_Actor) # Here, for Caterpillar users, if you don't use it:
# if @character.is_a?(Game_Player) or @event_size
self.zoom_x = @zoom_x # Here
self.zoom_y = @zoom_y # Here
end
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
#
スプライトの座標を設定
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

 Créez un nouveau script au dessus de "Main" et appellez le "Game_Player"

#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#
 プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================

class Game_Player < Game_Character
attr_accessor :move_speed # Here
#--------------------------------------------------------------------------
# ●
定数
#--------------------------------------------------------------------------
CENTER_X = (320 - 16) * 4 #
画面中央の X 座標 * 4
CENTER_Y = (240 - 16) * 4 #
画面中央の Y 座標 * 4
#--------------------------------------------------------------------------
# ●
通行可能判定
# x : X 座標
# y : Y 座標
# d : 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
#--------------------------------------------------------------------------
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
#
デバッグモードが ON かつ CTRL キーが押されている場合
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
#--------------------------------------------------------------------------
# ●
指定位置に移動
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
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
#
サイコロを 2 個振るイメージ
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
#--------------------------------------------------------------------------
# ●
リフレッシュ
#--------------------------------------------------------------------------
def refresh
@move_speed = move_speed # Here
#
パーティ人数が 0 人の場合
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 $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.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
#
ジャンプ中以外で、起動判定が正面のイベントなら
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)
# 1
タイル奥の座標を計算
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
#
全イベントのループ
for event in $game_map.events.values
#
イベントの座標とトリガーが一致した場合
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
#
ジャンプ中以外で、起動判定が正面のイベントなら
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
#
全イベントのループ
for event in $game_map.events.values
#
イベントの座標とトリガーが一致した場合
if event.x == x and event.y == y and [1,2].include?(event.trigger)
#
ジャンプ中以外で、起動判定が正面のイベントなら
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# ●
フレーム更新
#--------------------------------------------------------------------------
def update
#
ローカル変数に移動中かどうかを記憶
last_moving = moving?
#
移動中、イベント実行中、移動ルート強制中、
# メッセージウィンドウ表示中のいずれでもない場合
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
#
方向ボタンが押されていれば、その方向へプレイヤーを移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
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
#
デバッグモードが ON かつ CTRL キーが押されている場合を除き
unless $DEBUG and Input.press?(Input::CTRL)
#
エンカウント カウントダウン
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# C
ボタンが押された場合
if Input.trigger?(Input::C)
#
同位置および正面のイベント起動判定
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end

 Créez un nouveau script au dessus de "Main" et appelez le "Game_Map"

#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#
 マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
#--------------------------------------------------------------------------
# ●
公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :tileset_name #
タイルセット ファイル名
attr_accessor :autotile_names # オートタイル ファイル名
attr_accessor :panorama_name # パノラマ ファイル名
attr_accessor :panorama_hue # パノラマ 色相
attr_accessor :fog_name # フォグ ファイル名
attr_accessor :fog_hue # フォグ 色相
attr_accessor :fog_opacity # フォグ 不透明度
attr_accessor :fog_blend_type # フォグ ブレンド方法
attr_accessor :fog_zoom # フォグ 拡大率
attr_accessor :fog_sx # フォグ SX
attr_accessor :fog_sy #
フォグ SY
attr_accessor :battleback_name #
バトルバック ファイル名
attr_accessor :display_x # 表示 X 座標 * 128
attr_accessor :display_y #
表示 Y 座標 * 128
attr_accessor :need_refresh #
リフレッシュ要求フラグ
attr_reader :passages # 通行 テーブル
attr_reader :priorities # プライオリティ テーブル
attr_reader :terrain_tags # 地形タグ テーブル
attr_reader :events # イベント
attr_reader :fog_ox # フォグ 原点 X 座標
attr_reader :fog_oy # フォグ 原点 Y 座標
attr_reader :fog_tone # フォグ 色調
attr_accessor :worldmap # Here
attr_accessor :bigger # Optional
#--------------------------------------------------------------------------
# ●
オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@map_id = 0
@display_x = 0
@display_y = 0
@worldmap = false # Here
@bigger = false # Optional
end
#--------------------------------------------------------------------------
# ●
セットアップ
# map_id : マップ ID
#--------------------------------------------------------------------------
def setup(map_id)
#
マップ ID @map_id に記憶
@map_id = map_id
#
マップをファイルからロードし、@map に設定
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
if self.name.include?("*W") # Here
@bigger = false # Here
@worldmap = true # Optional
$game_player.move_speed = 2 # Optional
elsif self.name.include?("*B") # Optional
@worldmap = false # Optional
@bigger = true # Optional
$game_player.move_speed = 4 # Optional
else # Here
@worldmap = false # Here
@bigger = false # Optional
$game_player.move_speed = 4 # Optional
end # Here

#
公開インスタンス変数にタイルセットの情報を設定
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
#
表示座標を初期化
@display_x = 0
@display_y = 0
#
リフレッシュ要求フラグをクリア
@need_refresh = false
#
マップイベントのデータを設定
@events = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
end
#
コモンイベントのデータを設定
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
#
フォグの各情報を初期化
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
#
スクロール情報を初期化
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
#--------------------------------------------------------------------------
# ●
マップ ID の取得
#--------------------------------------------------------------------------
def map_id
return @map_id
end
#--------------------------------------------------------------------------
# ●
幅の取得
#--------------------------------------------------------------------------
def width
return @map.width
end
#--------------------------------------------------------------------------
# ●
高さの取得
#--------------------------------------------------------------------------
def height
return @map.height
end
#--------------------------------------------------------------------------
# ●
エンカウントリストの取得
#--------------------------------------------------------------------------
def encounter_list
return @map.encounter_list
end
#--------------------------------------------------------------------------
# ●
エンカウント歩数の取得
#--------------------------------------------------------------------------
def encounter_step
return @map.encounter_step
end
#--------------------------------------------------------------------------
# ●
マップデータの取得
#--------------------------------------------------------------------------
def data
return @map.data
end
#--------------------------------------------------------------------------
# ● BGM / BGS
自動切り替え
#--------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm
$game_system.bgm_play(@map.bgm)
end
if @map.autoplay_bgs
$game_system.bgs_play(@map.bgs)
end
end
#--------------------------------------------------------------------------
# ●
リフレッシュ
#--------------------------------------------------------------------------
def refresh
#
マップ ID が有効なら
if @map_id > 0
#
すべてのマップイベントをリフレッシュ
for event in @events.values
event.refresh
end
#
すべてのコモンイベントをリフレッシュ
for common_event in @common_events.values
common_event.refresh
end
end
#
リフレッシュ要求フラグをクリア
@need_refresh = false
end
#--------------------------------------------------------------------------
# ●
下にスクロール
# distance : スクロールする距離
#--------------------------------------------------------------------------
def scroll_down(distance)
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
#--------------------------------------------------------------------------
# ●
左にスクロール
# distance : スクロールする距離
#--------------------------------------------------------------------------
def scroll_left(distance)
@display_x = [@display_x - distance, 0].max
end
#--------------------------------------------------------------------------
# ●
右にスクロール
# distance : スクロールする距離
#--------------------------------------------------------------------------
def scroll_right(distance)
@display_x = [@display_x + distance, (self.width - 20) * 128].min
end
#--------------------------------------------------------------------------
# ●
上にスクロール
# distance : スクロールする距離
#--------------------------------------------------------------------------
def scroll_up(distance)
@display_y = [@display_y - distance, 0].max
end
#--------------------------------------------------------------------------
# ●
有効座標判定
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def valid?(x, y)
return (x >= 0 and x < width and y >= 0 and y < height)
end
#--------------------------------------------------------------------------
# ●
通行可能判定
# x : X 座標
# y : Y

Publicité

Publié dans Scripts RPG Makers XP

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article
B
Fonctionne pas, dommage..
Répondre