It is currently 22 Oct 2018, 18:20
   
Text Size

Embermaw Hellion Difficulties

Moderators: Xander9009, CCGHQ Admins

Embermaw Hellion Difficulties

Postby Xander9009 » 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:
Code: Select all
local Amount = Damage():GetAmount()
Damage():Multiply( (Amount+1)/Amount )
1: (1+1)/1 = 2/1 = 2 -> 1*2 = 2
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.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2820
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 101 times
Been thanked: 421 times

Re: Embermaw Hellion Difficulties

Postby RiiakShiNal » 23 Aug 2015, 23:43

There is not an easier way, but there is a better way. My recommendation would be to take the easier method in this case (meaning you can ignore the rest of this post unless you are curious).

Better way | Open
Unfortunately, the absolute best way to handle this would be to write a new damage dealing system then to have all cards use that system for dealing and/or modifying damage (preventing would remain the same), but this would essentially entail modifying all cards that deal damage (except through combat).

For example you write a new function:
Code: Select all
New_DealDamageTo = function(amount, target, source)
  -- First standard checks to make sure things are valid:
  if ((target == nil) or (source == nil) or (amount == nil) or (amount <= 0))
    return

  -- Here we check for any modifications to the amount such as with Embermaw Hellion
  amount = New_CheckForDamageMods(amount)

  -- Check to see that we still have damage to deal.
  if (amount > 0) then
    -- Now if we still have damage to do we will actually do the damage.
    source:DealDamageTo(amount, target)
  end
end
Then all cards that use the original DealDamageTo need to be updated to use the new one. Unfortunately, because the signature is different (because it is not related to the actual object) each instance needs to be updated properly and checked for correctness.

For example:
Code: Select all
EffectSourceLKI():DealDamageTo(1, player)
becomes:
Code: Select all
New_DealDamageTo(1, player, EffectSourceLKI())
Cards could make use of new damage modification APIs which would allow cards to put their changes into player chests for application later (or if unused would get cleared at a certain point, could make use of integer-based custom characteristics so losing all abilities would work properly).
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2098
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 462 times

Re: Embermaw Hellion Difficulties

Postby Xander9009 » 24 Aug 2015, 00:08

Alright. Then for now, I'll stick with the easier method. One hypothetical day in the future when my ambition overcomes my reason, I may attempt the better method. :)
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2820
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 101 times
Been thanked: 421 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 3 guests


Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 10 minutes)
Most users ever online was 279 on 11 Jul 2013, 22:03

Users browsing this forum: No registered users and 3 guests

Login Form