NeoAnderson wrote:Riiak i made some test I think you can resolve this issue using the function MTG():ReevaluateContinuousEffects(). (It seems to force the State_Base_Effect evaluation so could be what you are looking for)
ReevaluateContinuousEffects() is exactly what I was looking for, though I don't know how I missed it on the function list.
NeoAnderson wrote:I also find the follow thing :
1. CONSIDERED_FOR_CAST will automatically called for the first left card on your hand, doesn't matter if you are pointing it with the mouse.
Actually, when the card first enters the battlefield it seems to trigger for all cards in your hand.
NeoAnderson wrote:I also made some modify to your code and i think you could avoid to grant the ability into static ability, just adding it into the trigger ability, but i still have some troubles with the duration.
Anyway you could make some test using the follow code :
- Code: Select all
<TRIGGERED_ABILITY replacement_effect="1" linked_ability_group="1">
<TRIGGER value="CONSIDERED_FOR_CAST" pre_trigger="1">
if ((TriggerObject() ~= nil) and (TriggerPlayer() == EffectController())) then
if (TriggerObject():GetCardType():Test( CARD_TYPE_ARTIFACT )) then
if (LinkedDC():Int_Get(0) == 0) then
LinkedDC():Int_Set( 0, 1 )
if ((EffectSource() ~= nil) and (LinkedDC():Int_Get(0) == 1)) then
MTG():ReevaluateContinuousEffects()
return true
end
end
else
LinkedDC():Int_Set( 0, 0 )
return false
end
end
</TRIGGER>
<CONTINUOUS_ACTION layer="6" >
if (EffectSource() ~= nil) then
if (LinkedDC():Int_Get(0) == 1) then
EffectSource():GetCurrentCharacteristics():GrantAbility(0)
LinkedDC():Int_Inc(0)
end
end
</CONTINUOUS_ACTION>
<DURATION>
if LinkedDC():Int_Get(0) == 0 then
return true
end
</DURATION>
</TRIGGERED_ABILITY>
I am still not sure it works as you expected but try it, i have tested it with a non mana ability and it is granted while the card to cast is an artifact.
Your method will create and remove new continuous effects all the time (which will then require checking the durations), a STATIC_ABILITY works better in this case as you have a single ability that gets updated rather than continuously creating and removing effects.
Using ReevaluateContinuousEffects() I have managed to get a mostly working version, but there is still a timing issue with the actual casting (though I may be able to solve that with a few more tests).
- Closer to working code | Open
- Code: Select all
<MANA_ABILITY resource_id="0">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{T}: Produce {1}]]></LOCALISED_TEXT>
<COST type="TapSelf" />
<PRODUCES amount="{1}" />
</MANA_ABILITY>
<STATIC_ABILITY linked_ability_group="1">
<CONTINUOUS_ACTION layer="0">
if ((EffectSource() ~= nil) and (LinkedDC():Int_Get(0) == 1)) then
EffectSource():GetCurrentCharacteristics():GrantAbility(0)
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" linked_ability_group="1">
<TRIGGER value="CONSIDERED_FOR_CAST" pre_trigger="1">
return ((TriggerObject() ~= nil) and
(TriggerObject() ~= LinkedDC():Get_CardPtr(1)) and
(TriggerPlayer() == EffectController()))
</TRIGGER>
<RESOLUTION_TIME_ACTION>
LinkedDC():Set_CardPtr( 1, TriggerObject() )
if (TriggerObject():GetCardType():Test( CARD_TYPE_ARTIFACT )) then
if (LinkedDC():Int_Get(0) ~= 1) then
LinkedDC():Int_Set( 0, 1 )
MTG():ReevaluateContinuousEffects()
end
else
if (LinkedDC():Int_Get(0) ~= 0) then
LinkedDC():Int_Set( 0, 0 )
MTG():ReevaluateContinuousEffects()
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
You can watch the "

: Produce

" text appear and disappear on the card as you move over the cards in your hand, but it seems to remove the mana ability right as you cast an artifact so the artifact gets cast for free (which is obviously wrong).
Edit: After several more tests I can say the mana ability is not being removed before cast and it does not seem it will be possible to get it working properly as the game does not seem to properly update the available mana sources on the fly. It does show that it is possible to cast artifacts using the restricted mana (which indicates at least a partial update of the MANA_ABILITY calculations), but when cast it does not correctly use the restricted mana for the artifact spell (so it gets cast for free). Then when you cast another spell after that which should not be able to use the restricted mana (because it isn't an artifact) it will still use the restricted mana even though the ability has already been removed from the card.
Example: I had 2 copies of
Sejiri Refuge, 1
Kabira Crossroads, plus my test card (which produces

) in play and in hand I had an
Azorius Keyrune, AEther Figment, and an
Ajani's Sunstriker. I tapped a
Sejiri Refuge (produced

), tapped the other
Sejiri Refuge (produced

),
Azorius Keyrune appeared available for cast (so far so good). I cast
Azorius Keyrune (it cast for free, not good), then I cast AEther Figment (it tapped the test card even though the test card did not show the mana ability, not good). Now either it used the test card or the test card disappeared as a delayed reaction, if it used the test card then I should still have 1

left over so I tapped the
Kabira Crossroads (produced

) and
Ajani's Sunstriker appeared as available to cast so I cast it and it used the remaining mana and was cast.
So it appears that the engine just can't handle enabling/disabling mana abilities on the fly like this. Thus ends my hopes at updating manual mana to be able to work with mana restrictions (unless I get lucky, have a stroke of genius, or someone else has a bright idea).