Handling Alterable Values with multiple Groups
Hey
There is one challenge that keeps on haunting me, and Im curious as to if there is a more efficient way than what I do. Basically, most of my objects in my game are in multiple groups. Ill take an example of a Super Mario game. This is basically how I would build a simple enemy:
I make a group for Horizontal movement, that will require 2 Alterable Values: MovementSpeed (a constant number) and Direction (1 or -1).
I make a group for enemies that are killable by being jumped on. Lets just say this will require 1 Alterable Value for what the enemy will drop when it dies (coins, feather, mushroom, nothing).
I make a group for enemies that are killable by fireball, and give this 1 Alterable Value also for what the enemy will drop.
I make a group for enemies that will hurt Mario, and use 1 Alterable Value for the damage it does to Mario (so if Mario have a fire flower, 1 dmg will downgrade to just big, 2 dmg will downgrade to small and 3 dmg will instant kill).
So now, Alterable Value A, B, C, D and E are now occupied. If I make a new enemy that are not killable by being jumped on or shot by fire (say, a spike or just lava), the object will have to "waste" the first 4 Alterable Values, because they are irrelevant. This is a little bad in my opinion, but its not the biggest challenge. Lets say there are a bunch of more Alterable Values occupied (one for enemies that can be eaten by Yoshi and what he will spit out again, ++ lots others), I then decide that I want to add an Alterable Value to the group that are handling fireball. I want some enemies to take 2 or 3 hits. This is simple enough by just adding an Alterable Value FireballHealth or something to the enemies, but in my structure, this is getting a little tricky. I must then find the group that uses the last/lowest (closest to end) Alterable Value and use the next Alterable Value after this as the one handling the Health. At some point, this will just be a total mess.
So I am kinda curious as to if someone is having a clever technique to actually handle things like this? By the years, I am able to foresee a lot of this in my planning phase, but this happens everywhere. And I am mixing groups in every direction. Maybe I have enemies that the player can stand on, which will bring obstacles into the picture aswell, and obstacles uses Alterable Values that crashes with the enemy ones. Lots of possibilities..