Page 1 of 1

[still issue]Disciple of Tevesh Szat AI code?

PostPosted: 26 Oct 2018, 17:17
by Aswan jaguar
Describe the Bug:
When Disciple of Tevesh Szat is activated crashes game.

Which card did behave improperly?
Disciple of Tevesh Szat

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

What exactly should be the correct behavior/interaction?
Disciple of Tevesh Szat

Are any other cards possibly affected by this bug?
-

Re: When Disciple of Tevesh Szat is activated crashes game.

PostPosted: 16 Aug 2019, 18:14
by Aswan jaguar
Fixed crash and activation cost issues in commit 1a1afc10.
Edit: I had to remove the AI priority code for this card as it caused dump errors which seemed harmless but still were annoying and I haven't got a clue of what a proper AI decision would be like. If you can help with that please do.
Current code:
Code: Select all
int card_disciple_of_tevesh_szat(int player, int card, event_t event){
/*
Disciple of Tevesh Szat |2|B|B
Creature נHuman Cleric 3/1
{T}: Target creature gets -1/-1 until end of turn.
{4}{B}{B}, {T}, Sacrifice Disciple of Tevesh Szat: Target creature gets -6/-6 until end of turn.
*/
   if( ! IS_GAA_EVENT(event) ){
      return 0;
   }

   target_definition_t td;
   default_target_definition(player, card, &td, TYPE_CREATURE);
   td.preferred_controller = 1-player;

   card_instance_t *instance = get_card_instance(player, card);

   enum{
      CHOICE_M1_M1 = 1,
      CHOICE_M6_M6
   };

   if( event == EVENT_CAN_ACTIVATE ){
      if( generic_activated_ability(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST0, 0, &td, NULL) ){
         return 1;
       }
       return generic_activated_ability(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET | GAA_SACRIFICE_ME, MANACOST_XB(4, 2), 0, &td, NULL);
   }

   if( event == EVENT_ACTIVATE ){
      int abils[3] = {
                     0,
                         generic_activated_ability(player, card, EVENT_CAN_ACTIVATE, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST0, 0, &td, NULL),
                     generic_activated_ability(player, card, EVENT_CAN_ACTIVATE, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST_XB(4, 2), 0, &td, NULL)
      };

         int choice = DIALOG(player, card, event, DLG_RANDOM,
                          "Give -1/-1",       abils[1],   5,
                          "Sac and give -6/-6",   abils[2],    10);
         if( ! choice ){
              spell_fizzled = 1;
              return 0;
         }

         if( choice == CHOICE_M1_M1 ){
            return generic_activated_ability(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST0, 0, &td, "TARGET_CREATURE");
         }
         if( choice == CHOICE_M6_M6 ){
            return generic_activated_ability(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET | GAA_SACRIFICE_ME, MANACOST_XB(4, 2), 0, &td, "TARGET_CREATURE");
         }
   }

   if( event == EVENT_RESOLVE_ACTIVATION ){
      int choice = instance->info_slot;
      if( choice == CHOICE_M1_M1 && valid_target(&td) ){
         pump_until_eot(instance->parent_controller, instance->parent_card, instance->targets[0].player, instance->targets[0].card, -1, -1);
      }
      if( choice == CHOICE_M6_M6 && valid_target(&td) ){
         pump_until_eot(instance->parent_controller, instance->parent_card, instance->targets[0].player, instance->targets[0].card, -6, -6);
      }
   }
   return 0;
}