RGSS3 implemented in RMXP

RGSS3 implemented in RMXP


What is this?

RGSS3 implemented in RMXP, as per the tutorial in the eZine.

This is currently a very early form of what I hope will be a more solid demo, and will be edited.


What do I need to know?

1. You need to own both RPG Maker XP and RPG Maker VX Ace.
2. You need the VL Gothic font installed from RPG Maker VX Ace.
3. You need to copy the \Graphics\ and \Audio\ folders from the RMXP RTP into the project folder, as the RTP had to be turned off, and I didn't want to waste 20mb in the download. You'll probably find the two folders in: (Program Files)\Common Files\RGSS\


Download

http://afar.ws/hbgames/RGSS3_Test.zip


Credits

Enterbrain: RPG Maker VX Ace and XP
Poccil: Tilemap rewrite (viewtopic.php?p=365770#p365770)


Note

This is potentially useless as it's:

- For people who don't know how to use it, not explanatory enough about why it'd be cool.

- For people who do know how to use it, a pointless demo as they could set it up themselves.

But, it might be useful to somebody, and this thread can act as a talking point as to whether or not using RGSS3 in RMXP is a good idea, or a worthwhile venture at all.
I was a bit confounded by the instructions, so to expand:
You need to copy the Audio and Graphics from the RMXP RTP and the Fonts folder from the RMVXA RTP.

The download provides RGSS102e, to use RGSS301 you need to copy that in and change the Game.ini to have RGSS301.dll as the library to load

EDIT: Thank you for this Wyatt, I'll base my RGSS mods on this demo project so it is inline with the tutorials that everyone else is following
Ah sorry I should have explained that extra bit:

I renamed it RGSS102e.dll because when you save in XP the ini file is regenerated, with the wrong dll name. So I added RGSS301.dll but renamed it RGSS102e.dll. Probably a bad practice, but as it's in the folder and not in C:\WINDOWS I don't think it's a problem.
I originally thought this was to allow me to use VX/ACE scripts in RPG Maker XP. :D
I may write a tutorial on why you can't / how you can, but at that point you'd 've able to remake then anyway.
Sorry for potential advertising, but this tutorial led me to write a new game.exe for RGSS3, I'm currently looking at writing a cross version RGSS DLL and Player to unify RMXP, VX and VXA systems under one big compatibility layer, so this is something that is WIP.

Thanks again Wyatt for writing the tutorial, it directly inspired me to follow through with this plan.

viewtopic.php?f=179&p=913698#p913698

Edit: it's probably not worth saying, but for now that project relies on these instructions to run, so you'll have to follow this topic to get my game.exe working
Princess Amy wrote:
I may write a tutorial on why you can't / how you can, but at that point you'd 've able to remake then anyway.

I realize you can't, so yeah. It would have been nice due to Star not really wanting to leave XP due to the mapping. ;_;
I dunno how good/fast my version of the Tilemap rewrite script is, it was pretty fast for me, although map load times were increased, overall speed was almost the same as original RMXP Tilemap (at least at my PC, and it is quite crappy compared to today configurations). Take note that this is old, made back in 2010.

It was originally made for RMVX, but I think it could be used with RMVX Ace (or at least with little modification).

  1.  
  2. #=============================================================================
  3. # RMXP Tilemap Class
  4. # ---------------------------------------------------------------------------
  5. # Version 1.7
  6. # Author: Drago del Fato
  7. #=============================================================================
  8.  
  9. class Tilemap
  10.  
  11.   Autotiles = [
  12.     [[27, 28, 33, 34], [ 5, 28, 33, 34], [27,  6, 33, 34], [ 5,  6, 33, 34],
  13.      [27, 28, 33, 12], [ 5, 28, 33, 12], [27,  6, 33, 12], [ 5,  6, 33, 12]],
  14.     [[27, 28, 11, 34], [ 5, 28, 11, 34], [27,  6, 11, 34], [ 5,  6, 11, 34],
  15.      [27, 28, 11, 12], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12]],
  16.     [[25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
  17.      [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12]],
  18.     [[29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
  19.      [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46]],
  20.     [[25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
  21.      [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48]],
  22.     [[37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
  23.      [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8]]
  24.   ]
  25.  
  26.   attr_accessor :tileset
  27.   attr_accessor :autotiles
  28.   attr_accessor :priorities
  29.   attr_accessor :ox
  30.   attr_accessor :oy
  31.   attr_accessor :map_data
  32.  
  33.   def initialize(viewport)
  34.     @viewport = viewport
  35.     @tileset = nil
  36.     @map_data = nil
  37.     @priorities = nil
  38.     @autotiles = [nil, nil, nil, nil, nil, nil, nil]
  39.     @ox = 0
  40.     @oy = 0
  41.     @width = 0
  42.     @height = 0
  43.    
  44.     @visible = true
  45.    
  46.     @layers = []
  47.     @l1 = []
  48.     @a_layer = Sprite.new(@viewport)
  49.     @a_locs = nil
  50.    
  51.     @zsize = 0
  52.     @ysize = 0
  53.     @xsize = 0
  54.  
  55.     @disposed = false
  56.   end
  57.  
  58.   def priorities=(value)
  59.     @priorities = value
  60.     @xsize = @map_data.xsize - 1
  61.     @ysize = @map_data.ysize - 1
  62.     @zsize = @map_data.zsize - 1
  63.     @width = @map_data.xsize * 32
  64.     @height = @map_data.ysize * 32
  65.     @a_locs = Table.new(@map_data.xsize, @map_data.ysize, @map_data.zsize)
  66.     create_layers
  67.     draw_map
  68.   end
  69.  
  70.   def disposed?
  71.     return @disposed
  72.   end
  73.  
  74.   def dispose
  75.     return if self.disposed?
  76.     @layers.each{|layer| layer.bitmap = nil; layer.dispose}
  77.     @l1.each{|layer| layer.bitmap = nil; layer.dispose}
  78.     @autotiles.each{|autotile| autotile = nil}
  79.     @tileset = nil
  80.     @a_locs = nil
  81.     @priorities = nil
  82.     @map_data = nil
  83.     @flash_data = nil
  84.     @viewport = nil
  85.     @disposed = true
  86.   end
  87.  
  88.   def create_layers
  89.     max = -1
  90.     for x in 0..@priorities.xsize - 1
  91.       max = @priorities[x] if @priorities[x] > max
  92.     end
  93.    
  94.     for i in 0..max
  95.       @layers << Sprite.new(@viewport)
  96.       @layers[-1].z = 0
  97.       @layers[-1].bitmap = get_bitmap_size(@width, @height)
  98.     end
  99.    
  100.     @a_layer.z = 0
  101.     @a_layer.bitmap = get_bitmap_size(@width, @height)
  102.    
  103.   end
  104.  
  105.      # RMVX Bitmap Error Fix
  106.    def get_bitmap_size(width = 0, height = 0)
  107.      raise "Width or Height can't be 0 sized." if width == 0 || height == 0
  108.  
  109.      # This was originally a fix for a bug in RMVX where you cant create images bigger than 2000x2000
  110.      # it should be fixed in RMVX Ace though.
  111.      return Bitmap.new(width, height)
  112.      # Uncomment stuff below and comment the line above to enable the bug fix
  113.      # return Bitmap.new(width, height) if !defined?($TEST) # If rmxp then no need for fix
  114.      #if width < 1600 && height < 1600
  115.      #  return Bitmap.new(width, height)
  116.      #elsif width < 2241 && height < 1921
  117.      #  bitmap = Bitmap.new("Graphics/Pictures/size0")
  118.      #  bitmap.clear
  119.      #  return bitmap.clone
  120.      #elsif width < 3001 && height < 3001
  121.      #  bitmap = Bitmap.new("Graphics/Pictures/size1")
  122.      #  bitmap.clear
  123.      #  return bitmap.clone
  124.      #end
  125.    end
  126.    
  127.    
  128.    def draw_map
  129.      tmp_rect = Rect.new(0, 0, 0, 0)
  130.      for z in 0..@zsize
  131.        for y in 0..@ysize
  132.          for x in 0..@xsize
  133.            id = @map_data[x, y, z]
  134.            next if id == 0
  135.            
  136.            if max_frames(id) > 0 && id < 384
  137.              @a_locs[x, y, z] = id
  138.              frame = autotile_frame(id)
  139.              get_autotile(@a_layer.bitmap, x * 32, y * 32, id, frame)
  140.              next
  141.            end
  142.            
  143.            # Priority 1 is special so it's needed to go into separate sprite
  144.            if @priorities[id] == 1
  145.             @l1 << Sprite.new(@viewport)
  146.             @l1[-1].ox = @ox
  147.             @l1[-1].oy = @oy
  148.             @l1[-1].x = x * 32
  149.             @l1[-1].y = y * 32
  150.             @l1[-1].bitmap = Bitmap.new(32, 32)
  151.             if id >= 384
  152.              tmp_rect.set((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
  153.              @l1[-1].bitmap.blt(0, 0, @tileset, tmp_rect)
  154.             else
  155.              frame = autotile_frame(id)
  156.              get_autotile(@l1[-1].bitmap, 0, 0, id, frame)
  157.             end
  158.             @l1[-1].z = set_z(id, y)
  159.             next
  160.            end
  161.          
  162.            @layers[@priorities[id]].z = set_z(id, y)
  163.            
  164.            if id >= 384
  165.              
  166.              tmp_rect.set((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
  167.              @layers[@priorities[id]].bitmap.blt(x * 32, y * 32, @tileset, tmp_rect)
  168.            else
  169.              frame = autotile_frame(id)
  170.              get_autotile(@layers[@priorities[id]].bitmap, x * 32, y * 32, id, frame)
  171.            end
  172.          end
  173.        end
  174.      end
  175.      @layers[1].bitmap = nil if @l1.size > 0 # Free memory up if priority 1
  176.      @layers[0].z = 0
  177.      
  178.      # Free Memory
  179.      GC.start
  180.      
  181.      # Reset frames
  182.      Graphics.frame_reset
  183.    end
  184.    
  185.    def visible
  186.      return @visible
  187.    end
  188.    
  189.    def visible=(value)
  190.      @visible = value
  191.      @layers.each{|layer| layer.visible = value}
  192.      @l1.each{|layer| layer.visible = value}
  193.      @a_layer.visible = value
  194.    end
  195.    
  196.    def set_z(priority_id, y)
  197.      return 0 if @priorities[priority_id] == nil
  198.      return @viewport.z + y * 32 + @priorities[priority_id] * 32 + 32
  199.    end
  200.    
  201.     def max_frames(id)
  202.    autotile = @autotiles[id/48-1]
  203.    return 0 if !autotile || autotile.disposed?
  204.    return 1 if autotile.width > 96
  205.    return 0
  206.   end
  207.    
  208.   def get_autotile(bitmap,x,y,id,frame)
  209.    return if frame < 0
  210.    autotile = @autotiles[id / 48 - 1]
  211.    return if !autotile
  212.    if autotile.height == 32
  213.     anim = frame << 5
  214.     src_rect = Rect.new(anim, 0, 32, 32)
  215.     bitmap.blt(x, y, autotile, src_rect)
  216.    else
  217.     anim = frame * 96
  218.     id %= 48
  219.     tiles = Autotiles[id >> 3][id & 7]
  220.     src = Rect.new(0, 0, 0, 0)
  221.     for i in 0...4
  222.       tile_position = tiles[i] - 1
  223.       src.set((tile_position % 6)* 16 + anim,(tile_position / 6)* 16, 16, 16)
  224.       bitmap.blt(i % 2 * 16 + x, i / 2 * 16 + y, autotile, src)
  225.     end
  226.    end
  227.   end
  228.    
  229.   def autotile_frame(id)
  230.    autotile = @autotiles[id / 48 - 1]
  231.    return -1 if !autotile || autotile.disposed?
  232.    frames = 1
  233.    if autotile.height == 32
  234.     frames = autotile.width >> 5
  235.    else
  236.     frames = autotile.width / 96
  237.    end
  238.    return (Graphics.frame_count % frames)
  239.   end
  240.    
  241.    def ox=(value)
  242.      return if @ox == value
  243.      @ox = value
  244.      @a_layer.ox = value
  245.      @layers.each{|layer| layer.ox = value}
  246.      @l1.each{|layer| layer.ox = value}
  247.    end
  248.  
  249.    def oy=(value)
  250.      return if @oy == value
  251.      @oy = value
  252.      @a_layer.oy = value
  253.      @layers.each{|layer| layer.oy = value}
  254.      @l1.each{|layer| layer.oy = value}
  255.    end
  256.  
  257.    def update
  258.      return if !@visible
  259.      # Dummy for updating autotiles
  260.      update_autotiles if Graphics.frame_count % 25 == 0
  261.    end
  262.    
  263.    # Still getting it to work...
  264.    def update_autotiles
  265.    
  266.     # Get X Tiles
  267.     x_start = ([@ox / 32, 0].max).round
  268.     x_end = ((x_start + [@viewport.rect.width / 32, @xsize + 1].min) - 1).round
  269.    
  270.     # Get Y Tiles
  271.     y_start = ([@oy / 32, 0].max).round
  272.     y_end = ((y_start + [@viewport.rect.height / 32, @ysize + 1].min) - 1).round
  273.    
  274.     tmp_rect = Rect.new(0, 0, 0, 0)
  275.     for z in 0..@zsize
  276.       for y in y_start..y_end
  277.         for x in x_start..x_end
  278.           next if @a_locs[x, y, z] == 0
  279.           id = @a_locs[x, y, z]
  280.           frame = autotile_frame(id)
  281.           get_autotile(@a_layer.bitmap, x * 32, y * 32, id, frame)
  282.          end
  283.        end
  284.      end
  285.    end
  286.    
  287. end
  288.  
Expand to see the code.


Hope it helps at least. :)

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=77865