public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers
Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: KSetTilesets XP
  • Original author: kyonides
  • Original date: April 29, 2023
  • Source thread: https://forums.rpgmakerweb.com/threads/ksettilesets-xp.157064/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS Scripts (RMXP)

Summary

KSetTilesets XP Version 1.0.0 by Kyonides Arkanthes​ Introduction

Archived First Post

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.

DOWNLOAD DEMO

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.

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

License / Terms Note

Include my nickname in your game credits. You could include an URL to the website where you found this scriptlet.

Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#rgss#script-archive

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar