Just as a reference, I'm posting the code for
DotP2012 Precursor Golem:
- Code: Select all
<TRIGGERED_ABILITY active_zone="in_play">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Whenever a player casts an instant or sorcery spell that targets only a single Golem, that player copies that spell for each other Golem that spell could target. Each copy targets a different one of those Golems.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[À chaque fois qu'un joueur lance un sort d'éphémère ou de rituel qui ne cible qu'un seul golem, ce joueur copie ce sort pour chaque autre golem que ce sort pourrait cibler. Chaque copie cible un golem différent parmi eux.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Immer wenn ein Spieler einen Spontanzauber oder eine Hexerei wirkt, der bzw. die nur einen einzelnen Golem als Ziel hat, kopiert dieser Spieler diesen Zauber für jeden anderen Golem, den der Zauber als Ziel haben könnte. Jede dieser Kopien hat einen unterschiedlichen dieser Golems als Ziel.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Siempre que un jugador lance un hechizo instantáneo o conjuro que haga objetivo a un único Gólem, ese jugador copia ese hechizo para cada otro Gólem que ese hechizo podría hacer objetivo. Cada copia hace objetivo a cada uno de esos otros Gólems.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Ogniqualvolta un giocatore lancia una magia istantaneo o stregoneria che bersaglia solo un Golem, quel giocatore copia quella magia per ogni altro Golem che quella magia potrebbe bersagliare. Ogni copia bersaglia uno diverso di quei Golem.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[いずれかのプレイヤーが、ゴーレム1体のみ対象とする、インスタント呪文かソーサリー呪文を1つ唱えるたび、そのプレイヤーはその呪文を、その呪文が対象にできる他の各ゴーレム1体につき1回コピーする。 それぞれのコピーは、それらのゴーレムのうち別々のものを対象とする。]]></LOCALISED_TEXT>
<TRIGGER value="TARGETS_CHOSEN">
if TriggerObject() ~= nil and TriggerObject():GetDataChest() ~= nil then
local targetDC = TriggerObject():GetDataChest():Get_Targets(0)
if targetDC ~= nil then
local target_card = targetDC:Get_CardPtr(0)
return TriggerObject():WasCast() ~= 0 and
(TriggerObject():GetCardType():Test(CARD_TYPE_INSTANT) ~= 0 or
TriggerObject():GetCardType():Test(CARD_TYPE_SORCERY) ~= 0 ) and
(target_card ~= nil and
target_card:GetSubType():Test(CREATURE_TYPE_GOLEM) ~= 0)
else
return false
end
else
return false
end
</TRIGGER>
<FILTER>
return FilteredCard():GetSubType():Test( CREATURE_TYPE_GOLEM ) ~= 0
</FILTER>
<RESOLUTION_TIME_ACTION>
if TriggerObject() ~= nil then
local target_card = nil
local objDC = TriggerObject():GetDataChest()
if objDC ~= nil then
local targetDC = objDC:Get_Targets(0)
if targetDC ~= nil then
target_card = targetDC:Get_CardPtr(0)
end
end
if FilteredCard() ~= target_card then
local copied_spell = TriggerObject():GetPlayer():CopySpell( TriggerObject() )
if copied_spell ~= nil then
copied_spell:SetTargetCard(FilteredCard())
end
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
as I said before, this card was coded for a challenge, where it can't possibly interact with every kind of card, but just with the cards in that challenge. That made things easier for the developers.
As you can see from the code, the trigger condition checks for Get_Targets(0) (but what if the target was in Get_Targets(1) for example?). In resolution, the target of the copy is forced with SetTargetCard, which again I'm pretty sure changes only the target in register 0.
You can try to reuse parts of this code if you want, but I can't guarantee that it will work for every kind of instant and sorcery.