Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
512 stars 130 forks source link

Last Scenario #39

Closed BlackLotus closed 9 years ago

BlackLotus commented 9 years ago

I believe Last Scenario uses the RPG Maker XP. When I try to play it with mkxp I get this:

ruby:1:in `eval': Section007:289: syntax error, unexpected ( arg, expecting keyword_do or '{' or '(' ...s = otherweaponstr > -1 ? str (true) + otherweaponstr * 1.5 ... ... ^ Section007:289: syntax error, unexpected ':', expecting keyword_end ...(true) + otherweaponstr * 1.5 : str
... ^ (SyntaxError) EventThread termination requested RGSS thread ack'd request after 0 ms Shutting down.

I'm not sure if this is some kind of limitation or if this can be fixed.

cremno commented 9 years ago

Remove the space between str and (true):

s = otherweaponstr > -1 ? str(true) + otherweaponstr * 1.5 

I believe that should fix this error.

BlackLotus commented 9 years ago

How can I edit the game scripts of a game I didn't make? grep doesn't find the code so I guess it's compressed somewhere and I can't import the game into the RPG Maker XP Editor, because I don't have the project file.

Ancurio commented 9 years ago

Hah, after I found your initial problem I continued playing and fixing other errors, and now @cremno beat me to it =P

I use ttm_unpack to extract the RGSSAD archive, then use my fork of rgss_script_editor to edit the Scripts.rxdata. But if you're on Windows and don't know much about compiling things, you can decrypt the archive, put a random project file from another RPG Maker folder into it and open it in the Maker. How's your situation?

BlackLotus commented 9 years ago

compiled ttm_unpack and extracted it (didn't find the code in that with grep either). Compilg rgss_script_editor right now have to reinstall some deps. Would be great btw if the mkxp player could handly (possible syntax errors) the same way the original engine does :)

BlackLotus commented 9 years ago

Ok I compiled everything and opened the Scripts.rxdata file and opened it in your editor. Right now I'm searching for the line(s) I have to change, but can't find them.I'll update this if I manage to get it running.

Ancurio commented 9 years ago

The line you want to change is in Game_Battler 1, line 289.

BlackLotus commented 9 years ago

Oh so section 007 means really the 7th Element. :) And THANK YOU it works. Ahh that feels good.Thank you

Ancurio commented 9 years ago

Yes, you can turn on script names in error messages by putting useScriptNames=true into your mkxp.conf.

Another error I fixed is in Window_SpellcardList line line 20, changing

self.index = [$game_system.spellcard_menu_index, @data.size - 1].min

to

self.index = [$game_system.spellcard_menu_index.to_i, @data.size - 1].min

(This error will pop up if you open the Spellcard menu).

Something I'm investigating right now is extremely high memory and CPU usage when you enter the world map, which is making the game unplayable.

cremno commented 9 years ago

The $game_system.spellcard_menu_index problem can be solved in a better way by actually initializing the variable (@spellcard_menu_index) in Game_System#initialize.

Try pasting this above the end in line 70:

    # other initializations
    @spellcard_menu_index = 0
    # end (line 70)

Something I'm investigating right now is extremely high memory and CPU usage when you enter the world map, which is making the game unplayable.

Bitmap#{get,set}_pixel?

BlackLotus commented 9 years ago

Ahh I was thinking this was because of my low end laptop I'm trying to play it on.If this is a bug I'm kinda relieved.I tried enabling frameskipping, but it didn't really help.Is mkxp normally faster than the original binary with wine? Btw is there an irc channel or something for mkxp?

Ancurio commented 9 years ago

The $game_system.spellcard_menu_index problem can be solved in a better way by actually initializing the variable (@spellcard_menu_index) in Game_System#initialize.

We have different approaches I guess :D You like to fix the actual script bugs, I'm content with just replicating 1.8 behavior.

Bitmap#{get,set}_pixel?

I thought so at first, and callgrind does show unusually high call counts for these, but simply return-nooping them out doesn't change perf at all. I'm trying to pinpoint the exact script location that is eating up the processing time now.

Ancurio commented 9 years ago

Ahh I was thinking this was because of my low end laptop I'm trying to play it on.If this is a bug I'm kinda relieved.I tried enabling frameskipping, but it didn't really help.Is mkxp normally faster than the original binary with wine?

If you don't disable frameskip (which is on by default), the game might become completely unresponsive, so for debugging it's best to turn it off (this is generally the case when rendering takes unusual amount of times, eg. when running mkxp under valgrind). Not sure if mkxp is faster than Enterbrain's RGSS player, because we always limit the framerate anyway (and Enterbrains player only allows a FPS cap of 120, so it's impossible to judge its real performance).

Btw is there an irc channel or something for mkxp?

Nope. Maybe I should create one so people can get help more easily? Not sure.

BlackLotus commented 9 years ago

Yeah realized that frameskipping is causing hangs. I looked for an irc channel to faster respond to your answers.I don't know how much development talk is done and how often people come to seek help. I have here a pretty (I don't really want to say slow but hey...) slow laptop and wine has it running kinda slow on the worldmap as well (but somehow I can't get midi to work even thought timidity is working perfectly) so I searched for an open source engine and found mkxp. Right now I think that mkxp is running better but I can't say until I have played a bit with it.

BlackLotus commented 9 years ago

@cremno

other initializations

@spellcard_menu_index = 0

end (line 70)

Doesn't really stop it from crashing.

self.index = [$game_system.spellcard_menu_index.to_i, @data.size - 1].min

does.

Ancurio commented 9 years ago

The worldmap is spending 99% of its time in Graphics.update, so there must be a crapload of (invisible, unculled?) objects being drawn.

Ancurio commented 9 years ago

I'm starting to suspect that the worldmap is just a reeeeeeeeally huge map, completely overwhelming the GPU's vertex culling =/ Oh boy..

cremno commented 9 years ago

@BlackLotus: You need to start a new game or manipulate the savefile with my fix. Old Ruby versions sadly tolerate this kind of programming error. Sorry, I should have mentioned this. If you don't want to do this and just play the game, then use the other fix. (Honestly if you just want to play the game, use Wine or a Windows VM.)

@Ancurio: There are two kinds of world map. A scene and a map. I can't test it with mkxp at the moment – do you mean the map? The map is 400×400 (and two autotiles). The scene creates some (invisible) sprites, but not as many that I would classify them as “crapload”.

BlackLotus commented 9 years ago

I want to play the game and I want to help perfect the mkxp engine, because open source engines are important to me. So I just want to report bugs (and trust me if it wouldn't be all based on ruby I would probably try fixing most things myself :P) so that I can play it on my arm/mips/linux without wine devices as well.

Ancurio commented 9 years ago

There are two kinds of world map. A scene and a map. I can't test it with mkxp at the moment – do you mean the map? The map is 400×400 (and two autotiles). The scene creates some (invisible) sprites, but not as many that I would classify them as “crapload”.

I mean the "Tilemap" map. One draw of it takes ~463ms on my PC. There's occasionally a Sprite that takes ~360ms to draw, not sure about that one yet. However, it's clear that the GPU is overloaded with the culling (the worldmap results in 2,541,348 vertices per draw). Honestly, I never expected to see maps of these sizes, which is why I took the simple route of not doing any software culling whatsoever and completely relying on the GPU for it. Maybe it's time for a complete rewrite?..

cremno commented 9 years ago

@Ancurio: The world map also shows a minimap (see Spriteset_Worldmap and Sprite_Worldmap_Small). Yes, such map sizes are uncommon, but adding support for them would be great (max. is 500×500, BTW).

BlackLotus commented 9 years ago

A few things (I post them here because a new bug report would be weird and there is no forum). Have you considerd creating an irc channel for mkxp? I opened up bugs with Last Scenario under https://github.com/Ancurio/mkxp/issues/40 What license is the rgss_script_editor released under? Thx for your time/answers

Ancurio commented 9 years ago

Have you considerd creating an irc channel for mkxp?

You're the first one to ask, so it would just be us two =) I asked the folks over at #easyrpg on freenode if it's okay to discuss mkxp stuff there, and the said yes, so you can come by (if I'm online).

I opened up bugs with Last Scenario under #40

I saw that, but the last time I checked it there was only one problem listed. If you edit your post, github doesn't notify me in any way, so it's better if you just make a new comment if there's something new to add. I'm pretty busy this week, so I might not be able to look at it until next week.

What license is the rgss_script_editor released under?

Good question! I don't know because I didn't create the project (pinging @take-cheeze).

Ancurio commented 9 years ago

So, I hacked up the Tilemap class to only translate into vertices and draw the portion of the map that is currently visible on the screen, and loading the worldmap and running around in it are fast and mostly smooth now.. except for the 80(!!) getPixel/setPixel calls each frame, which slow down the rendering from 400 to 50 FPS; so I'm gonna look into how to optimize that part a bit. The game is now much more playable though. I will commit the rewrite soon when I have cleaned everything up.

Edit: For reference, the calls are made in Sprite_Worldmap_Small::update_worldmap, called from Spriteset_Worldmap::update_worldmap in the whole update loop.

Ancurio commented 9 years ago

Just pushed 295e0e5b1578301a983f1b3d279035d0575b5906 which should take care of the slow worldmap as well as d1bad9b45f19e2f8948d764ff2f8cb375b26a30b which optimizes all get_pixel calls (it's multiple times more expensive than set_pixel on my PC).

take-cheeze commented 9 years ago

(Sorry for late finding of this issue.)

I forgot to write the license. The license is MIT if there is no opinion from @Ancurio since @Ancurio made some pull request.

Though is there any good organization to maintain the rgss_script_editor? I don't have much interest to it now so it should be hand over to heavy users.

BlackLotus commented 9 years ago

Ancurio thx for the optimization. The game is now very playable. It seems multiple times faster then the original with wine. (I can't really compare it since I don't know how to check fps with the original), but now I get stable 40fps even on the world map.