It is currently 18 Apr 2024, 16:02
   
Text Size

[fixed]Bad parameter activating Thirsting Axe & bad code.

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

[fixed]Bad parameter activating Thirsting Axe & bad code.

Postby etphonehome » 09 Oct 2021, 22:47

Bad parameter after activating Thirsting Axe.

The effect of this card is not working either. If you don't deal damage to a creature, nothing happens.

THX
Attachments
thirsting axe.rar
(3.6 KiB) Downloaded 75 times
dump.rar
(272 Bytes) Downloaded 76 times
Captura de ecrã 2021-10-09 234426.jpg
Last edited by drool66 on 22 Oct 2021, 17:07, edited 2 times in total.
Reason: fixed
etphonehome
 
Posts: 300
Joined: 21 May 2020, 12:50
Has thanked: 270 times
Been thanked: 39 times

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby Aswan jaguar » 10 Oct 2021, 13:32

This fixes the error and some other issues but not the bad effect. And still doesn't respect the following rule:
7/13/2016 Thirsting Axe’s triggered ability checks whether the creature it’s attached to at the moment your end step begins dealt combat damage to a creature earlier in the turn. It doesn’t matter whether Thirsting Axe was attached to it (or to any creature at all) as combat damage was dealt.
Code: Select all
int card_thirsting_axe(int player, int card, event_t event)
{
   /* Thirsting Axe   |3   0x200f011
    * Artifact - Equipment
    * Equipped creature gets +4/+0.
    * At the beginning of your end step, if equipped creature didn't deal combat damage to a creature this turn, sacrifice it.
    * Equip |2 */

   if( is_equipping(player, card) ){
      card_instance_t *instance = get_card_instance(player, card);
      int p = instance->damage_target_player;
      int c = instance->damage_target_card;
      if( damage_dealt_by_me_arbitrary(player, card, event, DDBM_MUST_DAMAGE_CREATURE | DDBM_MUST_BE_COMBAT_DAMAGE, p, c) ){
         instance->info_slot = 66;
      }
      if( current_turn == player && trigger_condition == TRIGGER_EOT && affect_me(player, card) && reason_for_trigger_controller == player ){
         if( instance->info_slot ==  66 ){
            instance->info_slot = 0;
         }
         else{
            if( eot_trigger(player, card, event) ){
               kill_card(p, c, KILL_SACRIFICE);
            }
         }
      }
   }

   return vanilla_equipment(player, card, event, 2, 4, 0, 0, 0);
}
---
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

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby drool66 » 11 Oct 2021, 00:43

Borrowed from Shandalar:
Code: Select all
int card_thirsting_axe(int player, int card, event_t event)
{
   /* Thirsting Axe   |3   0x200f011
    * Artifact - Equipment
    * Equipped creature gets +4/+0.
    * At the beginning of your end step, if equipped creature didn't deal combat damage to a creature this turn, sacrifice it.
    * Equip |2 */

   if( eot_trigger(player, card, event) && current_turn == player && is_equipping(player, card)){
      card_instance_t *instance = get_card_instance( player, card);
      int eqdp = instance->targets[8].player;
      int eqdc = instance->targets[8].card;
      if( in_play(eqdp, eqdc) ){
         for (int p = 0; p < 2; ++p)
            for (int c = 0; c < active_cards_count[p]; ++c){
               card_instance_t* inst = get_card_instance(p, c);
               int oiid = inst->original_internal_card_id;   // cast for signedness (why doesn't static_cast do anything?)
               if (oiid == damage_card   // so it was a damage card (this turn)
                  && inst->damage_source_player == eqdp && inst->damage_source_card == eqdc
                  && inst->internal_card_id == -1   // already dealt its damage
                  && inst->info_slot > 0   // its damage wasn't prevented
                  && (inst->token_status & (STATUS_FIRST_STRIKE_DAMAGE | STATUS_COMBAT_DAMAGE))   // was combat damage
                  && (inst->targets[3].player & TYPE_CREATURE))   // to a creature
                  return 0;
            }
         kill_card(eqdp, eqdc, KILL_SACRIFICE);
      }
   }

   return vanilla_equipment(player, card, event, 2, 4, 0, 0, 0);
}
User avatar
drool66
Programmer
 
Posts: 1163
Joined: 25 Nov 2010, 22:38
Has thanked: 186 times
Been thanked: 267 times

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby Korath » 11 Oct 2021, 03:20

Shandalar can do that because I've been very careful about how damage is created and prevented:
  • Damage cards are never flagged STATUS_FIRST_STRIKE_DAMAGE or STATUS_COMBAT_DAMAGE except for damage as a result of the actual combat damage, not just by virtue of having been dealt by an attacking creature during the combat damage step (like Tephraderm does, or Commando Raid will let anything do).
  • Damage cards record the type of the object being damaged at the time it's being damaged, in case it later becomes some other type. Manalink just records the type of the object that's dealing the damage (in targets[3].player, which you check above).
  • Damage prevention always changes the damage card's info slot, even while preventing all its damage. It never taps or destroys the damage card, both of which also "work" to keep the damage from being dealt, and both of which I've seen cards in Manalink do. I haven't been paying attention to whether they've been fixed.
  • I don't remember if I ever put an equivalent of Shandalar's garbage_collect_card_instances() in Manalink, but this technique depends on damage cards never being collectable. I know that if there is a Manalink version it'll collect them, because no one else would prevented it from doing so, and because, er, I see I don't do so in Shandalar.
If this were an easy, or even feasible, backport, I'd have done it with the other Eldritch Moon artifacts in commit 101457719.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby Aswan jaguar » 11 Oct 2021, 09:23

Added the fix borrowed from shandalar in commit ea8e894. I guess it will not work correct in all cases as Korath says in his post above but it is way better than what we have now as it covers the main effect, respects the rule of checking damage to creature if not equipped and works if all damage gets prevented.
---
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

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby Korath » 11 Oct 2021, 15:51

As a bare minimum, this must check that it dealt damage to a creature, not a player or planeswalker. Otherwise, it's not even an approximation; it's implementing a completely different card.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: [confirm]Bad parameter activating Thirsting Axe & bad co

Postby drool66 » 11 Oct 2021, 18:19

Right - I'll take care of storing damage target types in targets[5].card of the damage card and rewrite Bronze Horse in the process. I'm thinking of checking whether the damage source targets the damage target and socking that as 1 or 0 in targets[7].player of the damage card for the Bronze Horse functionality.

EDIT: completed in d845490
User avatar
drool66
Programmer
 
Posts: 1163
Joined: 25 Nov 2010, 22:38
Has thanked: 186 times
Been thanked: 267 times


Return to Archived Reports

Who is online

Users browsing this forum: No registered users and 63 guests


Who is online

In total there are 63 users online :: 0 registered, 0 hidden and 63 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 63 guests

Login Form