Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
DASH (mechanic)
Moderator: CCGHQ Admins
DASH (mechanic)
by Tejahn » 21 Jan 2015, 04:09
I need help adding Haste to the Dash mechanic. I've already tested the card and it only returns to hand when the Dash cost is paid. If anyone can help me out I would greatly appreciate it.
Here is the code for Dash.
- Code: Select all
<UTILITY_ABILITY qualifier="Alternate">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Dash {3}{B} (You may cast this spell for its dash cost. If you do, it gains haste, and it's returned from the battlefield to its owner's hand at the beginning of the next end step.)]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Précipitation {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Rapidez {3}{B}.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sturmangriff {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Accelerare {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[疾駆{3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[질주 {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Рывок {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Investida {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[掩袭{3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[掩襲{3}{B}]]></LOCALISED_TEXT>
<COST mana_cost="{3}{B}" type="Mana" />
<COST type="Generic">
<PREREQUISITE>
return true
</PREREQUISITE>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr(0, EffectSource())
delayDC:Protect_CardPtr(0)
MTG():CreateDelayedTrigger(1, delayDC)
end
</RESOLUTION_TIME_ACTION>
</COST>
<ABILITY_TEXT tag="ALTERNATE_COST_PAY_DASH" />
</UTILITY_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" resource_id="1">
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
<TRIGGER value="SPELL_RESOLVED">
return TriggerObject() == EffectDC():Get_CardPtr(0)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local delayDC = EffectDC():Make_Chest(1)
MTG():CreateDelayedTrigger(2, delayDC)
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="2" priority="-1">
<CLEANUP fire_once="1" />
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_END_OF_TURN
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():PutInHand()
end
</RESOLUTION_TIME_ACTION>
<AUTO_SKIP no_effect_source="1" />
</TRIGGERED_ABILITY>
Re: DASH (mechanic)
by migookman » 21 Jan 2015, 06:17
Couldn't 'Dash' be coded similarly as the 'Kicker' ability?
Re: DASH (mechanic)
by Tejahn » 21 Jan 2015, 08:27
You're right. It can be coded as almost any alternative cost. I'll look into coding it that way.
Re: DASH (mechanic)
by Xander9009 » 22 Jan 2015, 02:37
I would try this.
- Code: Select all
<UTILITY_ABILITY qualifier="Alternate">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Dash {3}{B} (You may cast this spell for its dash cost. If you do, it gains haste, and it's returned from the battlefield to its owner's hand at the beginning of the next end step.)]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Précipitation {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Rapidez {3}{B}.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sturmangriff {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Accelerare {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[疾駆{3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[질주 {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Рывок {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Investida {3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[掩袭{3}{B}]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[掩襲{3}{B}]]></LOCALISED_TEXT>
<COST mana_cost="{3}{B}" type="Mana" />
<COST type="Generic">
<PREREQUISITE>
return true
</PREREQUISITE>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr(0, EffectSource())
delayDC:Protect_CardPtr(0)
MTG():CreateDelayedTrigger(1, delayDC)
MTG():CreateDelayedTrigger(3, delayDC)
end
</RESOLUTION_TIME_ACTION>
</COST>
<ABILITY_TEXT tag="ALTERNATE_COST_PAY_DASH" />
</UTILITY_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" resource_id="1">
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
<TRIGGER value="SPELL_RESOLVED">
return TriggerObject() == EffectDC():Get_CardPtr(0)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local delayDC = EffectDC():Make_Chest(1)
MTG():CreateDelayedTrigger(2, delayDC)
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="2" priority="-1">
<CLEANUP fire_once="1" />
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_END_OF_TURN
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():PutInHand()
end
</RESOLUTION_TIME_ACTION>
<AUTO_SKIP no_effect_source="1" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="2" priority="-1">
<CLEANUP fire_once="1" />
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_END_OF_TURN
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():PutInHand()
end
</RESOLUTION_TIME_ACTION>
<AUTO_SKIP no_effect_source="1" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="3">
<TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_BATTLEFIELD" />
<CONTINUOUS_ACTION layer="6">
if EffectSource() ~= nil then
EffectSource():GetCurrentCharacteristics():Bool_Set(CHARACTERISTIC_HASTE, 1)
end
</CONTINUOUS_ACTION>
<DURATION>
return EffectSource() == nil
</DURATION>
</TRIGGERED_ABILITY>
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: DASH (mechanic)
by Tejahn » 22 Jan 2015, 03:18
Okay. That works. However, each time the trigger effect shows when the card is returned to my hand. And strangely, the game is numericall keeping up with how may times the Dash effect is being played. For instance, I used the effect three times and now it shows the number three when it's on the battlefield. Thanks for your help!
Re: DASH (mechanic)
by Xander9009 » 22 Jan 2015, 04:01
Do you mean that at the end of the turn there's time to respond to the card returning to hand? Because if so, I'm pretty sure that's rule compliant. As for the other half, I'm not 100% certain what you. However, if it's what I think, then adding in MTG():RemoveDelayedTrigger(1) (repeat for 2 and 3) when it leaves the battlefield might fix it. If it's what I think it is, then you'll know because you'll pay its dash cost once and then it'll still return to hand the next time you play it even if you play it normally.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: DASH (mechanic)
by Tejahn » 23 Jan 2015, 01:54
Sorry for the horrible explanation. I only meant that it was displaying how many times the Dash ability was being used with each casting. As an example, when BrutalHorde chief attacks, a number is displayed on his card to show how much life the defending player is losing. I fixed your code by adding the following clean up tag:
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
Thanks for all the help!
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
Thanks for all the help!
Re: DASH (mechanic)
by Xander9009 » 23 Jan 2015, 02:01
Yeah, I forgot about that tag.Tejahn wrote:Sorry for the horrible explanation. I only meant that it was displaying how many times the Dash ability was being used with each casting. As an example, when Brutal Hordechief attacks, a number is displayed on his card to show how much life the defending player is losing. I fixed your code by adding the following clean up tag:
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
Thanks for all the help!
For displaying the number, I'd have to see it in action to know for sure if it's what I think it is. Because Brutal Hordechief's number showing up is because of the ability triggering multiple times simultaneously, which is what I was trying to say was the problem. However, the cleanup tag should fix that mostly. It would still show if you use dash twice (or more) in one turn, but not from turn to turn. Anyway, hopefully it works
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: DASH (mechanic)
by Tejahn » 07 Feb 2015, 18:53
Xander9009, I'm nearing the release of the Fate Reforged set but after putting together a Dash-based deck to be released with the above-mentioned set I've noticed that even if the creature is destroyed or exiled during combat it still returns to my hand. Can you finalize the code so that the creature remains in the graveyard or exile?
Here is the Mardu Shadowspear code:
Here is the Mardu Shadowspear code:
- Code: Select all
<UTILITY_ABILITY qualifier="Alternate">
<COST mana_cost="{1}{B}" type="Mana" />
<COST type="Generic">
<PREREQUISITE>
return true
</PREREQUISITE>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr(0, EffectSource())
delayDC:Protect_CardPtr(0)
MTG():CreateDelayedTrigger(1, delayDC)
MTG():CreateDelayedTrigger(3, delayDC)
end
</RESOLUTION_TIME_ACTION>
</COST>
<ABILITY_TEXT tag="CARD_QUERY_PAY_DASH_COST" />
</UTILITY_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" resource_id="1">
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
<TRIGGER value="SPELL_RESOLVED">
return TriggerObject() == EffectDC():Get_CardPtr(0)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local delayDC = EffectDC():Make_Chest(1)
MTG():CreateDelayedTrigger(2, delayDC)
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="2" priority="-1">
<CLEANUP fire_once="1" />
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_END_OF_TURN
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():PutInHand()
end
</RESOLUTION_TIME_ACTION>
<AUTO_SKIP no_effect_source="1" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY resource_id="3">
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
<TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_BATTLEFIELD" />
<CONTINUOUS_ACTION layer="6">
if EffectSource() ~= nil then
EffectSource():GetCurrentCharacteristics():Bool_Set(CHARACTERISTIC_HASTE, 1)
end
</CONTINUOUS_ACTION>
<DURATION simple_duration="UntilEOT" />
</TRIGGERED_ABILITY>
Re: DASH (mechanic)
by RiiakShiNal » 07 Feb 2015, 20:40
There are 2 things you can do quickly to fix your problem (must do both).
That is the easiest way to do it. Though a better way would be to have an additional TRIGGERED_ABILITY that triggers on ZONECHANGE_BEGIN and calls RemoveDelayedTrigger() to get rid of the delayed trigger.
- Modify your CLEANUP tag to clean up at end of turn.
- Check the current zone of the EffectSource() is ZONE_BATTLEFIELD before returning the card to your hand.
That is the easiest way to do it. Though a better way would be to have an additional TRIGGERED_ABILITY that triggers on ZONECHANGE_BEGIN and calls RemoveDelayedTrigger() to get rid of the delayed trigger.
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: 2183
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 496 times
Re: DASH (mechanic)
by Tejahn » 08 Feb 2015, 02:51
Thanks! I'll use the methods you suggested. But is there a specific reason why adding a separate TRIGGERED_ABILITY is better?
Re: DASH (mechanic)
by Xander9009 » 08 Feb 2015, 02:53
Flicker - The creature would still be on the battlefield at the end of that turn, and thus it would be returned to your hand even though it shouldn't be. In fact, before Riiak even posted that I already was preparing to do that before I got unexpected company and failed miserably to focus lol. It's really the only correct way to do it. It's not too difficult.Tejahn wrote:Thanks! I'll use the methods you suggested. But is there a specific reason why adding a separate TRIGGERED_ABILITY is better?
- Code: Select all
<TRIGGERED_ABILITY resource_id="4" priority="-1">
<CLEANUP fire_once="1" />
<TRIGGER value="ZONECHANGE_BEGIN" simple_qualifier="self" to_zone="ZONE_ANY" from_zone="ZONE_BATTLEFIELD" />
<RESOLUTION_TIME_ACTION>
MTG():RemoveDelayedTrigger(1)
MTG():RemoveDelayedTrigger(2)
MTG():RemoveDelayedTrigger(3)
</RESOLUTION_TIME_ACTION>
<AUTO_SKIP no_effect_source="1" />
</TRIGGERED_ABILITY>
EDIT: Riiak, should it be begin or end? If it's on begin, is it possible it might not actually end up leaving, or is it bound to happen at that point?
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: DASH (mechanic)
by RiiakShiNal » 08 Feb 2015, 03:10
As Xander9009 stated there are effects that can remove the card from the battlefield and then return it (it could also be killed then brought back by another effect). Which is why removing the delayed trigger on zone change is better (and more correct) than simply adding a still on battlefield check.Tejahn wrote:Thanks! I'll use the methods you suggested. But is there a specific reason why adding a separate TRIGGERED_ABILITY is better?
Most effects that prevent or replace zone changes work on ZONECHANGE_CONSIDERED which happens before ZONECHANGE_BEGIN and so should not interfere. There really shouldn't be any difference between ZONECHANGE_BEGIN and ZONECHANGE_END for this particular ability so either one should work. After ZONECHANGE_BEGIN is called a zone change will happen so might as well remove the abilities earlier rather than later (though again should not matter in this case).Xander9009 wrote:EDIT: Riiak, should it be begin or end? If it's on begin, is it possible it might not actually end up leaving, or is it bound to happen at that point?
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: 2183
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 496 times
23 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 11 guests