[fixed]Fabrication Module crashes when it triggers

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:
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);
}