Jump to content

PKMDS Code Library


codemonkey85

Does contest info really matter?  

37 members have voted

  1. 1. Does contest info really matter?

    • Yes, so include it in your viewer app!
      18
    • No, so exclude it from your viewer app!
      19


Recommended Posts

EDIT: My current project:

https://github.com/codemonkey85/PKMDS

Have any suggestions? Let me know in this collaborative document!

Check out PKMDS: Save Editor!

PKMDS

A Pokémon save hacking library written in C++! (currently supports Gen V and limited portions of Gen III / VI)

See pictures of the library in action: http://goo.gl/Fg7J1r

Project outline: http://goo.gl/4KRDxN

Collaboration document: http://goo.gl/iCTKme

Created by Michael Bond (aka Codemonkey85) https://plus.google.com/+MichaelBond/

 


Thanks to Alex "eevee" Munroe at http://veekun.com/ for his SQLite Pokedex database, which powers this software. "veekun-pokedex.sqlite" was built from his database.

 

Thanks to the fine folks at SQLite.org for making it possible to use the Pokedex database... the source files "sqlite3.c" and "sqlite3.h" came from these people.

Thanks to those of Project Pokemon who have helped research and document the underlying structure of Pokemon game save files.

Thanks to Nicholas Corgan (https://github.com/ncorgan) for contributing directly to this project's code, making it more portable.

Thanks to Antidote (https://github.com/Antidote) for plugging memory leaks.

Thanks to the folks at Smogon for the stat formula and other things.

Special thanks to SCV, Sabresite, loadingNOW, Poryhack, GatorShark, Chase, Jiggy-Ninja, Codr, Bond697, mingot, Guested, coolbho3000 and of course, COM.

Some save file documentation available at: http://www.projectpokemon.org/wiki/

 


This software is in no way affiliated with or endorsed by Nintendo, Creatures Inc. or Game Freak Inc, and is created for solely recreational and non-profit use. Pokémon, Pokémon character names, Nintendo DS and Nintendo 3DS are trademarks of Nintendo. Other trademarks are the property of their respective owners.

 

Edited by codemonkey85
Link to comment
Share on other sites

Yeah, maybe it is about the same.

Not sure, but it just seems like there's a lot of empty space.

Oh, and you technically don't NEED the contest stuff if it's a Gen V pokemon. I guess if you design the program to read Gen IV pkm files as well, it wouldn't hurt, since DPP had contests.

At any rate, I'm interested in seeing what you cook up.

Link to comment
Share on other sites

  • 1 month later...
Yeah, maybe it is about the same.

Not sure, but it just seems like there's a lot of empty space.

Oh, and you technically don't NEED the contest stuff if it's a Gen V pokemon. I guess if you design the program to read Gen IV pkm files as well, it wouldn't hurt, since DPP had contests.

At any rate, I'm interested in seeing what you cook up.

I agree with this. I think the contest/ribbons are only useful if this software can be applied to Gen IV pokemon. If it is only for Gen V, I doubt there will be any need for it. This is looking very nice by the way and I can't wait to see its finished version. I'll be checking back for more updates.

Link to comment
Share on other sites

  • 6 months later...

Just an FYI, I have changed directions for PKMDS once again. I've been coding a new library using Visual C++ (in the hopes to gradually drop the Visual part) and am now hosting most of my source code on Google Drive.

My PKMDS source on Google Drive!

If you use Google Drive, you should be able to add that folder to your account and sync it to your PC, at which point you can do just about whatever you want with it. I ask only that you link back to me as the original creator.

If you have any further questions, feel free to contact me at my Google+ page (or send me a PM here).

Edited by codemonkey85
Link to comment
Share on other sites

  • 6 months later...

Just as an update, I have been working away at my C++ library. There's quite a bit of open-ended functionality now. At this point one could use it to create a program that can:

  • Encrypt and / or decrypt a PC storage Pokémon (or party Pokémon) at will
  • Get or set any data for any Pokémon, and do that in a pretty readable way thanks to various value enumerations for species, items, in-game locations, etc.
  • Get or set the values and quantities of bag items
  • Fix checksums for Pokémon data, block data for the party, PC storage system, items, the save file as a whole, and really any other block you know the location for.
  • Sort Pokémon based on criteria of your choosing (work in progress)

As another proof of concept, here is a sample of how one could use my library to, say, turn every Pokémon in a given save file into a Psyduck:

#include "pkmds_g5_sqlite.h"
using namespace std;
int main(int argc, char* argv[])
{
char * savefile;
// Either you can name your in file manually
savefile = "IN.sav";
// Or you can drag and drop your in file onto the .exe
//savefile = argv[1];
// Name your out file
char * saveout = "OUT.sav";
// Declare your SAV and PKM pointers
bw2sav_obj* sav = new bw2sav_obj;
pokemon_obj* pkm = new pokemon_obj;
// Read your SAV object from the file
read(savefile,sav);
// Open your database file
opendb("veekun-pokedex.sqlite");
// Iterate through the members of your Pokemon party
for(unsigned int i = 0; i < sav->cur.party.size; i++)
{
	// Set your PKM pointer to the current party member
	pkm = &(sav->cur.party.pokemon[i].pkm_data);
	// Decrypt the party member
	decryptpkm(pkm);
	// Do stuff with PKM, which is now the party Pokemon at party slot [sLOT + 1]
	pkm->species = Species::psyduck;
	// Recalculate the party data of the current party member
	pctoparty(&(sav->cur.party.pokemon[i]),pkm);
	// Encrypt the current party member
	encryptpkm(&(sav->cur.party.pokemon[i]));
}
// Fix the party block checksum
calcpartychecksum(&(sav->cur));
// Iterate through each PC storage box and slot
for(int box = 0; box < 24; box++)
{
	for(int slot = 0; slot < 30; slot++)
	{
		// Set your PKM pointer to the current stored Pokemon
		pkm = &(sav->cur.boxes[box].pokemon[slot]);
		// Decrypt the stored Pokemon
		decryptpkm(pkm);
		// Determine whether or not this is an empty slot
		if(pkm->species != 0)
		{
			// Do stuff with PKM, which now points to the Pokemon at box [bOX + 1] and slot [sLOT + 1]
			pkm->species = Species::psyduck;
		}
		// Encrypt the current stored Pokemon
		encryptpkm(pkm);
	}
	// Fix the checksum of the current box
	calcboxchecksum(&(sav->cur),box,savisbw2(sav));
}
// Close the database file
closedb();
// Fix the save file checksums
fixsavchecksum(sav);
// Write the save file to the disk
write(saveout,sav);
// Clean up your pointers
delete sav;
sav = 0;
pkm = 0;
// Exit the program and return 0
return 0;
}

If there are any further questions, feel free to email or PM me!

Edited by codemonkey85
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

I want to use this library in a program I am making, and I would like to know what license the code is released under. My program is GPL'd, by the way. Can I use the GNU General Public License v2 (or greater) when dealing with your code? If so, that would be a great help. Thanks!

Link to comment
Share on other sites

@skylarmt Yeah, I never quite bothered to look into licensing and stuff, but I just tossed GNU into the readme for now. I'll add the little blurb to the source files sometime later. Anyway, do what you will.

I would love to know more about your project by the way. Feel free to PM (or preferably email) me about it sometime. And don't hesitate to contribute to the repository!

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Major thanks to Nicholas Corgan (https://github.com/ncorgan) for contributing directly to this project, making it more portable, and perhaps most excitingly more compatible with Linux! Work has yet to be done to get the Qt project working properly, but things are very exciting right now for the community of Pokémon hacking / open source overlappers!

Edited by codemonkey85
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

UPDATE! To make a long story short, this library is going to be CLR compatible pretty soon. What does this mean for you as a developer? It means you can have all the same functionality plus the ability to build a GUI in Visual Studio! WUT

I'll be working on extracting the SQL string generation from the existing functions and building another, more generic class for accepting those strings to return data, which means a lot of re-doing my work, unfortunately. But I do it for SCIENCE!

Edited by codemonkey85
Link to comment
Share on other sites

  • 2 months later...

Just FYI, I removed the SQLite database files from the Git repository to reduce the amount of bandwidth used when initializing a new environment. The databases can be downloaded from https://www.dropbox.com/sh/2etuv926vyey5ou/jeAXk1qDXc. Of course, they haven't changed since I moved them, so you could just copy them to a local directory yourself.

Actually, now that I'm thinking about it, I'll add the folder path I was using before to the .gitignore so that current local branches won't break after syncing the change.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...