Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
Let's talk about next damage prevention (again)
Moderator: CCGHQ Admins
Let's talk about next damage prevention (again)
by thefiremind » 23 Feb 2013, 11:04
For those who didn't see the previous topic, it's here:
viewtopic.php?f=63&t=7415
Basically I was asking if there was a way to understand how the built-in function "PreventNextDamage" works. I finally concluded that the function is a leftover from DotP2010 and cannot be used in more recent games because we miss a pointer to the ability itself (in DotP2010 it was Effect() which actually called rawget(_G, lua_effect_index) but this seems to return nil now).
On a side note, always preventing a certain amount of damage for a given duration works, by using this syntax:
Returning to the prevention of the next X damage, I made a better implementation for Ordruun Commando, without using ObjectDC (which allows this code to be reused for abilities that prevent the next X damage on other creatures):
viewtopic.php?f=63&t=7415
Basically I was asking if there was a way to understand how the built-in function "PreventNextDamage" works. I finally concluded that the function is a leftover from DotP2010 and cannot be used in more recent games because we miss a pointer to the ability itself (in DotP2010 it was Effect() which actually called rawget(_G, lua_effect_index) but this seems to return nil now).
On a side note, always preventing a certain amount of damage for a given duration works, by using this syntax:
- Code: Select all
Object():GetFilter():Clear()
Object():PreventDamage( amount_to_prevent, 0 )
Returning to the prevention of the next X damage, I made a better implementation for Ordruun Commando, without using ObjectDC (which allows this code to be reused for abilities that prevent the next X damage on other creatures):
- Code: Select all
<ACTIVATED_ABILITY firebreathing="1" immunity="1">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{W}: Prevent the next 1 damage that would be dealt to Ordruun Commando this turn.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{W}: Previeni il prossimo punto danno che verrebbe inflitto al Commando Ordruun in questo turno.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{W}: Verhindere den nächsten Schadenspunkt, der dem Ordruun-Kommando in diesem Zug zugefügt würde.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{W} : Prévenez, ce tour-ci, la prochaine 1 blessure qui devrait être infligée au Commando ordruun.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{W}: Prevén el siguiente punto de daño que se le fuera a hacer al Comando ordrúun este turno.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{W}:このターン、次にオルドルーンの猛士に与えられるダメージを1点軽減する。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{W}: Prevent the next 1 damage that would be dealt to Ordruun Commando this turn.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{W}: Предотвратите следующее 1 повреждение, которое будет нанесено Ордруунскому коммандо в этот ход.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{W}: Previne o próximo 1 ponto de dano que seria causado a Comando de Ordruun neste turno.]]></LOCALISED_TEXT>
<COST type="Mana" cost="{W}" />
<RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
local delayDC = EffectDC():Make_Chest(1)
delayDC:Set_CardPtr( 0, EffectSource() )
MTG():CreateDelayedTrigger(1, delayDC)
end
</RESOLUTION_TIME_ACTION>
<AI_AVAILABILITY step="in_response_dangerous" />
<AI_AVAILABILITY step="declare_blockers" blocking_or_blocked="1" />
</ACTIVATED_ABILITY>
<TRIGGERED_ABILITY internal="1" pre_trigger="1" resource_id="1">
<CLEANUP fire_once="1" simple_cleanup="EndOfTurn" />
<TRIGGER value="CREATURE_TOOK_DAMAGE">
if Damage():GetSource() ~= nil and Damage():GetAmount() > 0 then
return TriggerObject() == EffectDC():Get_CardPtr(0)
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local damage_amount = Damage():GetAmount()
if Damage():IsUnpreventable() == 0 and damage_amount > 0 then
Damage():SetAmount(damage_amount - 1)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Let's talk about next damage prevention (again)
by BETenner » 20 Mar 2013, 15:50
Just a guess:
Can you set the card's score to 0 if you prevented the next X damage?
Can this prevent the AI targeting it?
Can you set the card's score to 0 if you prevented the next X damage?
Can this prevent the AI targeting it?
Re: Let's talk about next damage prevention (again)
by thefiremind » 20 Mar 2013, 16:16
It wouldn't be correct all the times because maybe the AI really has enough damage to kill the creature despite my attempts to prevent damage.BETenner wrote:Just a guess:
Can you set the card's score to 0 if you prevented the next X damage?
Can this prevent the AI targeting it?
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Let's talk about next damage prevention (again)
by BETenner » 21 Mar 2013, 07:27
Then the only hope will be DotP2014..(which is coming soon)
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests