Re: Formal Request Thread
Intriguing idea, with intriguing results! Using the code below (as you suggested), I am able to have one Sarkhan that is a creature and one Sarkhan that is just a PW. There are still a few problems, however. 1) The new creature Sarkhan will permanently gain the legendary supertype once he goes back to being a PW; 2) There is no check during the end phase when there should be two identical Sarkhan Planeswalkers on the battlefield, and so they are both allowed to remain; 3) I get the following script error on exit: [lua] [string "_PLANESWALKERS_MANAGER_991800002_TITLE (RESOLUTION_TIME_ACTION)~0x0000034c"]:7: attempt to index global 'tobj' (a nil value). I think SweetLu's right, and that we're on the verge of making the new Sarkhan more fully rule compliant. If anyone who might know how to resolve the three issues I mention wants to see the PW Manager code I used, here it is:
- Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="11">
<FILENAME text="_PLANESWALKERS_MANAGER_991800002" />
<CARDNAME text="_PLANESWALKERS_MANAGER" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[プレインズウォーカー]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[플레인즈워커]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Planeswalker]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="991800002" />
<ARTID value="0" />
<ARTIST name="Nobody" />
<CASTING_COST cost="" />
<TYPE metaname="" />
<EXPANSION value="DPI" />
<RARITY metaname="C" />
<!-- Invisible token protection -->
<STATIC_ABILITY>
<CONTINUOUS_ACTION layer="8">
if EffectSource() ~= nil then
local characteristics = EffectSource():GetCurrentCharacteristics()
characteristics:Bool_Set(CHARACTERISTIC_SHROUD, 1)
characteristics:Bool_Set(CHARACTERISTIC_INDESTRUCTIBLE, 1)
characteristics:AI_SetWorthless()
end
</CONTINUOUS_ACTION>
<CONTINUOUS_ACTION layer="8">
if EffectSource() ~= nil then
local filter = ClearFilter()
filter:Add(FE_CMC, OP_GREATER_THAN_OR_EQUAL_TO, 0)
EffectSource():Protection()
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<!-- Planeswalker rules -->
<!-- 1. Planeswalker goes to the graveyard when it has no loyalty counters left -->
<TRIGGERED_ABILITY replacement_effect="1">
<COUNTER_REGISTRATION name="Loyalty" proliferate="11" />
<TRIGGER value="STATE_BASED_EFFECTS" />
<FILTER filter_id="0">
local filter = ClearFilter()
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
</FILTER>
<RESOLUTION_TIME_ACTION filter_id="0">
if FilteredCard() ~= nil and FilteredCard():CountCounters( MTG():GetCountersType("Loyalty") ) == 0 then
FilteredCard():PutInGraveyard()
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 2. Planeswalkers' "Legendary rule" -->
<TRIGGERED_ABILITY replacement_query="1">
<TRIGGER value="ZONECHANGE_END" simple_qualifier="objectyoucontrol" to_zone="ZONE_BATTLEFIELD">
return PLW_IsInNameSet( TriggerObject(), "PLANESWALKERS" )
</TRIGGER>
<RESOLUTION_TIME_ACTION>
MTG():ClearFilterMark()
local tobj = TriggerObject()
local filter = ClearFilter()
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
if TriggerObject:GetSubType() == "SARKHAN" then
if TriggerObject:GetCardType():Test( CARD_TYPE_CREATURE ) then
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
else
filter:Add( FE_TYPE, OP_NOT, CARD_TYPE_CREATURE )
end
end
local filter_count = filter:EvaluateObjects()
if filter:CountStopAt(2) == 2 then
for i=0,filter_count-1 do
local card = filter:GetNthEvaluatedObject(i)
if PLW_GetSubType(card) == PLW_GetSubType(tobj) then
card:MarkForFilter()
end
end
filter:SetMarkedObjectsOnly()
if filter:CountStopAt(2) == 2 then
EffectController():ChooseItem( "PLW_CARD_QUERY_CHOOSE_PLANESWALKER_TO_SAVE", EffectDC():Make_Targets(0) )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local to_keep = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
if to_keep ~= nil then
local filter = ClearFilter()
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
if TriggerObject:GetSubType() == "SARKHAN" then
if TriggerObject:GetCardType():Test( CARD_TYPE_CREATURE ) then
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
else
filter:Add( FE_TYPE, OP_NOT, CARD_TYPE_CREATURE )
end
end
local filter_count = filter:EvaluateObjects()
for i=0,filter_count-1 do
local card = filter:GetNthEvaluatedObject(i)
if card ~= to_keep and PLW_GetSubType(card) == PLW_GetSubType( TriggerObject() ) then
card:PutInGraveyard()
end
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 3. Planeswalkers' abilities can be played only once per turn -->
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="ACTIVATED_ABILITY_PLAYED" simple_qualifier="objectyoucontrol">
if not PLW_IsInNameSet( TriggerObject(), "PLANESWALKERS" ) then
return false
end
local activations_chest = PLW_MyDuelDC():Get_Chest(PLW_PLANESWALKERS_ACTIVATIONS_CHEST)
if activations_chest == nil then
activations_chest = PLW_MyDuelDC():Make_Chest(PLW_PLANESWALKERS_ACTIVATIONS_CHEST)
end
-- Find the Planeswalker
local current_index = -1
local last_index = activations_chest:Get_Int(0)
if last_index > 0 then
for i=1,last_index,2 do
local card = activations_chest:Get_CardPtr(i)
if card ~= nil and card == TriggerObject() then
-- Planeswalker found
current_index = i
break
end
end
else
last_index = -1 -- this will make it right when adding 2 later
end
if current_index == -1 then
-- Planeswalker not found, let's add it
last_index = last_index + 2
activations_chest:Set_Int(0, last_index)
activations_chest:Set_CardPtr( last_index, TriggerObject() )
activations_chest:Set_Int(last_index+1, 0)
current_index = last_index
end
-- Increase Planeswalker's activations count (1 register further than the card pointer)
activations_chest:Int_Inc(current_index+1)
-- Increase player's own activations count (will be used by The Chain Veil's first ability)
PLW_MyPlayerDC( EffectController() ):Int_Inc(PLW_PLANESWALKERS_ACTIVATIONS)
-- Save Planeswalker's activations count index for continuous action
EffectDC():Set_Int(1, current_index+1)
return true
</TRIGGER>
<CONTINUOUS_ACTION layer="8">
if TriggerObject() ~= nil then
local activations_chest = PLW_MyDuelDC():Get_Chest(PLW_PLANESWALKERS_ACTIVATIONS_CHEST)
if activations_chest ~= nil then
local loyalty_activations = activations_chest:Get_Int( EffectDC():Get_Int(1) )
local chain_veil_activations = PLW_MyPlayerDC( TriggerObject():GetController() ):Get_Int(PLW_CHAIN_VEIL_ACTIVATIONS)
if loyalty_activations > chain_veil_activations then
TriggerObject():GetCurrentCharacteristics():Bool_Set(CHARACTERISTIC_CANT_USE_ACTIVATED_ABILITIES, 1)
end
end
end
</CONTINUOUS_ACTION>
<DURATION simple_duration="UntilEOT" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_CLEANUP
</TRIGGER>
<RESOLUTION_TIME_ACTION>
PLW_MyDuelDC():Free_Compartment(PLW_PLANESWALKERS_ACTIVATIONS_CHEST)
for i=0,MTG():GetNumberOfPlayers()-1 do
local player_chest = PLW_MyPlayerDC( MTG():GetNthPlayer(i) )
player_chest:Set_Int(PLW_PLANESWALKERS_ACTIVATIONS, 0)
player_chest:Set_Int(PLW_CHAIN_VEIL_ACTIVATIONS, 0)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 4. Damage redirection -->
<TRIGGERED_ABILITY replacement_query="1" linked_ability_group="1">
<COUNTER_REGISTRATION name="Loyalty" proliferate="11" />
<TRIGGER value="SOURCE_DEALS_DAMAGE_TO_PLAYER" pre_trigger="1" damage_type="noncombat">
if LinkedDC():Get_Int(0) ~= 1 then
local controller = EffectController()
local amount = Damage() and Damage():GetAmount()
if amount ~= nil and amount > 0 and SecondaryPlayer() == controller and TriggerObject():GetPlayer():GetTeam() ~= controller:GetTeam() then
local filter = ClearFilter()
filter:Add(FE_CONTROLLER, OP_IS, controller)
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
if filter:CountStopAt(1) == 1 then
EffectDC():Set_Int(2, amount)
Damage():Multiply(0)
return true
end
end
else
LinkedDC():Set_Int(0, 0) -- reset the flag
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local source = TriggerObject()
if source ~= nil then
local player = source:GetPlayer()
if player ~= nil then
local filter = ClearFilter()
filter:Add( FE_CONTROLLER, OP_IS, EffectController() )
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
player:ChooseItem( "PLW_CARD_QUERY_CHOOSE_PLANESWALKER_REDIRECT_DAMAGE_TO", EffectDC():Make_Targets(1), QUERY_FLAG_MAY )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_Targets(1) and EffectDC():Get_Targets(1):Get_CardPtr(0)
local amount = EffectDC():Get_Int(2)
if target ~= nil then
PLW_SetLastDamageInfo( target, TriggerObject(), amount )
TriggerObject():DealDamageTo(amount, target)
if target:GetCardType():Test(CARD_TYPE_CREATURE) == false then -- if it's not a creature, dealing damage doesn't do anything
if PLW_MyPlayerDC( target:GetController() ):Get_Int(PLW_AJANI_STEADFAST_EMBLEM) == 0 then
target:RemoveCounters( MTG():GetCountersType("Loyalty"), amount )
else
target:RemoveCounters( MTG():GetCountersType("Loyalty"), 1 )
end
end
else
LinkedDC():Set_Int(0, 1) -- set this flag so the trigger won't trigger again this time
TriggerObject():DealDamageTo( amount, SecondaryPlayer() )
end
-- APPROXIMATION: if the damage is unpreventable, this way I'm removing that characteristic
-- APPROXIMATION: if the Planeswalker isn't a creature, damage triggers from the source won't trigger
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 5. Attacking Planeswalkers -->
<STATIC_ABILITY>
<FILTER filter_id="0">
local filter = ClearFilter()
filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
</FILTER>
<CONTINUOUS_ACTION layer="8" filter_id="0">
if FilteredCard() ~= nil then
local filter = ClearFilter()
filter:Add( FE_CARD_NAME, OP_IS, EffectSource() )
filter:EvaluateObjects()
if EffectSource() == filter:GetNthEvaluatedObject(0) then -- only 1 manager should grant the ability
FilteredCard():GetCurrentCharacteristics():GrantAbility(0)
end
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<TRIGGERED_ABILITY replacement_query="1" resource_id="0">
<TRIGGER value="ATTACKING" simple_qualifier="self" />
<RESOLUTION_TIME_ACTION>
local defending = TriggerObject() and TriggerObject():GetPlayerAttacked()
if defending ~= nil then
local filter = ClearFilter()
filter:Add(FE_CONTROLLER, OP_IS, defending)
PLW_FilterNameSet(filter, "PLANESWALKERS", true)
if filter:CountStopAt(1) == 1 then
EffectController():ChooseItem( "PLW_CARD_QUERY_CHOOSE_PLANESWALKER_TO_ATTACK", EffectDC():Make_Targets(0), QUERY_FLAG_MAY )
end
end
-- APPROXIMATION: a creature attacking a Planeswalker shouldn't be counted as attacking the player
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
if target ~= nil then
local defending = TriggerObject() and TriggerObject():GetPlayerAttacked()
if defending ~= nil and defending:IsAI() == false then
defending:SetCustomQueryInstructionCardPtr(target)
defending:BeginNewMultipleChoice()
defending:AddMultipleChoiceAnswer("CONTROL_MB_CONFIRM")
defending:AskMultipleChoiceQuestion( "PLW_CARD_QUERY_ATTACKED_PLANESWALKER", TriggerObject() )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
if target ~= nil then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr( 0, TriggerObject() )
delayDC:Set_CardPtr(1, target)
MTG():CreateDelayedTrigger(1, delayDC)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" resource_id="1">
<CLEANUP>
return MTG():GetStep() == STEP_END_OF_COMBAT
</CLEANUP>
<COUNTER_REGISTRATION name="Loyalty" proliferate="11" />
<TRIGGER value="SOURCE_DEALS_DAMAGE_TO_PLAYER" damage_type="combat" pre_trigger="1">
local amount = Damage() and Damage():GetAmount()
if amount ~= nil and amount > 0 and TriggerObject() == EffectDC():Get_CardPtr(0) then
local target = EffectDC():Get_CardPtr(1)
if target ~= nil then
PLW_SetLastDamageInfo( target, TriggerObject(), amount )
if target:GetCardType():Test(CARD_TYPE_CREATURE) then
Damage():RedirectAllTo(target)
else
Damage():Multiply(0)
if PLW_MyPlayerDC( target:GetController() ):Get_Int(PLW_AJANI_STEADFAST_EMBLEM) == 0 then
target:RemoveCounters( MTG():GetCountersType("Loyalty"), amount )
else
target:RemoveCounters( MTG():GetCountersType("Loyalty"), 1 )
end
EffectDC():Set_Int(2, amount)
MTG():CreateDelayedTrigger( 2, EffectDC() )
end
end
return true
end
return false
-- APPROXIMATION: if the Planeswalker isn't a creature, damage triggers from the source won't trigger
</TRIGGER>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY forced_skip="1" resource_id="2">
<CLEANUP fire_once="1" />
<TRIGGER value="STATE_BASED_EFFECTS" />
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_CardPtr(1)
if target ~= nil then
PLW_SetLastDamageInfo( target, EffectDC():Get_CardPtr(0), EffectDC():Get_Int(2) )
MTG():FireTrigger( TRIGGER_OBJECT_TAKES_DAMAGE, target )
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 6. Damage to Planeswalker creatures (this works only for Gideon when he becomes a creature) -->
<TRIGGERED_ABILITY replacement_effect="1">
<COUNTER_REGISTRATION name="Loyalty" proliferate="11" />
<TRIGGER value="OBJECT_TAKES_DAMAGE">
return PLW_IsInNameSet( TriggerObject(), "PLANESWALKERS" )
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if TriggerObject() ~= nil then
local amount = Damage() and Damage():GetAmount()
if amount ~= nil then
TriggerObject():RemoveCounters( MTG():GetCountersType("Loyalty"), amount )
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<!-- 7. Cards not allowed to target Planeswalkers -->
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="CARD_CONSIDERED_FOR_TARGETTING" pre_trigger="1">
local target = TriggerObject()
local filter = ClearFilter()
filter:Add(FE_CARD_NAME, OP_IS, "ENCHANTED_EVENING") -- With Enchanted Evening on the battlefield, Planeswalkers would be enchantments for real
if filter:CountStopAt(1) == 0 or target:GetZone() ~= ZONE_BATTLEFIELD then
local targetter = SecondaryObject()
if PLW_IsInNameSet(target, "PLANESWALKERS") and
( PLW_IsInNameSet(targetter, "TARGET_ENCHANTMENTS_NOT_CREATURES") or
(target:GetCardType():Test(CARD_TYPE_CREATURE) == false and
PLW_IsInNameSet(targetter, "TARGET_ENCHANTMENTS_AND_CREATURES")) ) then
MTG():OverrideEvent()
return true
end
end
return false
</TRIGGER>
</TRIGGERED_ABILITY>
<!-- 8. Planeswalker type hack -->
<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="objectyoucontrol" to_zone="ZONE_BATTLEFIELD">
if TriggerObject():GetCardType():Test(CARD_TYPE_PLANESWALKER) then
EffectDC():Protect_CardPtr(COMPARTMENT_ID_PARAM_TRIGGER_OBJECT)
return true
end
return false
</TRIGGER>
<CONTINUOUS_ACTION layer="1">
if TriggerObject() ~= nil then
local characteristics = TriggerObject():GetCurrentCharacteristics()
local card_type = characteristics:CardType_GetWritable()
local supertype = characteristics:SuperType_GetWritable()
card_type:Clear()
-- I chose "Basic Snow Enchantment", it seems the only safe choice.
-- I avoided Legendary since we are already managing the Planeswalkers' "Legendary rule" manually.
card_type:Add(CARD_TYPE_ENCHANTMENT)
supertype:Add(SUPERTYPE_BASIC)
supertype:Add(SUPERTYPE_SNOW)
end
</CONTINUOUS_ACTION>
<DURATION>
return TriggerObject() == nil
</DURATION>
</TRIGGERED_ABILITY>
<AI_BASE_SCORE score="-5000" zone="ZONE_BATTLEFIELD" />
</CARD_V2>
: Add
to your mana pool", "Other ___ creatures you control get +1/+1.", etc...). Other abilities you can get a piece of from one card or another (For example "Threshold" from one card and "gets +2/+2" from another card).