It is currently 29 Apr 2024, 14:59
   
Text Size

DASH (mechanic)

Moderator: CCGHQ Admins

DASH (mechanic)

Postby 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>
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby migookman » 21 Jan 2015, 06:17

Couldn't 'Dash' be coded similarly as the 'Kicker' ability?
User avatar
migookman
 
Posts: 135
Joined: 05 Aug 2014, 06:37
Has thanked: 21 times
Been thanked: 28 times

Re: DASH (mechanic)

Postby 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.
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby 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>
I have a feeling that won't work, though. I imagine it might have issues with the fact that it's not technically getting haste until it's on the battlefield at which point its ability is triggering. If that does in fact cause an issue, I would try giving it a static ability that grants itself haste in any zone (don't worry about exile) that only works if a certain int is set to 1 and set that int to one when the dash cost is paid. Unfortunately, I think that, too, might fail, because variables aren't carried from zone to zone.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
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)

Postby 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!
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby 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
User avatar
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)

Postby 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!
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby Xander9009 » 23 Jan 2015, 02:01

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!
Yeah, I forgot about that tag.

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
User avatar
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)

Postby Tejahn » 23 Jan 2015, 02:04

It worked perfectly.
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby 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:
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>
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby RiiakShiNal » 07 Feb 2015, 20:40

There are 2 things you can do quickly to fix your problem (must do both).
  • 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.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: DASH (mechanic)

Postby 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?
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Re: DASH (mechanic)

Postby Xander9009 » 08 Feb 2015, 02:53

Tejahn wrote:Thanks! I'll use the methods you suggested. But is there a specific reason why adding a separate TRIGGERED_ABILITY is better?
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.

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>
If you create that at the same time you create the delayed trigger 1, it should work as needed. Trigger 2 should still be given the cleanup tag "<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />"

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
User avatar
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)

Postby RiiakShiNal » 08 Feb 2015, 03:10

Tejahn wrote:Thanks! I'll use the methods you suggested. But is there a specific reason why adding a separate TRIGGERED_ABILITY is better?
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.

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?
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).
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: DASH (mechanic)

Postby Tejahn » 08 Feb 2015, 03:42

Those explanations were perfect!
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

Next

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 30 guests


Who is online

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

Login Form