Space Mercs now has more complex, DnD-like melee combat. The prototype game has been featuring a simple, no-hit roll melee system that simply did damage between 1 and whatever your character’s strength happened to be. Now, characters make a d20 roll whenever a character attempts to melee attack. The d20 roll is modified by your character’s BattleLevel, which is a facet of the game’s unique character-level system.
Here is the code for melee:
An entity calls this method whenever it tries to move into a square occupied by an entity of another team (the teams are currently only Players and Mobs). Initially I was going to have multiple enemy factions that would battle with each other, but I found that monsters would end up killing each other if the PCs waited long enough. Believable, but not fun. Unless I can figure out a way around that, it’s out for now.
Because of the real-time nature of combat in Space Mercs, I had to make sure that missing in melee is implemented in the game, although I was originally planning on having no-miss combat. Without it, the game runs simply too dangerously.
I have finally resolved the inventory stutter Space Mercs suffered from! As you can see in the below picture, the game recognizes the use of an item (such as a potion) and prevents itself from repeating the message a thousand times–success! What happened was that I had failed to correctly do a check for current key while ensuring that the key had previously NOT been held down.
I was under the impression that my code had corrected for this possibility without the need to actually check each keystroke against the previous stroke, but I guess that I had missed something somewhere. Adding in an explicit check like this takes almost no time or effort, however, and it works well enough that I don’t regret adding it in.