Page 1 of 1

[fixed]Fabrication Module crashes when it triggers

PostPosted: 29 Mar 2019, 18:45
by Aswan jaguar
Describe the Bug:
Fabrication Module crashes as soon as you activate it and have a creature or a creature with energy counters enters the battlefield.

Which card did behave improperly?
Fabrication Module

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

What exactly should be the correct behavior/interaction?


Are any other cards possibly affected by this bug?

I have tried a lot but either it will crash or it will trigger twice. Can you please tell me what is the problem?
My latest attempt it triggers twice:
Code: Select all
int card_fabrication_module(int player, int card, event_t event)
{
/*
Fabrication Module |3   0x200f458
Artifact
Whenever you get one or more |E (energy counters), put a +1/+1 counter on target creature you control.
|4, |T: You get |E.
*/
   enable_xtrigger_flags |= XTRIGGER_COUNTER_ENERGY;
   if( xtrigger_condition() == XTRIGGER_COUNTER_ENERGY && affect_me(player, card) && trigger_cause_controller == player &&
      ! is_humiliated(player, card))
   {
      if (event == EVENT_TRIGGER){
          event_result |= RESOLVE_TRIGGER_MANDATORY;
      }
       if (event == EVENT_RESOLVE_TRIGGER){
    
      target_definition_t td;
      default_target_definition(player, card, &td, TYPE_CREATURE);
      td.allowed_controller = td.preferred_controller = player;
      td.allow_cancel = 0;

      card_instance_t *instance = get_card_instance( player, card );

         if( can_target(&td) && new_pick_target(&td, "TARGET_CREATURE_YOU_CONTROL", 0, 0){
           add_1_1_counter(instance->targets[0].player, instance->targets[0].card);
         }
         instance->number_of_targets = 0;
      }    
   }
   if( event == EVENT_RESOLVE_ACTIVATION ){
      add_energy(player, 1);
   }

   return generic_activated_ability(player, card, event, GAA_UNTAPPED, MANACOST_X(4), 0, NULL, NULL);
}
-

Re: Fabrication Module crashes when it triggers

PostPosted: 31 Mar 2019, 00:16
by Korath
That shouldn't even compile; you've misbalanced parentheses on the line with new_pick_target().

I don't know why it would crash. It doesn't for me, once the missing close-paren is added. The reason the trigger happens twice is because it doesn't check reason_for_trigger_controller.

(Also, there's no such internationalization "TARGET_CREATURE_YOU_CONTROL", unless you've added it since our server broke. You want "ASHNODS_BATTLEGEAR".)

Re: Fabrication Module crashes when it triggers

PostPosted: 31 Mar 2019, 10:29
by Aswan jaguar
Korath wrote:That shouldn't even compile; you've misbalanced parentheses on the line with new_pick_target().
I guess I have posted this and then fixed the parentheses issue between so many tries and testing.
Korath wrote:(Also, there's no such internationalization "TARGET_CREATURE_YOU_CONTROL", unless you've added it since our server broke. You want "ASHNODS_BATTLEGEAR".)
Well, I have added this before the server issue in commit 73231e99c. And few others later as I was correcting such bugs.

Edit: Fixed in commit 7fd24c9a.

Re: [fixed]Fabrication Module crashes when it triggers

PostPosted: 20 Jul 2019, 14:12
by Korath
Trigger order is now always picked by the AI, instead of the Module's controller. Not that there are all that many "Whenever you get an energy counter" triggers so as to need ordering, but still.

Re: [fixed]Fabrication Module crashes when it triggers

PostPosted: 21 Jul 2019, 08:02
by Aswan jaguar
Fixed in commit ad30427a.