Page 1 of 1

Umbra Mystic

PostPosted: 12 Sep 2012, 04:32
by Dysgenics
Trying to implement Umbra Mystic, not entirely sure how to approach it.

If I make a TRIGGERED_ABILITY, is there a way to check whether a creature has been enchanted?

pseudocode of what I'd like to do:
Code: Select all
<TRIGGER value="DESTROYED">
  if (TriggerObject():GetController() == EffectController()) then
    if (TriggerObject():IsEnchanted()) then
      if (TriggerObject():GetChild():GetSubType() == ENCHANTMENT_TYPE_AURA) then
        override = true
        return true
      else
        return false
    else
      return false
  else
    return false
</TRIGGER>
From what I've seen in the documentation, there's nothing like IsEnchanted() or GetChild(); am I missing something, or is there a plausible workaround?

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 09:12
by thefiremind
Are you making this for DotP2012 or DotP2013? DotP2013 has IsEnchanted and it counts only Auras, so there's no need to make other checks.

This is the code I used for Umbra Mystic in DotP2012, with slight adaptations for DotP2013 (I don't know if I fully adapted it, I didn't test):
Code: Select all
  <TRIGGERED_ABILITY internal="1" pre_trigger="1">
    <TRIGGER value="DESTROYED">
    if TriggerObject():GetPlayer() == Object():GetPlayer() and TriggerObject():IsEnchanted() ~= 0 then
      override = true
      return true
    end
    return false
    </TRIGGER>
    <FILTER>
    return FilteredCard() ~= nil and
    FilteredCard():GetSubType():Test( ENCHANTMENT_TYPE_AURA ) ~= 0 and
    FilteredCard():GetZone() == ZONE_IN_PLAY and
    FilteredCard():GetParent() == TriggerObject()
    </FILTER>
    <RESOLUTION_TIME_ACTION ignore_filter="1">
    EffectDC():Int_Set( 1, 1 )
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION ignore_filter="1">
    TriggerObject():ClearDamage()
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if FilteredCard() ~= nil and EffectDC():Int_Get( 1 ) == 1 and FilteredCard():GetPlayer():GetTeam() ~= TriggerObject():GetPlayer():GetTeam() then
      FilteredCard():Destroy()
      EffectDC():Int_Set( 1, 0 )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if FilteredCard() ~= nil and EffectDC():Int_Get( 1 ) == 1 then
      FilteredCard():Destroy()
      EffectDC():Int_Set( 1, 0 )
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
According to the real rules, if a creature is enchanted with multiple Auras having totem armor, the creature's controller should be able to decide which one to destroy. Since this usually wouldn't happen with Auras that already have totem armor (the code would become really complicated, I'm not even sure it could be done), I'm not letting the controller decide, but I'm giving priority to the Auras controlled by opponents, which should be bad (like Pacifism, Arrest, etc.): if I find an opponent's Aura, I destroy that one, otherwise I destroy any Aura.

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 16:27
by Dysgenics
Sorry, should have specified- this is for DotP2013.

The code you provided looks perfect, but in game when Umbra Mystic is in play, no auras are ever destroyed, and all creatures the player controls (including those not enchanted) have damage cleared - even if I remove "TriggerObject():IsEnchanted()" from the condition.

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 18:47
by thefiremind
Sorry, that's something I often forget when I write code without testing... most false/true conditions are actually 0/1 conditions, so I forgot "~= 0" in
Code: Select all
TriggerObject():IsEnchanted() ~= 0
Try it now.

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 19:13
by Dysgenics
Ah, fixed that problem. Auras still don't destroy when they should though.

I'll tinker with it.

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 21:28
by thefiremind
I also forgot to substitute MTG():EffectDataChest() (DotP2012 syntax) with EffectDC() (DotP2013 syntax), but they could be equivalent, so I'm not sure if it helps.

Re: Umbra Mystic

PostPosted: 12 Sep 2012, 22:13
by Dysgenics
Close enough :D

I changed it to ObjectDC() and everthing's working splendid.

Thanks!

For anyone interested in the card:

Re: Umbra Mystic

PostPosted: 13 Sep 2012, 08:49
by thefiremind
Dysgenics wrote:I changed it to ObjectDC() and everthing's working splendid.
That's really strange, it should work with EffectDC the same way, and it's usually better to use the EffectDC because it's unique for each activation of each ability. Anyway you shouldn't have problems with ObjectDC here, since the register is set to 1 in each resolution.