It is currently 16 Apr 2024, 05:49
   
Text Size

AI - stoning code tweak?

Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

AI - stoning code tweak?

Postby Aswan jaguar » 05 Dec 2020, 13:25

For those of you that don't know we use AI stoning code for other cards besides stoning and similar like cards also to cards with deathtouch and others.
I was making Kjeldoran Frostbeast which in principle has stoning ability but I remembered the issues stoning AI had and I tried to improve it a little but I can't seem to find the correct way to do it.
One of the issues AI has with these kind of cards when not controlling Kjeldoran Frostbeast is that a single creature with stoning Human has can hold back a whole army of AI creatures unless of course AI goes for the the alpha strike win (I have exploited this numerous times while playing). We know AI will not think to trade creatures when considers to attack but if we tell AI that for instance if it has 6 or more creatures AI opponent's Kjeldoran Frostbeast doesn't have stoning will help AI at least to attack with creatures with toughness bigger than 2. This way AI will attack with 1/3,1/4...2/3,2/4...3/3..before alpha strike, gain turns and bring alpha strike sooner.
So my idea is to have AI not consider opponent's Kjeldoran Frostbeast has stoning if AI is attacking player and controls a number of creatures above 5? What do you think? And always assume it has stoning if AI controls it.
EDIT my code below doesn't take care of who is attacking or who is controlling Kjeldoran Frostbeast as I didn't manage to get both.
Code: Select all
static int kjeldoran_frostbeast_legacy(int player, int card, event_t event){

   if( end_of_combat_trigger(player, card, event, RESOLVE_TRIGGER_MANDATORY) ){
      card_instance_t *instance = get_card_instance(player, card);
      kill_card(instance->targets[0].player, instance->targets[0].card, KILL_DESTROY);
      kill_card(player, card, KILL_EXILE);
   }

   return 0;
}

static void attach_kjeldoran_frostbeast_legacy(int player, int card, int t_player, int t_card)
{
   create_targetted_legacy_effect(player, card, &kjeldoran_frostbeast_legacy, t_player, t_card);
}

int card_kjeldoran_frostbeast(int player, int card, event_t event){
   /* Kjeldoran Frostbeast   |3|G|W
    * Creature - Elemental Beast 2/4
    * At end of combat, destroy all creatures blocking or blocked by ~. */

    //int count_crit = IS_AI(player) == 1-player && count_subtype(1-player, TYPE_CREATURE, -1) < 6;
        //AI code for stoning
   if (event == EVENT_CHANGE_TYPE && affect_me(player, card) && !is_humiliated(player, card) /*&& count_crit*/)
      get_card_instance(player, card)->destroys_if_blocked |= DIFB_DESTROYS_ALL;
        //end of AI code
   if (event == EVENT_DECLARE_BLOCKERS && !is_humiliated(player, card)){
      card_instance_t *instance = get_card_instance( player, card);
      if( player == current_turn && (instance->state & STATE_ATTACKING) ){
         for_each_creature_blocking_me(player, card, attach_kjeldoran_frostbeast_legacy, player, card);
      }
      if( player == 1-current_turn && (instance->state & STATE_BLOCKING) ){
         for_each_creature_blocked_by_me(player, card, attach_kjeldoran_frostbeast_legacy, player, card);
      }
   }

   return 0;
}
Last edited by Aswan jaguar on 05 Dec 2020, 13:31, edited 2 times in total.
Reason: add edit
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Return to Development

Who is online

Users browsing this forum: No registered users and 17 guests


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 17 guests

Login Form