It is currently 27 Apr 2024, 16:21
   
Text Size

bug of Sneak Attack

Moderator: CCGHQ Admins

bug of Sneak Attack

Postby sumomole » 22 Mar 2014, 04:54

use Sneak Attack put a creature with "ZONECHANGE_TRANSITION"+"replacement_query" triggered ability(e.g. Hellkite Hatchling) onto the battlefield, that creature won't leave battlefield at the end of turn, but haste ability will be given it as usual. I can't find the reason, if anyone knows, please tell me, thanks in advance.
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 234 times

Re: bug of Sneak Attack

Postby RiiakShiNal » 22 Mar 2014, 12:57

I don't know, but given the test card you used and the code of Sneak Attack I can make an educated guess. My guess would be that because Hellkite Hatchling pauses its entry into the battlefield through its ZONECHANGE_TRANSITION replacement_query ability it doesn't actually pause the resolution of the Sneak Attack ability so while the delayed trigger does get created because the creature isn't actually in the battlefield at that time when Hellkite Hatchling does finally enter the battlefield because the stored pointer in the delayed trigger is not protected it gets cleared.

If that is the case then there are 2 possible fixes (that I can think of at this moment):
  1. Protect the card pointer after setting it on the delayDC.
    Code: Select all
    <RESOLUTION_TIME_ACTION>
      local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(0)
      if target_creature ~= nil then
        local delayDC = EffectDC():Make_Chest(1)
        delayDC:Set_CardPtr(0, target_creature)
        delayDC:Protect_CardPtr(0)
        MTG():CreateDelayedTrigger(2, delayDC)
      end
    </RESOLUTION_TIME_ACTION>
  2. Use a CONTINUOUS_ACTION (instead of the RESOLUTION_TIME_ACTION) to wait until the creature actually enters the battlefield then set the delayed trigger. Something like this:
    Code: Select all
    <CONTINUOUS_ACTION layer="0">
      local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
      if (target ~= nil) and (EffectDC():Int_Get(3) ~= 1) then
        if (target:GetZone() == ZONE_BATTLEFIELD) then
          local delayDC = EffectDC():Make_Chest(1)
          delayDC:Set_CardPtr(0, target)
          MTG():CreateDelayedTrigger(2, delayDC)
          EffectDC():Int_Set( 3, 1 )
        end
      end
    </CONTINUOUS_ACTION>
Though again this is just my educated guess without any actual testing so I could be completely off-base.

If I am correct though it could have some serious implications with other card interactions as this poses a problem for ability and interaction timing between cards that have ZONECHANGE_TRANSITION triggers and/or cause other cards to change zones.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 24 guests


Who is online

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

Login Form