It is currently 25 Apr 2024, 14:54
   
Text Size

Let's talk about next damage prevention (again)

Moderator: CCGHQ Admins

Let's talk about next damage prevention (again)

Postby 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:
Code: Select all
    Object():GetFilter():Clear()
    Object():PreventDamage( amount_to_prevent, 0 )
in fact I successfully used this in my Clerics deck.

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() &gt; 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 &gt; 0 then
       Damage():SetAmount(damage_amount - 1)
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
But the problem is always the same: the AI can't understand it, so Chandra will throw burn spells at it even if I can prevent them completely. Any ideas?
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
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)

Postby 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?
BETenner
 
Posts: 36
Joined: 07 Mar 2013, 14:20
Has thanked: 7 times
Been thanked: 4 times

Re: Let's talk about next damage prevention (again)

Postby thefiremind » 20 Mar 2013, 16:16

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?
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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
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)

Postby BETenner » 21 Mar 2013, 07:27

Then the only hope will be DotP2014..(which is coming soon)
BETenner
 
Posts: 36
Joined: 07 Mar 2013, 14:20
Has thanked: 7 times
Been thanked: 4 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 21 guests


Who is online

In total there are 21 users online :: 0 registered, 0 hidden and 21 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 21 guests

Login Form