Story Time: Damage Calcs (09-2024 W2)
A while back, I took a course on making a JRPG batsys. Even by the end, it only scratched the surface of what such a system should be. It was a bit… basic, albeit a good starting point. Thus, I still had a lot of work to do when making Trigram Islands’ battle system ^^; One big part of it: the damage-calcs. What the course taught was this: just reducing the HP of the target by the attack power of the skill they were hit with. Felt it’d be better to go with something like what RPG Maker has. Speaking of, here’s an example of a formula in RM:
a.atk – (b.def / 2)
With a.atk being the user’s Attack stat and b.def being the target’s Defense stat. You can work with other params too. For example…
- a.agi = attacker’s speed
- b.mhp = target’s max hp
You can see how this makes things nice and customizable. That was what I wanted to replicate. Handling stuff like a.atk was easy. What wasn’t… was the other stuff. Parentheses, plus-signs and so on. Thankfully, there’s a third-party library to handle it: MathEval. It had a nice interface that cut out the need for my code to do the string-substitutions too, which is nice. The fun didn’t end there, though! XD I implemented a couple things RM didn’t have. For example, shorthands like these:
- “userAvgAttack” for the average between the user’s Phys and Mag Atk
- “targAvgDef” for the average between the target’s Phys and Mag Def
- “userGreaterAtk” for the greater between the user’s Phys and Mag Atk
You can get the same results with RM, but you’d have to do a lot more typing. Compare “(a.atk + a.matk) / 2” to simply “userAvgAtk”. That’s a 10-keystroke difference! Maybe I should make a plugin for RM sometime that gives it the same convenience… All that said, I can’t blame the aforementioned course for what it didn’t do. After all, with how complex it is to code the average JRPG batsys from the ground up, it’d warrant multiple courses. And overall… I’m happy with the results I got ^^ Definitely gonna reuse my damage-calc code in another project.
Get Trigram Islands
Trigram Islands
Golden-Sun-Esque JRPG
Status | Released |
Author | CG-Tespy |
Genre | Role Playing |
Tags | 3D, Anime, JRPG, Short, Turn-based, Unity |
More posts
- Initial Release (10-2024 W3)54 days ago
- Downscoping And The Initial Release (10-2024 W2)61 days ago
- More BatSys and Overworld Integration (09-2024 W1)94 days ago
- Setbacks And Redos And Title Sequences, Oh My! (09-2024 W0)Sep 02, 2024
- Audio Sys Ready (08-2024 W4)Aug 25, 2024
- Audio Sys Looping (08-2024 W3)Aug 16, 2024
- Audio-Management & Title Screen Progress (08-2024 W2)Aug 11, 2024
- UI Progress (08-2024 W1)Aug 04, 2024
- Coming off Hiatus (07-2024 W4)Jul 28, 2024
Leave a comment
Log in with itch.io to leave a comment.