Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk
The big bug: hybrid mana
Moderator: CCGHQ Admins
The big bug: hybrid mana
by thefiremind » 06 May 2012, 23:54
As most modders already know, hybrid mana is badly coded in DotP2012 and leads to strange behaviours when it's time to pay it.
First of all, when a card has hybrid mana in the cost, a negative number with value equal to the card's converted mana cost is displayed while the card is on the stack. This is just cosmetic, but strange.
Then, I made some tries by coding Simic Guildmage. Don't ask about the abilities: I didn't even start putting them in. I just focused on the spell play.
So, with a cost of
, these have been the results:
What I'd like to achieve is a deeper knowledge of this bug, so that maybe we can find a workaround. If the hybrid mana is used for an activated ability, the trick used by nabeshin in his Figure of Destiny is OK (make the ability cost
and tap the right lands afterwards), but it's not possible to use the same trick for the casting cost: we should think about something different.
Thoughts? Other results? Suggestions?
First of all, when a card has hybrid mana in the cost, a negative number with value equal to the card's converted mana cost is displayed while the card is on the stack. This is just cosmetic, but strange.
Then, I made some tries by coding Simic Guildmage. Don't ask about the abilities: I didn't even start putting them in. I just focused on the spell play.
So, with a cost of
, these have been the results:- If I control only untapped Islands, or only untapped Forests, and no untapped lands of the other color, the card shows a normal behaviour. So it's safe to assume that you can use hybrid mana in mono-colored decks without worrying about the bugs (unless someone proves it wrong, of course).
- If I control 1 untapped Forest and 1 untapped Island, the game doesn't even let me play the card.

- If I control 2 untapped Forests and 1 untapped Island, only 1 Forest gets tapped.
- If I control 2 untapped Islands and 1 untapped Forest, only 1 Island gets tapped.
- If I control 2 (or more) untapped Islands and 2 (or more) untapped Forests, no land gets tapped: the spell goes on the stack for free.

What I'd like to achieve is a deeper knowledge of this bug, so that maybe we can find a workaround. If the hybrid mana is used for an activated ability, the trick used by nabeshin in his Figure of Destiny is OK (make the ability cost
and tap the right lands afterwards), but it's not possible to use the same trick for the casting cost: we should think about something different.Thoughts? Other results? Suggestions?
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
-

thefiremind - Programmer
- Posts: 1819
- Joined: 07 Nov 2011, 10:55
- Has thanked: 63 times
- Been thanked: 401 times
Re: The big bug: hybrid mana
by MisterBenn » 07 May 2012, 02:41
I am suffering from similar problems with Dominus of Fealty in a Red/Blue deck. I've had to implement with cost
because otherwise I've never been able to cast it. As a 5 drop I suspect the specific scenarios you laid out have never come up for me. Also in relation to your first bullet point, I have no problems casting Spiteful Visions in my Red/White deck. Having lands of a third colour available does not confuse the ability to cast a Red/Black hybrid card.
I'll rack my brains on this as it irks me a lot to make that card
cost! I guess screwing with the card cost is unlikely to be acceptable as some other cards like Steel Hellkite need the CMC of a card to be correct...
because otherwise I've never been able to cast it. As a 5 drop I suspect the specific scenarios you laid out have never come up for me. Also in relation to your first bullet point, I have no problems casting Spiteful Visions in my Red/White deck. Having lands of a third colour available does not confuse the ability to cast a Red/Black hybrid card.I'll rack my brains on this as it irks me a lot to make that card
cost! I guess screwing with the card cost is unlikely to be acceptable as some other cards like Steel Hellkite need the CMC of a card to be correct...- MisterBenn
- Posts: 92
- Joined: 19 Mar 2011, 16:19
- Has thanked: 23 times
- Been thanked: 11 times
Re: The big bug: hybrid mana
by thefiremind » 07 May 2012, 08:00
I think I'll adopt a workaround similar to yours: I'll make my Simic Guildmage costMisterBenn wrote:I'll rack my brains on this as it irks me a lot to make that cardcost! I guess screwing with the card cost is unlikely to be acceptable as some other cards like Steel Hellkite need the CMC of a card to be correct...
, then a static ability will check if I can afford
; if not, it will make it cost
or
according to the available mana. This will preserve CMC and will also keep the card colours understandable from the cost. There's no way to implement things like the Chroma mechanic (as in Primalcrux) so we don't have to worry about "real" costs. < DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
-

thefiremind - Programmer
- Posts: 1819
- Joined: 07 Nov 2011, 10:55
- Has thanked: 63 times
- Been thanked: 401 times
Re: The big bug: hybrid mana
by MisterBenn » 07 May 2012, 14:50
Having slept on it, the best suggestion I have is:
1) Set the mana as colourless to the correct CMC amount like I did.
2) Use a static ability to reduce the casting cost to
.
3) Use an AVAILABILITY block with logic around CanAfford() to make sure the correct mana is available to cast so you can't cheat with colourless mana.
4) Interrupt the casting and use either an ability, an addditional cost or a conditional cost to get the player to manually tap a valid permutation of lands.
That might be ugly but those individual steps sound alright so it could work. The last remaining part would be a correct interaction with cards that increase the casting cost of other cards like Grand Arbiter Augustin IV and Lodestone Golem. Not sure about that yet!
The more I think about it, the more I think this could work, particularly the Additional Cost method to tap the right lands. It might not be necessary to use step 3 that way as well. I will see if I can do it with Dominus of Fealty tonight.
1) Set the mana as colourless to the correct CMC amount like I did.
2) Use a static ability to reduce the casting cost to
.3) Use an AVAILABILITY block with logic around CanAfford() to make sure the correct mana is available to cast so you can't cheat with colourless mana.
4) Interrupt the casting and use either an ability, an addditional cost or a conditional cost to get the player to manually tap a valid permutation of lands.
That might be ugly but those individual steps sound alright so it could work. The last remaining part would be a correct interaction with cards that increase the casting cost of other cards like Grand Arbiter Augustin IV and Lodestone Golem. Not sure about that yet!
The more I think about it, the more I think this could work, particularly the Additional Cost method to tap the right lands. It might not be necessary to use step 3 that way as well. I will see if I can do it with Dominus of Fealty tonight.
- MisterBenn
- Posts: 92
- Joined: 19 Mar 2011, 16:19
- Has thanked: 23 times
- Been thanked: 11 times
Re: The big bug: hybrid mana
by kevlahnota » 07 May 2012, 14:57
Hi, I have some good workaround but I managed only to include up to two hybrid mana in the casting cost. maybe I'll post my little update to my mod tomorrow so you can see example.
-

kevlahnota - Programmer
- Posts: 418
- Joined: 19 Jul 2010, 17:45
- Location: Philippines
- Has thanked: 5 times
- Been thanked: 99 times
Re: The big bug: hybrid mana
by thefiremind » 07 May 2012, 15:45
It's very similar to what I did for Simic Guildmage:MisterBenn wrote:Having slept on it, the best suggestion I have is:
1) Set the mana as colourless to the correct CMC amount like I did.
2) Use a static ability to reduce the casting cost to.
3) Use an AVAILABILITY block with logic around CanAfford() to make sure the correct mana is available to cast so you can't cheat with colourless mana.
4) Interrupt the casting and use either an ability, an addditional cost or a conditional cost to get the player to manually tap a valid permutation of lands.
- Code: Select all
<CASTING_COST cost="{G}{U}" />
<STATIC_ABILITY zone="hand" layer="8">
<CONTINUOUS_ACTION>
if Object():GetPlayer():CanAfford("{G}", nil) == 1 and
Object():GetPlayer():CanAfford("{U}", nil) == 0 then
Object():IncreaseColouredCost( COLOUR_GREEN, 1 )
Object():DecreaseColouredCost( COLOUR_BLUE, 1 )
elseif Object():GetPlayer():CanAfford("{U}", nil) == 1 and
Object():GetPlayer():CanAfford("{G}", nil) == 0 then
Object():IncreaseColouredCost( COLOUR_BLUE, 1 )
Object():DecreaseColouredCost( COLOUR_GREEN, 1 )
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
I'm really looking forward to it!kevlahnota wrote:Hi, I have some good workaround but I managed only to include up to two hybrid mana in the casting cost. maybe I'll post my little update to my mod tomorrow so you can see example.
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
-

thefiremind - Programmer
- Posts: 1819
- Joined: 07 Nov 2011, 10:55
- Has thanked: 63 times
- Been thanked: 401 times
Re: The big bug: hybrid mana
by MisterBenn » 07 May 2012, 18:54
I was playing round with additional costs, just trying to tap the lands manually:
- Code: Select all
<STATIC_ABILITY influencing_zone="hand" zone="hand" layer="8">
<CONTINUOUS_ACTION>
Object():DecreaseCost(5)
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<UTILITY_ABILITY zone="any">
<COST type="Tap" qualifier="Additional" number="5">
<TARGET_DETERMINATION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetZone( ZONE_IN_PLAY )
filter:AddCardType( CARD_TYPE_LAND )
filter:SetPlayer( Object():GetPlayer() )
filter:AddSubType( LAND_TYPE_ISLAND )
filter:AddSubType( LAND_TYPE_MOUNTAIN )
filter:AddExtra( FILTER_EXTRA_ANY_SUB_TYPE )
filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
filter:NotTargetted()
return TargetGoodF()
</TARGET_DETERMINATION>
<PLAYTIME>
ChooseTarget( "CARD_QUERY_PAY_HYBRID_COST" )
</PLAYTIME>
</COST>
</UTILITY_ABILITY>
- MisterBenn
- Posts: 92
- Joined: 19 Mar 2011, 16:19
- Has thanked: 23 times
- Been thanked: 11 times
Re: The big bug: hybrid mana
by thefiremind » 08 May 2012, 08:57
Nice idea! If you want it to be playable only when you have 5 mana available, add the following code just after the cost decrease:MisterBenn wrote:I was playing round with additional costs, just trying to tap the lands manually:I'm thinking this would only work with basic lands though. It has an issue though, even with a quantity of 5 to tap, the card becomes castable with just a single land or more. Given that this would only be a limited solution anyway, I will see what Kev's solution is before I play around any further.
- Code: Select all
<STATIC_ABILITY influencing_zone="hand" zone="hand" layer="8">
<CONTINUOUS_ACTION>
Object():DecreaseCost(5)
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<UTILITY_ABILITY zone="any">
<COST type="Tap" qualifier="Additional" number="5">
<TARGET_DETERMINATION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetZone( ZONE_IN_PLAY )
filter:AddCardType( CARD_TYPE_LAND )
filter:SetPlayer( Object():GetPlayer() )
filter:AddSubType( LAND_TYPE_ISLAND )
filter:AddSubType( LAND_TYPE_MOUNTAIN )
filter:AddExtra( FILTER_EXTRA_ANY_SUB_TYPE )
filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
filter:NotTargetted()
return TargetGoodF()
</TARGET_DETERMINATION>
<PLAYTIME>
ChooseTarget( "CARD_QUERY_PAY_HYBRID_COST" )
</PLAYTIME>
</COST>
</UTILITY_ABILITY>
- Code: Select all
if Object():GetPlayer():CanAfford("{5}", nil) == 0 then
Object():GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_CANT_BE_PLAYED, 1 )
end
About kev's solution, he released the update but I can't find the hybrid card... there are too many to browse!

EDIT: OK, found it: Sapling of Colfenor. This is the code used by kev (curiously inside a static ability):
- Code: Select all
<PLAY_TIME_ACTION>
local player = Object():GetPlayer()
if player:CanAfford("{B}", nil) == 1 and player:CanAfford("{G}", nil) == 1 and Object():GetManaX() < 0 then
if player:CanAfford("{B}{B}", nil) == 1 then
player:TapLand("{B}{B}")
elseif player:CanAfford("{G}{G}", nil) == 1 then
player:TapLand("{G}{G}")
else
player:TapLand("{B}{G}")
end
end
</PLAY_TIME_ACTION>
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
-

thefiremind - Programmer
- Posts: 1819
- Joined: 07 Nov 2011, 10:55
- Has thanked: 63 times
- Been thanked: 401 times
Re: The big bug: hybrid mana
by kevlahnota » 08 May 2012, 10:10
@thefiremind:
can you test this?
the counthcolor i think is defined in my custom functions.
this is my curse of chains code:
can you test this?
the counthcolor i think is defined in my custom functions.
this is my curse of chains code:
- Code: Select all
<?xml version='1.0'?>
<CARD_V2>
<FILENAME text="CURSE_OF_CHAINS_88815068" />
<CARDNAME text="CURSE_OF_CHAINS" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Curse Of Chains]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="88815068" />
<ARTID value="88815068" />
<FRAMECOLOUR name="WU_HYBRID" />
<COLOUR value="WU" />
<ARTIST name="Drew Tucker" />
<CASTING_COST cost="{1}{WU}" />
<FLAVOURTEXT>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[The giant’s real punishment was the fleeting moment when he was allowed to stand before being dragged down to his knees again.]]></LOCALISED_TEXT>
</FLAVOURTEXT>
<TYPE metaname="Enchantment" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<SUB_TYPE metaname="Aura" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<EXPANSION value="DPE" />
<RARITY metaname="C" />
<SPELL_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
<TARGET_DETERMINATION>
local filter = Object():GetFilter()
filter:Clear()
filter:AddCardType( CARD_TYPE_CREATURE )
filter:SetZone( ZONE_IN_PLAY )
return TargetBadF()
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION target_choosing="1">
ChooseTarget( "CARD_QUERY_CHOOSE_CREATURE_TO_ENCHANT" )
</PLAY_TIME_ACTION>
<PLAY_TIME_ACTION>
local player = Object():GetPlayer()
if player:CanAfford("{U}", nil) == 1 and player:CanAfford("{W}", nil) == 1 and Object():GetManaX() < 0 then
local CU = CountHColor( COLOUR_BLUE )
local CW = CountHColor( COLOUR_WHITE )
if CU > CW then
player:TapLand("{W}")
elseif CW > CU then
player:TapLand("{U}")
else
player:TapLand("{U}")
end
end
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
Object():AttachmentFilter_Get():Clear()
Object():AttachmentFilter_Get():AddCardType( CARD_TYPE_CREATURE )
Object():Enchant( Object():GetTargetCard())
</RESOLUTION_TIME_ACTION>
</SPELL_ABILITY>
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[At the beginning of each upkeep, tap enchanted creature.]]></LOCALISED_TEXT>
<TRIGGER value="BEGINNING_OF_STEP">
return ( MTG():GetStep() == STEP_UPKEEP and TriggerPlayer():MyTurn() ~= 0 and Object():GetParent() ~= nil)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local parent = Object():GetParent()
if parent ~= nil then
parent:Tap()
end
</RESOLUTION_TIME_ACTION>
<AI_BASE_SCORE score="300" zone="in_play" />
</TRIGGERED_ABILITY>
</CARD_V2>
-

kevlahnota - Programmer
- Posts: 418
- Joined: 19 Jul 2010, 17:45
- Location: Philippines
- Has thanked: 5 times
- Been thanked: 99 times
Re: The big bug: hybrid mana
by thefiremind » 08 May 2012, 11:13
Oh, I see... you are counting the cards in your hand of a certain color so that you use the mana you need least. But this still doesn't solve the problem of making Simic Guildmage playable with 1 untapped Forest and 1 untapped Island (without changing the cost completely)... or any other hybrid card with 2 hybrid mana and no colorless mana in the cost.
< DotP2013 (and formerly 2012) modder >
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
WADs unrecognized by the game? Look here.
Need a basic modding tutorial? Try this.
Want to start coding cards? Try my web generator.
-

thefiremind - Programmer
- Posts: 1819
- Joined: 07 Nov 2011, 10:55
- Has thanked: 63 times
- Been thanked: 401 times
Re: The big bug: hybrid mana
by MisterBenn » 10 May 2012, 01:53
@thefiremind - You are right, Dominus casts correctly with the adjustment you suggested thanks. There's a certain satisfaction to tapping the lands yourself but the animation's a bit strange and there's no advantage apart from if it somehow ran into a "costs
less to cast" effect, this way it correctly wouldn't have its cost reduced. This deck doesn't have anything with mana producing abilities but I assume you can't tap the invisible mana tokens this way.
less to cast" effect, this way it correctly wouldn't have its cost reduced. This deck doesn't have anything with mana producing abilities but I assume you can't tap the invisible mana tokens this way.- MisterBenn
- Posts: 92
- Joined: 19 Mar 2011, 16:19
- Has thanked: 23 times
- Been thanked: 11 times
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests


