Page 1 of 1

Any tutorials

PostPosted: 06 May 2015, 22:47
by Aalnius
hey guys i've been wanting to code some original (non magic) cards to play about with and i've had a quick look about the forums but i can't seem to find a proper tutorial for how to code the cards.

I've found a web generator to grab magic cards as a base but i don't know how to add in abilities to the cards like lifelink or enter the battlefield.

so direction to a tutorial for this stuff would be great also if there are any tools which would help me other then the web grabber that'd be good too i found a bunch in the community wad tools folder but i dont know how to use them.

Re: Any tutorials

PostPosted: 06 May 2015, 23:00
by RiiakShiNal
There is a pretty good tutorial by Jacque here on the forum. You may also want to make sure you have my Deck Builder for finding other cards with either similar abilities that have already been coded or for functions that you are interested in finding out how they are used. The wiki can also be a good source of information, especially the functions reference and the decompiled lol contents (primarily for the constants).

Though the best reference for learning how to code cards are already coded cards.

Re: Any tutorials

PostPosted: 08 May 2015, 17:56
by Xander9009
Have you have tried any cards yet?

Re: Any tutorials

PostPosted: 31 May 2015, 16:54
by Aalnius
Hey guys sorry for the uber slow response I got busy with uni work and forgot I asked this question just looked through that tutorial.

I have coded Leper Gnome but he is basically a cheaper perilous myr so it wasn't that hard (i also deleted the creature targeting).

He seems to work fine no crashes or anything although i couldn't figure out how to link the art to the card but tbh majority of cards i've seen in the community wad don't seem to have art ingame anyway.

going to see if i can code more cards being able to see the XML using your deck builder is awesome i didn't even realise it was a function but tbh i hadn't been looking till now.

Re: Any tutorials

PostPosted: 31 May 2015, 17:15
by Xander9009
The Community Wad should definitely have art of almost all of the cards. There may be a few missing (feel free to tell me if you find any missing), but the only ones missing should be the very recently released. I just got Khans of Tarkir added.

For the art to work, you need to convert a PNG or JPG file to TDX format using Gibbed.Duels.TdxConvert.exe or Riiak's Tdx Convert Compressed.bat (which is the exact same thing, but also compresses the image to be smaller and possibly more efficient for the game). Once you have the TDX file, put it in DATA_ALL_PLATFORMS\ART_ASSETS\ILLUSTRATIONS\. Then, in the card, make the ARTID tag's value be the art file's filename without the ".tdx" extension. The art should show up in-game.

Not relevant | Open
If you have the Community Wad (which I only mention because you mentioned missing are, so it's likely you have it), you can use the art from there if you have all of the art files. Just use the artid "CW" followed by the card's MutliverseID. Make sure there are no spaces or underscores. For Abandon Hope, on gatherer.wizards.com, if you go to the card, the URL in the address bar is http://gatherer.wizards.com/Pages/Card/ ... rseid=4635. The multiverse ID is 4635. So, "CW4635" in the artid tag will load that card's art without you ever having to mess with image files. As long as you have the DATA_DLC_CW_TEMPEST.wad file. For Ojutai's Command, the MultiverseID is 394642, and since it's from the Dragons of Tarkir expansion, you'd need the DATA_DLC_CW_KHANS_OF_TARKIR.wad file to have the art (the art files are all split up based on the block they are from, which usually consist of three expansions, plus a few other wads for cards not from a block such as duel decks and event decks, as well as a misc file for tokens and the like). You can use the MultiverseID already in the card code if you made it using TFM's generator. That's where it gets the MultiverseID from.


EDIT: Just noticed the card you mentioned was a Hearthstones card, not a MTG card, so obviously the CW's art would be useless here. But the method of getting it to work in-game is exactly the same.

Re: Any tutorials

PostPosted: 31 May 2015, 20:00
by Aalnius
I am stupid i just realised i copied the art into a separate folder inside the magic folder instead of just copying it into the magic folder.
just loaded it up when testing a card and the art is showing up now.
thank you for that also thank you for explaining how to link the art i'll start doing that in future cards.

i've managed to code one more card so far working on a third atm which uses the opponents hand size to decrease the cost of itself.

Just done it and it seems to work properly but it chucks out a list when the game closes with errors that are apparently attempting to index nil value.
Code below:
| Open
<TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_ANY">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Affinity for opponent's hand size]]></LOCALISED_TEXT>
<TRIGGER value="CONSIDERED_FOR_CAST" simple_qualifier="self" pre_trigger="1" />
<RESOLUTION_TIME_ACTION>

if TriggerObject() ~= nil then
local filter = ClearFilter()
filter:SetFilterType( FILTER_TYPE_PLAYERS )
filter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
local total = 12 - target_player:Hand_Count()
TriggerObject():DecreaseCost(total)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

Re: Any tutorials

PostPosted: 31 May 2015, 21:26
by Aalnius
Just wondering is it possible to create keyword abilities or anything of the like.
I want to create a taunt ability (all creatures must attack it) but also a default can't block and i thought it'd likely be easiest if i could just make two keyword abilities and use them but i don't know how deeply moddable magic 2014 is.

Re: Any tutorials

PostPosted: 31 May 2015, 22:41
by sweetLu
You should check out Riiak's Custom Characteristics mod. You'll need to use a token manager to do what you are saying.
http://mtg.dragonanime.org/index.php?ti ... _Functions

Re: Any tutorials

PostPosted: 31 May 2015, 23:07
by Xander9009
Aalnius wrote:I am stupid i just realised i copied the art into a separate folder inside the magic folder instead of just copying it into the magic folder.
just loaded it up when testing a card and the art is showing up now.
thank you for that also thank you for explaining how to link the art i'll start doing that in future cards.

i've managed to code one more card so far working on a third atm which uses the opponents hand size to decrease the cost of itself.

Just done it and it seems to work properly but it chucks out a list when the game closes with errors that are apparently attempting to index nil value.
Code below:
| Open
<TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_ANY">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Affinity for opponent's hand size]]></LOCALISED_TEXT>
<TRIGGER value="CONSIDERED_FOR_CAST" simple_qualifier="self" pre_trigger="1" />
<RESOLUTION_TIME_ACTION>

if TriggerObject() ~= nil then
local filter = ClearFilter()
filter:SetFilterType( FILTER_TYPE_PLAYERS )
filter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
local total = 12 - target_player:Hand_Count()
TriggerObject():DecreaseCost(total)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
This tried to access a chest marked as a target chest. There is no target chest, though, because it doesn't target anything. This kind of ability would be tricky. However, you would be able to do it. You'd need the card to have an activated ability with active_zone="ZONE_ANY" which has replacement_effect="1" and linked_ability_group="1". In that ability, target a player with a normal player targeting tag, but add not_targeted="1". Then, store that player in LinkedDC():Set_PlayerPtr(0, EffectDC():Get_Targets(0):Get_PlayerPtr(0)). This way, the player chooses an opponent and that choice is stored in a variable the other ability can access. Then, in the other ability (the one that reduces the cost), make sure it also has linked_ability_group="1", and get LinkedDC():Get_PlaterPtr(0). If it's not nil, then reduce the cost based on that player's Hand_Count().

Also, if you put code inside of a [ code][ /code] block (which itself is inside of a spoiler block), then the code will keep the spacing, making it much easier to read.

Something like this | Open
Code: Select all
   <ACTIVATED_ABILITY replacement_effect="1" active_zone="ZONE_ANY" linked_ability_group="1">
      <LOCALISED_TEXT LanguageCose="en-US"><![CDATA[Choose an opponent.]]></LOCALISED_TEXT>
      <TARGET tag="CARD_QUERY_CHOOSE_OPPONENT" definition="0" compartment="0" count="1" not_targeted="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:SetFilterType( FILTER_TYPE_PLAYERS )
         filter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
      </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target_player = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
         if target_player ~= nil then
            LinkedDC():Set_PlayerPtr(0, target_player)
         end
      </RESOLUTION_TIME_ACTION>
   </ACTIVATED_ABILITY>
   <TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_ANY" linked_ability_group="1">
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Affinity for opponent's hand size]]></LOCALISED_TEXT>
      <TRIGGER value="CONSIDERED_FOR_CAST" simple_qualifier="self" pre_trigger="1" />
      <RESOLUTION_TIME_ACTION>
         if TriggerObject() ~= nil then
            local target_player = LinkedDC():Get_PlayerPtr(0)
            if target_player ~= nil then
               local total = 12 - target_player:Hand_Count()
               TriggerObject():DecreaseCost(total)
            end
         end
      </RESOLUTION_TIME_ACTION>
   </TRIGGERED_ABILITY>

Re: Any tutorials

PostPosted: 31 May 2015, 23:43
by Aalnius
ahh right thanks guys ill have a look at it again tomorrow