Advice on how to set up script hierarchy for turned based combat system enemies

I’m interested in make a classic rpg game with a turn based combat system, similar to the battle system Paper Mario franchise (obviously excluding Super Paper Mario). I’m wondering what the best practices would be for setting up the enemy scripts. I’m experimenting to learn better scripting practices as currently my skills are very basic.

In regards to the enemies, should each enemy and the attacks it can perform be contained within its own module script? Or should I be making general classes for enemies and having each enemy inherit from those classes? Does anyone have any good learning resources for setting up this kind of system?



I can’t find any direct resource but here’s something I found useful

All about OOP

OOP in Lua

Kurdiez Scripting #5: Uni-directional data flow

OOP and Metatable are really advance topics, with that said it’s perfect for the job!

So you create a Base_Class for all NPCs

Why do you need a Base_Class?
Because all NPCs will have the same basic stats like; Health, Damage, Armor, WalkSpeed, EXPOnDeath, ItemDrops, etc
They will also have basic functions like; Move,Attack,Spawn,Die etc

You know like Humans;
Gender, Age, Race, etc

then you create another Class for specific types of NPCs like
Lava_Class; Has fire skills, Immune to Fire Magic etc,

With OOP and MetaTables it will make your Code really clean and very organized.

Other related stuff


Thanks this was super useful! Exactly the breakdown I needed.