Embermaw Hellion Difficulties
Posted: 23 Aug 2015, 08:38
So, I've encountered another card that just doesn't seem to be nearly as simple as it should be. Embermaw Hellion is simply supposed to add 1 damage to any damage another red source you control would deal. However, thanks to a lack of any function to modify damage except to prevent it or multiply it, I first tried this:
2: (2+1)/2 = 3/2 = 1.5 -> 2*1.5 = 3
It continues to work like it should and I was hopeful. However, the Multiply function apparently only accepts integers, not floats, even if the resulting damage amount would still be an integer. So, it only works for 1 original damage (where it gets multiplied by 2). Any more damage and the multiplier is between 1 and 2. So, that method wouldn't work.
I decided to go with the code that seemed to work, and sure enough, in most situations, it does. It multiplies by the smallest number needed to ensure that at least enough damage is being dealt, and then it prevents any extra.
Cast Lightning Bolt with 4 Hellions, and it'll multiply by 3, and then it'll prevent 2, for a total of 7 damage (correct). If you have 1 Embermaw Hellion, it'll multiply by 2 and prevent 2, for the correct result of 4.
However, there's a flaw with this: some damage can't be prevented. An Embermaw Hellion and a Wild Slash results in 4 damage being dealt, not 3. Arrow Storm after attacking results in 10 rather than 6.
So, my friend thought of making it so that right before a source that can deal unpreventable damage deals any damage, it runs a function to check for any cards that add to the damage first and modifies the damage before dealing it. Anything that adds damage will exclude anything that has the ability to deal unpreventable damage.
My question is this: is there an easier or better way to do this so that Flaring Pain doesn't double all damage dealt when you have an Embermaw Hellion? There are 15 cards than can deal unpreventable damage (including Flaring Pain) and 4 that add to the amount of damage things deal. Embermaw Hellion is staying as it is for now, but I'd like to eventually fix this.
- Code: Select all
local Amount = Damage():GetAmount()
Damage():Multiply( (Amount+1)/Amount )
2: (2+1)/2 = 3/2 = 1.5 -> 2*1.5 = 3
It continues to work like it should and I was hopeful. However, the Multiply function apparently only accepts integers, not floats, even if the resulting damage amount would still be an integer. So, it only works for 1 original damage (where it gets multiplied by 2). Any more damage and the multiplier is between 1 and 2. So, that method wouldn't work.
I decided to go with the code that seemed to work, and sure enough, in most situations, it does. It multiplies by the smallest number needed to ensure that at least enough damage is being dealt, and then it prevents any extra.
Cast Lightning Bolt with 4 Hellions, and it'll multiply by 3, and then it'll prevent 2, for a total of 7 damage (correct). If you have 1 Embermaw Hellion, it'll multiply by 2 and prevent 2, for the correct result of 4.
However, there's a flaw with this: some damage can't be prevented. An Embermaw Hellion and a Wild Slash results in 4 damage being dealt, not 3. Arrow Storm after attacking results in 10 rather than 6.
So, my friend thought of making it so that right before a source that can deal unpreventable damage deals any damage, it runs a function to check for any cards that add to the damage first and modifies the damage before dealing it. Anything that adds damage will exclude anything that has the ability to deal unpreventable damage.
My question is this: is there an easier or better way to do this so that Flaring Pain doesn't double all damage dealt when you have an Embermaw Hellion? There are 15 cards than can deal unpreventable damage (including Flaring Pain) and 4 that add to the amount of damage things deal. Embermaw Hellion is staying as it is for now, but I'd like to eventually fix this.