In my game, the player will be able to access a menu and change their elemental attack mid-stage. There are four elements: lightning/wind, fire, earth, and water/ice.
I wanted the enemies to have a variety of possible elemental defenses. From normal damage, to double damage, to half damage, to zero damage. And in my attempt to to this all in as few events as possible, as efficiently as possible, I gave the Enemy group 4 variables: lightning, fire, earth, and water. Now I didn't have to make separate groups for different elemental enemies, and if I wanted to allow an enemy to have more than one elemental defense, or a contradicting one, I could!
Just so you know what I planned...
Lightning weapon VS neutral enemy = normal damage.
Fire weapon VS fire-resistant enemy = 0.5 damage.
Earth weapon VS earth-weakness enemy = 2x damage.
Water weapon VS water-immune enemy = no damage.
What I tried for the variables was this:
1 = normal damage to that element.
2 = double damage to that element.
0 = immunity to that element.
0.5 = half damage to that element.
That was my plan in working out some calculation to handle all that stuff. "Base Damage" is how much damage an attack would be able to do, having given the Attack family a "Base Damage" variable so all objects under that family could have that variable, but modified for each hit box. I also gave that family its own set of elemental variables just so I wouldn't have to make new families for each element either. If an attack didn't have one of the elements, that element would be set at 0.
Attack.Value('Base Damage')*((Attack.Value('Lightning')*.Value('Lightning'))*(Attack.Value('Fire')*.Value('Fire'))*(Attack.Value('Earth')*.Value('Earth'))*(Attack.Value('Water')*.Value('Water')))*global('Attack Strength')*global('Extra Attack')
Now obviously, throwing ALL the elemental variables for the enemies and attacks gives us a little problem. Sure, it'd be novel if an attack had ALL elemental properties, used against an enemy weak to fire, but resistant to ice, since theoretically we could do something like that. But before we think of that, this calculation needs fixing. We can't even have ONE elemental attack against an enemy because we're multiplying by zeros here, and that sets the entire equation to 0.
Would anyone happen to have any ideas or ways around this? Any suggestions? I doubt it, but I wouldn't imagine Construct would have an expression where something multiplied by zero could still equal 1. And I wanted this to be as universal as possible, done on one event, so I couldn't have to code specific weaknesses and resistances for each enemy, or certain properties into every attack's hit box. I just change some variables and I'm done.