It is currently 24 May 2013, 09:53
   
Text Size

The big bug: hybrid mana

Moderator: CCGHQ Admins

The big bug: hybrid mana

Postby 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 {GU} {GU}, 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. #-o
  • 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. :lol:
After those tries, it seems that the bug is somehow connected to the available mana.

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 {0} 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.
User avatar
thefiremind
Programmer
 
Posts: 1664
Joined: 07 Nov 2011, 10:55
Has thanked: 61 times
Been thanked: 364 times

Re: The big bug: hybrid mana

Postby 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 {5} 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 {5} 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

Postby thefiremind » 07 May 2012, 08:00

MisterBenn wrote:I'll rack my brains on this as it irks me a lot to make that card {5} 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...
I think I'll adopt a workaround similar to yours: I'll make my Simic Guildmage cost {G} {U}, then a static ability will check if I can afford {G} {U}; if not, it will make it cost {G} {G} or {U} {U} 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. :wink:
< 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.
User avatar
thefiremind
Programmer
 
Posts: 1664
Joined: 07 Nov 2011, 10:55
Has thanked: 61 times
Been thanked: 364 times

Re: The big bug: hybrid mana

Postby 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 {0}.
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

Postby 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.
User avatar
kevlahnota
Programmer
 
Posts: 418
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 5 times
Been thanked: 97 times

Re: The big bug: hybrid mana

Postby thefiremind » 07 May 2012, 15:45

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 {0}.
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.
It's very similar to what I did for Simic Guildmage:
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>
This doesn't allow the player to make decisions about the mana, but it has the advantage of being completely automatic. In short: if you don't have blue mana, make it cost 2 green mana; if you don't have green mana, make it cost 2 blue mana; otherwise, 1 mana of both types. I think I'll settle with this solution for now. Besides, the activated abilities of my Simic Guildmage are also a bit approximated because they are far from easy.

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.
I'm really looking forward to it! :D
< 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.
User avatar
thefiremind
Programmer
 
Posts: 1664
Joined: 07 Nov 2011, 10:55
Has thanked: 61 times
Been thanked: 364 times

Re: The big bug: hybrid mana

Postby 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>
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.
MisterBenn
 
Posts: 92
Joined: 19 Mar 2011, 16:19
Has thanked: 23 times
Been thanked: 11 times

Re: The big bug: hybrid mana

Postby thefiremind » 08 May 2012, 08:57

MisterBenn wrote: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>
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.
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:
Code: Select all
      if Object():GetPlayer():CanAfford("{5}", nil) == 0 then
        Object():GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_CANT_BE_PLAYED, 1 )
      end
and it should work as intended.

About kev's solution, he released the update but I can't find the hybrid card... there are too many to browse! #-o
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() &lt; 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>
I find particularly interesting the check of Object():GetManaX() &lt; 0 which explains why the hybrid cards show a negative number while they are on the stack. But I'm afraid this won't work with cards that have only hybrid mana in the cost: when I had only 1 Forest and 1 Island, I couldn't play Simic Guildmage at all, so this is not a problem of unexpected cost decrease, but of unexpected cost increase, which can't be solved by tapping more lands.
< 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.
User avatar
thefiremind
Programmer
 
Posts: 1664
Joined: 07 Nov 2011, 10:55
Has thanked: 61 times
Been thanked: 364 times

Re: The big bug: hybrid mana

Postby 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:

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() &lt; 0 then
      local CU = CountHColor( COLOUR_BLUE )
      local CW = CountHColor( COLOUR_WHITE )
      if CU &gt; CW then
         player:TapLand("{W}")
      elseif CW &gt; 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>

User avatar
kevlahnota
Programmer
 
Posts: 418
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 5 times
Been thanked: 97 times

Re: The big bug: hybrid mana

Postby 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.
User avatar
thefiremind
Programmer
 
Posts: 1664
Joined: 07 Nov 2011, 10:55
Has thanked: 61 times
Been thanked: 364 times

Re: The big bug: hybrid mana

Postby 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 {1} 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


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 0 guests


Who is online

In total there are 0 users online :: 0 registered, 0 hidden and 0 guests (based on users active over the past 10 minutes)
Most users ever online was 177 on 10 Oct 2011, 16:37

Users browsing this forum: No registered users and 0 guests

Login Form