设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 109|回复: 0

[转载发布] KSetTilesets XP

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    6120

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    26247
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    33261

    灌水之王

    发表于 2026-7-16 14:33:27 | 显示全部楼层 |阅读模式
    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:       
    1. # * KSetTilesets XP * #
    2. #   Scripter : Kyonides Arkanthes
    3. #   v1.0.0 - 2024-05-02
    4. # * Warning! * #
    5. # If you have implemented other scripts that have changed how the Game_Map
    6. # class works, make sure you place this script above all of them.
    7. # It should let you completely replace your current map's tileset with another
    8. # one that shares similar passability and other settings, while retaining all
    9. # of the changes you have made to its actual tiles.
    10. # * Script Calls * #
    11. #  Both script calls will refresh the target map's Tileset Data
    12. #  IF the new MapID matches with the current MapID.
    13. # - Set a new Tileset for MapID n
    14. #   $game_map.change_tileset(map_id, tileset_id)
    15. # - Remove any new Tileset for MapID n
    16. #   $game_map.default_tileset(map_id)
    17. class Game_Map
    18.   alias :kyon_tileset_sw_gm_map_init :initialize
    19.   def initialize
    20.     kyon_tileset_sw_gm_map_init
    21.     @tilesets = {}
    22.   end
    23.   def setup(map_id)
    24.     @map_id = map_id
    25.     @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
    26.     setup_tileset
    27.     setup_events
    28.     setup_fog
    29.     setup_scroll
    30.   end
    31.   def find_current_tileset
    32.     @tilesets[@map_id] || @map.tileset_id
    33.   end
    34.   def setup_tileset
    35.     tileset_id = find_current_tileset
    36.     tileset = $data_tilesets[tileset_id]
    37.     @tileset_name = tileset.tileset_name
    38.     @autotile_names = tileset.autotile_names
    39.     @panorama_name = tileset.panorama_name
    40.     @panorama_hue = tileset.panorama_hue
    41.     @fog_name = tileset.fog_name
    42.     @fog_hue = tileset.fog_hue
    43.     @fog_opacity = tileset.fog_opacity
    44.     @fog_blend_type = tileset.fog_blend_type
    45.     @fog_zoom = tileset.fog_zoom
    46.     @fog_sx = tileset.fog_sx
    47.     @fog_sy = tileset.fog_sy
    48.     @battleback_name = tileset.battleback_name
    49.     @passages = tileset.passages
    50.     @priorities = tileset.priorities
    51.     @terrain_tags = tileset.terrain_tags
    52.   end
    53.   def setup_events
    54.     @need_refresh = false
    55.     @events = {}
    56.     for i in @map.events.keys
    57.       @events[i] = Game_Event.new(@map_id, @map.events[i])
    58.     end
    59.     @common_events = {}
    60.     for i in 1...$data_common_events.size
    61.       @common_events[i] = Game_CommonEvent.new(i)
    62.     end
    63.   end
    64.   def setup_fog
    65.     @fog_ox = 0
    66.     @fog_oy = 0
    67.     @fog_tone = Tone.new(0, 0, 0, 0)
    68.     @fog_tone_target = Tone.new(0, 0, 0, 0)
    69.     @fog_tone_duration = 0
    70.     @fog_opacity_duration = 0
    71.     @fog_opacity_target = 0
    72.   end
    73.   def setup_scroll
    74.     @display_x = 0
    75.     @display_y = 0
    76.     @scroll_direction = 2
    77.     @scroll_rest = 0
    78.     @scroll_speed = 4
    79.   end
    80.   def change_tileset(map_id, tileset_id)
    81.     return if tileset_id == 0 or @tilesets[map_id] == tileset_id
    82.     @tilesets[map_id] = tileset_id
    83.     setup_tileset if @map_id == map_id
    84.   end
    85.   def default_tileset(map_id)
    86.     return unless @tilesets[map_id]
    87.     @tilesets[map_id] = nil
    88.     setup_tileset if @map_id == map_id
    89.   end
    90.   attr_reader :tilesets
    91. 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/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-27 07:01 , Processed in 0.068777 second(s), 58 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表