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



Help with Divine Deflection
Moderator: CCGHQ Admins
1 post
• Page 1 of 1
Help with Divine Deflection
by Zarroc » 24 Nov 2014, 23:22
Hi I'm trying to code Divine Deflection and I'm having trouble with the damageprevention part. If I don't spend enough Mana to prevent all the damage it still prevents all and it deals X damage (X = Mana spent) to the target everytime I would recieve damage.
Example:
Example:
- Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
<FILENAME text="DIVINE_DEFLECTION_500240072" />
<CARDNAME text="DIVINE_DEFLECTION" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Divine Deflection]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Déflexion divine]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Redirección divina]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Göttliche Ablenkung]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Deviazione Divina]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[神聖なる反撃]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[신성한 굴절]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Божественное Отклонение]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Deflexão Divina]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="500240072" />
<ARTID value="500240072" />
<ARTIST name="Steve Prescott" />
<CASTING_COST cost="{X}{W}" />
<TYPE metaname="Instant" />
<EXPANSION value="AVR" />
<RARITY metaname="R" />
<SPELL_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Prevent the next X damage that would be dealt to you and/or permanents you control this turn. If damage is prevented this way, Divine Deflection deals that much damage to target creature or player.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Prévenez, ce tour-ci, les prochaines X blessures qui devraient être infligées à vous et/ou aux permanents que vous contrôlez. Si des blessures sont prévenues de cette manière, la Déflexion divine inflige autant de blessures à une cible, créature ou joueur.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Prevén los siguientes X puntos de daño que se te fueran a hacer a ti y/o a los permanentes que controlas este turno. Si se previene daño de esta manera, la Redirección divina hace esa misma cantidad de daño a la criatura o jugador objetivo.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Verhindere die nächsten X Schadenspunkte, die dir und/oder bleibenden Karten, die du kontrollierst, in diesem Zug zugefügt würden. Falls auf diese Weise Schaden verhindert wurde, fügt die Göttliche Ablenkung einer Kreatur oder einem Spieler deiner Wahl so viele Schadenspunkte zu.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Previeni i prossimi X danni che verrebbero inflitti a te e/o ai permanenti che controlli in questo turno. Se i danni vengono prevenuti in questo modo, la Deviazione Divina infligge altrettanti danni a una creatura o a un giocatore bersaglio.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[クリーチャー1体かプレイヤー1人を対象とする。このターン、次にあなたやあなたがコントロールするパーマネントに与えられるダメージをX点軽減する。 これによりダメージが軽減される場合、神聖なる反撃はその点数に等しい点数のダメージを、そのクリーチャーやプレイヤーに与える。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[생물 한 개나 플레이어 한 명을 목표로 정한다. 이 턴에 당신 및/또는 당신이 조종하는 지속물에게 입혀지려 하는 피해 X점을 방지한다. 이렇게 피해를 방지하면, 신성한 굴절은 그 목표에게 방지된 만큼의 피해를 입힌다.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Предотвратите следующие Х повреждений, которые должны быть нанесены вам и перманентам под вашим контролем в этом ходу. Если повреждения предотвращаются таким образом, Божественное Отклонение наносит столько же повреждений целевому существу или игроку.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Previna os próximos X pontos de dano que seriam causados a você e/ou às permanentes que você controla neste turno. Se algum dano for prevenido dessa forma, Deflexão Divina causará uma quantidade equivalente de dano ao jogador ou criatura alvo.]]></LOCALISED_TEXT>
<TARGET tag="CARD_QUERY_CHOOSE_CREATURE_OR_PLAYER_TO_DAMAGE" definition="0" compartment="0" count="1" />
<TARGET_DEFINITION id="0">
local filter = ClearFilter()
filter:SetFilterType( FILTER_TYPE_CARDS + FILTER_TYPE_PLAYERS )
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
</TARGET_DEFINITION>
<RESOLUTION_TIME_ACTION>
local damage = GetEffectX()
local target_creature = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
local target_player = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_PlayerPtr(0)
if ( target_creature ~= nil ) then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr(0, target_creature)
delayDC:Set_Int(1, damage)
MTG():CreateDelayedTrigger(11, delayDC)
elseif ( target_player ~= nil ) then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_PlayerPtr(0, target_player)
delayDC:Set_Int(1, damage)
MTG():CreateDelayedTrigger(11, delayDC)
end
</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" />
<AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ENEMY_ONLY" />
</SPELL_ABILITY>
<TRIGGERED_ABILITY replacement_effect="1" resource_id="11">
<TRIGGER value="SOURCE_DEALS_DAMAGE" pre_trigger="1"/>
<CLEANUP simple_cleanup="EndOfTurn" fire_once="1" />
<RESOLUTION_TIME_ACTION>
local prevent = EffectDC():Get_Int(1)
EffectDC():Set_Int(10, prevent )
local damage = Damage():GetAmount()
if (damage >= prevent) then
Damage():PreventAmount(prevent)
EffectDC():Set_Int(10, 0 )
EffectDC():Set_Int(11, prevent)
elseif (damage < prevent) then
Damage():PreventAmount(damage)
EffectDC():Set_Int(10, (prevent - damage) )
EffectDC():Set_Int(11, damage)
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target_creature = EffectDC():Get_CardPtr(0)
local target_player = EffectDC():Get_PlayerPtr(0)
local prevented = EffectDC():Get_Int(11)
if (target_creature ~= nil) then
EffectSourceLKI():DealDamageTo(prevented, target_creature)
elseif (target_player ~= nil) then
EffectSourceLKI():DealDamageTo(prevented, target_player)
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target_creature = EffectDC():Get_CardPtr(0)
local target_player = EffectDC():Get_PlayerPtr(0)
if ( target_creature ~= nil ) then
local Toprevent = EffectDC():Get_Int(10)
if Toprevent > 0 then
local delayDC = EffectDC():Make_Chest(4)
delayDC:Set_CardPtr(0, target_creature)
delayDC:Set_Int(1, Toprevent)
MTG():CreateDelayedTrigger(11, delayDC)
end
elseif (target_player ~= nil) then
local Toprevent = EffectDC():Get_Int(10)
if Toprevent > 0 then
local delayDC = EffectDC():Make_Chest(4)
delayDC:Set_PlayerPtr(0, target_player)
delayDC:Set_Int(1, Toprevent)
MTG():CreateDelayedTrigger(11, delayDC)
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<AI_BASE_SCORE score="900" zone="ZONE_HAND" />
</CARD_V2>
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 11 guests