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.
No comments:
Post a Comment