Tuesday, June 28, 2016

Guests have items!



It might not look like much, but let me explain this image:

This is a guest character imported from a different save file. She brought all her equipment with her. Important to note: Because of the planned crafting/enchanting system in this game, this is way more hard than it was in the original RPGMaker MV.

RPGMaker uses a design pattern called "Flyweights," meaning that items in RPGMaker are just pointers to a "prototype" item that represents all items of that class. For example, because all "shortswords" are identical, whenever anybody buys a shortsword, rather than creating anew shortsword and giving it to the player, it just gives the player a  pointer to the original swortsword.

This causes problems when you want to enchant things or otherwise edit how items work. If I don't actually have my own shortsword, but just a pointer to some "base" shortsword, then if I make my shortsword a fiery shortsword, all other shortswords in the world change to match.

To fix this problem, Yanfly wrote some code she called "independent items" that makes it so whenever you get a new item, it actually creates a new item that can be modified independently of the original. The problem is, in order to maintain compatibility with other RPGMaker plugins, she had to do it in sort of a hacky way. The new item is also a flyweight, and is stored with all the other flyweight classes in the same database!

This made it a real pain to copy equipment from one save to another. I couldn't just copy it, I needed to dig in the original save's database, copy it into the new database, and then re-align all the pointers to match up. It took way too long to do this; at this rate, the game isn't going to be done in time. I hope either I start solving these problems faster or the problems get smaller as I progress, or I'm going to have to cut some features to make the deadline.

But the good news is that you can now play with guests, and they keep their items when they arrive. This means I can test the dungeons in the conditions I intend: a party of 2-3 characters working together. That means I can balance the first dungeon or two and get the system out to my alpha testers before too much longer.

Thank goodness.

No comments:

Post a Comment