Page 1 of 1

[fixed]Belbe's Armor AI no consider in attack/de decisions

PostPosted: 23 May 2017, 13:07
by Aswan jaguar
Describe the Bug:
1- AI never uses Belbe's Armor to reduce opponent's creature power even if it will die.It only uses the ability to it's own creatures to boost their toughness. fix
2- Also AI doesn't consider the ability while thinking if it will attack or not or block or not.
Which card did behave improperly?
Belbe's Armor AI part.

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Manalink 2016/08/27: Eldritch Moon v2, duel

What exactly should be the correct behavior/interaction?
1- AI can also use Belbe's Armor ability to reduce an opponent's creature power to reduce/prevent damage.
2- Also AI considers the ability while thinking if it will attack or not or block or not.
Are any other cards possibly affected by this bug?
-

Re: [confirm]Belbe's Armor AI never activates on opponent's

PostPosted: 02 Mar 2019, 09:59
by Aswan jaguar
Allow AI to target creatures in cd06792.

Re: [confirm]Belbe's Armor AI never activates on opponent's

PostPosted: 18 Jul 2019, 22:20
by Korath
default_target_definition() defaults preferred_controller to 1-player, so if you don't override it - and with this change, you don't - it'll prefer to always target the opponent's creature, never its own.

Re: [confirm]Belbe's Armor AI never activates on opponent's

PostPosted: 19 Jul 2019, 11:15
by Aswan jaguar
Fixed so now AI can target creatures of both players in commit aee0ac9010.

Re: [confirm]Belbe's Armor AI never activates on opponent's

PostPosted: 19 Jul 2019, 17:21
by Aswan jaguar
Korath any example card I can follow to get "2- Also AI doesn't consider the ability while thinking if it will attack or not or block or not." working?

Re: [confirm]Belbe's Armor AI never activates on opponent's

PostPosted: 19 Jul 2019, 18:40
by Korath
I don't see any card in Manalink of the form " {X}, (maybe some other costs): (This/Target creature) gets (±XX / ±X/+0 / +0/±X) until end of turn" with any combat AI at all, but for activated abilities of permanents - like this is - the form used in Shandalar's implementation of Belbe's Armor in src/shandalar/cards/pump_target_activated.cpp will work. There isn't an exact equivalent to has_mana_to_activate_X(), but when there isn't a mana cost in addition to {X} and you're not worried about accounting for external cost modifications, "avail = has_mana(player, COLOR_ANY, 1);" is close enough.

Re: [confirm]Belbe's Armor AI no consider in attack/de decis

PostPosted: 16 Nov 2019, 18:41
by Aswan jaguar
Fixed in commit 6ba435bd.
Current code is:
Code: Select all
int card_belbes_armor(int player, int card, event_t event){
/* CARD_ID_BELBES_ARMOR   4670
Belbe's Armor   |3
Artifact
|X, |T: Target creature gets -X/+X until end of turn. */
   
   target_definition_t td;
   default_target_definition(player, card, &td, TYPE_CREATURE);
    td.preferred_controller = ANYBODY;

    if (event == EVENT_CHECK_PUMP)
    {
      int avail = generic_activated_ability(player, card, EVENT_CAN_ACTIVATE, GAA_UNTAPPED | GAA_CAN_TARGET,
                                                                   MANACOST_X(-1), 0, &td, "TARGET_CREATURE");
      pumpable_power[1-player] -= avail;
      pumpable_toughness[player] += avail;
    }
   
   if( ! IS_GAA_EVENT(event) ){
      return 0;
   }

   card_instance_t *instance = get_card_instance(player, card);

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

   return generic_activated_ability(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST_X(-1), 0, &td, "TARGET_CREATURE");
}
And the values in AI inc power/toughness in Manalink.csv are -100/100.
Generally AI most of the times gets the ability in attack/defend decisions but I see weird decisions with creatures with first strike. I think it is a problem with EVENT_CHECK_PUMP vs first strike.
For instance AI has a 4/4, an 1/1 and a 3/2 creature with first strike and an untapped Belbe's Armor and 6 mana available while I have a 5/5 first striker. AI will attack only with the 2 non strikers.