Page 1 of 1

Blaze Commando vs Arc Lightning

PostPosted: 10 Jul 2019, 18:08
by Aswan jaguar
Describe the Bug:
Blaze Commando didn't trigger in dev. I fixed that but it doesn't work with cards like Arc Lightning correctly Blaze Commando triggers 1 time per different target so with 3 different targets will make 6 tokens instead of 2 per spell that deals damage. Is this still Arc Lightning's issue not dealing damage in one packet? or is it Blaze Commando's fault?
Old working code EMNV2 had also this bug.
current code:
Code: Select all
int card_blaze_commando(int player, int card, event_t event){
/* Blaze Commando   |3|R|W
 * Creature - Minotaur Soldier 5/3
 * Whenever an instant or sorcery spell you control deals damage,
 *       put two 1/1 |Sred and |Swhite Soldier creature tokens with haste onto the battlefield. */
if( event == EVENT_DEAL_DAMAGE ){
      test_definition_t test;
      default_test_definition(&test, TYPE_SPELL);
      check_damage_test(player, -1, event, 0, player, card, 0, &test);

   int result = resolve_damage_trigger(player, card, event, 0, player, card);
   if( result ){
      token_generation_t token;
      default_token_definition(player, card, CARD_ID_SOLDIER, &token);
      token.qty = 2*result;
      token.color_forced = get_sleighted_color_test(player, card, COLOR_TEST_RED) |
                     get_sleighted_color_test(player, card, COLOR_TEST_WHITE);
      token.s_key_plus = SP_KEYWORD_HASTE;

   return global_enchantment(player, card, event);
Which card did behave improperly?

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Manalink dev

What exactly should be the correct behavior/interaction?
Blaze Commando’s ability triggers each time an instant or sorcery spell you control deals damage (or, put another way, the number of times the word “deals” appears in its instructions), no matter how much damage is dealt or how many players or permanents are dealt damage. For example, if you cast Punish the Enemy and it “deals 3 damage to target player or planeswalker and 3 damage to target creature,” Blaze Commando’s ability will trigger once and you’ll get two Soldier tokens.

Are any other cards possibly affected by this bug?

Re: Blaze Commando vs Arc Lightning

PostPosted: 11 Jul 2019, 03:00
by Korath
It's Blaze Commando's fault. Arc Lightning's already doing the best it can - you'll find that if you have it deal all its damage to one target, it'll deal its damage all it one packet, producing two tokens, instead of three packets of one damage each like it used to.

The engine doesn't natively have any events or triggers for damage dealing except "Whenever a source deals damage to a target", so if you want to implement "Whenever a source deals damage to one or more targets" (or the reverse), you've got to filter out the duplicates yourself, the same way Blaze Commando already filters out damage sources that aren't instants or sorceries or that aren't controlled by you. DDBM_TRACE_DAMAGING_SOURCES almost does what you need; in check_damage_test(), it'll record the source of each packet of damage in the triggering card's targets[] array and a count of them in its info_slot, and in resolve_damage_trigger(), it'll clear info_slot and return its previous value.

What you need to do is add another DDBM_ bit that, when combined with DDBM_TRACE_DAMAGING_SOURCES, checks to see if a source it's about to add is already present, and not add it if it is.

Alternately, you can just pass DDBM_TRACE_DAMAGING_SOURCES in card_blaze_commando and search for duplicates yourself when resolve_damage_trigger() returns. But that's sloppy, and there's a lot of other cards that need this functionality (look for "(merged)" in src/shandalar/cards/deals_damage_trigger.cpp).

Re: Blaze Commando vs Arc Lightning

PostPosted: 11 Jul 2019, 13:00
by Aswan jaguar
Just checked again, aren't we safe to just make it produce 2 tokens if a source deals damage instead of 2tokens X a source deals damage (that it is now)? Are there any cards that have "deal damage" more than once in their rules text so they could cause a problem? My search if correct didn't find any. Or is there another interaction that I don't take into consideration.
If not Blaze Commando works fine with Arc Lightning if token.qty is not 2Xresult but as it should be just 2.

Re: Blaze Commando vs Arc Lightning

PostPosted: 11 Jul 2019, 14:27
by Korath
I'd be fragile, and I wouldn't trust it - the card you'd be implementing would be "Whenever one or more instant or sorcery spells you control deal damage, create two tokens", which isn't quite the same thing. It would certainly break if WOTC printed a card reading something similar to "Counter all other spells. Each spell countered this way deals one damage to its controller."; would be likely to break with delayed triggers like Quenchable Fire's; and I wouldn't be surprised if it broke if you cast, say, more than one Fiery Temper as a result of a single discard effect.

Less hypothetically, there's plenty of cards that cause multiple permanents to simultaneously deal damage, and so this wouldn't work for cards triggering on non-spell damage sources, for example Tamanoa (which is currently broken the same way as Blaze Commando, demonstrable with either another card that triggers on life gain or with Angel of Vitality) or Rite of Passage (which currently tries to avoid the issue with a truly abominable hack).

Re: Blaze Commando vs Arc Lightning

PostPosted: 11 Jul 2019, 16:46
by Aswan jaguar
Fixed no trigger and token quantity only in 8dc2379a. This remains open for a proper fix by a developer who can follow Korath's instructions.