Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



Choosing a target. -_-
Moderator: CCGHQ Admins
Choosing a target. -_-
by Jspapp » 01 Sep 2012, 15:20
I don't know if I've been staring at this for too long or what, but I just can't get this to work at all. I'm trying to code Nyxathid, and as it comes into the battlefield you choose an opponent.
- Code: Select all
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
<RESOLUTION_TIME_ACTION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetFilterType( FILTER_TYPE_OPPONENTS )
EffectController():ChooseTarget( NO_VALIDATION, "CARD_QUERY_CHOOSE_OPPONENT", EffectDC():Make_Targets(0) )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
Re: Choosing a target. -_-
by BlindWillow » 01 Sep 2012, 17:35
The filter for opponents is actually set like this:
- Code: Select all
local filter = Object():GetFilter()
filter:Clear()
filter:SetFilterType( FILTER_TYPE_PLAYERS + FILTER_TYPE_OPPONENTS)
filter:SetOwner( EffectController() )
filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
- BlindWillow
- Posts: 213
- Joined: 19 Jul 2012, 00:26
- Has thanked: 11 times
- Been thanked: 46 times
Re: Choosing a target. -_-
by BlindWillow » 01 Sep 2012, 17:39
I see Kevlahnota has already coded Nyxathid for the Community DLC mod.
Here's the code from that:
Here's the code from that:
- Code: Select all
<TRIGGERED_ABILITY pre_trigger="1" replacement_query="1" active_zone="ZONE_TRANSITION">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[As Nyxathid enters the battlefield, choose an opponent.]]></LOCALISED_TEXT>
<TRIGGER value="ZONECHANGE_TRANSITION" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:SetFilterType( FILTER_TYPE_PLAYERS + FILTER_TYPE_OPPONENTS)
filter:SetOwner( EffectController() )
filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
filter:NotTargetted()
</TARGET_DEFINITION>
<TARGET_DETERMINATION>
return AtLeastOneTargetFromDefinition(0)
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION target_choosing="1">
EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_OPPONENT", EffectDC():Make_Targets(0) )
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_PlayerPtr(0, player)
MTG():CreateDelayedTrigger(1, delayDC)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
EffectDC():Protect_CardPtr( COMPARTMENT_ID_EFFECT_SOURCE )
</RESOLUTION_TIME_ACTION>
<CONTINUOUS_ACTION layer="0">
local player = ObjectDC():Get_PlayerPtr(0)
if player ~= nil then
player:AddBadge(PLAYER_BADGE_ICON_CHOSEN_PLAYER, "PLAYER_CHOSEN_ICON")
end
</CONTINUOUS_ACTION>
<DURATION>
return (EffectSource() == nil)
</DURATION>
</TRIGGERED_ABILITY>
<STATIC_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Nyxathid gets -1/-1 for each card in the chosen player’s hand.]]></LOCALISED_TEXT>
<CONTINUOUS_ACTION layer="7C">
local chosen_opponent = ObjectDC():Get_PlayerPtr(0)
if chosen_opponent ~= nil then
local total = CountCardsInHand( chosen_opponent )
local characteristics = Object():GetCurrentCharacteristics()
characteristics:Power_Add( -total )
characteristics:Toughness_Add( -total )
end
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<TRIGGERED_ABILITY internal="1" resource_id="1" active_zone="ZONE_IN_PLAY">
<TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
<CLEANUP fire_once="1" />
<RESOLUTION_TIME_ACTION>
ObjectDC():Set_PlayerPtr(0, EffectDC():Get_PlayerPtr(0))
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
- BlindWillow
- Posts: 213
- Joined: 19 Jul 2012, 00:26
- Has thanked: 11 times
- Been thanked: 46 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests