Is there a way to get all unblocked creatures power?
Posted: 29 Oct 2020, 16:19
I want to use it in AI code in cards with clause "If you do, ~ assigns no combat damage this turn." so AI doesn't screw that by selecting to not assign damage with that creature when AI goes for an alpha strike. Because for now I check only the card with that ability to assign combat damage if opponent's life is equal or less to the creatures power but I want to check all unblocked creatures.
I tried the following which still counts only the creature with this ability
and not all unblocked attackers (but possibly I am not doing it correctly):
I tried the following which still counts only the creature with this ability
and not all unblocked attackers (but possibly I am not doing it correctly):
- Code: Select all
int card_farrels_zealot(int player, int card, event_t event){
/* CARD_ID_FARRELS_ZEALOT 1777
Farrel's Zealot |1|W|W
Creature - Human 2/2
Whenever ~ attacks and isn't blocked, you may have it deal 3 damage to target creature. If you do, ~ assigns no combat damage this turn. */
if( event == EVENT_DECLARE_BLOCKERS ){
if( is_unblocked(player, card) && ! is_humiliated(player, card) ){
int ai_choice = 1;
//int gp = get_power(player, card);
int unblocked_att_pow = 0;
int c;
target_definition_t td;
default_target_definition(player, card, &td, TYPE_CREATURE);
for(c=active_cards_count[current_turn]-1; c > -1; c--){
if( in_play(current_turn, c) && is_what(current_turn, c, TYPE_CREATURE) && is_attacking(current_turn, c) &&
is_unblocked(current_turn, c) )
{
unblocked_att_pow = get_power(current_turn, c);
}
}
if( IS_AI(player) && current_turn == player && !( unblocked_att_pow >= life[1-player]) ){
td.toughness_requirement = 3 | TARGET_PT_LESSER_OR_EQUAL | TARGET_PT_INCLUDE_DAMAGE;
ai_choice = 0;
}
int choice = do_dialog(player, player, card, -1, -1, " Damage creature\n Pass", ai_choice);
if( choice == 0 ){
if( can_target(&td) && pick_target(&td, "TARGET_CREATURE") ){
damage_target0(player, card, 3);
negate_combat_damage_this_turn(player, card, player, card, 0);
}
}
get_card_instance(player, card)->number_of_targets = 0;
}
}
return 0;
}