Monday, March 10, 2014

7DRL 2014 day 3: Gotta go fast!

Today I added components to BOSWP. I actually didn't do it quite the way I planned - I'd originally intended to have separate classes and data files for each type of component (e.g. engine, weapon, shield), but I realized I could just make one generic component class which can have all the various component attributes. This way you can make a component that's both a weapon and an engine, for instance! (Thraddash afterburner from Star Control much?)

I am storing the component data in a JSON file, though. Components have a name, description, cost, mass, and max hitpoints, and then the optional abilities, which are currently limited to crew, thrust, and weapon, though I'll eventually add more like shields and scanners. I was going to have a "bridge" component which destroys the ship when lost, but that seemed a bit unfair, so I limited ship destruction to reduction of speed to zero (dead in space) or crew count below mass (drifting away aimlessly). Or of course loss of all components, but in pretty much all cases, one of the other scenarios will happen first!

It's interesting to note that as your ship (or an enemy ship) loses components other than engines, it will actually go faster, since its mass is reduced but the thrust stays the same.

Enemy ship designs are stored in a JSON file as named lists of components. (The player's starting ship is of course stored in its own file.) I replaced the generic red "J" for enemy ships with the first letter of the ship name, so scouts will appear as "S", destroyers as "D", etc. This should help with threat analysis! Of course they won't change to other letters as they lose components, so you'll have to keep track of them. Enemy shipyards will tend to save up for the most expensive ship possible (currently a battleship), though they have a small chance each turn of splurging on whatever they can afford on any given turn. (Might want to check that that's game turn, not player turn, now that I have a proper speed system!) They will also build immediately (if possible) to defend themselves when the player ship is present in their system.





Sunday, March 9, 2014

7DRL 2014 day 2 - Real time enemies, turn based player

So, today I implemented enemies, and a very basic form of combat. Basically, your ship automatically fires at the nearest enemy that's within 3 squares (though it prioritizes shipyards over ships - if you want to attack a ship, just retreat from the shipyard and the ship will gladly follow you). The enemy ships will of course fire at you, too, and they will try to pursue you. Eventually when I add different weapons, I might have them try to stay at some optimal range, but for now they just try to get right up in your face. If you're not in the same system as an enemy ship, it will instead randomly patrol the galaxy, going from warp point to warp point.

There really aren't all that many enemies spawning at the moment, but the game is still pretty hard, if not impossible, because there's no way to repair your ship between battles. I guess when I add friendly colonies, I'll have to add repairs, too. Since destroyed components will be permanently lost, I think giving the player free repairs to any components that are damaged but not destroyed should be reasonable, assuming there aren't too many friendly colonies. And maybe the player can only be repaired while there are no enemies in the system...

A funny thing happened with the enemies, actually. As soon as I added the enemy shipyards, the game froze! At first I thought it was because the code to build enemy ships was extremely inefficient, but I optimized it, and it still froze. Then I noticed that the shipyards were churning out ships very fast, and their saved build rate was shooting up to ridiculous numbers! (It costs 1000 points to build a ship right now; I saw a shipyard with over 200,000 build rate saved!) Then it occurred to me - I was letting the enemies take turns continuously between player turns! So I made it so the enemies could only take one turn per player turn, and that solved my problem. Of course, tomorrow when I add components like engines, I'll implement a proper speed system, but for now, a 1:1 player/enemy speed ratio should be good.

Saturday, March 8, 2014

7DRL 2014 day 1 - Beware of warp points leading nowhere!

So, I think I accomplished my goals for today. And it's only 8 in the morning, how about that! I've got a cave-like grid of star systems, and each system contains a star, some planets, and warp points leading to the adjacent systems. The player can move his @ about on the star system map, and moving onto a warp point teleports him to the next star system over. (I decided to make warping automatic instead of requiring a keypress just to keep things simple, and not require that the game allow more than one space object per sector.)

If you'd like to check out my code, you can grab it over at Bitbucket. I've also got a screenshot in case you just want a quick glimpse at the game:


Wednesday, February 26, 2014

7DRL 2014 plans

I figured it would probably be a good idea to set goals for myself for this year's 7DRL challenge, like I did last year, so here goes:

Day 1: Map generation. This involves creating a network of linked star system maps ("rooms"), connected by warp points ("doors"). They'll probably be laid out on a grid to simplify map generation code, and so I don't have to swipe code from FrEee to do that. And of course, the stereotypical @-ship running around on the galaxy-map!

Day 2: Enemies and combat! This means enemy shipyards (which will start off as visible, until I implement tachyon sensors) that spawn enemy ships. Combat will be simplified, since I won't have ship components yet.

Day 3: Ship components. For both the player and enemies! Will be defined in JSON files for easy moddability. Won't have generic "abilities" like in SE4; that's too much work for a 7DRL. Instead, each component will have a single function, and each JSON file will contain only components of a single function (e.g. weapons.json or engines.json). Not all components will be defined yet; only a basic subset of them as a proof of concept.

Day 4: Shopping shopping shopping shopping! Killing enemies should give the player minerals, as should discovering allied colonies. Allied colonies should also allow refitting of your ship using some sort of shop interface.

Day 5: More components! Just filling out the data files here with more components to make the game interesting, now that we have shopping. This is when the enemy shipyards become cloaked, since now you can buy tachyon sensors.

Day 6: Testing & bugfixes. Let's make sure the game is winnable, and it doesn't crash (very much)!

Day 7: Extra day planned into the schedule in case I'm not up to working on the game some other day!

Thursday, February 20, 2014

7DRL 2014 ponderings: Beware of Strange Warp Points

So I thought it would be fun to do a Space Empires themed roguelike for this year's 7DRL challenge. I think I'll call it "Beware of Strange Warp Points". It will play out sort of like the old DOS Trek games (could those perhaps be considered early roguelikes?), or like last year's KlingonRL - you're the captain of the last surviving ship of the Terran fleet, and it's your job to stop the Jraenar invasion!

I'm thinking the map will be laid out on a grid, with star systems being like "rooms" and warp points being like "doors". I say a grid and not a freeform warp point network because grids are easier to program. That said, I'd like for there to be "holes" in the galaxy map, so it resembles a cave level in a traditional roguelike.

The player will start with a basic ship, and will be able to upgrade it at a spacedock using minerals he collects, either from defeated enemies, or from allied colonies. Unlike in traditional Space Empires games, ship design will be a bit more freeform - there won't be any preset "hull sizes"; instead, you can just install whatever components you want. The more components you install, the heavier your ship becomes and the slower it goes, unless you install more engines to counter this effect. I guess it's kind of akin to a traditional roguelike's inventory system - you carry more equipment, it slows you down; you drink strength potions, it lets you carry more stuff!

Since most weapons in Space Empires are ranged, and targeting ranged weapons in a roguelike is a pain, I thought I'd do something a bit different with the combat system. Weapons will automatically fire at a randomly selected (or perhaps the closest, if there is ranged accuracy/damage loss) appropriate target every time they are reloaded. So all you have to worry about is maneuvering your ship to stay in range, but out of range of too many enemies' weapons!

I'm thinking the goal of the game will ultimately be to destroy all the Jraenar shipyards scattered around Terran space. Perhaps they will be cloaked, so you'll need to upgrade your ship with a tachyon sensor to detect them! Destroying the Jraenar ships is ultimately a diversion; once you take out all the shipyards, the game would only get easier from there, so there's no point in dragging it out.

I haven't decided how I'm going to handle missiles and units yet. Perhaps missiles will behave the same as they did in SE4 - move at a set speed toward their target, and be able to be shot down by specialized point defense weapons. Or, if I'm feeling lazy, they'll just be long-ranged weapons with 100% accuracy but high cost and low fire rate. Another alternative is a MOO2-style "missile evasion" stat, which the point defense weapons would increase, abstracting away the missile/PD balance while still keeping it in play.

As for units, I suppose there's really only a few kinds that I'd need to worry about. Troops and weapon platforms are pretty much irrelevant, unless I actually want to include planetary combat. Drones are basically just fancy missiles, so I don't really see the need to include them. Fighters would be interesting - have them controlled by AI and pursue the enemy (or you, if they're enemy fighters)? Mines would also be interesting, especially if they're invisible like in SE4! Satellites are basically just giant immobile fighters, so I'm not sure if they're really all that necessary.

Sunday, December 8, 2013

Infinite diversity in infinite combinations? Not so great after all.

Suppose there were, as some scientists have proposed, an infinite multitude of parallel universes, each differing from the next in only the minutest detail. For instance, in one universe, my favorite color is red, while in another, my favorite color is blue, and in a third, I still can't make up my mind.

This might sound like a wonderful thing - it means that anything truly is possible. But is it really all that great? I think that if such a thing were true, it would mean that we actually have no free will. Because all the choices we make would be preordained at the creation of our universe, our actions would have no meaning - for every choice I make, my counterpart in another universe would make a different choice. For every time I say "yes" when my sister asks if I want to play a game, there's a universe where I say "no". There's also a universe where I walk off silently, a universe where I punch her in the face, and a universe where I spontaneously combust, then teleport to Mars. What kind of freedom is that if I'm constrained to do only what's within the parameters of our particular universe?

Now it could be that there are so many universes that there's room for more than one identical copy of each. That would allow for free will, and it would be the ultimate expression of God's creative power. But is that actually a good thing? A simple look at history would say: almost certainly not. You thought the Holocaust was bad? Multiply that by infinity! Of course, there would also be universes where the world was at peace all along, and unicorns frolicked among the verdant truffula trees. But would God actually allow an infinite amount of human suffering? Somehow I doubt this; it seems beyond cruel, even if he can make it up in the end.

So, I'd have to say that if there are multiple universes (whatever exactly that means*), there are only a finite number of them, because if there were an infinite number, either life would be utterly meaningless or God would be infinitely cruel.

*What's "multiple universes" mean? Well, I suppose that a "universe" can be defined as a self-contained region of spacetime to which there is no entry or exit. So, obviously, the universe we live in is one, as there's no way to enter or escape it. Also, any alternate dimension is a universe, as we can't get there, and whoever lives there can't get here. A black hole, though, while it might appear to be a universe, is not, because it has a connection (albeit one-way) with the outside world. Likewise, a warp bubble as envisaged by Star Trek is not a universe, because even if it is isolated spatially from the outside world, it is still connected via time at the moment the ship enters or drops out of warp.

Tuesday, November 19, 2013

Why I love Mega Man (and Rogue Legacy, and Zelda, and Metroid)

This morning I was playing the excellent indie platformer Rogue Legacy, and something occurred to me - there's one way in that Rogue Legacy is like one of my favorite series, Mega Man. It's that both have steep difficulty curves early on, which level off as you progress, with occasional spikes throughout the game.

See, in Mega Man, you start off with pretty much nothing. All you have is your wimpy (except in Mega Man 5) mega buster, and maybe a few special moves like a slide or a Rush Coil. You have to claw your way to the top of the robot pack, defeating robot master after robot master, growing stronger all the while, until you're finally ready to take on Dr. Wily. It can be insanely difficult early on, especially for someone new to the series, and I'd have to say that the game actually gets easier as you progress - at least until the final stages when you confront Wily!

In Rogue Legacy, you again start off with pretty much nothing. 100 HP, 100 mana, only a few classes to play as, and no special equipment. Throughout the game, you can find and buy upgrades, which you get to keep even after your character dies and you start a new one (hence the "Legacy" in the title). The game, like Mega Man, is brutally difficult at first, but once you get used to the controls, and upgrade your HP, mana, classes, and equipment, it becomes... well, only moderately difficult. (There's actually an item you can equip that depowers enemies at the cost of reduced gold drops!)

So why do I enjoy these games so much? Is it because I'm a masochist? Well, no, I'm not a masochist. (At least, I don't think I am!) I think it's actually because there's a sense of accomplishment that comes from pressing on and finally defeating the initial challenge of the game, making my character powerful enough to tackle the rest of the game. Then when I get to the grand finale, and the difficulty ramps up again, I can really appreciate how much I've progressed.

To take an example from one of Jirard "The Completionist" Khalil's favorite games (and one of mine as well), in Mega Man X (which he does an excellent review of in his first episode of his YouTube series), at the beginning you as X are pretty wimpy, and have no hope to defeat Vile (though to be fair, he was riding in a mech...); you're saved by Zero, who says that someday you may be as strong as him. Well, sure enough, at the end of the game, Zero gives you his weapon (which lets you charge up any weapon you have captured from a boss, which is totally awesome)... but then Zero gets into another fight with Vile, and blows himself up to destroy Vile's mech so you can take out Vile himself. And sure enough, the fight with Vile is challenging, but not impossible. It's awesome to be able to fight for Zero, just like he fought for X in the beginning of the game, using all the new powers you've acquired throughout the course of the game!

Another series which has this sort of inverted difficulty curve is the Zelda series. In some of the games (such as the original Legend of Zelda, Ocarina of Time, and Wind Waker), you don't even start with a sword! Of course, there's not much actual danger at that point (except in the original Zelda), so that doesn't really count. But once you start exploring, you'll find yourself confronted with seemingly insurmountable obstacles, such as those annoying centaurs that shoot deadly sword beams at you and take way too many hits to kill in the original game. Eventually, though, you'll find some item that makes you start to wonder if you've somehow become God incarnate, because it makes dealing with the lesser challenges a complete cakewalk. Master sword that does 4x normal damage? Check. Blue ring that halves all damage taken? Check. Double hookshot that lets you zip around the sky level like Spider-Man? Check. Once you have these items in hand, you realize that maybe it's time to take on some of those obstacles that previously seemed impossible - and what do you know, they're not so hard after all!

And then there's Metroid. You start with 99 max health, a wimpy blaster that (in the original at least) doesn't even shoot all the way across the screen, and no advanced weaponry like missiles or bombs. But when you get to the end of the game, you can have over 1000 health, a wave spazer plasma ice beam that freezes and/or obliterates multiple enemies at once, 100 missiles, bombs, a dozen or so each of super missiles and super bombs, and the screw attack. Yeah, the screw attack. Seriously the most overpowered item in all of gaming. (Except in Metroid Prime 3; there it kinda sucked.) It lets you literally jump through enemies to kill them, as if they were balloons waiting to be popped. And you still get health and missile pickups! Oh, and did I mention you can use it repeatedly in midair, allowing you to kill lots of enemies at once, or just air-climb up to high platforms? And yet still, all these weapons aren't quite enough to defeat Mother Brain (at least in Super Metroid) - you still need the hyper beam!

Come to think of it, the inverted difficulty curve isn't all that uncommon. It's especially prevalent in roguelikes such as Angband, where progress is measured not just in terms of character stats and equipment, but also in terms of player skill, as characters are expected (as in Rogue Legacy, which draws inspiration from roguelikes) to die like Chicagoans vote - early and often! Permadeath games in general, such as The Binding of Isaac and FTL, don't necessarily qualify, though, as they usually get much harder as the player progresses to compensate for the lack of length. I included Rogue Legacy because your accomplishments carry over from one game to the next, making future playthroughs easier, and Angband because the difficulty curve, while sloping upward, does so gently, what with the game's ridiculously long length; the real difficulty comes from mastering the game's mechanics and strategies. Not that games with upward-sloping difficulty curves are less enjoyable than games with downward-sloping curves with the occasional spike; each style has its own unique charm!