For one of our labs in a game development course I was taking, we were told to just have fun and make a simple game using what we had learned in the course up to that point. I decided to try my hand at random, procedural generation as well as a turn-based RPG-style stat and battle system.
Click here to download and install the game: Procedural Turn-Based Dungeon Crawler.zip
Click here to view the code on the project’s repository: Procedural Turn-Based Dungeon Crawler Source Code
Click here to view and download the soundtrack: Procedurally Generated Role Playing Game Original Soundtrack
Screenshot of PGT… whatever I call it.
Working on this game went rather smoothly. Not surprisingly, the most time-consuming parts of it were the random map generation, enemy AI, and stat balancing. It was all very experimental, and no “official” algorithms were used. …or if there were, it was by accident!
The calculations I concocted for leveling up, damage, etc. were pretty convoluted. I basically just experimented with math through what was partially trial and error until things seemed to balance out.
Some interesting aspects I implemented are:
- Stats (STR, AGI, etc.) will increase more depening on what actions you do in battle most often. For example, if you do a lot of melee attacks, your ATK will increase quicker. So ATK = melee, DEF = blocks (defends), MAG = magic, DEX = successful dodges.
- HP and MP will increase more upon level up depending on if ATK or DEF is higher.
- Known spells and weapons are based on MAG and ATK level (respectively).
- Each weapon has a base damage amount, a critical hit chance, and an accuracy rate. Each of these, as well as both the attacker and target’s stats, are used in the equations to calculate the result of an attack.
- Each spell was meant to be unique to each other. Fireball simply deals damage, Cure simply heals, Convert swaps the caster’s HP with their MP, and Absorb steals life from the target and gives it to the caster.
The AI is rather large and branching. Certainly too much to fit on this page. It is aware of it’s HP, MP, known spells, known melee attacks, and opponent’s HP and MP. Depending on all of these stats, they may choose to be aggressive, figuring the odds are in their favor. They may see that they are in danger and choose to play defensively. There is always a chance that they will behave recklessly, despite the circumstances. This is mostly to keep them beatable.
The map generation is rather convoluted and hard-coded. Feel free to look at it in the source code if you dare (Map Generation Code), but I won’t bother to try and put it into words.
This project was incredibly fun to work on and I am quite pleased with what I was able to accomplish in a week.