It is currently 19 Apr 2024, 06:32
   
Text Size

DotP2015: Overload is possible!

Moderator: CCGHQ Admins

DotP2015: Overload is possible!

Postby thefiremind » 06 Jul 2015, 00:15

It seems I haven't been careful enough when I tested the overload mechanic back when we were using the 3DM Chinese patch for our tests. It is possible to make it work, but it's clear that the developers didn't make a complete work (probably once they knew that no cards with overload would have been officially coded).

First of all, overload needs to be selected by zooming the card and clicking on the ability text. If you try to cast the spell normally, you aren't given any casting choice and you are asked to select a target. If there are no legal targets but you can afford the overload, you'll notice that the card glows red, and clicking on it auto-zooms it.

That's not all. Just granting the overload ability doesn't make overload work: the part where the spell affects all creatures you don't control needs to be coded manually, and of course, there could be more than one way to do it. The card needs to check whether it has been overloaded or not. You can't check if the target is nil, because the target could become nil after it has been chosen (for example it could have been removed from the battlefield in response). My idea involves setting a flag in LinkedDC, and since LinkedDC can't be used in UTILITY_ABILITY, my overload ability creates a delayed trigger which then sets the flag.

Here is my code for Electrickery:
Electrickery (tested) | Open
Code: Select all
<?xml version="1.0"?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="ELECTRICKERY_199253545" />
  <CARDNAME text="ELECTRICKERY" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Electrickery]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Électromperie]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Eléctruco]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Elektrickserei]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Elettroinganno]]></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[Eletrotruque]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[电流恶戏]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[電流惡戲]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="199253545" />
  <ARTID value="199253545" />
  <ARTIST name="Greg Staples" />
  <CASTING_COST cost="{R}" />
  <TYPE metaname="Instant" />
  <EXPANSION value="RTR" />
  <RARITY metaname="C" />
  <SPELL_ABILITY linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Electrickery deals 1 damage to target creature you don’t control.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[L’Électromperie inflige 1 blessure à une créature ciblée que vous ne contrôlez pas.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Eléctruco hace 1 punto de daño a la criatura objetivo que no controlas.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Elektrickserei fügt einer Kreatur deiner Wahl, die du nicht kontrollierst, 1 Schadenspunkt zu.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[L’Elettroinganno infligge 1 danno a una creatura bersaglio che non controlli.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたがコントロールしていないクリーチャー1体を対象とする。電謀はそれに1点のダメージを与える。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[당신이 조종하지 않는 생물 한 개를 목표로 정한다. 전기 속임수는 그 생물에게 피해 1점을 입힌다.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Электротрюк наносит 1 повреждение целевому существу не под вашим контролем.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Eletrotruque causa 1 ponto de dano à criatura alvo que você não controla.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[电流恶戏对目标不由你操控的生物造成1点伤害。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[電流惡戲對目標不由你操控的生物造成1點傷害。]]></LOCALISED_TEXT>
    <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_DEAL_1_DAMAGE" definition="0" compartment="0" count="1" />
    <SFX text="TARGET_LIGHTNING_PLAY" />
    <TARGET_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
    filter:Add( FE_CONTROLLER, OP_NOT, EffectController() )
    </TARGET_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target_creature ~= nil then
       EffectSourceLKI():DealDamageTo(1, target_creature)
    end
    </RESOLUTION_TIME_ACTION>
    <FILTER filter_id="0">
    local filter = ClearFilter()
    if LinkedDC():Get_Int(0) ~= 1 then
       filter:Invalidate() -- If the card hasn't been overloaded, this filter must not work
    else
       filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
       filter:Add( FE_CONTROLLER, OP_NOT, EffectController() )
    end
    </FILTER>
    <RESOLUTION_TIME_ACTION filter_id="0">
    if FilteredCard() ~= nil then
       EffectSourceLKI():DealDamageTo( 1, FilteredCard() )
    end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
  <UTILITY_ABILITY qualifier="Overload">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Overload {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Surcharge {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Sobrecarga {1}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Überlast {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sovraccarico {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[超過 {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[과부하 {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Перегрузка {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Sobrecarga {1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[超载{1}{R}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[超載{1}{R}]]></LOCALISED_TEXT>
    <COST mana_cost="{1}{R}" type="Mana" />
    <COST type="Generic">
      <PREREQUISITE>
      return true
      </PREREQUISITE>
      <RESOLUTION_TIME_ACTION>
      local delayDC = EffectDC():Make_Chest(0)
      MTG():CreateDelayedTrigger(1, delayDC)
      </RESOLUTION_TIME_ACTION>
    </COST>
  </UTILITY_ABILITY>
  <TRIGGERED_ABILITY replacement_effect="1" resource_id="1" linked_ability_group="1" active_zone="ZONE_ANY">
    <TRIGGER value="SPELL_PLAYED" simple_qualifier="self" />
    <RESOLUTION_TIME_ACTION>
    LinkedDC():Set_Int(0, 1) -- Mark the card as overloaded
    </RESOLUTION_TIME_ACTION>
    <CLEANUP fire_once="1" />
  </TRIGGERED_ABILITY>
  <HELP title="MORE_INFO_TITLE_OVERLOAD" body="MORE_INFO_BODY_OVERLOAD" zone="ZONE_ANY" />
  <QUERYTEXT tag="CARD_QUERY_CHOOSE_CREATURE_DEAL_1_DAMAGE">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Choose a creature to deal 1 damage to.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Choisissez une créature pour lui infliger 1 blessure.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Elige una criatura para hacerle 1 punto de daño.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bestimme eine Kreatur, der 1 Schadenspunkt zugefügt werden soll.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Scegli una creatura a cui infliggere 1 danno.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[1点のダメージを与えるクリーチャーを1体選んでください。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[피해 1점을 입을 생물을 고르십시오.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Выберите существо, которому нужно нанести 1 повреждение.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Escolha uma criatura para causar 1 ponto de dano a ela.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[选择一个生物,以对其造成1点伤害。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[選擇一個生物來對其造成1點傷害。]]></LOCALISED_TEXT>
  </QUERYTEXT>
</CARD_V2>
(The HELP explanation for overload needs to be written.)

There's a minor problem: the animation will run even when the spell has been overloaded. I tried to use the new AllowSFX(false) which is used on the official cards with extort, but it doesn't seem to work here (maybe it doesn't work for targetted animations?). If you aren't satisfied with it, you can use a global animation or no animation at all, the choice is yours.

On a different note, it's the first time I tried to use Invalidate() on a filter, and it seems to work exactly as one could guess. It's more elegant than setting an impossible condition (filtering schemes or similar). :wink:

If you come up with different (maybe shorter, maybe more functional) versions of overload, please share them.
< 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: DotP2015: Overload is possible!

Postby cenarius » 10 Jul 2015, 08:33

Oh, this is nice. We'll see what cards can come out from this, though i admit i'm more like an "old school" magic fan.

But this is nice indeed, good job ;)
cenarius
 
Posts: 87
Joined: 09 Jun 2015, 14:40
Has thanked: 0 time
Been thanked: 0 time

Re: DotP2015: Overload is possible!

Postby Tejahn » 11 Jul 2015, 21:34

Just wanted to re-confirm that this works. Thanks!
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 28 guests


Who is online

In total there are 28 users online :: 0 registered, 0 hidden and 28 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 28 guests

Login Form