Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
Umbra Mystic
Moderator: CCGHQ Admins
Umbra Mystic
by 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:
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>
Re: Umbra Mystic
by 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):
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>
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...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Umbra Mystic
by 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.
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
by 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
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Umbra Mystic
by Dysgenics » 12 Sep 2012, 19:13
Ah, fixed that problem. Auras still don't destroy when they should though.
I'll tinker with it.
I'll tinker with it.
Re: Umbra Mystic
by 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...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Umbra Mystic
by Dysgenics » 12 Sep 2012, 22:13
Close enough
I changed it to ObjectDC() and everthing's working splendid.
Thanks!
For anyone interested in the card:
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
Re: Umbra Mystic
by thefiremind » 13 Sep 2012, 08:49
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.Dysgenics wrote:I changed it to ObjectDC() and everthing's working splendid.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 22 guests