Week of June 5, 2011
Aw yeah, bitches, three major updates. Not a lot of small ones because honestly fuck those, what’s even the point. Yeah, I altered some variables here and there. Maybe tightened some stuff up. Who cares, because I took three things I’d been dreading for a while and kicked their ass.
Warning: The first two of these are going to be boring. The third one is exciting.
– Save/load. You would think this was already in, wouldn’t you? You’d think it’d be easy to do, wouldn’t you? You’d think that, wouldn’t you? Well, no, Megatronica has a lot of variables. It has to remember the location of every building, character, the state of their inventory, the player’s inventory, the state of every quest, every chest, every NPC, every fucking TREE, etc… And that’s just the basics, because a lot of those have their own variables, besides x/y coordinates. Anyway, right now it’s just basic stuff, but I have a system planned for all that fiddly stuff.
It uses two .inis – one for the player, and one for the world. They’re separate. You can delete the entire world and still have your character’s stats and inventory intact. This is important for some secret stuff. It also allows, say, multiple players for one game. It allows multiple worlds for one player to level up in before going to a ‘main’ save to kick ass. Because the world of Megatronica can change so much depending on the story, this is one way for the player to see more.
There’s also probably going to be a ‘Free Mode’, where the story and its dangers are left out, so the player can just explore and build cities and shit. Might save that for after they beat the Story Mode though.
– Inventory improved (somewhat). This isn’t the all-encompassing fix I was planning (yet), but it’s working great for now. Basically, every item in the game was saved to an array, which is like a filing cabinet. It saved every item to a number, which served as its unique ID. Originally, I categorized items based on the range of IDs. 1 – 100 were fruits, 101 – 200 were seeds, 10001 – 20000 were weapons, etc… And that was really stupid, because it turns out it saved every variable between those to memory. I didn’t have 10000 weapons, only like 4, to start with. But it still had to save those 10000 variables for later.
I had saved 30000 variables that had to be kept track of.
So I got rid of that and now categorize items based on what the item is. ‘Red Fruit’ is now saved as a fruit. ‘Acoustic Guitar’ is saved as a weapon. This has reduced the size of the item database (so far) from 30000 to 92. And now if I want to add an item, I can make its ID whatever I want without worrying about slotting it into the right category.
The next step is enabling ‘unique items’. I want the player to craft their own weapons without having to program every possibility in the code. Procedurally generated items, basically. ‘Procedurally generated’ is a weird-ass term. And you’re going to have to get used to it, because…
– Procedurally generated dungeons.
Okay, ‘procedurally generated’ means this: It is generated, by the computer, automatically. Using a procedure, if you will. This is really special to me, because it’s basically right up Megatronica’s alley. It allows for infinite replayability, with no idea of what’s coming up next. I also long considered it way, way above my level, programming-wise. I came up with a process one night and then I just sat down and coded for six hours straight, and now it’s there. And it’s beautiful.
The main problem with procedural generation is that computers aren’t creative. They can’t make things interesting. But dungeon layouts are rarely interesting to begin with. I tried to do it myself, but there’s something about having to plonk down simple rooms and hallways that makes me completely demotivated. My map editing process isn’t very good, for starts. Also, there’s no way to really make them interesting.
The procedural generation actually makes things more interesting than I ever could. There’s something about making a computer do something that it doesn’t quite understand that produces some pretty cool results. It simply puts down rooms, checks if it’s going to overlap, then draws the floor, then connects it to another room with a hallway, and repeats until there’s a certain number of rooms. it also does a sanity check to ensure that the player can reach the exit. But beyond that sanity check, the computer has free license to go absolutely batshit.
It’s a beautiful fucking mess. And I know the visuals are bland, but that’s only because I (still) don’t have assets. Every room actually has its own identifier so, when there are actually graphics, they can have their own floors and walls. And no, they’re not going to be gray. The game will have no gray in it, once it’s done. Promise. But yes, the computer’s only restraints are:
1. Make a room
2. Make sure that room isn’t inside another room
3. Make sure there’s a hallway involved somehow
4. Make it so the player can actually get to the exit
And the result is basically like watching a retarded kid fingerpaint: oddly fascinating. So no two dungeons are going to look identical, and once I actually have an art style, with graphics for each room, it’ll actually look kind of interesting. There’s no stylistic downside. It’s taken the simple act of ‘putting down random rooms and hallways’ and made it into an art.
The only real downside is that it takes a few seconds to generate a room, so far the only ‘loading’ done in the game, aside from saving. The average is 2.5 seconds, though – more, if it has to throw a dungeon out, which is occasionally has to do because it either can’t make hallways, can’t fit the required number of rooms in place, or the player can’t reach the exit. Then it just quietly starts over. So far, though, this isn’t really an issue – it’s just an extra couple of seconds.
The upside? Um. Infinite levels. Forever.
I also made it tweakable, so rooms can be any shape, and not just squares or rectangles. I can make them circular. I can make them heart-shaped. I can make a room into a goddamn smiley face. Later I’ll probably add lava pits, doors, levers, etc…
– Homing was broken apparently. Now it’s not. Go me.
– Lots and lots of planning. The story was put on hold, because at one point, the characters actually asked the player to ‘go do stuff’, making a brief pause in events. The purpose of this was to have the player explore the sandbox, because that’s ultimately what it is. Hence why the dungeon generator became a thing – I needed to start adding stuff for the player to do outside of the storyline. The main things for the player to do are taking care of their city, or adventuring. At this point in the story, city building hasn’t been introduced, so it’s just adventuring.
There is a point to going through dungeons. They’re all accessed from the overworld, where the villagers and cities are. If the dungeon hasn’t been ‘conquered’, there will be a boss monster inside that routinely comes up to ruin your people’s day by attacking, and waves of enemies that do the same. It also belches up enemies to infest the overworld in general. Going into the dungeon not only alleviates this threat, but it ‘purifies’ the dungeon and makes it into a shrine, which has a positive effect on the area around it. There’s an ecosystem in the game that’s going to be expanded on. Right now, it just affects the fertility of the land, as in the growth of crops and trees. Some things hurt the land, other things help. This will become more complex, with time.
Next up are sidequests, and maybe some Animal Crossing style errands to run. I really want there to be a constant stream of things to do. Atelier Annie is one game I’ve played recently where 90% of it can be summed up as, ‘go fuck around’, sans plot, and it pulled it off fine. It had multiple things to take care of, though, like getting as much money as possible, training character levels for both combat and crafting, and doing sidequests. So… I guess I’ll start looking into things like that.