It is currently 14 Nov 2025, 10:34
   
Text Size

Add one mana of any color

Moderator: CCGHQ Admins

Add one mana of any color

Postby BlindWillow » 03 Sep 2012, 20:32

Well, my Melira Pod deck was badly missing Birds of Paradise after adding a third color. So here's what I came up with for an "add one mana of any color" ability:

Code: Select all
  <TRIGGERED_ABILITY auto_skip="1" pre_trigger="1" filter_zone="ZONE_IN_PLAY" active_zone="ZONE_TRANSITION">
    <TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
    <RESOLUTION_TIME_ACTION>
    EffectController():ChooseColour( "CARD_QUERY_CHOOSE_COLOUR", 1 )
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    ObjectDC():Set_Int( 0, GetChosenColour() )
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <TRIGGERED_ABILITY internal="1" filter_zone="ZONE_IN_PLAY">
    <TRIGGER value="STATE_BASED_EFFECTS">
    local characteristics = Object():GetCurrentCharacteristics()
    local ability_check = characteristics:Characteristic_Get( CHARACTERISTIC_CANT_USE_ACTIVATED_ABILITIES )
    if ability_check ~= 0 then
   characteristics:Characteristic_Set( CHARACTERISTIC_CANT_USE_ACTIVATED_ABILITIES, 0 )
   return true
    end
    return false
    </TRIGGER>
  </TRIGGERED_ABILITY>
  <ACTIVATED_ABILITY forced_skip="1" filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{T}: Add one mana of any color to your mana pool.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{T}: Aggiungi un mana di un qualsiasi colore alla tua riserva di mana.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{T}: Erhöhe deinen Manavorrat um ein Mana einer beliebigen Farbe.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{T} : Ajoutez un mana de la couleur de votre choix à votre réserve.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{T}: Agrega un maná de cualquier color a tu reserva de maná.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{T}:あなたのマナ・プールに、好きな色1色のマナ1点を加える。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{T}: Add one mana of any color to your mana pool.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{T}: добавьте одну ману любого цвета в ваше хранилище маны.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{T}: Adicione um mana de qualquer cor à sua reserva de mana.]]></LOCALISED_TEXT>
    <COST type="Mana" cost="{0}" />
    <RESOLUTION_TIME_ACTION>
    EffectController():ChooseColour( "CARD_QUERY_CHOOSE_COLOUR", 1 )
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    ObjectDC():Set_Int( 0, GetChosenColour() )
    </RESOLUTION_TIME_ACTION>
    <AI_AVAILABILITY step="main_1" turn="my_turn" />
    <AI_AVAILABILITY step="main_1" turn="their_turn" />
  </ACTIVATED_ABILITY>
  <STATIC_ABILITY filter_zone="ZONE_IN_PLAY">
    <CONTINUOUS_ACTION layer="6">
    local characteristics = Object():GetCurrentCharacteristics()
    local mana_color = ObjectDC():Get_Int(0)
    characteristics:GrantAbility(mana_color)
    </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
  <MANA_ABILITY resource_id="1" filter_zone="ZONE_IN_PLAY">
    <COST type="TapSelf" />
    <PRODUCES amount="{W}" />
  </MANA_ABILITY>
  <MANA_ABILITY resource_id="2" filter_zone="ZONE_IN_PLAY">
    <COST type="TapSelf" />
    <PRODUCES amount="{U}" />
  </MANA_ABILITY>
  <MANA_ABILITY resource_id="3" filter_zone="ZONE_IN_PLAY">
    <COST type="TapSelf" />
    <PRODUCES amount="{B}" />
  </MANA_ABILITY>
  <MANA_ABILITY resource_id="4" filter_zone="ZONE_IN_PLAY">
    <COST type="TapSelf" />
    <PRODUCES amount="{R}" />
  </MANA_ABILITY>
  <MANA_ABILITY resource_id="5" filter_zone="ZONE_IN_PLAY">
    <COST type="TapSelf" />
    <PRODUCES amount="{G}" />
  </MANA_ABILITY>
Basically you have an activated ability that allows you to choose the mana color the card is adding. I added a triggered ability for state based effects that checks to see if something like Linvala is trying to shut its ability down and resets the can't used activated abilities characteristic. Of course, that will be an issue if you have a card that has an activated ability besides a mana ability, but as long as you stick to cards like Birds, it should be fine. I haven't worked on getting the AI to use it properly yet. So any help there would be most welcome.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Add one mana of any color

Postby pcastellazzi » 04 Sep 2012, 04:35

There are a few more things you may need to consider, like limiting the AI posibilities of using the ability. In my tests without limiting the AI choices the game becomes very slow or it crashes. Also a mana cost of cero is not the best choice, there is a cost of type generic for this particular case.

You can find my current implementation here. The core module contains Birds of Paradise and a few dual lands all wrapped around a set of functions to make it easy to implement variations.

I being working on this for a while with the help of other community members. I believe we ironed out all problems. Please try it and send me a message if you find a bug.
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: Add one mana of any color

Postby BlindWillow » 05 Sep 2012, 01:05

Yeah, the AI has no idea what to do with the activated ability. None of the AI_AVAILABILITY options I tried seem to cut it either. I had concluded that the best thing would be to leave the activated ability unavailable to the AI, which would have to make do with the initial choice made when the Birds enter the battlefield. I'll try out your functions, though. I just need the MECHANIC_MULTI_LAND file?
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Add one mana of any color

Postby pcastellazzi » 19 Sep 2012, 08:03

BlindWillow wrote:I just need the MECHANIC_MULTI_LAND file?
Yes.

I was playing a little bit more with this concept today. The latest incarnation of the code allow the AI to play fairly well (at least in the preliminary tests).

I removed the old code, there was some bugs causing the game to crash often. This new version is more stable and free of hacks to make the AI use the activated ability for colour selection.

I also added badges when a mana ability is enabled. For now is using the land walk badges from the game. If anyone know how to add new ones please let me know.
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: Add one mana of any color

Postby BlindWillow » 27 Sep 2012, 19:00

pcastellazzi wrote:I was playing a little bit more with this concept today. The latest incarnation of the code allow the AI to play fairly well (at least in the preliminary tests)...I also added badges when a mana ability is enabled. For now is using the land walk badges from the game. If anyone know how to add new ones please let me know.
Finally got around to implementing your code for my Birds of Paradise and Noble Hierarch. Everything seems to be working fine so far. One change I noticed needed to be made in the .lol file for the AI's PlayableByEngine() function was that MTG():Interrogate_CardsDrawnThisTurn(player) == 0 needs to be MTG():Interrogate_CardsDrawnThisTurn(player) == 1 as the engine counts the card being drawn for the trigger.

I coded out the badges for myself (just weirds me out having the game explain nonexistent landwalk abilities). I get why you're using them, though, and it would be nice to have some customized ones. I think it is possible to add new badges (would probably still have to use existing graphics) in a config file, a la new counters, but as no examples for badges exist outside the .exe, it's harder to figure out exactly how to do it. I'll keep trying to figure it out.

And thanks for the functions. :)
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Add one mana of any color

Postby pcastellazzi » 28 Sep 2012, 23:30

BlindWillow wrote:One change I noticed needed to be made in the .lol file for the AI's PlayableByEngine() function was that MTG():Interrogate_CardsDrawnThisTurn(player) == 0 needs to be MTG():Interrogate_CardsDrawnThisTurn(player) == 1 as the engine counts the card being drawn for the trigger.
Thank you for the report. The fix is on the repo already. You may want to check
the repository's rss feed. All changes i made are listed there as soon as they are uploaded.
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: Add one mana of any color

Postby BlindWillow » 29 Sep 2012, 00:30

Forgot to mention too, that you can deal with cards that shut down abilities like Linvala with the following triggered ability:

Code: Select all
  <TRIGGERED_ABILITY internal="1" filter_zone="ZONE_IN_PLAY">
    <TRIGGER value="STATE_BASED_EFFECTS">
    local characteristics = Object():GetCurrentCharacteristics()
    local ability_check = characteristics:Characteristic_Get( CHARACTERISTIC_CANT_USE_ACTIVATED_ABILITIES )
    if ability_check ~= 0 then
   characteristics:Characteristic_Set( CHARACTERISTIC_CANT_USE_ACTIVATED_ABILITIES, 0 )
   return true
    end
    return false
    </TRIGGER>
  </TRIGGERED_ABILITY>
I don't know how or if you would want to include that in your .lol file.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 10 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 10 users online :: 0 registered, 0 hidden and 10 guests (based on users active over the past 10 minutes)
Most users ever online was 9824 on 10 Nov 2025, 04:33

Users browsing this forum: No registered users and 10 guests

Login Form