Class: Game_Map
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb
Overview
Describe the Map processing
Constant Summary collapse
- ENC_FREQ_DEC =
The list of ability that decrease the encounter frequency
%i[white_smoke quick_feet stench]
- ENC_FREQ_INC =
The list of ability that increase the encounter frequency
%i[no_guard illuminate arena_trap]
- ENC_FREQ_DEC_HAIL =
Ability that decrese the encounter during hail weather
[:snow_cloak]
- ENC_FREQ_DEC_SANDSTORM =
Ability that decrese the encounter during sandstorm weather
[:sand_veil]
- MACH_BIKE_BGM =
Audiofile to play when the player is on mach bike
RPG::AudioFile.new('09 Bicycle', 100, 100)
- ACRO_BIKE_BGM =
Audiofile to play when the player is on acro bike
MACH_BIKE_BGM.clone
- PATH_FINDING_ENABLED =
If the Path Finding system is enabled
true
- CenterPlayer =
If the player is always on the center of the screen
Configs.display.is_player_always_centered
- NUM_TILE_VIEW_Y =
Number of tiles the player can see in x
15
- NUM_TILE_VIEW_X =
Number of tiles the player can see in y
20
- FOLLOWER_ID_REGEXP =
Regular expression catching follower id
/\[follow=([0-9]+)\]/
- TERRAIN_TAGS_TABLE =
Convert terrain tag to location symbol
{ GameData::SystemTags::TGrass => :grass, GameData::SystemTags::TTallGrass => :grass, GameData::SystemTags::HeadButt => :grass, GameData::SystemTags::TSnow => :snow, GameData::SystemTags::TPond => :shallow_water, GameData::SystemTags::TWetSand => :shallow_water, GameData::SystemTags::SwampBorder => :shallow_water, GameData::SystemTags::DeepSwamp => :shallow_water, GameData::SystemTags::TSand => :desert, GameData::SystemTags::TCave => :cave, GameData::SystemTags::TMount => :cave, GameData::SystemTags::TIce => :icy_cave, GameData::SystemTags::TSea => :water, GameData::SystemTags::WaterFall => :water, GameData::SystemTags::RapidsL => :water, GameData::SystemTags::RapidsD => :water, GameData::SystemTags::RapidsU => :water, GameData::SystemTags::RapidsR => :water }
- IVAR_TO_REMOVE_FROM_SAVE_FILE =
List of variable to remove in order to keep the map data safe
%i[@map @tileset_name @autotile_names @panorama_name @panorama_hue @fog_name @fog_hue @fog_opacity @fog_blend_type @fog_zoom @fog_sx @fog_sy @battleback_name @passages @priorities @terrain_tags @events @common_events @system_tags]
Instance Attribute Summary collapse
-
#autotile_names
オートタイル ファイル名.
-
#battleback_name
バトルバック ファイル名.
-
#display_x
表示 X 座標 * 128.
-
#display_y
表示 Y 座標 * 128.
-
#event_erased ⇒ Boolean
If an event has been erased (helps removing it).
-
#events ⇒ Hash{Integer => Game_Event}
readonly
All the living events.
-
#events_sym_to_id ⇒ Hash<Symbol, Integer>
Return the hash of symbol associate to event id.
-
#fog_blend_type
フォグ ブレンド方法.
-
#fog_hue
フォグ 色相.
-
#fog_name
フォグ ファイル名.
-
#fog_opacity
フォグ 不透明度.
-
#fog_ox
readonly
フォグ 原点 X 座標.
-
#fog_oy
readonly
フォグ 原点 Y 座標.
-
#fog_sx
フォグ SX.
-
#fog_sy
フォグ SY.
-
#fog_tone
readonly
フォグ 色調.
-
#fog_zoom
フォグ 拡大率.
-
#maplinker_disabled ⇒ Boolean
readonly
If the maplinker was disabled when the map was setup.
-
#need_refresh
リフレッシュ要求フラグ.
-
#panorama_hue
パノラマ 色相.
-
#panorama_name
パノラマ ファイル名.
-
#passages
readonly
通行 テーブル.
-
#priorities
readonly
プライオリティ テーブル.
-
#terrain_tags
readonly
地形タグ テーブル.
-
#tileset_name
タイルセット ファイル名.
Instance Method Summary collapse
-
#autoplay
Auto play bgm and bgs of the map if defined.
-
#begin_save
Method that prevent non wanted data save of the Game_Map object.
-
#bush?(x, y) ⇒ Boolean
Tells if the tile is a bush tile.
-
#counter?(x, y) ⇒ Boolean
カウンター判定 (no idea, need GTranslate).
-
#data ⇒ Table
Returns the tile matrix of the Map.
-
#encounter_list
deprecated
Deprecated.
Not used by the Core of PSDK because not precise enough to be used
-
#encounter_step ⇒ Integer
Returns the encounter step of the map (including ability modifier).
-
#end_save
Method that end the save state of the Game_Map object.
-
#get_tile(x, y) ⇒ Integer
Retrieve the id of a specific tile.
-
#height ⇒ Integer
Returns the height of the map.
-
#initialize ⇒ Game_Map
constructor
Initialize the default Game_Map object.
-
#jump_passable?(x, y, d) ⇒ Boolean
Check if the player can jump a case with the acro bike.
-
#load_systemtags
Loads the SystemTags of the map.
-
#location_type(x, y) ⇒ Symbol
Return the current location type.
-
#map_id ⇒ Integer
Returns the ID of the Map.
-
#passable?(x, y, d, self_event = nil) ⇒ Boolean
Tells if the tile front/current tile is passsable or not.
-
#refresh
Refresh events and common events of the map.
-
#rmxp_encounter_steps ⇒ Integer
Returns the encounter steps from RMXP data.
-
#scroll_down(distance, is_priority = false)
Scrolls the map down.
-
#scroll_left(distance, is_priority = false)
Scrolls the map left.
-
#scroll_right(distance, is_priority = false)
Scrolls the map right.
-
#scroll_up(distance, is_priority = false)
Scrolls the map up.
-
#scrolling? ⇒ Boolean
is the map scrolling ?.
-
#setup(map_id)
setup the Game_Map object with the right Map data.
-
#start_fog_opacity_change(opacity, duration)
Starts a fog opacity change process.
-
#start_fog_tone_change(tone, duration)
Starts a fog tone change process.
-
#start_scroll(direction, distance, speed, x_priority = false, y_priority = false)
Starts a scroll processing.
-
#system_tag(x, y) ⇒ Integer
Retrieve the ID of the SystemTag on a specific tile.
-
#system_tag_here?(x, y, tag) ⇒ Boolean
Check if a specific SystemTag is present on a specific tile.
-
#terrain_tag(x, y) ⇒ Integer?
Returns the tag of the tile.
-
#update
Update the Map processing.
-
#valid?(x, y) ⇒ Boolean
Tells if the x,y coordinate is valid or not (inside of bounds).
-
#width ⇒ Integer
Returns the width of the map.
Constructor Details
#initialize ⇒ Game_Map
Initialize the default Game_Map object
55 56 57 58 59 60 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 55 def initialize @map_id = 0 @display_x = 0 @display_y = 0 @maplinker_disabled = false end |
Instance Attribute Details
#autotile_names
オートタイル ファイル名
27 28 29 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 27 def autotile_names @autotile_names end |
#battleback_name
バトルバック ファイル名
37 38 39 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 37 def battleback_name @battleback_name end |
#display_x
表示 X 座標 * 128
38 39 40 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 38 def display_x @display_x end |
#display_y
表示 Y 座標 * 128
39 40 41 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 39 def display_y @display_y end |
#event_erased ⇒ Boolean
If an event has been erased (helps removing it)
6 7 8 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 6 def event_erased @event_erased end |
#events ⇒ Hash{Integer => Game_Event} (readonly)
Returns all the living events.
45 46 47 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 45 def events @events end |
#events_sym_to_id ⇒ Hash<Symbol, Integer>
Return the hash of symbol associate to event id
48 49 50 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 48 def events_sym_to_id @events_sym_to_id end |
#fog_blend_type
フォグ ブレンド方法
33 34 35 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 33 def fog_blend_type @fog_blend_type end |
#fog_hue
フォグ 色相
31 32 33 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 31 def fog_hue @fog_hue end |
#fog_name
フォグ ファイル名
30 31 32 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 30 def fog_name @fog_name end |
#fog_opacity
フォグ 不透明度
32 33 34 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 32 def fog_opacity @fog_opacity end |
#fog_ox (readonly)
フォグ 原点 X 座標
49 50 51 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 49 def fog_ox @fog_ox end |
#fog_oy (readonly)
フォグ 原点 Y 座標
50 51 52 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 50 def fog_oy @fog_oy end |
#fog_sx
フォグ SX
35 36 37 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 35 def fog_sx @fog_sx end |
#fog_sy
フォグ SY
36 37 38 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 36 def fog_sy @fog_sy end |
#fog_tone (readonly)
フォグ 色調
51 52 53 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 51 def fog_tone @fog_tone end |
#fog_zoom
フォグ 拡大率
34 35 36 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 34 def fog_zoom @fog_zoom end |
#maplinker_disabled ⇒ Boolean (readonly)
Returns if the maplinker was disabled when the map was setup.
53 54 55 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 53 def maplinker_disabled @maplinker_disabled end |
#need_refresh
リフレッシュ要求フラグ
40 41 42 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 40 def need_refresh @need_refresh end |
#panorama_hue
パノラマ 色相
29 30 31 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 29 def panorama_hue @panorama_hue end |
#panorama_name
パノラマ ファイル名
28 29 30 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 28 def panorama_name @panorama_name end |
#passages (readonly)
通行 テーブル
41 42 43 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 41 def passages @passages end |
#priorities (readonly)
プライオリティ テーブル
42 43 44 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 42 def priorities @priorities end |
#terrain_tags (readonly)
地形タグ テーブル
43 44 45 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 43 def @terrain_tags end |
#tileset_name
タイルセット ファイル名
26 27 28 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 26 def tileset_name @tileset_name end |
Instance Method Details
#autoplay
Auto play bgm and bgs of the map if defined
198 199 200 201 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 198 def autoplay $game_system.bgm_play(current_bgm) if autoplay_bgm? $game_system.bgs_play(current_bgs) if autoplay_bgs? end |
#begin_save
Method that prevent non wanted data save of the Game_Map object
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 166 def begin_save Pathfinding.save save_follower save_events arr = [] IVAR_TO_REMOVE_FROM_SAVE_FILE.each do |ivar_name| arr << instance_variable_get(ivar_name) remove_instance_variable(ivar_name) end arr << $game_player.follower $game_player.instance_variable_set(:@follower, nil) $TMP_MAP_DATA = arr end |
#bush?(x, y) ⇒ Boolean
Tells if the tile is a bush tile
341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 341 def bush?(x, y) if @map_id != 0 2.downto(0) do |i| tile_id = data[x, y, i] if tile_id.nil? return false elsif @passages[tile_id] & 0x40 == 0x40 return true end end end return false end |
#counter?(x, y) ⇒ Boolean
カウンター判定 (no idea, need GTranslate)
359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 359 def counter?(x, y) if @map_id != 0 2.downto(0) do |i| tile_id = data[x, y, i] if tile_id.nil? return false elsif @passages[tile_id] & 0x80 == 0x80 return true end end end return false end |
#data ⇒ Table
Returns the tile matrix of the Map
193 194 195 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 193 def data return @map.data end |
#encounter_list
Not used by the Core of PSDK because not precise enough to be used
Returns the encounter list
161 162 163 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 161 def encounter_list return @map.encounter_list end |
#encounter_step ⇒ Integer
Returns the encounter step of the map (including ability modifier)
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 173 def encounter_step return rmxp_encounter_steps unless $actors ability = $actors[0]&.ability_db_symbol || :__undef__ # the first pokemon in the party's ability # if the ability matches the encounter increasing ability the encounter rate is doubled return rmxp_encounter_steps / 2 if ENC_FREQ_INC.include?(ability) # if the ability matches the encounter lowering ability the encounter rate is halved if ENC_FREQ_DEC.include?(ability) || (ENC_FREQ_DEC_HAIL.include?(ability) && $env.hail?) || (ENC_FREQ_DEC_SANDSTORM.include?(ability) && $env.sandstorm?) return rmxp_encounter_steps * 2 end return rmxp_encounter_steps # else the normal encounter rate is returned end |
#end_save
Method that end the save state of the Game_Map object
182 183 184 185 186 187 188 189 190 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 182 def end_save arr = $TMP_MAP_DATA IVAR_TO_REMOVE_FROM_SAVE_FILE.each_with_index do |ivar_name, index| instance_variable_set(ivar_name, arr[index]) end $game_player.instance_variable_set(:@follower, arr.last) unsave_followers @events_info = nil end |
#get_tile(x, y) ⇒ Integer
Retrieve the id of a specific tile
61 62 63 64 65 66 67 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 61 def get_tile(x, y) 2.downto(0) do |i| tile = data[x, y, i] return tile if tile and tile > 0 end return 0 end |
#height ⇒ Integer
Returns the height of the map
155 156 157 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 155 def height return @map.height end |
#jump_passable?(x, y, d) ⇒ Boolean
Check if the player can jump a case with the acro bike
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 75 def jump_passable?(x, y, d) z = $game_player.z new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) sys_tag = system_tag(new_x, new_y) = GameData::SystemTags if z <= 1 and (system_tag(x, y) == ::AcroBike or sys_tag == ::AcroBike) return true elsif z > 1 and (Game_Player::AccroTag.include?(sys_tag) or sys_tag == ::BridgeUD) return true end case d when 2 new_d = 8 when 6 new_d = 4 when 4 new_d = 6 else new_d = 2 end # 与えられた座標がマップ外の場合 unless valid?(x, y) and valid?(new_x, new_y) # 通行不可 return false end # 方向 (0,2,4,6,8,10) から 障害物ビット (0,1,2,4,8,0) に変換 bit = (1 << (d / 2 - 1)) & 0x0f bit2 = (1 << (new_d / 2 - 1)) & 0x0f # レイヤーの上から順に調べるループ 2.downto(0) do |i| # タイル ID を取得 tile_id = data[x, y, i] tile_id2 = data[new_x, new_y, i] if @passages[tile_id] & bit != 0 or @passages[tile_id2] & bit2 != 0 # 通行不可 return false elsif @priorities[tile_id] == 0 # 通行可 return true end end # 通行可 return true end |
#load_systemtags
Loads the SystemTags of the map
51 52 53 54 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 51 def $data_system_tags[@map.tileset_id] ||= Array.new($data_tilesets[@map.tileset_id].priorities.xsize, 0) @system_tags = $data_system_tags[@map.tileset_id] end |
#location_type(x, y) ⇒ Symbol
Return the current location type
123 124 125 126 127 128 129 130 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 123 def location_type(x, y) zone = $env.current_zone_data location = zone.global_location_type if zone.respond_to?(:global_location_type) # @todo add global_location_type to Studio::Zone location ||= TERRAIN_TAGS_TABLE.select { |tag, _location| system_tag_here?(x, y, tag) }.values[0] location ||= zone.default_location_type if zone.respond_to?(:default_location_type) # @todo add default_location_type to Studio::Zone location ||= :__undef__ return location end |
#map_id ⇒ Integer
Returns the ID of the Map
143 144 145 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 143 def map_id return @map_id end |
#passable?(x, y, d, self_event = nil) ⇒ Boolean
Tells if the tile front/current tile is passsable or not
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 282 def passable?(x, y, d, self_event = nil) # 与えられた座標がマップ外の場合 unless valid?(x, y) # 通行不可 return false end # 方向 (0,2,4,6,8,10) から 障害物ビット (0,1,2,4,8,0) に変換 bit = (1 << (d / 2 - 1)) & 0x0f # すべてのイベントでループ events.each_value do |event| # 自分以外のタイルと座標が一致した場合 if (event.tile_id >= 0) && (event != self_event) && (event.x == x) && (event.y == y) && !event.through # 障害物ビットがセットされている場合 if @passages[event.tile_id] & bit != 0 # 通行不可 return false # 全方向の障害物ビットがセットされている場合 elsif @passages[event.tile_id] & 0x0f == 0x0f # 通行不可 return false # それ以外で プライオリティが 0 の場合 elsif @priorities[event.tile_id] == 0 # 通行可 return true end end end # レイヤーの上から順に調べるループ 2.downto(0) do |i| # タイル ID を取得 tile_id = data[x, y, i] # タイル ID 取得失敗 if tile_id.nil? # 通行不可 return false # 障害物ビットがセットされている場合 elsif @passages[tile_id] & bit != 0 # 通行不可 return false # 全方向の障害物ビットがセットされている場合 elsif @passages[tile_id] & 0x0f == 0x0f # 通行不可 return false # それ以外で プライオリティが 0 の場合 elsif @priorities[tile_id] == 0 # 通行可 return true end end # 通行可 return true end |
#refresh
Refresh events and common events of the map
204 205 206 207 208 209 210 211 212 213 214 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 204 def refresh # マップ ID が有効なら if @map_id > 0 # すべてのマップイベントをリフレッシュ @events.each_value(&:refresh) # すべてのコモンイベントをリフレッシュ @common_events.each_value(&:refresh) end # リフレッシュ要求フラグをクリア @need_refresh = false end |
#rmxp_encounter_steps ⇒ Integer
Returns the encounter steps from RMXP data
167 168 169 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 167 def rmxp_encounter_steps @map.encounter_step end |
#scroll_down(distance, is_priority = false)
Scrolls the map down
219 220 221 222 223 224 225 226 227 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 219 def scroll_down(distance, is_priority = false) return if @scroll_y_priority && !is_priority if @maplinker_disabled @display_y = (@display_y + distance).clamp(0, (height - NUM_TILE_VIEW_Y) * 128) else @display_y += distance end end |
#scroll_left(distance, is_priority = false)
Scrolls the map left
232 233 234 235 236 237 238 239 240 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 232 def scroll_left(distance, is_priority = false) return if @scroll_x_priority && !is_priority if @maplinker_disabled @display_x = (@display_x - distance).clamp(0, @display_x) else @display_x -= distance end end |
#scroll_right(distance, is_priority = false)
Scrolls the map right
245 246 247 248 249 250 251 252 253 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 245 def scroll_right(distance, is_priority = false) return if @scroll_x_priority && !is_priority if @maplinker_disabled @display_x = (@display_x + distance).clamp(0, (width - NUM_TILE_VIEW_X) * 128) else @display_x += distance end end |
#scroll_up(distance, is_priority = false)
Scrolls the map up
258 259 260 261 262 263 264 265 266 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 258 def scroll_up(distance, is_priority = false) return if @scroll_y_priority && !is_priority if @maplinker_disabled @display_y = (@display_y - distance).clamp(0, @display_y) else @display_y -= distance end end |
#scrolling? ⇒ Boolean
is the map scrolling ?
407 408 409 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 407 def scrolling? return @scroll_rest > 0 end |
#setup(map_id)
setup the Game_Map object with the right Map data
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 64 def setup(map_id) Yuki::ElapsedTime.start(:map_loading) @map_id = map_id # We save events to make sure they'll be correctly transfered on the with the MapLinker save_events_offset unless @events_info # We store the new state of the map linker enable state @maplinker_disabled = $game_switches[Yuki::Sw::MapLinkerDisabled] # マップをファイルからロードし、@map に設定 @map = Yuki::MapLinker.load_map(@map_id) Yuki::ElapsedTime.show(:map_loading, 'MapLinker.load_map took') # 公開インスタンス変数にタイルセットの情報を設定 tileset = $data_tilesets[@map.tileset_id] # -- Scheduler.start(:on_getting_tileset_name) @tileset_name = Yuki::MapLinker.tileset_name # -- get_tileset_name($game_temp.tileset_name || tileset.tileset_name) # -- $game_temp.tileset_name = nil @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 # Force the first tile to be properly configured @passages[0] = 0 @priorities[0] = 5 @terrain_tags = tileset. # 表示座標を初期化 @display_x = 0 @display_y = 0 # リフレッシュ要求フラグをクリア @need_refresh = false # マップイベントのデータを設定 env = $env # @type [Hash{ Integer => Game_Event }] @events = {} @events_sym_to_id = { player: -1 } @map.events.each do |i, event| next if env.get_event_delete_state(i) event.name.force_encoding(Encoding::UTF_8) # £EncodingPatch e = @events[i] = Game_Event.new(@map_id, event) if e.sym_alias log_error("Alias #{e.sym_alias} appear multiple time in the map #{@map_id}.\n\tPlease use uniq aliases.") if @events_sym_to_id.key?(e.sym_alias) @events_sym_to_id[e.sym_alias] = i end end load_events load_following_events Yuki::ElapsedTime.show(:map_loading, 'Loading events took') # コモンイベントのデータを設定 @common_events = {} 1.upto($data_common_events.size - 1) do |i| @common_events[i] = Game_CommonEvent.new(i) end Yuki::ElapsedTime.show(:map_loading, 'Loading common events took') # フォグの各情報を初期化 @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 load_follower if @next_setup_followers end |
#start_fog_opacity_change(opacity, duration)
Starts a fog opacity change process
423 424 425 426 427 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 423 def start_fog_opacity_change(opacity, duration) @fog_opacity_target = opacity * 1.0 @fog_opacity_duration = duration @fog_opacity = @fog_opacity_target if @fog_opacity_duration == 0 end |
#start_fog_tone_change(tone, duration)
Starts a fog tone change process
414 415 416 417 418 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 414 def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration @fog_tone = @fog_tone_target.clone if @fog_tone_duration == 0 end |
#start_scroll(direction, distance, speed, x_priority = false, y_priority = false)
Starts a scroll processing
397 398 399 400 401 402 403 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 397 def start_scroll(direction, distance, speed, x_priority = false, y_priority = false) @scroll_direction = direction @scroll_rest = distance * 128 @scroll_speed = speed @scroll_x_priority = x_priority @scroll_y_priority = y_priority end |
#system_tag(x, y) ⇒ Integer
Retrieve the ID of the SystemTag on a specific tile
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 13 def system_tag(x, y) return Yuki::MapLinker.system_tag(x, y) unless valid?(x, y) if @map_id != 0 tiles = data 2.downto(0) do |i| tile_id = tiles[x, y, i] return 0 unless tile_id tag_id = @system_tags[tile_id] return tag_id if tag_id && tag_id > 0 end end return 0 end |
#system_tag_here?(x, y, tag) ⇒ Boolean
Check if a specific SystemTag is present on a specific tile
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00650 Game_Map_Ext.rb', line 35 def system_tag_here?(x, y, tag) return Yuki::MapLinker.system_tag_here?(x, y) unless valid?(x, y) if @map_id != 0 tiles = data 2.downto(0) do |i| tile_id = tiles[x, y, i] next unless tile_id return true if @system_tags[tile_id] == tag end end return false end |
#terrain_tag(x, y) ⇒ Integer?
Returns the tag of the tile
377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 377 def terrain_tag(x, y) if @map_id != 0 2.downto(0) do |i| tile_id = data[x, y, i] if tile_id.nil? return 0 elsif @terrain_tags[tile_id] && (@terrain_tags[tile_id] > 0) return @terrain_tags[tile_id] end end end return 0 end |
#update
Update the Map processing
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 430 def update Pathfinding.update if PATH_FINDING_ENABLED # 必要ならマップをリフレッシュ refresh if $game_map.need_refresh # スクロール中の場合 if @scroll_rest > 0 # スクロール速度からマップ座標系での距離に変換 distance = 2**@scroll_speed # スクロールを実行 case @scroll_direction when 2 # 下 scroll_down(distance, @scroll_y_priority) when 4 # 左 scroll_left(distance, @scroll_x_priority) when 6 # 右 scroll_right(distance, @scroll_x_priority) when 8 # 上 scroll_up(distance, @scroll_y_priority) end # スクロールした距離を減算 @scroll_rest -= distance @scroll_y_priority = @scroll_x_priority = nil unless scrolling? end # >Partie édition des SystemTag # return if Yuki::SystemTag.running? # マップイベントを更新 @events.each_value(&:update) # コモンイベントを更新 @common_events.each_value(&:update) # t2=Time.new # p t2-t1 if Input.trigger?(Input::F6) # フォグのスクロール処理 @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 # フォグの色調変更処理 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end # フォグの不透明度変更処理 if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end end |
#valid?(x, y) ⇒ Boolean
Tells if the x,y coordinate is valid or not (inside of bounds)
272 273 274 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 272 def valid?(x, y) return ((x >= 0) && (x < width) && (y >= 0) && (y < height)) end |
#width ⇒ Integer
Returns the width of the map
149 150 151 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00600 Game_Map.rb', line 149 def width return @map.width end |