Posted March 25, 2024 by PestoRavioli
So yesterday (3/24) I spent some time implementing a move called Cat Breath (RIP to in inspiration Lucy up the street) that will work like a normal attack, but has a significantly increased chance at a critical hit; however, it will also delay your next turn. I also worked a bit on trying to implement turn order. When I say turn order, I don't mean based on the graceful stat (ie agility). The way I'm going to implement skills (and items if I decide to have items) is to have skills essentially make you lose a turn (or more than one turn). It almost certainly would be easier to do a straight magic point system, but I figured this would be a nice spin on things and if I can nail the battle system and damage calculations, this could add a bit of strategy to the encounters. Right now, I think it's working with the 2 skills I have (dusty's chirp -- healing -- and cat breath), but I haven't tested extensively because the damage calculations and/or stats for both player and enemy are just way off. Best I can tell by testing my 'great porkachew' encounters, it seems like this works. I'll leave it for now and go back to this at a later date.
To determine the roll for critical hits, I normally have two damage multipliers that are a random value between 1 and 4. If both fields roll a 4, you score a critical that is double the typical damage. For cat breath, you essentially have a 50% chance at a crit. I roll the first multiplier to a random value of 1 or 2. So I'm only looking for a 2 to get a crit. Big difference in frequency, but is it worth the risk on stronger enemies (ie bosses)!?
To implement losing/delaying your turn, I created variables for both the player and the enemy called turnOrder. Since battles are menu driven, I leverage the menu selection to drive most of the logic in my flows. I have multiple scripts throughout the battle flow. It's hands down the most complex system I have and probably will remain the most complex. Generally speaking, the flow goes like this:
Whew! That was so much text! I didn't plan on giving this long and detailed of an update! I just started typing and one thought led tot he next. It's nice to see the flow laid out though. I should create a workflow diagram at some point.
My code has gotten really messy. I tried creating a script, but no matter where I put it, it felt like it was never functioning correctly. So I ended up building nested if statements in to the battle flow. It sucks and will make maintaining things moving forward a nightmare. I probably should focus on refactoring the entire codebase while it's small. Perhaps I will at some point over the coming weeks. I'm far from a professional developer and in fact my day job is 'product owner', so i'm even at a loss for how to best parse this all out in to scripts. But code cleanliness isn't exactly a good or flashy update, so I'll leave it at that. It is on my list of 'some day maybe' items.