It is currently 18 Apr 2024, 07:39
   
Text Size

Umbra Mystic

Moderator: CCGHQ Admins

Umbra Mystic

Postby Dysgenics » 12 Sep 2012, 04:32

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?
User avatar
Dysgenics
 
Posts: 13
Joined: 25 Aug 2012, 19:33
Has thanked: 5 times
Been thanked: 0 time

Re: Umbra Mystic

Postby thefiremind » 12 Sep 2012, 09:12

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.
Last edited by thefiremind on 12 Sep 2012, 21:27, edited 2 times in total.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Umbra Mystic

Postby Dysgenics » 12 Sep 2012, 16:27

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.
User avatar
Dysgenics
 
Posts: 13
Joined: 25 Aug 2012, 19:33
Has thanked: 5 times
Been thanked: 0 time

Re: Umbra Mystic

Postby thefiremind » 12 Sep 2012, 18:47

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Umbra Mystic

Postby Dysgenics » 12 Sep 2012, 19:13

Ah, fixed that problem. Auras still don't destroy when they should though.

I'll tinker with it.
User avatar
Dysgenics
 
Posts: 13
Joined: 25 Aug 2012, 19:33
Has thanked: 5 times
Been thanked: 0 time

Re: Umbra Mystic

Postby thefiremind » 12 Sep 2012, 21:28

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Umbra Mystic

Postby Dysgenics » 12 Sep 2012, 22:13

Close enough :D

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

Thanks!

For anyone interested in the card:
Attachments
Umbra Mystic.rar
(109.85 KiB) Downloaded 198 times
User avatar
Dysgenics
 
Posts: 13
Joined: 25 Aug 2012, 19:33
Has thanked: 5 times
Been thanked: 0 time

Re: Umbra Mystic

Postby thefiremind » 13 Sep 2012, 08:49

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 22 guests


Who is online

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

Login Form