Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
bug of Sneak Attack
Moderator: CCGHQ Admins
bug of Sneak Attack
by 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.
-
sumomole - Programmer
- Posts: 611
- Joined: 07 Jun 2011, 08:34
- Has thanked: 51 times
- Been thanked: 234 times
Re: bug of Sneak Attack
by 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):
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.
If that is the case then there are 2 possible fixes (that I can think of at this moment):
- 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>
- 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>
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.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 24 guests