Hard-Coding different enemy/object behaviors

Hello,

As of late I have been working on some games that have some more complex objects such as weapons, enemies, and tiles. For each of these categories, there are different things that each can be, for example, a tile can be a bush or a barrel. A weapon has different attributes such as noise, range, and damage. Enemies have different attributes and AI’s. I just wanted to ask what the best way of implementing these different behaviors would be. As much as I despise singletons, right now I am using a singleton table to store the different behaviors and reading from that based on an ID. Are there any alternative ways to accomplish these different behaviors? I could use class inheritance, but that would end in a lot of classes. I could hard-code it with if statements, but that is hardly expandable. How have you accomplished different behaviors for similar objects in the past? What is the best practice for doing what I described?

Is it just attributes or behaviour too?

As much as I despise singletons, right now I am using a singleton table to store the different behaviors and reading from that based on an ID.

If it’s just attributes, a table.

If it’s behaviour with methods, perhaps subclasses? Just be careful not to let the hierarchy get too deep.

A table for holding generic behaviour patterns sounds fine to me

Alright, thanks so much! Really it’s just attributes for the weapons, but for the tiles I guess I could simplify the behavior to attributes, even though I was planning on using methods (I.E. onShot, onCollide, etc) those could be turned into things like flammable=true/false, solid=true/false. Thanks again!