Is there a way to get all unblocked creatures power?
Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!
PLEASE DO NOT REPORT BUGS HERE!
Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins
Is there a way to get all unblocked creatures power?
by Aswan jaguar » 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;
}
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8080
- Joined: 13 May 2010, 12:17
- Has thanked: 732 times
- Been thanked: 458 times
Re: Is there a way to get all unblocked creatures power?
by drool66 » 30 Oct 2020, 06:46
To add up all the powers, I think you could just change:
unblocked_att_pow = get_power(current_turn, c);
to:
unblocked_att_pow += get_power(current_turn, c);
I'm not sure, but if you include "is_unblocked" do you necessarily need to check if it's a creature or if it's attacking?
unblocked_att_pow = get_power(current_turn, c);
to:
unblocked_att_pow += get_power(current_turn, c);
I'm not sure, but if you include "is_unblocked" do you necessarily need to check if it's a creature or if it's attacking?
-
drool66 - Programmer
- Posts: 1163
- Joined: 25 Nov 2010, 22:38
- Has thanked: 186 times
- Been thanked: 267 times
Re: Is there a way to get all unblocked creatures power?
by FastEddie » 30 Oct 2020, 06:49
Drool66 beat me on that.
What you want is
What you want is
- Code: Select all
unblocked_att_pow = unblocked_att_pow + get_power(current_turn, c);
- Code: Select all
unblocked_att_pow += get_power(current_turn, c);
Is_unblocked() checks whether STATE_ATTACKING is set. So you don't need to check that. A quick search didn't show, however, where this is set (look for something like "| STATE_ATTACKING" or "|= STATE_ATTACKING") so I don't know whether you also can safely cut out the creature check.I'm not sure, but if you include "is_unblocked" do you necessarily need to check if it's a creature or if it's attacking?
---
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
Re: Is there a way to get all unblocked creatures power?
by Aswan jaguar » 30 Oct 2020, 16:36
Thanks for the help guys, it works now. I am quite happy with AI now.
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8080
- Joined: 13 May 2010, 12:17
- Has thanked: 732 times
- Been thanked: 458 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests