It is currently 20 Jul 2025, 09:48
   
Text Size

Formal Request Thread

Moderator: CCGHQ Admins

Re: Formal Request Thread

Postby RiiakShiNal » 29 Mar 2014, 17:54

Unfortunately, Ancient Ziggurat, Primal Beyond, and Smokebraider are impossible to code. "Spend this mana only to cast and/or activate" can't be coded, a workaround can't even be coded due to engine issues (believe me, I tried multiple different methods).
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Formal Request Thread

Postby lilqi » 06 Apr 2014, 18:18

Hi,

can someone code Spreading Plague for me?

thx
lilqi
 
Posts: 27
Joined: 31 Mar 2014, 20:18
Has thanked: 0 time
Been thanked: 0 time

Re: Formal Request Thread

Postby Ferrix » 10 Apr 2014, 11:54

Is it possible to code Sage of Hours?
http://www.wizards.com/Magic/Magazine/A ... ly/ftl/294

I can probably do the rest myself if someone can tell me how to code the second ability. I could approximate it by testing if the counters are between X and Y but that would mean that I need to know the maximum number of counters that can be on a card.

Also, is Lonely Sandbar possible without Riiak's mana mod? I think it should be, but please let me know (no need to code the card, I can do it easily then probably).
Ferrix
 
Posts: 32
Joined: 02 Apr 2014, 21:14
Has thanked: 2 times
Been thanked: 2 times

Re: Formal Request Thread

Postby RiiakShiNal » 10 Apr 2014, 12:47

Ferrix wrote:Is it possible to code Sage of Hours?
http://www.wizards.com/Magic/Magazine/A ... ly/ftl/294

I can probably do the rest myself if someone can tell me how to code the second ability. I could approximate it by testing if the counters are between X and Y but that would mean that I need to know the maximum number of counters that can be on a card.
Yes, it is possible. You can use NeoAnderson's Heroic check for the first ability to keep it compatible with his Bestow cards.

The second ability is actually relatively easy (first count the counters then remove them):
Code: Select all
<ACTIVATED_ABILITY>
  <!-- Localized Text omitted -->
  <COST type="Generic">
    <PREREQUISITE>
      -- Only allow to activate the ability if there is at least 1 counter.
      --  This prevents pointless activations, though to be completely accurate
      --  you could just change this to "return true".
      return (Object():CountCounters( MTG():PlusOnePlusOneCounters() ) &gt; 0)
    </PREREQUISITE>
    <RESOLUTION_TIME_ACTION>
      if (EffectSource() ~= nil) then
        local nCounters = EffectSource():CountCounters( MTG():PlusOnePlusOneCounters() )
        EffectDC():Int_Set( 0, nCounters )
        EffectSource():RemoveCounters( MTG():PlusOnePlusOneCounters(), nCounters )
      end
    </RESOLUTION_TIME_ACTION>
  </COST>
  <RESOLUTION_TIME_ACTION>
    local nCounters = EffectDC():Int_Get( 0 )
    local nTurns = math.floor( nCounters / 5 )
    if (nTurns &gt; 0) then
      for i=1, nTurns do
        EffectController():GetTeam():TakeExtraTurn()
      end
    end
  </RESOLUTION_TIME_ACTION>
</ACTIVATED_ABILITY>
Oh and the maximum number of counters of any one type that can be on a card is 9999. This means you could have 9999 Charge counters and 9999 +1/+1 counters on a single creature. Note though that the maximum P/T a creature can have is 9999/9999 so if you have a 4/4 creature with 9999 +1/+1 counters it will only be a 9999/9999 creature instead of a 10003/10003 creature.

Put Sage of Hours in a {U} / {G} Elf deck with Immaculate Magistrate to really rack up extra turns (infinite extra turns with just 5 elves).

Ferrix wrote:Also, is Lonely Sandbar possible without Riiak's mana mod? I think it should be, but please let me know (no need to code the card, I can do it easily then probably).
Yes, it is easily possible (the engine does have support for this). Here is the Mana ability:
Code: Select all
   <MANA_ABILITY>
      <!-- Localized Text omitted -->
      <COST type="TapSelf" />
      <PRODUCES amount="{U}" />
   </MANA_ABILITY>
As for the other abilities they are easy to pull from other cards.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Formal Request Thread

Postby thefiremind » 18 Apr 2014, 09:02

Just in case someone wants to finally build that scry deck we all imagined when we first looked at Flamespeaker Adept, here's the code for Knowledge and Power, the new card from Journey into Nyx:
Knowledge and Power's triggered ability (untested, needs my mod and needs scry cards to be coded using my scry functions) | Open
Code: Select all
  <TRIGGERED_ABILITY linked_ability_group="1" replacement_effect="1" priority="20">
    <TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_BATTLEFIELD" />
    <TRIGGER value="CONTROLLER_CHANGED" simple_qualifier="self" />
    <RESOLUTION_TIME_ACTION>
    -- Align the card's scry count with the controller's scry count
    LinkedDC():Set_Int( 0, TFM_MyPlayerDC( EffectController() ):Get_Int(TFM_PLAYER_SCRY_COUNT) )
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <TRIGGERED_ABILITY linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Whenever you scry, you may pay {2}. If you do, Knowledge and Power deals 2 damage to target creature or player.]]></LOCALISED_TEXT>
    <TRIGGER value="STATE_BASED_EFFECTS">
    -- If the card's scry count gets disaligned, it means its controller scried
    if TFM_MyPlayerDC( EffectController() ):Get_Int(TFM_PLAYER_SCRY_COUNT) &gt; LinkedDC():Get_Int(0) then
       LinkedDC():Int_Inc(0)
       return true
    end
    return false
    </TRIGGER>
    <TARGET tag="CARD_QUERY_CHOOSE_DEAL_2_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 controller = EffectController()
    if controller ~= nil and controller:CanPayManaCost("{2}") then
       controller:BeginNewMultipleChoice()
       controller:AddMultipleChoiceAnswer( "UI_CONDITIONAL_QUESTION_YES", controller:CanPayManaCost("{2}") )
       controller:AddMultipleChoiceAnswer("UI_CONDITIONAL_QUESTION_NO")
       controller:AskMultipleChoiceQuestion( "OPTIONAL_ABILITY_QUESTION", Object() )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local controller = EffectController()
    if controller ~= nil and controller:CanPayManaCost("{2}") and controller:GetMultipleChoiceResult() == 0 then
       controller:PayManaCost("{2}")
       EffectDC():Set_Int(1, 1)
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if EffectDC():Get_Int(1) == 1 then
       local target_creature = EffectDC():Get_Targets(0):Get_CardPtr(0)
       local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
       if target_creature ~= nil then
          EffectSourceLKI():DealDamageTo(2, target_creature)
       elseif target_player ~= nil then
          EffectSourceLKI():DealDamageTo(2, target_player)
       end
    end
    </RESOLUTION_TIME_ACTION>
    <AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ENEMY_ONLY" />
  </TRIGGERED_ABILITY>
The code for my Flamespeaker Adept can be found here. Same pre-requisites apply.
< 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: 722 times

Re: Formal Request Thread

Postby Hacker85 » 19 Apr 2014, 00:21

im trying to do the cards Goblin Matron and Warren Weirding.
Maybe someone can help me with the abilitys.

Edit: Ok Goblin Matron is done but still need help with Warren Weirding.
Hacker85
 
Posts: 31
Joined: 29 Mar 2014, 06:19
Has thanked: 3 times
Been thanked: 0 time

Re: Formal Request Thread

Postby thefiremind » 19 Apr 2014, 09:45

Hacker85 wrote:still need help with Warren Weirding.
This should work:
Warren Weirding (untested) | Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="WARREN_WEIRDING_152732" />
  <CARDNAME text="WARREN_WEIRDING" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Warren Weirding]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Déterminisme du terrier]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Multiplicación del barracón]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bizarre Barackenrituale]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Stranezze del Cunicolo]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[巣穴の運命支配]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Warren Weirding]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Очуднение Муравейника]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Esquisitice do Vilarejo]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="152732" />
  <ARTID value="152732" />
  <ARTIST name="Matt Cavotta" />
  <CASTING_COST cost="{1}{B}" />
  <FLAVOURTEXT>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[“And that’s when it was discovered that boggarts have just half a brain.”
—The Book of Other Folk]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[« Et c’est ainsi qu’on découvrit que les boggarts n’avaient qu’un demi cerveau. »
—Le livre des Autres]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[“Y fue entonces cuando se descubrió que los boggarts tienen sólo medio cerebro.”
—El Libro de Otros Pueblos]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[„Und somit wurde entdeckt, dass Boggarts nur ein halbes Gehirn haben.”
—Das Buch der anderen Völker]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[“E qui è quando è stato scoperto che i boggart hanno solo metà cervello.”
—Il Tomo delle Altre Genti]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[「かくして、その時ボガートの脳が半分しかないと知れることとなった。」
――「他族の書」より]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[“And that’s when it was discovered that boggarts have just half a brain.”
—The Book of Other Folk]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[«Вот тогда-то все и узнали, что у боггартов всего лишь полмозга».
—Кискенская книга о других народах]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[“E foi então que se descobriu que os papões só têm meio cérebro.”
— O Livro dos Outros Povos]]></LOCALISED_TEXT>
  </FLAVOURTEXT>
  <TYPE metaname="Tribal" />
  <TYPE metaname="Sorcery" />
  <SUB_TYPE metaname="Goblin" />
  <EXPANSION value="MOR" />
  <RARITY metaname="U" />
  <SPELL_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Target player sacrifices a creature. If a Goblin is sacrificed this way, that player puts two 1/1 black Goblin Rogue creature tokens onto the battlefield, and those tokens gain haste until end of turn.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Le joueur ciblé sacrifie une créature. Si un gobelin est sacrifié de cette manière, ce joueur met sur le champ de bataille deux jetons de créature 1/1 noire Gobelin et Gredin. Ces jetons acquièrent la célérité jusqu’à la fin du tour.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[El jugador objetivo sacrifica una criatura. Si se sacrifica un Trasgo de esta manera, ese jugador pone en el campo de batalla dos fichas de criatura Bribón Trasgo negras 1/1, y esas fichas ganan la habilidad de prisa hasta el final del turno.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Ein Spieler deiner Wahl opfert eine Kreatur. Falls auf diese Weise ein Goblin geopfert wurde, bringt dieser Spieler zwei 1/1 schwarze (Goblin, Räuber)-Kreaturenspielsteine ins Spiel, die bis zum Ende des Zuges Eile haben.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Un giocatore bersaglio sacrifica una creatura. Se un Goblin viene sacrificato in questo modo, quel giocatore mette sul campo di battaglia due pedine creatura Farabutto Goblin 1/1 nere, e quelle pedine guadagnano rapidità fino alla fine del turno.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[プレイヤー1人を対象とする。そのプレイヤーはクリーチャーを1体生け贄に捧げる。 これによりゴブリンが生け贄に捧げられた場合、そのプレイヤーは黒の1/1のゴブリン・ならず者・クリーチャー・トークンを2体場に出す。それらのトークンはターン終了時まで速攻を得る。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Target player sacrifices a creature. If a Goblin is sacrificed this way, that player puts two 1/1 black Goblin Rogue creature tokens onto the battlefield, and those tokens gain haste until end of turn.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Целевой игрок приносит в жертву существо. Если таким образом в жертву приносится Гоблин, тот игрок кладет в игру две фишки существа 1/1 черный Гоблин Бродяга, и те фишки получают Ускорение до конца хода.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[O jogador alvo sacrifica uma criatura. Se um Goblin é sacrificado dessa maneira, aquele jogador coloca no campo de batalha duas fichas de criatura pretas 1/1 do tipo Goblin Ladino e elas ganham ímpeto até o final do turno.]]></LOCALISED_TEXT>
    <TARGET tag="CARD_QUERY_CHOOSE_PLAYER_TO_SACRIFICE_CREATURE" definition="0" compartment="0" count="1" />
    <TARGET_DEFINITION id="0">
    local filter = ClearFilter()
    filter:SetFilterType(FILTER_TYPE_PLAYERS)
    </TARGET_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
    if target ~= nil then
       local filter = ClearFilter()
       filter:Add(FE_CONTROLLER, OP_IS, target)
       filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
       target:ChooseItem( "CARD_QUERY_CHOOSE_CREATURE_TO_SACRIFICE", EffectDC():Make_Targets(1) )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
    if target ~= nil then
       local creature = EffectDC():Get_Targets(1):Get_CardPtr(0)
       if creature ~= nil then
          if creature:GetSubType():Test(CREATURE_TYPE_GOBLIN) then
             EffectDC():Set_Int(2, 1) -- it's a Goblin, let's remember it with this flag before it gets sacrificed
          end
          target:Sacrifice(creature)
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    -- If a Goblin was sacrificed, create the tokens and store them into a chest
    local target = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
    if target ~= nil and EffectDC():Get_Int(2) == 1 then
       MTG():PutTokensOntoBattlefield( "TOKEN_GOBLIN_ROGUE_1_1_B_1000000", 2, target, EffectDC():Make_Chest(3) )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    -- Save how many tokens were actually produced (in case of Doubling Season and similar effects)
    local tokenDC = EffectDC():Get_Chest(3)
    if tokenDC ~= nil then
       EffectDC():Set_Int( 4, tokenDC:Count() )
    end
    </RESOLUTION_TIME_ACTION>
    <CONTINUOUS_ACTION layer="6">
    -- Give each token haste
    local tokenDC = EffectDC():Get_Chest(3)
    if tokenDC ~= nil then
       local token_count = EffectDC():Get_Int(4)
       for i=0,token_count-1 do
          local token = tokenDC:Get_CardPtr(i)
          if token ~= nil then
             token:GetCurrentCharacteristics():Bool_Set(CHARACTERISTIC_HASTE, 1)
          end
       end
    end
    </CONTINUOUS_ACTION>
    <DURATION simple_duration="UntilEOT" />
    <AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ENEMY" />
  </SPELL_ABILITY>
  <TOKEN_REGISTRATION reservation="1" type="TOKEN_GOBLIN_ROGUE_1_1_B_1000000" />
  <HELP title="MORE_INFO_BADGE_TITLE_14" body="MORE_INFO_BADGE_BODY_14" zone="ZONE_ANY" />
  <AI_BASE_SCORE score="450" zone="ZONE_HAND" />
</CARD_V2>
I included the Goblin Rogue token in the attachment (I had made it for DotP2013 so it required no additional effort) but I gave it 1000000 as Multiverse ID, I'd suggest you to give it a different one that has more chances to be unique. Be sure to change it everywhere if you do.
Attachments
WARREN_WEIRDING_152732.zip
Warren Weirding + Goblin Rogue token (unprefixed, untested, illustrations included)
(180.81 KiB) Downloaded 274 times
< 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: 722 times

Re: Formal Request Thread

Postby Hacker85 » 19 Apr 2014, 13:32

thanks for that working nice. but another question the game crashes after a match and says v34-20140419-152700-4132-3880.dmp please attach to it bug report but that was already before ur cards. what can be the reason for that.
Hacker85
 
Posts: 31
Joined: 29 Mar 2014, 06:19
Has thanked: 3 times
Been thanked: 0 time

Re: Formal Request Thread

Postby RiiakShiNal » 19 Apr 2014, 13:38

Hacker85 wrote:thanks for that working nice. but another question the game crashes after a match and says v34-20140419-152700-4132-3880.dmp please attach to it bug report but that was already before ur cards. what can be the reason for that.
Crashing after a match usually indicates that there is a missing TOKEN_REGISTRATION, but I see one in thefiremind's card so I would assume you changed the multiverse id of the token, but forgot to change the TOKEN_REGISTRATION in Warren Weirding (but remembered to change the text for PutTokensOntoBattlefield()).

If, however, you did properly change the TOKEN_REGISTRATION then it could be a missing TOKEN_REGISTRATION from another card in either your deck or the deck you were playing against.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Formal Request Thread

Postby Hacker85 » 19 Apr 2014, 16:18

works fine now. thx
Hacker85
 
Posts: 31
Joined: 29 Mar 2014, 06:19
Has thanked: 3 times
Been thanked: 0 time

Re: Formal Request Thread

Postby Misplay » 23 Apr 2014, 02:30

Hi!

I tried to code Genesis... But I've got no experience in code, and my first attempt was really messy. Maybe someone could help me?
(Also, I'm not fluent in english, I hope you'll understand what I'm trying to explain... :wink: )

Here's the code I used (a mix of "Oversold Cemetery" and "Mana Vault" from the Sumomole's DLC):

Code: Select all
  <TRIGGERED_ABILITY active_zone="ZONE_GRAVEYARD">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[XXXXXXX]]></LOCALISED_TEXT>
    <TRIGGER value="BEGINNING_OF_PLAYERS_STEP" simple_qualifier="controller">
    return MTG():GetStep() == STEP_UPKEEP
    </TRIGGER>
    <RESOLUTION_TIME_ACTION id="0">
    if EffectController():CanPayManaCost("{2}{G}") then
       EffectController():BeginNewMultipleChoice()   
       EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_YES" )   
       EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_NO" )
       EffectController():AskMultipleChoiceQuestion( "CARD_QUERY_OPTION_PAY_2G", EffectSource() )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if EffectController():CanPayManaCost("{2}{G}") then
       local result = EffectController():GetMultipleChoiceResult()
       if result == 0 then
          EffectController():PayManaCost("{2}{G}")
       end
    end
    </RESOLUTION_TIME_ACTION>
    <TARGET tag="CARD_QUERY_CHOOSE_A_CREATURE_TO_PUT_INTO_YOUR_HAND" definition="0" compartment="0" count="1" />
    <MAY />
    <TARGET_DEFINITION>
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
    filter:SetZone( ZONE_GRAVEYARD, EffectController() )
    </TARGET_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target ~= nil then
       target:PutInHand()
    end 
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
I've got several issues with this code:
> First of all, the sequence of the effect doesn't work like I want. The AI asks me to choose a creature card in my graveyard (step 1), if I want to use this ability (step 2) and finally if I want to pay 2G to activate the ability (step 3).

How can I change the code to have the following sequence?
Step 1: "Do I want to use this ability?"
Step 2: "Choose the target of the ability".
Step 3: "Pay for the activation of the ability".

> id="0" (Ex: <RESOLUTION_TIME_ACTION id="0">)
I see that line in several cards, but I don't understand the effect on the card... How does > id="0"< change the function of an ability?

Any help would be welcome!
Misplay
 
Posts: 92
Joined: 29 Aug 2013, 08:26
Has thanked: 50 times
Been thanked: 10 times

Re: Formal Request Thread

Postby sumomole » 23 Apr 2014, 07:43

Misplay wrote:Hi! I tried to code Genesis...
1. you must ensure that your choice can affect the final result.
| Open
Code: Select all
  <TRIGGERED_ABILITY active_zone="ZONE_GRAVEYARD">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[At the beginning of your upkeep, if Genesis is in your graveyard, you may pay {2}{G}. If you do, return target creature card from your graveyard to your hand.]]></LOCALISED_TEXT>
    <TRIGGER value="BEGINNING_OF_PLAYERS_STEP" simple_qualifier="controller">
    return MTG():GetStep() == STEP_UPKEEP
    </TRIGGER>
    <INTERVENING_IF>
    return EffectSource() ~= nil
    </INTERVENING_IF>
    <TARGET tag="CARD_QUERY_CHOOSE_A_CREATURE_TO_PUT_INTO_YOUR_HAND" definition="0" compartment="0" count="1" />
    <TARGET_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
    filter:SetZone( ZONE_GRAVEYARD, EffectController() )
    </TARGET_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target ~= nil and EffectController():CanPayManaCost("{2}{G}") then
       EffectController():BeginNewMultipleChoice()   
       EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_INTET_PAY_MANA_COST" )
       EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_INTET_DO_NOT_PAY_MANA" )
       EffectController():AskMultipleChoiceQuestion( "CARD_QUERY_INTET_QUESTION", target )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target ~= nil and EffectController():CanPayManaCost("{2}{G}") then
      if EffectController():GetMultipleChoiceResult() == 0 then
         EffectController():PayManaCost("{2}{G}")
         target:PutInHand()
       end
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
2. this ability doesn't require the step 1.
3. id="0" is the number of target, and it's used in target definition block, not resolution time action block, it corresponds to definition="0" that in target block.
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 234 times

Re: Formal Request Thread

Postby thefiremind » 23 Apr 2014, 08:32

Misplay wrote:The AI asks me to choose a creature card in my graveyard (step 1), if I want to use this ability (step 2) and finally if I want to pay 2G to activate the ability (step 3).
As sumomole said, there's no need to ask if you want to use the ability, because deciding whether to pay or not is enough. Aside from that, the order is correct: I know it sounds counter-intuitive, but targets are always chosen before resolution, while everything else (usually) happens after resolution. So you actually need to choose the target before you decide to pay for the ability.
< 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: 722 times

Re: Formal Request Thread

Postby Misplay » 23 Apr 2014, 13:48

Thx for your replies, very impressive.

Where did you learn to code? Is there a manual or something like that I can read to learn too?!

Sometimes, I don't really understand what I'm coding... For example, what does "~= nil" mean?
Misplay
 
Posts: 92
Joined: 29 Aug 2013, 08:26
Has thanked: 50 times
Been thanked: 10 times

Re: Formal Request Thread

Postby thefiremind » 23 Apr 2014, 14:27

Misplay wrote:Where did you learn to code? Is there a manual or something like that I can read to learn too?!
What usually happens is that you learn your first programming language (maybe at school), and together with that, you learn how to "think" when you write code, then no matter which other languages you need to use, you already know what you are doing (variables, iterations, conditions, etc.) and you just need to browse a manual for the new language's syntax. If you have such basics, then the language used here (Lua) is really easy to learn and understand, since it's a scripting language (that is, a programming language with facilities that are intended to make life easier for those who don't usually write elaborated code).
http://www.lua.org/docs.html can be useful when you need to check how things need to be written, but again, programming basics are recommended.

Misplay wrote:what does "~= nil" mean?
"~=" means "not equal to", while "nil" (also called "null" in other languages) is something that stands for "no value". For example, when you check the condition "EffectSource() ~= nil" you are checking that there's actually something stored in the register returned by the EffectSource() function (which might not be the case, if the card changed zone).
< 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: 722 times

PreviousNext

Return to 2014

Who is online

Users browsing this forum: No registered users and 4 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 4 guests

Login Form