KSetTilesets XP
Version 1.0.0
by Kyonides Arkanthes
Introduction
This scriptlet should let you set a new tileset as the default one for any given map via script call.
The main idea behind it is to replace the default tileset with another one with some tiles changed for any specific reason, like different house facades or withered trees or an open well or all of them at the same time.
It is pretty much like a method to stop making dozens of events to cover those areas. This might be especially useful if the changes are supposed to last for a long period of time or even for the rest of your game.
It DOES refresh the current map and its spriteset.
The script will also work on other maps, obviously.
Warning
If you have implemented other scripts that have changed how the Game_Map class works, make sure you place this script above all of them.
The Script
Ruby:
# * KSetTilesets XP * # # Scripter : Kyonides Arkanthes # v1.0.0 - 2024-05-02 # * Warning! * # # If you have implemented other scripts that have changed how the Game_Map # class works, make sure you place this script above all of them. # It should let you completely replace your current map's tileset with another # one that shares similar passability and other settings, while retaining all # of the changes you have made to its actual tiles. # * Script Calls * # # Both script calls will refresh the target map's Tileset Data # IF the new MapID matches with the current MapID. # - Set a new Tileset for MapID n # $game_map.change_tileset(map_id, tileset_id) # - Remove any new Tileset for MapID n # $game_map.default_tileset(map_id) class Game_Map alias :kyon_tileset_sw_gm_map_init :initialize def initialize kyon_tileset_sw_gm_map_init @tilesets = {} end def setup(map_id) @map_id = map_id @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id)) setup_tileset setup_events setup_fog setup_scroll end def find_current_tileset @tilesets[@map_id] || @map.tileset_id end def setup_tileset tileset_id = find_current_tileset tileset = $data_tilesets[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 end def setup_events @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 end def setup_fog @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 end def setup_scroll @display_x = 0 @display_y = 0 @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end def change_tileset(map_id, tileset_id) return if tileset_id == 0 or @tilesets[map_id] == tileset_id @tilesets[map_id] = tileset_id setup_tileset if @map_id == map_id end def default_tileset(map_id) return unless @tilesets[map_id] @tilesets[map_id] = nil setup_tileset if @map_id == map_id end attr_reader :tilesets end 复制代码
Terms & Conditions
Free for use in your game projects.
Include my nickname in your game credits.
You could include an URL to the website where you found this scriptlet.
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/ksettilesets-xp.157064/