Gosu RGSS Player

So I was thinking in the shower (as you do), about RPG Maker.

RGSS, specifically. It's a nicely packaged set of Ruby scripts, which are ran by a C made program.

Now let's say we rewrote all of the hidden scripts and pasted them into the scripts.rxdata file. Would it then not be feasible to create a ruby program to run this file, as game.exe does?

My thought is basically one of expandability and user choice. If we did have this scenario, then a different Bitmap class could be created for say, Gosu, or SFML, or any other graphics library you can think of. The game could be encrypted with any form of encryption.

If this is the case, couple of questions:

1. What are the default scripts? (Or, have I missed any?)

Bitmap
Sprite
Plane
Viewport
Tilemap
Window
Color
Table
Tone
RPG::*
Audio
Graphics

(Seems a lot..)

2. Is there a method in Ruby to print out... well, there is, but I can't get it to work... method forms:

to_print = ""
methods = Object.methods
for i in 0..methods.size
to_print += methods[i] + " " + Object.method[methods[i]].parameters.join(", ") + "\n"
end
print to_print

Should work... well, in my mind should work. It doesn't.

Anyway, would simply be useful (and necessary, really) for recreating the hidden scripts.
you know i have though about this often (Since i wrote my own bitmap, plane, and viewport classes) im interested in what people say. hence this post lol.
theres already a rewritten RGSS using Gosu http://www.libgosu.org/cgi-bin/mwf/topi ... l?pid=4015
Not sure if its full, i doubt it. Anyway gosu differs too much about the graphics and audio system so its not suitable for this project.

Theres also ARGSS, the miscalled RGSS3 from the brazillians and the ARC player from Blizzard and company. im sure theres more.

Go ahead!
All I can add is that there's a listing of the "hidden" scripts in the help file of each maker. It lists available methods and accessable variables, however obviously doesn't show any actual code.
Oh that's great, thanks.
None of the above listed "scripts" are actually scripts. They are all C classes, which are interfaced with Ruby, meaning they allow Ruby to make calls that actually fire C code, not Ruby code. Ruby alone really isn't powerful enough, or in close enough contact with the OS to run a game, therefore this is how it needs to be done. Sure, you could use about 5000 Win32API calls to different graphic rendering libraries and audio drivers, but Ruby cannot do these things on its own with the type of efficiency that is required.
I made a Gosu equivalent to the Input module a while ago. It's mostly self-contained, with two methods that just have to be called from the main Gosu Window instance.

Input module:
  1. module Input
  2.     UP, DOWN, LEFT, RIGHT = 8, 2, 4, 6
  3.     A, B, C, X, Y, Z, L, R = 11, 12, 13, 14, 15, 16, 17, 18
  4.     F5, F6, F7, F8, F9 = 21, 22, 23, 24, 25
  5.     SHIFT, CTRL, ALT = 31, 32, 33
  6.     MAPPING = {Gosu::KbUp => UP, Gosu::KbDown => DOWN, Gosu::KbLeft => LEFT, Gosu::KbRight => RIGHT,
  7.                          Gosu::KbNumpad8 => UP, Gosu::KbNumpad2 => DOWN,
  8.                          Gosu::KbNumpad4 => LEFT, Gosu::KbNumpad6 => RIGHT,
  9.                          Gosu::KbZ => A, Gosu::KbX => B, Gosu::KbC => C,
  10.                          Gosu::KbNumpad0 => B, Gosu::KbSpace => C, Gosu::KbReturn => C,
  11.                          Gosu::KbEnter => C, Gosu::KbPageUp => L, Gosu::KbPageDown => R,
  12.                          Gosu::KbA => X, Gosu::KbS => Y, Gosu::KbD => Z,
  13.                          Gosu::KbQ => L, Gosu::KbW => L,
  14.                          Gosu::KbF5 => F5, Gosu::KbF6 => F6, Gosu::KbF7 => F7, Gosu::KbF8 => F8, Gosu::KbF9 => F9,
  15.                          Gosu::KbLeftShift => SHIFT, Gosu::KbLeftControl => CTRL, Gosu::KbLeftAlt => ALT
  16.                         }
  17.     @@key_state = {}
  18.     @@key_state.default = -1
  19.     def self.update
  20.         @@key_state.each_pair do |key, value|
  21.             next if value == -1
  22.             @@key_state[key] += 1
  23.             @@key_state[key] = 20 if value == 25
  24.         end
  25.     end
  26.     def self.press?(id)
  27.         return @@key_state[id] > 0
  28.     end
  29.     def self.trigger?(id)
  30.         return @@key_state[id] == 1
  31.     end
  32.     def self.repeat?(id)
  33.         return @@key_state[id] == 1 || @@key_state[id] == 24
  34.     end
  35.     def self.dir4
  36.         return 2 if @@key_state[DOWN] > 0
  37.         return 8 if @@key_state[UP] > 0
  38.         return 4 if @@key_state[LEFT] > 0
  39.         return 6 if @@key_state[RIGHT] > 0
  40.         return 0
  41.     end
  42.     def self.dir8
  43.         return 1 if @@key_state[DOWN] > 0 && @@key_state[LEFT] > 0
  44.         return 3 if @@key_state[DOWN] > 0 && @@key_state[RIGHT] > 0
  45.         return 2 if @@key_state[DOWN] > 0
  46.         return 7 if @@key_state[UP] > 0 && @@key_state[LEFT] > 0
  47.         return 9 if @@key_state[UP] > 0 && @@key_state[RIGHT] > 0
  48.         return 8 if @@key_state[UP] > 0
  49.         return 4 if @@key_state[LEFT] > 0
  50.         return 6 if @@key_state[RIGHT] > 0
  51.         return 0
  52.     end
  53.     def self.any?
  54.         @@key_state.each_value do |value|
  55.             return true if value != -1
  56.         end
  57.         return false
  58.     end
  59.     def self.down(id)
  60.         key = MAPPING[id]
  61.         if key
  62.             @@key_state[key] = 0 if @@key_state[key] == -1
  63.         end
  64.     end
  65.     def self.up(id)
  66.         key = MAPPING[id]
  67.         if key
  68.             @@key_state[key] = -1
  69.         end
  70.     end
  71. end
Expand to see the code.


Gosu Window implementation:
  1. class Main < Gosu::Window
  2.     def button_down(id)
  3.         Input.down(id)
  4.     end
  5.     def button_up(id)
  6.         Input.up(id)
  7.     end
  8. end
Expand to see the code.
It's slightly different than that. As mentioned above, all these classes are written in C and compiled into the DLL with their respective Ruby interfaces, usually for performance reasons (notably the graphics stuff). You could do the equivalent with Gosu, since it's a C++ lib with a Ruby interface; if well programmed, it would probably be faster, to be honest.
The RPG::* modules and classes does seem to be only written in RGSS. You can see their code in the help file, yes their functional code, not just the signature. (There is at least one error, so be careful about using it)
I think that the classes and modules who don't have their code shown in the help file are written in C with the only Ruby code being a simple wrapper. I don't actually know this, I'm just guessing.

*hugs*
I agree with zeriab, ive always heard that. I have rewritten RPG::Cache recently and had no isssues what so ever. granted i was doing simple stuff like:

  1. def self.title(filename)
  2.   return @converter.create_bitmap(filename)
  3. end
Expand to see the code.
Caching is actually easy; all it does is grab and keep a reference to a unique location in memory where the resource is stored, so that it will never be garbage collected (i.e. as long as there exists a reference to an object, it will not be purged). That's not very intensive in terms of CPU cycles. The Bitmap and Graphics portion are definitely, and perhaps even others I can't remember (i.e. accurate, high quality audio might be one of these)
i use a custom file format instead of bitmap, thats why i had to change the cache
you have the cache module in the help file
  1. module RPG
  2.   module Cache
  3.     @cache = {}
  4.     def self.load_bitmap(folder_name, filename, hue = 0)
  5.       path = folder_name + filename
  6.       if not @cache.include?(path) or @cache[path].disposed?
  7.         if filename != ""
  8.           @cache[path] = Bitmap.new(path)
  9.         else
  10.           @cache[path] = Bitmap.new(32, 32)
  11.         end
  12.       end
  13.       if hue == 0
  14.         @cache[path]
  15.       else
  16.         key = [path, hue]
  17.         if not @cache.include?(key) or @cache[key].disposed?
  18.           @cache[key] = @cache[path].clone
  19.           @cache[key].hue_change(hue)
  20.         end
  21.         @cache[key]
  22.       end
  23.     end
  24.     def self.animation(filename, hue)
  25.       self.load_bitmap("Graphics/Animations/", filename, hue)
  26.     end
  27.     def self.autotile(filename)
  28.       self.load_bitmap("Graphics/Autotiles/", filename)
  29.     end
  30.     def self.battleback(filename)
  31.       self.load_bitmap("Graphics/Battlebacks/", filename)
  32.     end
  33.     def self.battler(filename, hue)
  34.       self.load_bitmap("Graphics/Battlers/", filename, hue)
  35.     end
  36.     def self.character(filename, hue)
  37.       self.load_bitmap("Graphics/Characters/", filename, hue)
  38.     end
  39.     def self.fog(filename, hue)
  40.       self.load_bitmap("Graphics/Fogs/", filename, hue)
  41.     end
  42.     def self.gameover(filename)
  43.       self.load_bitmap("Graphics/Gameovers/", filename)
  44.     end
  45.     def self.icon(filename)
  46.       self.load_bitmap("Graphics/Icons/", filename)
  47.     end
  48.     def self.panorama(filename, hue)
  49.       self.load_bitmap("Graphics/Panoramas/", filename, hue)
  50.     end
  51.     def self.picture(filename)
  52.       self.load_bitmap("Graphics/Pictures/", filename)
  53.     end
  54.     def self.tileset(filename)
  55.       self.load_bitmap("Graphics/Tilesets/", filename)
  56.     end
  57.     def self.title(filename)
  58.       self.load_bitmap("Graphics/Titles/", filename)
  59.     end
  60.     def self.windowskin(filename)
  61.       self.load_bitmap("Graphics/Windowskins/", filename)
  62.     end
  63.     def self.tile(filename, tile_id, hue)
  64.       key = [filename, tile_id, hue]
  65.       if not @cache.include?(key) or @cache[key].disposed?
  66.         @cache[key] = Bitmap.new(32, 32)
  67.         x = (tile_id - 384) % 8 * 32
  68.         y = (tile_id - 384) / 8 * 32
  69.         rect = Rect.new(x, y, 32, 32)
  70.         @cache[key].blt(0, 0, self.tileset(filename), rect)
  71.         @cache[key].hue_change(hue)
  72.       end
  73.       @cache[key]
  74.     end
  75.     def self.clear
  76.       @cache = {}
  77.       GC.start
  78.     end
  79.   end
  80. end
  81.  
Expand to see the code.


Everything in the RPG:: module is pure ruby, the rest (Helpfile->Built-in Classes) is hardcoded in C.

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