Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
COST Limitations *Solved*
Moderator: CCGHQ Admins
COST Limitations *Solved*
by RiiakShiNal » 18 Jul 2013, 17:52
It seems the game has a built-in limitation on costs using the COST tag. I was coding Benthic Explorers and noticed that no matter how I tried to code the cost "Untap a tapped land an opponent controls" using the COST tag (as types "Untap" and "Generic") I was unable to get the ability to ever be available. However, if I put almost the exact same code in a couple of PLAY_TIME_ACTIONS everything works fine. The limitation seems to be that items used for the COST tag must be controlled by the EffectController() and not by any other player.
Here are a couple of attempts:
Using type "Untap":
Using type "Generic":
Ultimately, I got the card working by changing it from a COST to a couple of PLAY_TIME_ACTIONS that happen before anything else in the ability. Though I just could not get it to work as a COST, if someone sees something I did wrong and can get it working using COST tags please tell me.
Edit: I was missing the PREREQUISITE block which allows the Generic cost to work:
Here are a couple of attempts:
Using type "Untap":
- Code: Select all
<COST type="Untap" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_LAND_TO_UNTAP" item_count="1" />
<COST_DEFINITION id="0">
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
</COST_DEFINITION>
Using type "Generic":
- Code: Select all
<COST type="Generic">
<PLAY_TIME_ACTION>
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
EffectController():ChooseItem( "CARD_QUERY_CHOOSE_LAND_TO_UNTAP", EffectDC():Make_Targets( 1 ) )
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local oLand = EffectDC():Get_Targets(1):Get_CardPtr(0)
if (oLand ~= nil) then
oLand:Untap()
end
</RESOLUTION_TIME_ACTION>
</COST>
Ultimately, I got the card working by changing it from a COST to a couple of PLAY_TIME_ACTIONS that happen before anything else in the ability. Though I just could not get it to work as a COST, if someone sees something I did wrong and can get it working using COST tags please tell me.
Edit: I was missing the PREREQUISITE block which allows the Generic cost to work:
- Benthic Explorers (Fully Working) | Open
- Code: Select all
<?xml version='1.0'?>
<CARD_V2>
<FILENAME text="RSN_BENTHIC_EXPLORERS_201159" />
<CARDNAME text="BENTHIC_EXPLORERS" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Benthic Explorers]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="201159" />
<ARTID value="RSN201159" />
<ARTIST name="Greg Simanson" />
<CASTING_COST cost="{3}{U}" />
<FLAVOURTEXT>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[The rising oceans brought new lakes—and new terrors—to Terisiare. The Explorers found their ancient enemies spawning everywhere.]]></LOCALISED_TEXT>
</FLAVOURTEXT>
<TYPE metaname="Creature" />
<SUB_TYPE metaname="Merfolk" />
<SUB_TYPE metaname="Scout" />
<EXPANSION value="ME3" />
<RARITY metaname="C" />
<POWER value="2" />
<TOUGHNESS value="4" />
<ACTIVATED_ABILITY forced_skip="1">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{T}, Untap a tapped land an opponent controls: Add one mana of any type that land could produce to your mana pool.]]></LOCALISED_TEXT>
<COST type="TapSelf" />
<COST type="Generic">
<PREREQUISITE>
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
return (oFilter:CountStopAt(1) == 1)
</PREREQUISITE>
<RESOLUTION_TIME_ACTION>
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
EffectController():ChooseItem( "CARD_QUERY_CHOOSE_LAND_TO_UNTAP", EffectDC():Make_Targets( 1 ) )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local oLand = EffectDC():Get_Targets(1):Get_CardPtr(0)
if (oLand ~= nil) then
oLand:Untap()
end
</RESOLUTION_TIME_ACTION>
</COST>
<PLAY_TIME_ACTION>
RSN_MarkManaAbilityStart()
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local oPlayer = EffectController()
local oLand = EffectDC():Get_Targets(1):Get_CardPtr(0)
if ((oPlayer ~= nil) and (oLand ~= nil) and (RSN_GetFirstProducibleColour( oLand ) ~= -1)) then
oPlayer:BeginNewMultipleChoice()
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_C", RSN_GetCanProduceMana( oLand, COLOUR_COLOURLESS ) )
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_W", RSN_GetCanProduceMana( oLand, COLOUR_WHITE ) )
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_U", RSN_GetCanProduceMana( oLand, COLOUR_BLUE ) )
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_B", RSN_GetCanProduceMana( oLand, COLOUR_BLACK ) )
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_R", RSN_GetCanProduceMana( oLand, COLOUR_RED ) )
oPlayer:AddMultipleChoiceAnswer( "RSN_MODE_PRODUCE_G", RSN_GetCanProduceMana( oLand, COLOUR_GREEN ) )
oPlayer:AskMultipleChoiceQuestion( "MODE_CHOOSE_ONE", oCard )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local oLand = EffectDC():Get_Targets(1):Get_CardPtr(0)
if ((oLand ~= nil) and (RSN_GetFirstProducibleColour( oLand ) ~= -1)) then
local nColour = EffectController():GetMultipleChoiceResult()
if (nColour == COLOUR_COLOURLESS) then
RSN_Produce( "{1}", 1 )
elseif (nColour == COLOUR_BLACK) then
RSN_Produce( "{B}", 1 )
elseif (nColour == COLOUR_BLUE) then
RSN_Produce( "{U}", 1 )
elseif (nColour == COLOUR_GREEN) then
RSN_Produce( "{G}", 1 )
elseif (nColour == COLOUR_RED) then
RSN_Produce( "{R}", 1 )
elseif (nColour == COLOUR_WHITE) then
RSN_Produce( "{W}", 1 )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
RSN_EliminateExtraManaTokens()
RSN_MarkManaAbilityEnd()
</RESOLUTION_TIME_ACTION>
<AI_AVAILABILITY window_step="upkeep" type="window" />
<AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
<AI_AVAILABILITY window_step="begin_combat" window_turn="their_turn" type="window" />
<AI_AVAILABILITY window_step="declare_attackers" window_turn="their_turn" type="window" />
<AI_AVAILABILITY window_step="declare_blockers" type="window" />
<AI_AVAILABILITY window_step="main_2" window_turn="my_turn" type="window" />
<AI_AVAILABILITY window_step="end_of_turn" type="window" />
<AI_AVAILABILITY window_step="end_of_turn" window_turn="their_turn" type="window" />
<AI_AVAILABILITY type="in_response" response_source="1" response_target="1" />
<AI_AVAILABILITY type="in_response" response_source="1" />
<AI_AVAILABILITY type="in_response" response_target="1" />
</ACTIVATED_ABILITY>
<TRIGGERED_ABILITY forced_skip="1" replacement_effect="1">
<TRIGGER value="BEGINNING_OF_STEP" pre_trigger="1" />
<RESOLUTION_TIME_ACTION>
RSN_ClearProducedMana()
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY forced_skip="1" replacement_effect="1">
<TRIGGER value="ZONECHANGE_END" to_zone="ZONE_BATTLEFIELD" from_zone="ZONE_ANY">
-- Since we only care about lands for checking what we can produce.
return ((TriggerObject() ~= nil) and (TriggerObject():GetCardType():Test( CARD_TYPE_LAND )))
</TRIGGER>
<TRIGGER value="ZONECHANGE_END" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_ANY">
-- Since we only care about lands for checking what we can produce.
return ((TriggerObject() ~= nil) and (TriggerObject():GetCardType():Test( CARD_TYPE_LAND )))
</TRIGGER>
<RESOLUTION_TIME_ACTION>
RSN_ClearCanProduceMana()
-- Look through my opponents' lands to see what this can produce.
for i=0, (MTG():GetNumberOfPlayers() - 1) do
local oPlayer = MTG():GetNthPlayer( i )
if (oPlayer:GetTeam() ~= EffectController():GetTeam()) then
RSN_MarkCanProduceColourOfAnyTypeOtherLandPlayerControls( oPlayer )
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_B" />
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_C" />
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_G" />
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_R" />
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_U" />
<TOKEN_REGISTRATION reservation="1" type="RSN_TOKEN_MANA_W" />
</CARD_V2>
Last edited by RiiakShiNal on 18 Jul 2013, 18:18, edited 1 time in total.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: COST Limitations
by thefiremind » 18 Jul 2013, 17:59
I think that the predefined costs (such as untap, tap, sacrifice, etc.) are set to work only on what's controlled by EffectController(), as you said. But I'm almost sure that the generic cost would have worked, the problem is that you missed the PREREQUISITE block. I remember someone else having discovered that it's mandatory, even with only "return true" inside.
< 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: COST Limitations
by RiiakShiNal » 18 Jul 2013, 18:16
Ahh... That was the piece I was missing, this works:
- Code: Select all
<COST type="Generic">
<PREREQUISITE>
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
return (oFilter:CountStopAt(1) == 1)
</PREREQUISITE>
<RESOLUTION_TIME_ACTION>
local oFilter = ClearFilter()
oFilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
oFilter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
oFilter:Add( FE_IS_TAPPED, true )
EffectController():ChooseItem( "CARD_QUERY_CHOOSE_LAND_TO_UNTAP", EffectDC():Make_Targets( 1 ) )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local oLand = EffectDC():Get_Targets(1):Get_CardPtr(0)
if (oLand ~= nil) then
oLand:Untap()
end
</RESOLUTION_TIME_ACTION>
</COST>
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 22 guests