Extracting data from Enemies/Troops database

Heya, I'm a person who likes to go looking through data and collecting information and drawing conclusions based on what I find.

To that effect, I enjoy spending far too much time manually editing information using RPGMaker VX Ace's inbuilt databases and would like to see if anyone is willing to write up a script to do the lifting for me.

My requirements are:-
Extract most/all data from the monster database into a .txt. Preferably in the format below:-
Code:
ID|Name|MHP|MMP|ATK|DEF|MAT|MDF|AGI|LUK|EXP|Gold

Similarly, do the same for troop database.
Code:
ID|EXP gained|Gold gained

Failing that since I'm guessing it's a bit harder to extract data that relies on variables(exp/gold per monster * actual troop formation), a script to change the name of all enemies to be the same as their id and autonaming every troop encounter also works.

Regardless, feel free to contact me via this thread if anyone is interested in working on it.
You just want to extract it or use it for something too?
Simply writing these into a text file is not hard to do at all, but to make the game actually use the text file itself to get the data would require additional coding.
I already wrote a script to extract the database into a text file or spreadsheet. Search the RGSS3 Scripts section for a thread with the word Extract in the title.
You just want to extract it or use it for something too?
Simply writing these into a text file is not hard to do at all, but to make the game actually use the text file itself to get the data would require additional coding.

Just writing it into a text file. I just want something really simple since I don't want to do anything fancy that would take up a scripter's time. Fancy is trying to figure out what to do with the extracted data and make it useful for a player on wikis or walkthroughs.

I already wrote a script to extract the database into a text file or spreadsheet. Search the RGSS3 Scripts section for a thread with the word Extract in the title.

Tried looking for it and found your Event Extractor, but I can't seem to find anything that might work for the database. Sorry for the trouble. @_@;
Sorry - I was working on one, but never got it finished. Someone actually asked the question in that thread.

If you create a new script slot and paste this into it, it will extract enemy info.

Code:
ef = File.open('Data/_EnemyStats.csv', 'w')
ef.puts(sprintf('Enemy id,name,MHP,MMP,ATK,DEF,MAT,MDF,AGI,LUK,GOLD'))
$data_enemies.each do |enemy|
  next if enemy.nil? || enemy.name == ''
  ef.puts(sprintf('%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s', enemy.id.to_s, enemy.name,
    enemy.params[0].to_s, enemy.params[1].to_s, enemy.params[2].to_s, enemy.params[3].to_s,
    enemy.params[4].to_s, enemy.params[5].to_s, enemy.params[6].to_s, enemy.params[7].to_s, enemy.gold.to_s))
end
ef.close

This creates an _EnemyStats.csv file in your Data folder. It doesn't include features, actions or drop items - just the stats.

How do you want the troop info output?
Sorry - I was working on one, but never got it finished. Someone actually asked the question in that thread.

If you create a new script slot and paste this into it, it will extract enemy info.

Code:
ef = File.open('Data/_EnemyStats.csv', 'w')
ef.puts(sprintf('Enemy id,name,MHP,MMP,ATK,DEF,MAT,MDF,AGI,LUK,GOLD'))
$data_enemies.each do |enemy|
  next if enemy.nil? || enemy.name == ''
  ef.puts(sprintf('%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s', enemy.id.to_s, enemy.name,
    enemy.params[0].to_s, enemy.params[1].to_s, enemy.params[2].to_s, enemy.params[3].to_s,
    enemy.params[4].to_s, enemy.params[5].to_s, enemy.params[6].to_s, enemy.params[7].to_s, enemy.gold.to_s))
end
ef.close

This creates an _EnemyStats.csv file in your Data folder. It doesn't include features, actions or drop items - just the stats.

How do you want the troop info output?


Just the ID and exp/gold gained. Barring that just a simple file outputting the troop name should work too, I can just throw that into excel and make it reference enemy data without too much trouble.

Thanks a lot for this!
EXP and GOLD are stored against the enemy, not the troop. Also, troop -> enemy is a 1-to-many relationship. Can you give me an example of what kind of output you would expect for a troop that has 2 bats, 1 slime and 3 rats? How is it going to look when it reaches your spreadsheet?
While exp/gold drop is stored in enemy, but you're fighting troop, not a singular enemy. I guess they want to draw a conclusion on how the exp/gold drop based from the troops first? I somehow could see what they want to do hmmm
But if you get the troop details and the enemy details, you can work out what the entire troop would provide with lookups in the spreadsheet.
But if you get the troop details and the enemy details, you can work out what the entire troop would provide with lookups in the spreadsheet.

Since it's not stored in the database itself, this is what I plan to do.

So just:

Code:
1 | Bat*2, Slime , Rat*3

Then I'll have to manually split it up and add a few more columns to do vlookups for the Enemy * quantity and then a sum at the end and probably hide tje columns for any values not relevant(everything but the totals)

A bit of work, but I'm not sure what else to do with it at the moment.
Made a few minor changes to what was already provided and got what I needed.

Code:
ef = File.open('Data/_Troops.csv', 'w')
ef.puts(sprintf('Troop id,Composition'))
$data_troops.each do |troop|
  next if troop.nil? || troop.name == ''
  ef.puts(sprintf('%s,%s', troop.id.to_s, troop.name))
end
ef.close

ef = File.open('Data/_EnemyStats.csv', 'w')
ef.puts(sprintf('Enemy id,name,MHP,MMP,ATK,DEF,MAT,MDF,AGI,LUK,EXP,GOLD'))
$data_enemies.each do |enemy|
  next if enemy.nil? || enemy.name == ''
  ef.puts(sprintf('%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s', enemy.id.to_s, enemy.name,
    enemy.params[0].to_s, enemy.params[1].to_s, enemy.params[2].to_s, enemy.params[3].to_s,
    enemy.params[4].to_s, enemy.params[5].to_s, enemy.params[6].to_s, enemy.params[7].to_s,enemy.exp.to_s , enemy.gold.to_s))
end
ef.close

As a bonus, the troop data comes out a bit better than I expected. it's already aligned into columns of different enemy types since autoname uses commas.

Thank you a lot Shaz!
Nice. You're unstoppable now!
Hi, I'm a digital acquaintance of Thormented who is trying to plagiarize... adapt his work into a more functional database for presenting enemy and troop info on a game specific wiki, although a more general implementation may be feasible.

I'm having trouble getting the above quoted script to function as directed in spite of, or perhaps because of, my being a reasonably good programmer. My first mistake was assuming that it would need to be integrated in the game's function calls so that a menu item in the game's interface during playtesting, but it actually appears the instructions are to just copy and paste the above text into a new script, and that the game executes any code not in a class or module.

Problem is, the script still won't work for me, in my case it seems to be because it has no idea what the troop or enemy classes are. If I put in just the first 7 lines of Thormented's last quoted script, it errors out on line 3, giving a message indicating that there is no method "each" for "nilClass", or words to that effect.

Since I just want to dump the contents of the game's internal database to a few text files, pull that data into a toy relational database engine like Access or Filemaker, and use that database to generate a nice wikia page presenting info on the game's enemies, enemy skills and other such fun stuff, I'm finding it all rather frustrating.

If you could point me in the direction for documentation on the troop and enemy classes and/or objects once you explain the obviously very stupid thing I must be doing with this script, that would be infinitely kind of you. Skills and states would also be nice.
That is only a small part of a larger script that I haven't finished yet. Now that you mention the error, I'm not sure how Thormented got it to work, as it makes the assumption the database has been loaded into memory.

If you put a new line above it, and enter this:
Code:
DataManager.load_normal_database

you should be able to extract the info.

If you have Ace, the Help file (Help on the menu or F1) will give you the list of all the database classes and contents.
Well that did it.

Reading integral Windows Help Files? How delightfully retro 2002...
Reading integral Windows Help Files? How delightfully retro 2002...
Why, how does a modern help file looks like? Is it 3D, maybe holographic? Full with useless decoration images/videos? 😀

You can also simply use that script in a "Script Call" event command, that would work too.
Generally speaking, nowadays, when I dick around with a custom scripting language, especially one made by Microsoft, I go to Google and then the Microsoft Knowledge Base. Technical information about a given game title is usually found in a wikia for that title or franchise. RPG Maker is neither of these, of course.
then why compare it with those?

If it provides the help you need, it has done its job.
I wasn't criticizing. Just noting that it's a change in pace.
It occurs to me that in addition to being sarcastically flip and projecting an air of criticism I did no intend, I did not thank the people who responded to my question.

So thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/extracting-data-from-enemies-troops-database.88507/